← Back to Pull requests

feat(app): add faceted filters to the sessions page #2992

Open
vinzee opened this pull request with 825 lines diff across 12 files
View on GitHub
vinzee vinzee commented on Aug 25, 2026 01:01 UTC
Author

Summary

Bring the search page's faceted filter sidebar to /sessions and wire the selected filters into the session aggregation query.

  • Add a SessionFilters wrapper around DBSearchPageFilters that hides the analysis-mode tabs, denoise, and root-spans-only toggles that don't apply to sessions.

  • Persist sidebar filters in the URL and thread them through useSessions so they constrain the trace aggregation alongside the free-text query.

  • Scope both the facet sidebar and the aggregation to RUM session spans:

  • Add unit tests covering the new sessions behavior.
  • Screenshots or video


    The Sessions Tab now has a sidebar with filters:
    <img width="1921" height="929" alt="image" src="https://github.com/user-attachments/assets/e1cc37ea-ffe6-4223-8b39-55ba62256e11" />

    How to test on Vercel preview

    Preview routes: /sessions

    Steps (/sessions):
    1. Open /sessions.
    2. In the "Data Source" dropdown (combobox labeled "Data Source"), confirm a session source (labeled "Sessions") is selected; if it is not, open the dropdown and choose the "Sessions" source.
    3. Wait for the results area (data-testid "session-card-list") to render at least one session card (each card has a data-testid beginning with "session-card-").
    4. Confirm the filters sidebar is visible to the left of the results with a "Filters" heading.
    5. Confirm the sidebar is populated: at least one facet group is listed (for example a group labeled "ServiceName") and the text "No filters available" is NOT shown.
    6. Click the "ServiceName" facet group header to expand it, then click the first value's checkbox inside its panel.
    7. Confirm an active filter pill appears above the results list and the page URL gains a "filters=" query parameter.
    8. Click "Hide filters", confirm the sidebar collapses, then click "Show filters" and confirm the sidebar reappears.
    9. Verify the results area (data-testid "session-card-list") re-rendered after the filter was applied and no red error notification was shown.

    References

  • Linear Issue: n/a

  • Related PRs: n/a
  • Diff: 825 lines (+670 / -155) across 12 files Reviewer: pulpdrew Review duration: 146100m
    All Vouch review confidence checks passed
    Residual risk 0.10 = Change Risk (0.66) × (1 − Review Confidence (0.85)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 825 lines diff across 12 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.90 · 5 substantive comment(s)
    0.90
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    85%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Real PR Conversation Timeline
    38 items
    changeset-bot[bot] changeset-bot[bot] commented on Aug 25, 2026 01:01 UTC
    Bot

    🦋 Changeset detected

    Latest commit: 5e43cd6bfd7d47e17d64b38277affb1f0a31a314

    The changes in this PR will be included in the next version bump.

    <details><summary>This PR includes changesets to release 3 packages</summary>

    | Name | Type |
    | ----------------------- | ----- |
    | @hyperdx/app | Patch |
    | @hyperdx/api | Patch |
    | @hyperdx/otel-collector | Patch |

    </details>

    Not sure what this means? Click here to learn what changesets are.

    Click here if you're a maintainer who wants to add another changeset to this PR%3A%20add%20faceted%20filters%20to%20the%20sessions%20page%0A)

    vercel[bot] vercel[bot] commented on Aug 25, 2026 01:01 UTC
    Bot

    @vinzee is attempting to deploy a commit to the HyperDX Team on Vercel.

    A member of the Team first needs to authorize it.

    greptile-apps[bot] greptile-apps[bot] commented on Aug 25, 2026 01:06 UTC
    Bot

    <!-- greptile_summary -->

    <h2><a href="https://app.greptile.com/api/retrigger?id=56482116"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/hyperdx/github/hyperdxio/hyperdx/-/pull/2992"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5</h2>

    [Medium impact] The PR appears safe to merge.

    <h3>Summary</h3>

    The PR adds URL-persisted faceted filters to the sessions page and applies them to trace-backed session aggregation.

  • Adds a sessions-specific wrapper around the shared filter sidebar.

  • Scopes facet and aggregation queries to RUM session spans.

  • Reconciles filters when the selected session source changes.

  • Adds filter parsing, query-composition, wrapper, and active-pill tests.
  • <details open><summary><h3>Diagram</h3></summary>

    %%{init: {'theme': 'neutral'}}%%
    flowchart LR
      U[Session query and facet selections] --> URL[URL-backed search state]
      URL --> S[Sessions page]
      S --> F[Session filter sidebar]
      S --> C[Combined RUM scope and query]
      F --> SF[Structured filters]
      C --> Q[Trace-backed session aggregation]
      SF --> Q
      Q --> L[Filtered session cards]
    

    </details>

    <!-- greptile_confidence_score:5 -->

    <sub>Reviews (10) · Last reviewed commit: "feat(app): add faceted filters to the se..." · Reviewed by Greptile</sub>

    greptile-apps[bot] greptile-apps[bot] commented on code on Aug 25, 2026 01:06 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +102,91 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM
    +      // sessions. `otel_traces` is sorted by (ServiceName, SpanName, Timestamp),
    +      // so with no ServiceName predicate the time filter can't prune via the
    +      // primary index — the query scans the whole table's marks (~100k) to
    +      // evaluate the `rum.sessionId` skip index. RUM traffic comes from a tiny
    +      // set of services, which we read cheaply from the session source (sorted
    +      // by time), turning the trace scan into a primary-key range (~50 marks,
    +      // ~20x faster cold). Purely an optimization: on any failure or when no
    +      // services resolve, we fall back to the unscoped (correct) scan.
    +      const serviceNameExpression =
    +        traceSource.serviceNameExpression || 'ServiceName';
    +      let rumServiceNames: string[] = [];
    +      try {
    +        const serviceNamesQuery = await renderChartConfig(
    +          {
    +            select: [
    +              {
    +                valueExpression: `DISTINCT ${serviceNameExpression}`,
    +                alias: 'serviceName',
    +              },
    +            ],
    +            from: sessionSource.from,
    +            dateRange,
    +            where: `notEmpty(${getSessionsSourceFieldExpression(
    +              sessionSource.resourceAttributesExpression ??
    +                'ResourceAttributes',
    +              'rum.sessionId',
    +            )})`,
    +            whereLanguage: 'sql',
    +            timestampValueExpression: sessionSource.timestampValueExpression,
    +            connection: sessionSource.connection,
    +          },
    +          metadata,
    +          sessionSource.querySettings,
    +        );
    +        const serviceNamesJson = await clickhouseClient
    +          .query({
    +            query: serviceNamesQuery.sql,
    +            query_params: serviceNamesQuery.params,
    +            connectionId: sessionSource.connection,
    +          })
    +          .then(res => res.json<{ serviceName: string }>());
    +        rumServiceNames = (serviceNamesJson.data ?? [])
    +          .map(row => row.serviceName)
    +          .filter((name): name is string => !!name);
    +      } catch {
    +        // Optimization only — fall back to an unscoped scan.
    +      }
    +
    +      // Applied to the main aggregation alongside any user search. Kept separate
    +      // from `hasSearchQuery` so it never flips the HAVING/CTE behavior below.
    +      const serviceScopeFilters: Filter[] =
    +        rumServiceNames.length > 0
    +          ? [
    +              {
    +                type: 'sql',
    +                condition: `${serviceNameExpression} IN (${rumServiceNames
    +                  .map(name => `'${name.replace(/'/g, "''")}'`)
    +                  .join(', ')})`,
    +              } as Filter,
    +            ]
    +          : [];

    <a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> Service scope drops valid sessions

    If the session table lacks rows for a service that has qualifying RUM trace spans in the selected range, this nonempty IN scope excludes that service from the trace aggregation, causing its sessions to disappear from the list.

    Knowledge Base Used: Session replay and exploration

    <a href="https://app.greptile.com/ide/claude-code?prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2Fsessions.ts%0ALine%3A%20174-184%0A%0AComment%3A%0AService%20scope%20drops%20valid%20sessions%0A%0AIf%20the%20session%20table%20lacks%20rows%20for%20a%20service%20that%20has%20qualifying%20RUM%20trace%20spans%20in%20the%20selected%20range%2C%20this%20nonempty%20%60IN%60%20scope%20excludes%20that%20service%20from%20the%20trace%20aggregation%2C%20causing%20its%20sessions%20to%20disappear%20from%20the%20list.%0A%0AKnowledge%20Base%20Used%3A%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaudeDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaude.svg?v=6"><img alt="Fix in Claude Code" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaude.svg?v=6"></picture></a> <a href="https://app.greptile.com/api/ide/conductor?prompt=IMPORTANT%3A%20Work%20in%20the%20repository%20%22hyperdxio%2Fhyperdx%22%20on%20the%20existing%20branch%20%22add-session-filters%22.%20Checkout%20that%20branch%20%E2%80%94%20do%20NOT%20create%20a%20new%20branch%20or%20open%20a%20new%20PR.%20Push%20your%20changes%20to%20%22add-session-filters%22.%0A%0AThis%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2Fsessions.ts%0ALine%3A%20174-184%0A%0AComment%3A%0AService%20scope%20drops%20valid%20sessions%0A%0AIf%20the%20session%20table%20lacks%20rows%20for%20a%20service%20that%20has%20qualifying%20RUM%20trace%20spans%20in%20the%20selected%20range%2C%20this%20nonempty%20%60IN%60%20scope%20excludes%20that%20service%20from%20the%20trace%20aggregation%2C%20causing%20its%20sessions%20to%20disappear%20from%20the%20list.%0A%0AKnowledge%20Base%20Used%3A%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductorDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductor.svg?v=6"><img alt="Fix in Conductor" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductor.svg?v=6"></picture></a> <a href="https://app.greptile.com/api/ide/cursor?prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2Fsessions.ts%0ALine%3A%20174-184%0A%0AComment%3A%0AService%20scope%20drops%20valid%20sessions%0A%0AIf%20the%20session%20table%20lacks%20rows%20for%20a%20service%20that%20has%20qualifying%20RUM%20trace%20spans%20in%20the%20selected%20range%2C%20this%20nonempty%20%60IN%60%20scope%20excludes%20that%20service%20from%20the%20trace%20aggregation%2C%20causing%20its%20sessions%20to%20disappear%20from%20the%20list.%0A%0AKnowledge%20Base%20Used%3A%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursorDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursor.svg?v=6"><img alt="Fix in Cursor" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursor.svg?v=6"></picture></a> <a href="https://app.greptile.com/api/ide/codex?prompt=IMPORTANT%3A%20Work%20in%20the%20repository%20%22hyperdxio%2Fhyperdx%22%20on%20the%20existing%20branch%20%22add-session-filters%22.%20Checkout%20that%20branch%20%E2%80%94%20do%20NOT%20create%20a%20new%20branch%20or%20open%20a%20new%20PR.%20Push%20your%20changes%20to%20%22add-session-filters%22.%0A%0AThis%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2Fsessions.ts%0ALine%3A%20174-184%0A%0AComment%3A%0AService%20scope%20drops%20valid%20sessions%0A%0AIf%20the%20session%20table%20lacks%20rows%20for%20a%20service%20that%20has%20qualifying%20RUM%20trace%20spans%20in%20the%20selected%20range%2C%20this%20nonempty%20%60IN%60%20scope%20excludes%20that%20service%20from%20the%20trace%20aggregation%2C%20causing%20its%20sessions%20to%20disappear%20from%20the%20list.%0A%0AKnowledge%20Base%20Used%3A%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodexDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodex.svg?v=6"><img alt="Fix in Codex" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodex.svg?v=6"></picture></a>

    greptile-apps[bot] greptile-apps[bot] commented on code on Aug 25, 2026 01:06 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -390,11 +481,19 @@ function SessionsPage() {
         // TODO: if selectedSession is not null, we should filter by that session id
         where: appliedConfig.where as SearchCondition,
         whereLanguage: appliedConfig.whereLanguage as SearchConditionLanguage,
    +    filters: appliedConfig.filters ?? undefined,

    <a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> Source changes retain stale filters

    When a user applies a facet and then selects a session source whose trace source lacks that field or assigns it different semantics, the URL-persisted filter is sent directly to the new source, causing the sessions query to fail or return incorrect results.

    Knowledge Base Used:

  • Search and log exploration

  • Session replay and exploration
  • <a href="https://app.greptile.com/ide/claude-code?prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2FSessionsPage.tsx%0ALine%3A%20481-484%0A%0AComment%3A%0ASource%20changes%20retain%20stale%20filters%0A%0AWhen%20a%20user%20applies%20a%20facet%20and%20then%20selects%20a%20session%20source%20whose%20trace%20source%20lacks%20that%20field%20or%20assigns%20it%20different%20semantics%2C%20the%20URL-persisted%20filter%20is%20sent%20directly%20to%20the%20new%20source%2C%20causing%20the%20sessions%20query%20to%20fail%20or%20return%20incorrect%20results.%0A%0AKnowledge%20Base%20Used%3A%0A-%20%5BSearch%20and%20log%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsearch-and-log-exploration.md%29%0A-%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaudeDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaude.svg?v=6"><img alt="Fix in Claude Code" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaude.svg?v=6"></picture></a> <a href="https://app.greptile.com/api/ide/conductor?prompt=IMPORTANT%3A%20Work%20in%20the%20repository%20%22hyperdxio%2Fhyperdx%22%20on%20the%20existing%20branch%20%22add-session-filters%22.%20Checkout%20that%20branch%20%E2%80%94%20do%20NOT%20create%20a%20new%20branch%20or%20open%20a%20new%20PR.%20Push%20your%20changes%20to%20%22add-session-filters%22.%0A%0AThis%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2FSessionsPage.tsx%0ALine%3A%20481-484%0A%0AComment%3A%0ASource%20changes%20retain%20stale%20filters%0A%0AWhen%20a%20user%20applies%20a%20facet%20and%20then%20selects%20a%20session%20source%20whose%20trace%20source%20lacks%20that%20field%20or%20assigns%20it%20different%20semantics%2C%20the%20URL-persisted%20filter%20is%20sent%20directly%20to%20the%20new%20source%2C%20causing%20the%20sessions%20query%20to%20fail%20or%20return%20incorrect%20results.%0A%0AKnowledge%20Base%20Used%3A%0A-%20%5BSearch%20and%20log%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsearch-and-log-exploration.md%29%0A-%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductorDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductor.svg?v=6"><img alt="Fix in Conductor" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductor.svg?v=6"></picture></a> <a href="https://app.greptile.com/api/ide/cursor?prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2FSessionsPage.tsx%0ALine%3A%20481-484%0A%0AComment%3A%0ASource%20changes%20retain%20stale%20filters%0A%0AWhen%20a%20user%20applies%20a%20facet%20and%20then%20selects%20a%20session%20source%20whose%20trace%20source%20lacks%20that%20field%20or%20assigns%20it%20different%20semantics%2C%20the%20URL-persisted%20filter%20is%20sent%20directly%20to%20the%20new%20source%2C%20causing%20the%20sessions%20query%20to%20fail%20or%20return%20incorrect%20results.%0A%0AKnowledge%20Base%20Used%3A%0A-%20%5BSearch%20and%20log%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsearch-and-log-exploration.md%29%0A-%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursorDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursor.svg?v=6"><img alt="Fix in Cursor" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursor.svg?v=6"></picture></a> <a href="https://app.greptile.com/api/ide/codex?prompt=IMPORTANT%3A%20Work%20in%20the%20repository%20%22hyperdxio%2Fhyperdx%22%20on%20the%20existing%20branch%20%22add-session-filters%22.%20Checkout%20that%20branch%20%E2%80%94%20do%20NOT%20create%20a%20new%20branch%20or%20open%20a%20new%20PR.%20Push%20your%20changes%20to%20%22add-session-filters%22.%0A%0AThis%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2FSessionsPage.tsx%0ALine%3A%20481-484%0A%0AComment%3A%0ASource%20changes%20retain%20stale%20filters%0A%0AWhen%20a%20user%20applies%20a%20facet%20and%20then%20selects%20a%20session%20source%20whose%20trace%20source%20lacks%20that%20field%20or%20assigns%20it%20different%20semantics%2C%20the%20URL-persisted%20filter%20is%20sent%20directly%20to%20the%20new%20source%2C%20causing%20the%20sessions%20query%20to%20fail%20or%20return%20incorrect%20results.%0A%0AKnowledge%20Base%20Used%3A%0A-%20%5BSearch%20and%20log%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsearch-and-log-exploration.md%29%0A-%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodexDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodex.svg?v=6"><img alt="Fix in Codex" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodex.svg?v=6"></picture></a>

    github-actions[bot] github-actions[bot] commented on Aug 25, 2026 01:14 UTC
    Bot

    <!-- deep-review-state: diff=f6c89d9eecac76e1cf12c01775aba341e756091456352a17c2885bc9cb123c9a; plugin=compound-engineering-v3.6.1 -->
    <!-- deep-review -->

    Deep Review

    Faceted filters for /sessions: URL-persisted filters threaded into the RUM-scoped trace aggregation, with DBSearchPageFilters refactored behind a SessionFilters wrapper. The core logic is sound — the SQL/lucene scope builder, the zod-validated ?filters= parser, the whitespace handling, and the forceExactFacetMode facet scoping all check out, and every prior reviewer concern was verified as genuinely addressed. The open items cluster around how source changes and deep-linked URLs reconcile incompatible filters.

    ✅ No critical issues found.

    🟡 P2 — recommended

  • packages/app/src/SessionsPage.tsx:462 — URL-seeded and cross-source filters bypass retainCompatibleFilters because the reconcile only runs when pendingFilterReconcileRef is set, which happens solely on an interactive source change with paramSource != null; a shared or hand-edited URL whose ?filters= reference columns absent from the (auto-selected or param) source execute against the trace query with no dropped-filter notice, surfacing a column-not-found error as a bare "No matching sessions".

  • - Fix: Run the reconcile once after the first traceColumns load whenever appliedConfig.filters is non-empty, not only on interactive source switches.
    - <sub>adversarial, correctness, julik-frontend-races, kieran-typescript</sub>
  • packages/app/src/sessions.ts:241 — sessionFiltersParser accepts the full FilterSchema union, so non-canonical frames (type: 'lucene', type: 'sql_ast', or a non-IN sql condition) in ?filters= are executed verbatim via traceQueryFilters yet render no pill or facet state, so displayed and executed filter sets silently diverge with no removal path except the blanket "Clear filters" button.

  • - Fix: Validate persisted session filters against the renderable-filter predicate and drop or flag frames that will not round-trip to a visible facet.
    - <sub>adversarial</sub>
  • packages/app/src/SessionsPage.tsx:462 — The new pendingFilterReconcileRef/retainCompatibleFilters handshake and the filters threading in useSessions (the PR's core behavior, including the hasSearchQuery HAVING/CTE branch) have no test; the multi-condition guard and cross-effect ordering are the most breakage-prone new logic and are only exercised indirectly through the unit-tested retainFiltersByColumns primitive.

  • - Fix: Add a page/hook-level test for a source switch that drops filters referencing columns absent on the new source, and a useSessions test asserting filters reach the aggregation query and flip the hasSearchQuery branch.
    - <sub>testing, correctness, maintainability, julik-frontend-races, kieran-typescript</sub>

    <details>
    <summary>🔵 P3 nitpicks (6)</summary>

  • packages/app/src/sessions.ts:157 — The SQL branch's AND (${query}\n) newline only neutralizes a trailing -- line comment; an unterminated block comment (/) in the query still swallows the injected ), and the inline comment overstates the invariant.

  • - Fix: Scope the comment to line comments and normalize or reject a trailing unterminated block comment before wrapping.
    - <sub>
    correctness, adversarial</sub>
  • packages/app/src/SessionsPage.tsx:533 — appliedConfig.whereLanguage is 'sql' | 'lucene' | null, but the as SearchConditionLanguage cast forces null into a type that forbids it (and the adjacent as SearchCondition is a redundant string→string cast), disabling the checker for this flow.

  • - Fix: Use appliedConfig.whereLanguage ?? undefined and drop the redundant where cast.
    - <sub>
    kieran-typescript</sub>
  • packages/app/src/sessions.ts:137 — The fallback string 'ResourceAttributes' is duplicated across buildSessionsScope, useSessions, and SessionsPage.tsx:385.

  • - Fix: Hoist it to one shared named constant.
    - <sub>
    maintainability</sub>
  • packages/app/src/SessionsPage.tsx:684 — ActiveFilterPills renders unconditionally (not gated by canShowFilterSidebar), so with a non-empty URL filter set and traceTrace still null, its in-pill value picker can issue key-value queries against the empty fallback chartConfig (connection: '', from: {'',''}).

  • - Fix: Gate the pills on canShowFilterSidebar, or pass a disabled flag when the empty fallback config is in use.
    - <sub>
    correctness, kieran-typescript</sub>
  • packages/app/src/SessionsPage.tsx:453 — pendingFilterReconcileRef can remain set forever when switching to a source whose trace columns never load (no traceSourceId or unreachable columns), so a later unrelated traceColumns arrival could fire a reconcile the user never triggered.

  • - Fix: Reset the ref on every terminal branch, or key it to a specific (sourceId, traceSourceId) pair.
    - <sub>
    julik-frontend-races</sub>
  • packages/app/src/components/DBSearchPageFilters.tsx:1121 — hideAnalysisMode now gates five distinct UI regions (header justify, header text, tabs, denoise checkbox, root-spans checkbox), and its name implies it only hides the tabs, so future UI additions must remember to gate on it.

  • - Fix: Extract the analysis-mode header/tabs/denoise block into a sub-component rendered only when enabled.
    - <sub>
    maintainability*</sub>

    </details>

    ---
    Reviewers (9): correctness, testing, maintainability, kieran-typescript, performance, adversarial, julik-frontend-races, project-standards, previous-comments.

    Testing gaps:

  • No test for deep-link/URL-seeded ?filters= referencing columns absent from the auto-selected source (the reconcile-never-fires path).

  • No test for a rapid A→B source switch asserting the sessions query does not fire with the previous source's filters.

  • No test exercises the forceExactFacetMode → mode: 'exact' branch at the facet query (only prop forwarding at the wrapper boundary is covered).

  • No test for the filtersChartConfig empty-config fallback or that notifications.show fires exactly once per reconcile.
  • <sub>No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond</sub>

    greptile-apps[bot] greptile-apps[bot] commented on code on Aug 25, 2026 01:25 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +102,104 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM
    +      // sessions. `otel_traces` is sorted by (ServiceName, SpanName, Timestamp),
    +      // so with no ServiceName predicate the time filter can't prune via the
    +      // primary index — the query scans the whole table's marks (~100k) to
    +      // evaluate the `rum.sessionId` skip index. RUM traffic comes from a tiny
    +      // set of services, which we read cheaply from the session source (sorted
    +      // by time), turning the trace scan into a primary-key range (~50 marks,
    +      // ~20x faster cold). Purely an optimization: on any failure or when no
    +      // services resolve, we fall back to the unscoped (correct) scan.
    +      const serviceNameExpression =
    +        traceSource.serviceNameExpression || 'ServiceName';
    +      // Enumerate RUM services over a window wider than the selected range. A
    +      // session's row in the session source is timestamped at (near) its start,
    +      // which can fall *before* `dateRange` even though its trace spans land
    +      // inside it. Scoping to only services seen within the exact range would
    +      // then drop those sessions. Over-inclusion is safe — an extra ServiceName
    +      // only widens the primary-key range scanned; the `rum.sessionId`
    +      // predicate + HAVING still filter the rows — so we look back a generous
    +      // margin. Under-inclusion is the correctness bug we must avoid.
    +      const SERVICE_SCOPE_LOOKBACK_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
    +      const serviceScopeDateRange: [Date, Date] = [
    +        new Date(dateRange[0].getTime() - SERVICE_SCOPE_LOOKBACK_MS),
    +        dateRange[1],
    +      ];

    <a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> Finite service scope drops sessions

    If trace retention exceeds session retention, or a trace-derived session has no recording row in this 30-day window, the nonempty service list becomes a hard ServiceName IN filter that excludes the session's service, causing valid sessions to disappear from the list.

    Knowledge Base Used: Session replay and exploration

    <a href="https://app.greptile.com/ide/claude-code?prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2Fsessions.ts%0ALine%3A%20142-146%0A%0AComment%3A%0AFinite%20service%20scope%20drops%20sessions%0A%0AIf%20trace%20retention%20exceeds%20session%20retention%2C%20or%20a%20trace-derived%20session%20has%20no%20recording%20row%20in%20this%2030-day%20window%2C%20the%20nonempty%20service%20list%20becomes%20a%20hard%20%60ServiceName%20IN%60%20filter%20that%20excludes%20the%20session's%20service%2C%20causing%20valid%20sessions%20to%20disappear%20from%20the%20list.%0A%0AKnowledge%20Base%20Used%3A%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaudeDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaude.svg?v=6"><img alt="Fix in Claude Code" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaude.svg?v=6"></picture></a> <a href="https://app.greptile.com/api/ide/conductor?prompt=IMPORTANT%3A%20Work%20in%20the%20repository%20%22hyperdxio%2Fhyperdx%22%20on%20the%20existing%20branch%20%22add-session-filters%22.%20Checkout%20that%20branch%20%E2%80%94%20do%20NOT%20create%20a%20new%20branch%20or%20open%20a%20new%20PR.%20Push%20your%20changes%20to%20%22add-session-filters%22.%0A%0AThis%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2Fsessions.ts%0ALine%3A%20142-146%0A%0AComment%3A%0AFinite%20service%20scope%20drops%20sessions%0A%0AIf%20trace%20retention%20exceeds%20session%20retention%2C%20or%20a%20trace-derived%20session%20has%20no%20recording%20row%20in%20this%2030-day%20window%2C%20the%20nonempty%20service%20list%20becomes%20a%20hard%20%60ServiceName%20IN%60%20filter%20that%20excludes%20the%20session's%20service%2C%20causing%20valid%20sessions%20to%20disappear%20from%20the%20list.%0A%0AKnowledge%20Base%20Used%3A%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductorDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductor.svg?v=6"><img alt="Fix in Conductor" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductor.svg?v=6"></picture></a> <a href="https://app.greptile.com/api/ide/cursor?prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2Fsessions.ts%0ALine%3A%20142-146%0A%0AComment%3A%0AFinite%20service%20scope%20drops%20sessions%0A%0AIf%20trace%20retention%20exceeds%20session%20retention%2C%20or%20a%20trace-derived%20session%20has%20no%20recording%20row%20in%20this%2030-day%20window%2C%20the%20nonempty%20service%20list%20becomes%20a%20hard%20%60ServiceName%20IN%60%20filter%20that%20excludes%20the%20session's%20service%2C%20causing%20valid%20sessions%20to%20disappear%20from%20the%20list.%0A%0AKnowledge%20Base%20Used%3A%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursorDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursor.svg?v=6"><img alt="Fix in Cursor" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursor.svg?v=6"></picture></a> <a href="https://app.greptile.com/api/ide/codex?prompt=IMPORTANT%3A%20Work%20in%20the%20repository%20%22hyperdxio%2Fhyperdx%22%20on%20the%20existing%20branch%20%22add-session-filters%22.%20Checkout%20that%20branch%20%E2%80%94%20do%20NOT%20create%20a%20new%20branch%20or%20open%20a%20new%20PR.%20Push%20your%20changes%20to%20%22add-session-filters%22.%0A%0AThis%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2Fsessions.ts%0ALine%3A%20142-146%0A%0AComment%3A%0AFinite%20service%20scope%20drops%20sessions%0A%0AIf%20trace%20retention%20exceeds%20session%20retention%2C%20or%20a%20trace-derived%20session%20has%20no%20recording%20row%20in%20this%2030-day%20window%2C%20the%20nonempty%20service%20list%20becomes%20a%20hard%20%60ServiceName%20IN%60%20filter%20that%20excludes%20the%20session's%20service%2C%20causing%20valid%20sessions%20to%20disappear%20from%20the%20list.%0A%0AKnowledge%20Base%20Used%3A%20%5BSession%20replay%20and%20exploration%5D%28https%3A%2F%2Fapp.greptile.com%2Fhyperdx%2F-%2Fcustom-context%2Fknowledge-base%2Fhyperdxio%2Fhyperdx%2F-%2Fdocs%2Fsession-replay-and-exploration.md%29%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodexDark.svg?v=6"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodex.svg?v=6"><img alt="Fix in Codex" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodex.svg?v=6"></picture></a>

    pulpdrew pulpdrew commented on code on Sep 01, 2026 19:11 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -490,43 +601,79 @@ function SessionsPage() {
                   </Group>
                 </PageHeader>
               }
    -          padded
               content={
    -            <>
    -              {isSessionsLoading || isSessionSourceLoading ? (
    -                <Group mt="md" align="center" justify="center" gap="xs">
    -                  <IconRefresh className="spin-animate" size={14} />
    -                  {isSessionSourceLoading
    -                    ? 'Loading...'
    -                    : 'Searching sessions...'}
    -                </Group>
    -              ) : (
    -                <>
    -                  {!sessions.length ? (
    -                    <Flex
    -                      align="center"
    -                      justify="center"
    -                      style={{ flex: 1, minHeight: 0 }}
    -                    >
    -                      <SessionSetupInstructions />
    -                    </Flex>
    -                  ) : (
    -                    <div
    -                      style={{ minHeight: 0 }}
    -                      data-testid="session-card-list"
    -                    >
    -                      <SessionCardList
    -                        onClick={session => {
    -                          setSelectedSession(session);
    -                        }}
    -                        sessions={sessions}
    -                        isSessionLoading={isSessionsLoading}
    -                      />
    -                    </div>
    +            <div
    +              className={searchPageStyles.searchPageContainer}
    +              style={{ minHeight: 0, height: '100%' }}
    +            >
    +              {sessionSource != null &&
    +                traceTrace != null &&
    +                !isFilterSidebarCollapsed && (
    +                  <ErrorBoundary message="Unable to render session filters">
    +                    <SessionFilters
    +                      chartConfig={filtersChartConfig}
    +                      sourceId={traceTrace.id}
    +                      onCollapse={() => setIsFilterSidebarCollapsed(true)}
    +                      {...searchFilters}
    +                    />
    +                  </ErrorBoundary>
    +                )}
    +              <Flex
    +                direction="column"
    +                p="sm"
    +                style={{ flex: 1, minWidth: 0, minHeight: 0 }}
    +              >
    +                <Group gap={4} align="center" wrap="nowrap">
    +                  {isFilterSidebarCollapsed && (
    +                    <Tooltip label="Show filters" position="bottom">
    +                      <ActionIcon
    +                        variant="subtle"
    +                        size="sm"
    +                        onClick={() => setIsFilterSidebarCollapsed(false)}
    +                        aria-label="Show filters"
    +                      >
    +                        <IconArrowBarToRight size={16} />
    +                      </ActionIcon>
    +                    </Tooltip>
                       )}
    -                </>
    -              )}
    -            </>
    +                  <ActiveFilterPills
    +                    searchFilters={searchFilters}
    +                    chartConfig={filtersChartConfig}
    +                    dateTimeColumns={dateTimeColumns}
    +                    style={{ flex: 1 }}
    +                  />

    I think we could use some bottom margin here, and maybe some alignment of the left margin between these pills and the session card list

    <img width="1944" height="152" alt="Image" src="https://github.com/user-attachments/assets/7192d0d6-538a-4bcc-8f42-9f3389129048" />

    pulpdrew pulpdrew commented on code on Sep 01, 2026 19:22 UTC
    Code Review
    packages/app/src/components/SessionFilters.tsx:1
    @@ -0,0 +1,39 @@
    +import { ComponentProps } from 'react';
    +
    +import { DBSearchPageFilters } from './DBSearchPageFilters';
    +
    +// Props the sessions page controls. The analysis-mode toggles, delta view, and
    +// live-tail behavior don't apply to sessions, so they're baked in here instead
    +// of being threaded through the page.
    +type SessionFiltersProps = Omit<
    +  ComponentProps<typeof DBSearchPageFilters>,
    +  | 'analysisMode'
    +  | 'setAnalysisMode'
    +  | 'showDelta'
    +  | 'denoiseResults'
    +  | 'setDenoiseResults'
    +  | 'isLive'
    +  | 'hideAnalysisMode'
    +  | 'forceExactFacetMode'
    +>;
    +
    +/**
    + * Sessions-specific filter sidebar: the same faceted filters as the search
    + * page, minus the "Analysis Mode" header/tabs and denoise toggle. A thin
    + * wrapper over {@link DBSearchPageFilters} so the two stay in sync without
    + * duplicating the facet machinery.
    + *
    + * `forceExactFacetMode` is on because the sessions `chartConfig` scopes facets
    + * to RUM session spans; "all" mode would strip that scope and sample the whole
    + * trace table, which times out and leaves the sidebar empty.
    + */
    +export function SessionFilters(props: SessionFiltersProps) {
    +  return (
    +    <DBSearchPageFilters
    +      {...props}
    +      isLive={false}
    +      hideAnalysisMode
    +      forceExactFacetMode

    If we're forcing exact mode, we should avoid showing the option to toggle between exact and all mode

    <img width="342" height="241" alt="Image" src="https://github.com/user-attachments/assets/ebe74fa0-9d40-4e81-b7d8-f2b668eaed84" />

    github-actions[bot] github-actions[bot] commented on code on Sep 01, 2026 19:26 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -326,6 +347,84 @@ function SessionsPage() {
         })();
       }, [handleSubmit, setAppliedConfig, onSearch, displayedTimeInputValue]);
     
    +  // The sidebar filters run against the trace source, so its columns are what
    +  // we quote against and read DateTime types from.
    +  const { data: traceColumns } = useColumns(
    +    {
    +      databaseName: traceTrace?.from?.databaseName ?? '',
    +      tableName: traceTrace?.from?.tableName ?? '',
    +      connectionId: traceTrace?.connection ?? '',
    +    },
    +    { enabled: !!traceTrace },
    +  );
    +  const knownColumns = useMemo(
    +    () =>
    +      traceColumns ? new Set(traceColumns.map(c => c.name)) : new Set<string>(),
    +    [traceColumns],
    +  );
    +  const { dateTimeColumns } = useResolvedDateTimeColumns(traceColumns);
    +
    +  // Applying a facet filter re-runs the query immediately (against the current
    +  // time range), mirroring the search page's debounced auto-submit.
    +  const handleSetFilters = useCallback(

    🟠 major — Clicking a sidebar facet resets the form and discards a typed-but-unsubmitted query

    useForm({ values: {...} }) at SessionsPage.tsx:272 has no resetOptions, so RHF does a full reset whenever the values object changes. handleSetFilters calls setAppliedConfig({ filters }), which changes appliedConfig → changes values → resets where back to appliedConfig.where. Concretely: type error in the search box (don't press Run), click a ServiceName checkbox — the search box visibly reverts to empty and the query never runs. The comment claims this mirrors the search page, but DBSearchPage.tsx:1122 sets resetOptions: { keepDirtyValues: true } and its handleSetFilters (DBSearchPage.tsx:1296) calls debouncedSubmit() so the whole form is applied. Do the same here: add resetOptions: { keepDirtyValues: true } to the useForm call and make handleSetFilters call onSubmit() instead of writing only filters.

    <!-- hdxr:020520d46aaf9c3d -->

    github-actions[bot] github-actions[bot] commented on code on Sep 01, 2026 19:26 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +134,110 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM

    🟠 major — ServiceName scope derived from the session source can silently drop whole services' sessions

    The scope list is built from a DISTINCT ServiceName scan of sessionSource.from (the rrweb table), then applied as a hard ServiceName IN (...) predicate on the trace aggregation. A service that emits RUM spans (rum.sessionId, component:"user-interaction") but writes no rrweb rows — session recording disabled in the browser SDK, recording not yet started, or a shorter TTL on the sessions table — contributes zero rows to that DISTINCT, so its sessions disappear from /sessions entirely, with no error and no UI signal. The try/catch only covers query failure, not a successfully-returned-but-incomplete list. Either derive the scope from the trace source itself (a cheap DISTINCT serviceNameExpression with the rum.sessionId predicate over the same range), or gate the whole optimization behind an explicit source/feature flag so correctness isn't traded away by default.

    <!-- hdxr:93022b65e8d09d1f -->

    github-actions[bot] github-actions[bot] commented on code on Sep 01, 2026 19:26 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -326,6 +347,84 @@ function SessionsPage() {
         })();
       }, [handleSubmit, setAppliedConfig, onSearch, displayedTimeInputValue]);
     
    +  // The sidebar filters run against the trace source, so its columns are what
    +  // we quote against and read DateTime types from.
    +  const { data: traceColumns } = useColumns(
    +    {
    +      databaseName: traceTrace?.from?.databaseName ?? '',
    +      tableName: traceTrace?.from?.tableName ?? '',
    +      connectionId: traceTrace?.connection ?? '',
    +    },
    +    { enabled: !!traceTrace },
    +  );
    +  const knownColumns = useMemo(
    +    () =>
    +      traceColumns ? new Set(traceColumns.map(c => c.name)) : new Set<string>(),
    +    [traceColumns],
    +  );
    +  const { dateTimeColumns } = useResolvedDateTimeColumns(traceColumns);
    +
    +  // Applying a facet filter re-runs the query immediately (against the current
    +  // time range), mirroring the search page's debounced auto-submit.
    +  const handleSetFilters = useCallback(
    +    (newFilters: Filter[]) => {
    +      setValue('filters', newFilters);
    +      setAppliedConfig({ filters: newFilters });
    +    },
    +    [setValue, setAppliedConfig],
    +  );
    +
    +  const filters = useWatch({ control, name: 'filters' });
    +  const searchFilters = useSearchPageFilterState({
    +    searchQuery: filters ?? undefined,
    +    onFilterChange: handleSetFilters,
    +    dateTimeColumns,
    +    knownColumns,
    +  });
    +
    +  // Chart config used by the filters sidebar to fetch facet values and
    +  // distributions. Scoped to the trace source with the currently applied
    +  // where + filters so counts reflect the filtered set.
    +  const filtersChartConfig = useMemo<BuilderChartConfigWithDateRange>(() => {
    +    const overrides = { dateRange: searchedTimeRange } as const;
    +    if (traceTrace == null) {
    +      return {
    +        timestampValueExpression: '',
    +        connection: '',
    +        from: { databaseName: '', tableName: '' },
    +        where: '',
    +        select: '',
    +        ...overrides,
    +      };
    +    }
    +    // Scope facets to RUM session spans only. Without this the facet sidebar
    +    // queries the entire trace table (all services, tens of millions of spans),
    +    // which times out and leaves the sidebar empty. The `indexHint` lets the
    +    // `rum.sessionId` skip index prune to just the session rows. This is applied
    +    // as an always-on SQL filter alongside the user's search + facet selections.
    +    const rumSessionIdKey = `${traceTrace.resourceAttributesExpression}['rum.sessionId']`;

    🟠 major — rumScopeFilter hardcodes Map access and mapContains, breaking JSON-typed ResourceAttributes

    ${traceTrace.resourceAttributesExpression}['rum.sessionId'] and mapContains(...) assume the column is a Map. The repo already has useFieldExpressionGenerator (packages/app/src/hooks/useFieldExpressionGenerator.tsx) for exactly this — sessions.ts:132 uses it to build traceSessionIdExpression for the same key, emitting toString(col.key) for JSON columns. On a JSON-typed ResourceAttributes the sidebar's facet query is invalid SQL, so every facet fetch fails and the user gets a red notification plus an empty sidebar. resourceAttributesExpression is also z.string().optional() (common-utils/src/types.ts:2279), so it can render as the literal undefined. Build the expression with useFieldExpressionGenerator(traceTrace) and apply the ?? 'ResourceAttributes' fallback used elsewhere in sessions.ts.

    <!-- hdxr:1d0b318fd4e0a50f -->

    github-actions[bot] github-actions[bot] commented on code on Sep 01, 2026 19:26 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -490,43 +601,79 @@ function SessionsPage() {
                   </Group>
                 </PageHeader>
               }
    -          padded
               content={
    -            <>
    -              {isSessionsLoading || isSessionSourceLoading ? (
    -                <Group mt="md" align="center" justify="center" gap="xs">
    -                  <IconRefresh className="spin-animate" size={14} />
    -                  {isSessionSourceLoading
    -                    ? 'Loading...'
    -                    : 'Searching sessions...'}
    -                </Group>
    -              ) : (
    -                <>
    -                  {!sessions.length ? (
    -                    <Flex
    -                      align="center"
    -                      justify="center"
    -                      style={{ flex: 1, minHeight: 0 }}
    -                    >
    -                      <SessionSetupInstructions />
    -                    </Flex>
    -                  ) : (
    -                    <div
    -                      style={{ minHeight: 0 }}
    -                      data-testid="session-card-list"
    -                    >
    -                      <SessionCardList
    -                        onClick={session => {
    -                          setSelectedSession(session);
    -                        }}
    -                        sessions={sessions}
    -                        isSessionLoading={isSessionsLoading}
    -                      />
    -                    </div>
    +            <div
    +              className={searchPageStyles.searchPageContainer}
    +              style={{ minHeight: 0, height: '100%' }}
    +            >
    +              {sessionSource != null &&
    +                traceTrace != null &&
    +                !isFilterSidebarCollapsed && (
    +                  <ErrorBoundary message="Unable to render session filters">
    +                    <SessionFilters
    +                      chartConfig={filtersChartConfig}
    +                      sourceId={traceTrace.id}
    +                      onCollapse={() => setIsFilterSidebarCollapsed(true)}
    +                      {...searchFilters}
    +                    />
    +                  </ErrorBoundary>
    +                )}
    +              <Flex
    +                direction="column"
    +                p="sm"
    +                style={{ flex: 1, minWidth: 0, minHeight: 0 }}
    +              >
    +                <Group gap={4} align="center" wrap="nowrap">
    +                  {isFilterSidebarCollapsed && (
    +                    <Tooltip label="Show filters" position="bottom">
    +                      <ActionIcon
    +                        variant="subtle"
    +                        size="sm"
    +                        onClick={() => setIsFilterSidebarCollapsed(false)}
    +                        aria-label="Show filters"
    +                      >
    +                        <IconArrowBarToRight size={16} />
    +                      </ActionIcon>
    +                    </Tooltip>
                       )}
    -                </>
    -              )}
    -            </>
    +                  <ActiveFilterPills

    🟠 major — In-pill value picker strips the RUM scope that forceExactFacetMode exists to preserve

    ActiveFilterPills is handed filtersChartConfig, and FilterPill builds its value-picker config as { ...chartConfig, where: '', filters: [] } (packages/app/src/components/ActiveFilterPills.tsx:160). That clears rumScopeFilter, so clicking a pill on /sessions runs groupUniqArray over the entire trace table for the selected range — the exact unscoped query the PR added forceExactFacetMode to avoid. Carry the always-on scope outside filters (e.g. fold it into the config's where, or add a prop for a non-strippable base filter honoured by both useFacets' mode === 'all' branch and valueChartConfig) so the pill picker stays scoped.

    <!-- hdxr:f55e684ab9897cb1 -->

    github-actions[bot] github-actions[bot] commented on code on Sep 01, 2026 19:26 UTC
    Code Review
    packages/app/src/components/DBSearchPageFilters.tsx:1
    @@ -1182,7 +1193,7 @@ const DBSearchPageFiltersComponent = ({
         chartConfig,
         sourceId: sourceId ?? null,
         dateRange,
    -    mode: showAllValues ? 'all' : 'exact',
    +    mode: forceExactFacetMode || !showAllValues ? 'exact' : 'all',

    🔵 minor — "Show all values" setting is inert on /sessions but still writes the shared localStorage key

    With forceExactFacetMode, mode is always 'exact', yet FilterSettingsPanel (line 1661) still renders the showAllValues switch, wired to the shared hdx-show-all-filter-values key. On /sessions the toggle does nothing locally while silently changing the search page's facet behaviour. Add a prop to hide (or disable with an explanatory tooltip) the "Show all values" control when forceExactFacetMode is set.

    <!-- hdxr:4d0810a21bf76ed1 -->

    github-actions[bot] github-actions[bot] commented on code on Sep 01, 2026 19:26 UTC
    Code Review
    packages/app/src/components/DBSearchPageFilters.tsx:1
    @@ -1622,9 +1633,11 @@ const DBSearchPageFiltersComponent = ({
           >
             <Stack gap="sm" p="xs">
               <Flex align="center" justify="space-between">

    🔵 minor — Sidebar toolbar icons jump to the left edge when hideAnalysisMode is set

    The header <Flex align="center" justify="space-between"> relies on the "Analysis Mode" Text as its first item. With hideAnalysisMode the Group holding the settings gear and the "Hide filters" collapse button is the only flex child, so space-between places it at flex-start — the controls render at the top-left of the sessions sidebar instead of the top-right where they sit on the search page. Use justify={hideAnalysisMode ? 'flex-end' : 'space-between'}.

    <!-- hdxr:01662b3f88855d9b -->

    github-actions[bot] github-actions[bot] commented on code on Sep 01, 2026 19:26 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -490,43 +601,79 @@ function SessionsPage() {
                   </Group>
                 </PageHeader>
               }
    -          padded
               content={
    -            <>
    -              {isSessionsLoading || isSessionSourceLoading ? (
    -                <Group mt="md" align="center" justify="center" gap="xs">
    -                  <IconRefresh className="spin-animate" size={14} />
    -                  {isSessionSourceLoading
    -                    ? 'Loading...'
    -                    : 'Searching sessions...'}
    -                </Group>
    -              ) : (
    -                <>
    -                  {!sessions.length ? (
    -                    <Flex
    -                      align="center"
    -                      justify="center"
    -                      style={{ flex: 1, minHeight: 0 }}
    -                    >
    -                      <SessionSetupInstructions />
    -                    </Flex>
    -                  ) : (
    -                    <div
    -                      style={{ minHeight: 0 }}
    -                      data-testid="session-card-list"
    -                    >
    -                      <SessionCardList
    -                        onClick={session => {
    -                          setSelectedSession(session);
    -                        }}
    -                        sessions={sessions}
    -                        isSessionLoading={isSessionsLoading}
    -                      />
    -                    </div>
    +            <div
    +              className={searchPageStyles.searchPageContainer}
    +              style={{ minHeight: 0, height: '100%' }}
    +            >
    +              {sessionSource != null &&
    +                traceTrace != null &&
    +                !isFilterSidebarCollapsed && (
    +                  <ErrorBoundary message="Unable to render session filters">
    +                    <SessionFilters
    +                      chartConfig={filtersChartConfig}
    +                      sourceId={traceTrace.id}
    +                      onCollapse={() => setIsFilterSidebarCollapsed(true)}
    +                      {...searchFilters}
    +                    />
    +                  </ErrorBoundary>
    +                )}
    +              <Flex
    +                direction="column"
    +                p="sm"
    +                style={{ flex: 1, minWidth: 0, minHeight: 0 }}
    +              >
    +                <Group gap={4} align="center" wrap="nowrap">
    +                  {isFilterSidebarCollapsed && (

    🔵 minor — Show-filters button duplicates DBSearchPage's ExpandFiltersButton

    The Tooltip + subtle ActionIcon + IconArrowBarToRight + aria-label="Show filters" block is a copy of ExpandFiltersButton in DBSearchPage.tsx:312 (differing only in icon/ActionIcon size). Export that component (or move it next to DBSearchPageFilters) and use it here so the two collapse affordances can't drift.

    <!-- hdxr:46b64c1ce8af4f7c -->

    github-actions[bot] github-actions[bot] commented on code on Sep 01, 2026 19:26 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +134,110 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM
    +      // sessions. `otel_traces` is sorted by (ServiceName, SpanName, Timestamp),
    +      // so with no ServiceName predicate the time filter can't prune via the
    +      // primary index — the query scans the whole table's marks (~100k) to
    +      // evaluate the `rum.sessionId` skip index. RUM traffic comes from a tiny
    +      // set of services, which we read cheaply from the session source (sorted
    +      // by time), turning the trace scan into a primary-key range (~50 marks,
    +      // ~20x faster cold).
    +      //
    +      // Correctness assumption: the session and trace sources report the same
    +      // `ServiceName` for RUM spans (the session source is the cheap,
    +      // time-sorted projection of the same RUM traffic, which is why we read the
    +      // list from there instead of re-scanning the trace table). If they diverge
    +      // — a service present in trace RUM spans but absent from the session-source
    +      // scan, or a differing service-name column — that service's sessions would
    +      // be dropped. On any query failure or an empty result we fall back to the
    +      // unscoped (correct) scan.
    +      const serviceNameExpression =
    +        traceSource.serviceNameExpression || 'ServiceName';
    +      // Enumerate RUM services over a window wider than the selected range. A
    +      // session's row in the session source is timestamped at (near) its start,
    +      // which can fall *before* `dateRange` even though its trace spans land
    +      // inside it. Scoping to only services seen within the exact range would
    +      // then drop those sessions. Over-inclusion is safe — an extra ServiceName
    +      // only widens the primary-key range scanned; the `rum.sessionId`
    +      // predicate + HAVING still filter the rows — so we look back a generous
    +      // margin. Under-inclusion is the correctness bug we must avoid.
    +      const SERVICE_SCOPE_LOOKBACK_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
    +      const serviceScopeDateRange: [Date, Date] = [
    +        new Date(dateRange[0].getTime() - SERVICE_SCOPE_LOOKBACK_MS),
    +        dateRange[1],
    +      ];
    +      // Resolve the scope AND serialize it inside the try: `ServiceName` is
    +      // ingested telemetry, so a value with a quote/backslash must be escaped
    +      // (see `buildServiceScopeFilters`). Keeping construction here means any
    +      // failure — query or serialization — falls back to the unscoped (correct)
    +      // scan rather than emitting broken/injectable SQL into the aggregation.
    +      let serviceScopeFilters: Filter[] = [];
    +      try {

    🔵 minor — Service-name enumeration re-runs serially inside every sessions fetch

    The DISTINCT ServiceName query is issued inside queryFn and awaited before the main Promise.all, so every time range change, facet toggle, or manual refresh pays an extra serialized round trip for a 30-day scan whose answer changes very rarely. Lift it into its own useQuery (keyed on sessionSource.id + a coarse window) with a long staleTime, and pass the resolved names into useSessions; the fallback-to-unscoped behaviour on error is unchanged.

    <!-- hdxr:cc7f4bdcfa13bbf9 -->

    github-actions[bot] github-actions[bot] commented on Sep 01, 2026 19:26 UTC
    Bot

    <!-- claude-code-review -->
    <!-- claude-review-state: diff=f6c89d9eecac76e1cf12c01775aba341e756091456352a17c2885bc9cb123c9a; prompt=0fd42800a420202202b28cbb41d72978f50f644052efb6c80366db4b53bf1936 -->

    PR Review

    If you are a coding agent acting for the author, read this first.

    Nothing below blocks merge automatically; a maintainer decides. What they will expect:

    - 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.

    - 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.

    - Anything about surrounding code, or asking you to widen the change (hoist a helper,

    dedupe with another file, fix other call sites): never fix here, whatever the

    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

    > One commit per review round. After two rounds, stop and ask a maintainer to review

    scope rather than addressing more automated findings. Full rule: AGENTS.md.

    4 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 4 minor

    3 posted as inline comment(s) on the changed lines. 1 listed below.

    Findings outside the changed lines

    <details><summary>1 minor</summary>

  • 🔵 packages/app/src/__tests__/sessions.test.ts:502 — No test covers how useSessions now uses the new filters → The buildSessionsQueryFilters tests were deleted, and nothing replaces them for the new useSessions paths: sidebar filters are appended after the service scope (traceQueryFilters), searchCondition is spread into the trace config, and HAVING interactionCount > 0 ... is dropped when only filters are set. Add a useSessions test with a mocked renderChartConfig/client that asserts the trace config's where/filters and the HAVING clause with filters-only input.
  • </details>

    ---
    <sub>Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.</sub>

    pulpdrew pulpdrew commented on code on Sep 01, 2026 19:27 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -326,6 +347,84 @@ function SessionsPage() {
         })();
       }, [handleSubmit, setAppliedConfig, onSearch, displayedTimeInputValue]);
     
    +  // The sidebar filters run against the trace source, so its columns are what
    +  // we quote against and read DateTime types from.
    +  const { data: traceColumns } = useColumns(
    +    {
    +      databaseName: traceTrace?.from?.databaseName ?? '',
    +      tableName: traceTrace?.from?.tableName ?? '',
    +      connectionId: traceTrace?.connection ?? '',
    +    },

        tcFromSource(traceTrace)
    

    pulpdrew pulpdrew commented on code on Sep 01, 2026 19:31 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -326,6 +347,84 @@ function SessionsPage() {
         })();
       }, [handleSubmit, setAppliedConfig, onSearch, displayedTimeInputValue]);
     
    +  // The sidebar filters run against the trace source, so its columns are what
    +  // we quote against and read DateTime types from.
    +  const { data: traceColumns } = useColumns(
    +    {
    +      databaseName: traceTrace?.from?.databaseName ?? '',
    +      tableName: traceTrace?.from?.tableName ?? '',
    +      connectionId: traceTrace?.connection ?? '',
    +    },
    +    { enabled: !!traceTrace },
    +  );
    +  const knownColumns = useMemo(
    +    () =>
    +      traceColumns ? new Set(traceColumns.map(c => c.name)) : new Set<string>(),
    +    [traceColumns],
    +  );
    +  const { dateTimeColumns } = useResolvedDateTimeColumns(traceColumns);
    +
    +  // Applying a facet filter re-runs the query immediately (against the current
    +  // time range), mirroring the search page's debounced auto-submit.
    +  const handleSetFilters = useCallback(
    +    (newFilters: Filter[]) => {
    +      setValue('filters', newFilters);
    +      setAppliedConfig({ filters: newFilters });
    +    },
    +    [setValue, setAppliedConfig],
    +  );
    +
    +  const filters = useWatch({ control, name: 'filters' });
    +  const searchFilters = useSearchPageFilterState({
    +    searchQuery: filters ?? undefined,
    +    onFilterChange: handleSetFilters,
    +    dateTimeColumns,
    +    knownColumns,
    +  });
    +
    +  // Chart config used by the filters sidebar to fetch facet values and
    +  // distributions. Scoped to the trace source with the currently applied
    +  // where + filters so counts reflect the filtered set.
    +  const filtersChartConfig = useMemo<BuilderChartConfigWithDateRange>(() => {
    +    const overrides = { dateRange: searchedTimeRange } as const;
    +    if (traceTrace == null) {
    +      return {
    +        timestampValueExpression: '',
    +        connection: '',
    +        from: { databaseName: '', tableName: '' },
    +        where: '',
    +        select: '',
    +        ...overrides,
    +      };
    +    }
    +    // Scope facets to RUM session spans only. Without this the facet sidebar
    +    // queries the entire trace table (all services, tens of millions of spans),
    +    // which times out and leaves the sidebar empty. The `indexHint` lets the
    +    // `rum.sessionId` skip index prune to just the session rows. This is applied
    +    // as an always-on SQL filter alongside the user's search + facet selections.
    +    const rumSessionIdKey = `${traceTrace.resourceAttributesExpression}['rum.sessionId']`;
    +    const rumScopeFilter: Filter = {
    +      type: 'sql',
    +      condition: `notEmpty(${rumSessionIdKey}) AND indexHint(mapContains(${traceTrace.resourceAttributesExpression}, 'rum.sessionId'))`,
    +    };

    I believe this will probably break when the trace source is the JSON schema (where resource attributes is not a map but rather a JSON column) due to the mapContains.

    Same thing above for the rumSessionIdKey using bracket syntax

    pulpdrew pulpdrew commented on code on Sep 01, 2026 19:37 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +134,110 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM
    +      // sessions. `otel_traces` is sorted by (ServiceName, SpanName, Timestamp),
    +      // so with no ServiceName predicate the time filter can't prune via the
    +      // primary index — the query scans the whole table's marks (~100k) to
    +      // evaluate the `rum.sessionId` skip index. RUM traffic comes from a tiny
    +      // set of services, which we read cheaply from the session source (sorted
    +      // by time), turning the trace scan into a primary-key range (~50 marks,
    +      // ~20x faster cold).
    +      //
    +      // Correctness assumption: the session and trace sources report the same
    +      // `ServiceName` for RUM spans (the session source is the cheap,
    +      // time-sorted projection of the same RUM traffic, which is why we read the
    +      // list from there instead of re-scanning the trace table). If they diverge
    +      // — a service present in trace RUM spans but absent from the session-source
    +      // scan, or a differing service-name column — that service's sessions would
    +      // be dropped. On any query failure or an empty result we fall back to the
    +      // unscoped (correct) scan.
    +      const serviceNameExpression =
    +        traceSource.serviceNameExpression || 'ServiceName';
    +      // Enumerate RUM services over a window wider than the selected range. A
    +      // session's row in the session source is timestamped at (near) its start,
    +      // which can fall *before* `dateRange` even though its trace spans land
    +      // inside it. Scoping to only services seen within the exact range would
    +      // then drop those sessions. Over-inclusion is safe — an extra ServiceName
    +      // only widens the primary-key range scanned; the `rum.sessionId`
    +      // predicate + HAVING still filter the rows — so we look back a generous
    +      // margin. Under-inclusion is the correctness bug we must avoid.
    +      const SERVICE_SCOPE_LOOKBACK_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
    +      const serviceScopeDateRange: [Date, Date] = [
    +        new Date(dateRange[0].getTime() - SERVICE_SCOPE_LOOKBACK_MS),
    +        dateRange[1],
    +      ];
    +      // Resolve the scope AND serialize it inside the try: `ServiceName` is
    +      // ingested telemetry, so a value with a quote/backslash must be escaped
    +      // (see `buildServiceScopeFilters`). Keeping construction here means any
    +      // failure — query or serialization — falls back to the unscoped (correct)
    +      // scan rather than emitting broken/injectable SQL into the aggregation.
    +      let serviceScopeFilters: Filter[] = [];
    +      try {
    +        const serviceNamesQuery = await renderChartConfig(
    +          {
    +            select: [
    +              {
    +                valueExpression: `DISTINCT ${serviceNameExpression}`,
    +                alias: 'serviceName',
    +              },
    +            ],
    +            from: sessionSource.from,
    +            dateRange: serviceScopeDateRange,
    +            where: `notEmpty(${getSessionsSourceFieldExpression(
    +              sessionSource.resourceAttributesExpression ??
    +                'ResourceAttributes',
    +              'rum.sessionId',
    +            )})`,
    +            whereLanguage: 'sql',
    +            timestampValueExpression: sessionSource.timestampValueExpression,
    +            connection: sessionSource.connection,
    +          },
    +          metadata,
    +          sessionSource.querySettings,
    +        );
    +        const serviceNamesJson = await clickhouseClient
    +          .query({
    +            query: serviceNamesQuery.sql,
    +            query_params: serviceNamesQuery.params,
    +            connectionId: sessionSource.connection,

                connectionId: sessionSource.connection,
                format: 'JSON',
    

    pulpdrew pulpdrew commented on code on Sep 01, 2026 19:40 UTC
    Code Review
    packages/app/src/components/SessionFilters.tsx:1
    @@ -0,0 +1,39 @@
    +import { ComponentProps } from 'react';
    +
    +import { DBSearchPageFilters } from './DBSearchPageFilters';
    +
    +// Props the sessions page controls. The analysis-mode toggles, delta view, and
    +// live-tail behavior don't apply to sessions, so they're baked in here instead
    +// of being threaded through the page.
    +type SessionFiltersProps = Omit<
    +  ComponentProps<typeof DBSearchPageFilters>,
    +  | 'analysisMode'
    +  | 'setAnalysisMode'
    +  | 'showDelta'
    +  | 'denoiseResults'
    +  | 'setDenoiseResults'
    +  | 'isLive'
    +  | 'hideAnalysisMode'
    +  | 'forceExactFacetMode'
    +>;
    +
    +/**
    + * Sessions-specific filter sidebar: the same faceted filters as the search
    + * page, minus the "Analysis Mode" header/tabs and denoise toggle. A thin
    + * wrapper over {@link DBSearchPageFilters} so the two stay in sync without
    + * duplicating the facet machinery.
    + *
    + * `forceExactFacetMode` is on because the sessions `chartConfig` scopes facets
    + * to RUM session spans; "all" mode would strip that scope and sample the whole
    + * trace table, which times out and leaves the sidebar empty.
    + */
    +export function SessionFilters(props: SessionFiltersProps) {
    +  return (
    +    <DBSearchPageFilters
    +      {...props}
    +      isLive={false}
    +      hideAnalysisMode
    +      forceExactFacetMode

    Two other reachable paths wipe chartConfig.filters too: DBSearchPageFilters/hooks.ts:225 (loadMoreFacetsForKey) and ActiveFilterPills.tsx:161 (in-pill value picker). "Show more values" and pill-editing therefore scan the whole trace table unscoped

    pulpdrew pulpdrew commented on code on Sep 01, 2026 19:45 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +134,110 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM
    +      // sessions. `otel_traces` is sorted by (ServiceName, SpanName, Timestamp),
    +      // so with no ServiceName predicate the time filter can't prune via the
    +      // primary index — the query scans the whole table's marks (~100k) to
    +      // evaluate the `rum.sessionId` skip index. RUM traffic comes from a tiny
    +      // set of services, which we read cheaply from the session source (sorted
    +      // by time), turning the trace scan into a primary-key range (~50 marks,
    +      // ~20x faster cold).
    +      //
    +      // Correctness assumption: the session and trace sources report the same
    +      // `ServiceName` for RUM spans (the session source is the cheap,
    +      // time-sorted projection of the same RUM traffic, which is why we read the
    +      // list from there instead of re-scanning the trace table). If they diverge
    +      // — a service present in trace RUM spans but absent from the session-source
    +      // scan, or a differing service-name column — that service's sessions would
    +      // be dropped. On any query failure or an empty result we fall back to the
    +      // unscoped (correct) scan.
    +      const serviceNameExpression =
    +        traceSource.serviceNameExpression || 'ServiceName';
    +      // Enumerate RUM services over a window wider than the selected range. A
    +      // session's row in the session source is timestamped at (near) its start,
    +      // which can fall *before* `dateRange` even though its trace spans land
    +      // inside it. Scoping to only services seen within the exact range would
    +      // then drop those sessions. Over-inclusion is safe — an extra ServiceName
    +      // only widens the primary-key range scanned; the `rum.sessionId`
    +      // predicate + HAVING still filter the rows — so we look back a generous
    +      // margin. Under-inclusion is the correctness bug we must avoid.
    +      const SERVICE_SCOPE_LOOKBACK_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
    +      const serviceScopeDateRange: [Date, Date] = [
    +        new Date(dateRange[0].getTime() - SERVICE_SCOPE_LOOKBACK_MS),
    +        dateRange[1],
    +      ];

    This optimization seems like a separate change, with separate risks - could we split it out into it's own PR for discussion?

    pulpdrew pulpdrew commented on code on Sep 01, 2026 19:48 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +134,110 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM
    +      // sessions. `otel_traces` is sorted by (ServiceName, SpanName, Timestamp),
    +      // so with no ServiceName predicate the time filter can't prune via the
    +      // primary index — the query scans the whole table's marks (~100k) to
    +      // evaluate the `rum.sessionId` skip index. RUM traffic comes from a tiny
    +      // set of services, which we read cheaply from the session source (sorted
    +      // by time), turning the trace scan into a primary-key range (~50 marks,
    +      // ~20x faster cold).
    +      //
    +      // Correctness assumption: the session and trace sources report the same
    +      // `ServiceName` for RUM spans (the session source is the cheap,
    +      // time-sorted projection of the same RUM traffic, which is why we read the
    +      // list from there instead of re-scanning the trace table). If they diverge
    +      // — a service present in trace RUM spans but absent from the session-source
    +      // scan, or a differing service-name column — that service's sessions would
    +      // be dropped. On any query failure or an empty result we fall back to the
    +      // unscoped (correct) scan.
    +      const serviceNameExpression =
    +        traceSource.serviceNameExpression || 'ServiceName';
    +      // Enumerate RUM services over a window wider than the selected range. A
    +      // session's row in the session source is timestamped at (near) its start,
    +      // which can fall *before* `dateRange` even though its trace spans land
    +      // inside it. Scoping to only services seen within the exact range would
    +      // then drop those sessions. Over-inclusion is safe — an extra ServiceName
    +      // only widens the primary-key range scanned; the `rum.sessionId`
    +      // predicate + HAVING still filter the rows — so we look back a generous
    +      // margin. Under-inclusion is the correctness bug we must avoid.
    +      const SERVICE_SCOPE_LOOKBACK_MS = 30 * 24 * 60 * 60 * 1000; // 30 days

    I'm curious why this would be such a long lookback - it seems excessive to scan 30 days back before each sessions query. And since this is tied to the selected date range, if won't necessarily be cached when changing date ranges.

    pulpdrew pulpdrew requested changes on Sep 01, 2026 19:50 UTC
    Changes Requested Reviewer

    Requested changes.

    github-actions[bot] github-actions[bot] commented on code on Oct 12, 2026 23:00 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -325,20 +344,120 @@ function SessionsPage() {
         })();
       }, [handleSubmit, setAppliedConfig, onSearch, displayedTimeInputValue]);
     
    +  const { data: traceColumns } = useColumns(tcFromSource(traceTrace), {
    +    enabled: !!traceTrace,
    +  });
    +  const knownColumns = useMemo(
    +    () =>
    +      traceColumns ? new Set(traceColumns.map(c => c.name)) : new Set<string>(),
    +    [traceColumns],
    +  );
    +  const { dateTimeColumns } = useResolvedDateTimeColumns(traceColumns);
    +
    +  const handleSetFilters = useCallback(
    +    (newFilters: Filter[]) => {
    +      setValue('filters', newFilters);
    +      setAppliedConfig({ filters: newFilters });
    +    },
    +    [setValue, setAppliedConfig],
    +  );
    +
    +  const filters = useWatch({ control, name: 'filters' });
    +  const searchFilters = useSearchPageFilterState({
    +    searchQuery: filters ?? undefined,
    +    onFilterChange: handleSetFilters,
    +    dateTimeColumns,
    +    knownColumns,
    +  });
    +
    +  const rumScopeCondition = `${traceTrace?.resourceAttributesExpression ?? 'ResourceAttributes'}.rum.sessionId:*`;
    +  const rumScopeFilters = useMemo<Filter[]>(
    +    () => [{ type: 'lucene', condition: rumScopeCondition }],
    +    [rumScopeCondition],
    +  );
    +
    +  // The RUM scope goes in `where` because the facet "load more" path replaces
    +  // `filters`; the user's query moves into `filters` instead.
    +  const filtersChartConfig = useMemo<BuilderChartConfigWithDateRange>(() => {
    +    const overrides = { dateRange: searchedTimeRange } as const;
    +    if (traceTrace == null) {
    +      return {
    +        timestampValueExpression: '',
    +        connection: '',
    +        from: { databaseName: '', tableName: '' },
    +        where: '',
    +        select: '',
    +        ...overrides,
    +      };
    +    }
    +    const config = buildSearchChartConfig(traceTrace, {
    +      where: rumScopeCondition,
    +      whereLanguage: 'lucene',
    +      filters: [

    🟠 major — Facet "Load more" drops the user's search-bar query, so it lists values outside the current results

    The RUM scope now sits in where and the user's free-text query was moved into filters. But in exact mode, loadMoreFacetsForKey (packages/app/src/components/DBSearchPageFilters/hooks.ts:219-230) replaces chartConfig.filters with a list rebuilt from filterState alone, so the appliedConfig.where filter gets thrown away. The search page doesn't have this problem because its query stays in where. To fix it, either put the user query in where (AND-ed with the RUM scope), or have load-more keep any chartConfig.filters entries that don't come from filterState.

    <sub>Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond</sub>

    <!-- hdxr:0d55a0887bd2a538 -->

    github-actions[bot] github-actions[bot] commented on code on Oct 12, 2026 23:00 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -325,20 +344,120 @@ function SessionsPage() {
         })();
       }, [handleSubmit, setAppliedConfig, onSearch, displayedTimeInputValue]);
     
    +  const { data: traceColumns } = useColumns(tcFromSource(traceTrace), {
    +    enabled: !!traceTrace,
    +  });
    +  const knownColumns = useMemo(
    +    () =>
    +      traceColumns ? new Set(traceColumns.map(c => c.name)) : new Set<string>(),
    +    [traceColumns],
    +  );
    +  const { dateTimeColumns } = useResolvedDateTimeColumns(traceColumns);
    +
    +  const handleSetFilters = useCallback(
    +    (newFilters: Filter[]) => {
    +      setValue('filters', newFilters);
    +      setAppliedConfig({ filters: newFilters });
    +    },
    +    [setValue, setAppliedConfig],
    +  );
    +
    +  const filters = useWatch({ control, name: 'filters' });
    +  const searchFilters = useSearchPageFilterState({
    +    searchQuery: filters ?? undefined,
    +    onFilterChange: handleSetFilters,
    +    dateTimeColumns,
    +    knownColumns,
    +  });
    +
    +  const rumScopeCondition = `${traceTrace?.resourceAttributesExpression ?? 'ResourceAttributes'}.rum.sessionId:*`;
    +  const rumScopeFilters = useMemo<Filter[]>(
    +    () => [{ type: 'lucene', condition: rumScopeCondition }],
    +    [rumScopeCondition],
    +  );
    +
    +  // The RUM scope goes in `where` because the facet "load more" path replaces
    +  // `filters`; the user's query moves into `filters` instead.
    +  const filtersChartConfig = useMemo<BuilderChartConfigWithDateRange>(() => {
    +    const overrides = { dateRange: searchedTimeRange } as const;
    +    if (traceTrace == null) {
    +      return {
    +        timestampValueExpression: '',
    +        connection: '',
    +        from: { databaseName: '', tableName: '' },
    +        where: '',
    +        select: '',
    +        ...overrides,
    +      };
    +    }
    +    const config = buildSearchChartConfig(traceTrace, {

    🔵 minor — Stale "Load more" facet values persist when only the search query changes

    useFetchFacets only clears extraFacets when chartConfig.where, chartConfig.whereLanguage or filterState change (packages/app/src/components/DBSearchPageFilters/hooks.ts:405-421). On this page where is always the fixed RUM scope and the user's query lives in chartConfig.filters, so loaded-more values from an earlier query stay merged into the facet list after a new search. Keep the user query in where (same fix as the load-more finding), or add the query to the reset dependencies.

    <sub>Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond</sub>

    <!-- hdxr:9cb82281f1332ceb -->

    github-actions[bot] github-actions[bot] commented on code on Oct 12, 2026 23:00 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -325,20 +344,120 @@ function SessionsPage() {
         })();
       }, [handleSubmit, setAppliedConfig, onSearch, displayedTimeInputValue]);
     
    +  const { data: traceColumns } = useColumns(tcFromSource(traceTrace), {
    +    enabled: !!traceTrace,
    +  });
    +  const knownColumns = useMemo(
    +    () =>
    +      traceColumns ? new Set(traceColumns.map(c => c.name)) : new Set<string>(),
    +    [traceColumns],
    +  );
    +  const { dateTimeColumns } = useResolvedDateTimeColumns(traceColumns);
    +
    +  const handleSetFilters = useCallback(
    +    (newFilters: Filter[]) => {
    +      setValue('filters', newFilters);
    +      setAppliedConfig({ filters: newFilters });
    +    },
    +    [setValue, setAppliedConfig],
    +  );
    +
    +  const filters = useWatch({ control, name: 'filters' });
    +  const searchFilters = useSearchPageFilterState({
    +    searchQuery: filters ?? undefined,
    +    onFilterChange: handleSetFilters,
    +    dateTimeColumns,
    +    knownColumns,
    +  });
    +
    +  const rumScopeCondition = `${traceTrace?.resourceAttributesExpression ?? 'ResourceAttributes'}.rum.sessionId:*`;

    🔵 minor — Session search scope (RUM condition + where→Filter conversion) is built twice, with a cast, and the two copies already differ

    rumScopeCondition and the {type, condition: appliedConfig.where} as Filter construction here repeat sessions.ts:111-124 and sessions.ts:183. useSessions maps promql to lucene but this copy doesn't, and this copy adds a 'ResourceAttributes' fallback that useSessions doesn't have. Export one helper from sessions.ts that returns { where, filters } for a trace source plus a query, and use it in both places. Build the filter with satisfies Filter rather than as Filter, per the TypeScript convention.

    <sub>Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond</sub>

    <!-- hdxr:072c6eca31bbf9e8 -->

    github-actions[bot] github-actions[bot] commented on code on Oct 12, 2026 23:00 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -490,43 +616,82 @@ function SessionsPage() {
                   </Group>
                 </PageHeader>
               }
    -          padded
               content={
    -            <>
    -              {isSessionsLoading || isSessionSourceLoading ? (
    -                <Group mt="md" align="center" justify="center" gap="xs">
    -                  <IconRefresh className="spin-animate" size={14} />
    -                  {isSessionSourceLoading
    -                    ? 'Loading...'
    -                    : 'Searching sessions...'}
    -                </Group>
    -              ) : (
    -                <>
    -                  {!sessions.length ? (
    -                    <Flex
    -                      align="center"
    -                      justify="center"
    -                      style={{ flex: 1, minHeight: 0 }}
    -                    >
    -                      <SessionSetupInstructions />
    -                    </Flex>
    -                  ) : (
    -                    <div
    -                      style={{ minHeight: 0 }}
    -                      data-testid="session-card-list"
    -                    >
    -                      <SessionCardList
    -                        onClick={session => {
    -                          setSelectedSession(session);
    -                        }}
    -                        sessions={sessions}
    -                        isSessionLoading={isSessionsLoading}
    -                      />
    -                    </div>
    +            <div
    +              className={searchPageStyles.searchPageContainer}
    +              style={{ minHeight: 0, height: '100%' }}
    +            >
    +              {sessionSource != null &&
    +                traceTrace != null &&
    +                !isFilterSidebarCollapsed && (
    +                  <ErrorBoundary message="Unable to render session filters">
    +                    <SessionFilters
    +                      chartConfig={filtersChartConfig}
    +                      sourceId={traceTrace.id}
    +                      onCollapse={() => setIsFilterSidebarCollapsed(true)}
    +                      {...searchFilters}
    +                    />
    +                  </ErrorBoundary>
    +                )}
    +              <Flex
    +                direction="column"
    +                p="sm"
    +                style={{ flex: 1, minWidth: 0, minHeight: 0 }}
    +              >
    +                <Group gap={4} align="center" wrap="nowrap">
    +                  {isFilterSidebarCollapsed && (
    +                    <Tooltip label="Show filters" position="bottom">
    +                      <ActionIcon
    +                        variant="subtle"
    +                        size="sm"
    +                        onClick={() => setIsFilterSidebarCollapsed(false)}
    +                        aria-label="Show filters"
    +                      >
    +                        <IconArrowBarToRight size={16} />
    +                      </ActionIcon>
    +                    </Tooltip>
                       )}
    -                </>
    -              )}
    -            </>
    +                  <ActiveFilterPills
    +                    searchFilters={searchFilters}
    +                    chartConfig={filtersChartConfig}
    +                    pickerFilters={rumScopeFilters}
    +                    dateTimeColumns={dateTimeColumns}
    +                    px={0}
    +                    mb="xs"
    +                    style={{ flex: 1 }}
    +                  />
    +                </Group>
    +                {isSessionsLoading || isSessionSourceLoading ? (
    +                  <Group mt="md" align="center" justify="center" gap="xs">
    +                    <IconRefresh className="spin-animate" size={14} />
    +                    {isSessionSourceLoading
    +                      ? 'Loading...'
    +                      : 'Searching sessions...'}
    +                  </Group>
    +                ) : !sessions.length && !hasActiveSearch ? (

    🔵 minor — A query with no matches now shows a legacy ad-hoc empty state with a forbidden button variant and an install-integration CTA

    When there are no results and hasActiveSearch is true, the page now renders SessionCardList. Its empty branch (SessionsPage.tsx:157-177) is a raw <div> with a variant="outline-success" Button telling the user to install the browser integration, even though the real cause is just that nothing matched. Render EmptyState here instead, with no-match copy (e.g. title "No matching sessions") and a secondary action to clear filters. This follows the REQUIRED EmptyState and Button-variant rules.

    <sub>Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond</sub>

    <!-- hdxr:160af050315d1c4f -->

    github-actions[bot] github-actions[bot] commented on code on Oct 12, 2026 23:00 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -97,6 +108,21 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      const searchFilters: Filter[] = [

    🔵 minor — New session query logic (filters merged into the aggregation, HAVING dropped whenever any filter exists) has no test

    sessions.test.ts only covers the URL parser, and SessionFilters.test.tsx only checks that props are forwarded. Nothing tests that filters reach the trace aggregation's filters, that sidebar-only filters (with no where) remove the HAVING interactionCount > 0 clause and switch to the joined finalQuery, or that the source-change filter reconciliation works. Add a useSessions test that captures the rendered SQL for where-only, filters-only and neither.

    <sub>Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond</sub>

    <!-- hdxr:ac11124cdf4e43a7 -->

    greptile-apps[bot] greptile-apps[bot] commented on code on Oct 12, 2026 23:04 UTC
    Code Review
    packages/app/src/SessionsPage.tsx:1
    @@ -325,20 +344,120 @@ function SessionsPage() {
         })();
       }, [handleSubmit, setAppliedConfig, onSearch, displayedTimeInputValue]);
     
    +  const { data: traceColumns } = useColumns(tcFromSource(traceTrace), {
    +    enabled: !!traceTrace,
    +  });
    +  const knownColumns = useMemo(
    +    () =>
    +      traceColumns ? new Set(traceColumns.map(c => c.name)) : new Set<string>(),
    +    [traceColumns],
    +  );
    +  const { dateTimeColumns } = useResolvedDateTimeColumns(traceColumns);
    +
    +  const handleSetFilters = useCallback(
    +    (newFilters: Filter[]) => {
    +      setValue('filters', newFilters);
    +      setAppliedConfig({ filters: newFilters });
    +    },
    +    [setValue, setAppliedConfig],
    +  );
    +
    +  const filters = useWatch({ control, name: 'filters' });
    +  const searchFilters = useSearchPageFilterState({
    +    searchQuery: filters ?? undefined,
    +    onFilterChange: handleSetFilters,
    +    dateTimeColumns,
    +    knownColumns,
    +  });
    +
    +  const rumScopeCondition = `${traceTrace?.resourceAttributesExpression ?? 'ResourceAttributes'}.rum.sessionId:*`;
    +  const rumScopeFilters = useMemo<Filter[]>(
    +    () => [{ type: 'lucene', condition: rumScopeCondition }],
    +    [rumScopeCondition],
    +  );
    +
    +  // The RUM scope goes in `where` because the facet "load more" path replaces
    +  // `filters`; the user's query moves into `filters` instead.
    +  const filtersChartConfig = useMemo<BuilderChartConfigWithDateRange>(() => {
    +    const overrides = { dateRange: searchedTimeRange } as const;
    +    if (traceTrace == null) {
    +      return {
    +        timestampValueExpression: '',
    +        connection: '',
    +        from: { databaseName: '', tableName: '' },
    +        where: '',
    +        select: '',
    +        ...overrides,
    +      };
    +    }
    +    const config = buildSearchChartConfig(traceTrace, {
    +      where: rumScopeCondition,
    +      whereLanguage: 'lucene',
    +      filters: [
    +        ...(appliedConfig.where
    +          ? [
    +              {
    +                type: appliedConfig.whereLanguage ?? 'lucene',
    +                condition: appliedConfig.where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...appliedConfig.filters,

    <a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> Facet search drops the query

    On the sessions page, searching a facet's values or clicking “Load more” drops the free-text query. filtersChartConfig stores that query in filters, but loadMoreFacetsForKey replaces them with sidebar selections alone. The sidebar then offers values outside the search, unlike its initial list. Selecting one can produce no results.

    Preserve the free-text query when removing the selected field's filter.

    <a href="https://app.greptile.com/ide/claude-code?prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2FSessionsPage.tsx%0ALine%3A%20396-405%0A%0AComment%3A%0AFacet%20search%20drops%20the%20query%0A%0AOn%20the%20sessions%20page%2C%20searching%20a%20facet's%20values%20or%20clicking%20%E2%80%9CLoad%20more%E2%80%9D%20drops%20the%20free-text%20query.%20%60filtersChartConfig%60%20stores%20that%20query%20in%20%60filters%60%2C%20but%20%60loadMoreFacetsForKey%60%20replaces%20them%20with%20sidebar%20selections%20alone.%20The%20sidebar%20then%20offers%20values%20outside%20the%20search%2C%20unlike%20its%20initial%20list.%20Selecting%20one%20can%20produce%20no%20results.%0A%0APreserve%20the%20free-text%20query%20when%20removing%20the%20selected%20field's%20filter.%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaudeDark.svg?v=7"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaude.svg?v=7"><img alt="Fix in Claude Code" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInClaude.svg?v=7"></picture></a> <a href="https://app.greptile.com/api/ide/conductor?prompt=IMPORTANT%3A%20Work%20in%20the%20repository%20%22hyperdxio%2Fhyperdx%22%20on%20the%20existing%20branch%20%22add-session-filters%22.%20Checkout%20that%20branch%20%E2%80%94%20do%20NOT%20create%20a%20new%20branch%20or%20open%20a%20new%20PR.%20Push%20your%20changes%20to%20%22add-session-filters%22.%0A%0AThis%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2FSessionsPage.tsx%0ALine%3A%20396-405%0A%0AComment%3A%0AFacet%20search%20drops%20the%20query%0A%0AOn%20the%20sessions%20page%2C%20searching%20a%20facet's%20values%20or%20clicking%20%E2%80%9CLoad%20more%E2%80%9D%20drops%20the%20free-text%20query.%20%60filtersChartConfig%60%20stores%20that%20query%20in%20%60filters%60%2C%20but%20%60loadMoreFacetsForKey%60%20replaces%20them%20with%20sidebar%20selections%20alone.%20The%20sidebar%20then%20offers%20values%20outside%20the%20search%2C%20unlike%20its%20initial%20list.%20Selecting%20one%20can%20produce%20no%20results.%0A%0APreserve%20the%20free-text%20query%20when%20removing%20the%20selected%20field's%20filter.%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductorDark.svg?v=7"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductor.svg?v=7"><img alt="Fix in Conductor" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInConductor.svg?v=7"></picture></a> <a href="https://app.greptile.com/api/ide/cursor?prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2FSessionsPage.tsx%0ALine%3A%20396-405%0A%0AComment%3A%0AFacet%20search%20drops%20the%20query%0A%0AOn%20the%20sessions%20page%2C%20searching%20a%20facet's%20values%20or%20clicking%20%E2%80%9CLoad%20more%E2%80%9D%20drops%20the%20free-text%20query.%20%60filtersChartConfig%60%20stores%20that%20query%20in%20%60filters%60%2C%20but%20%60loadMoreFacetsForKey%60%20replaces%20them%20with%20sidebar%20selections%20alone.%20The%20sidebar%20then%20offers%20values%20outside%20the%20search%2C%20unlike%20its%20initial%20list.%20Selecting%20one%20can%20produce%20no%20results.%0A%0APreserve%20the%20free-text%20query%20when%20removing%20the%20selected%20field's%20filter.%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&expires=1792451038&sig=462e07423a289b588e62d146e32832b7ce74e27bd59e7cf8460840a312fb62d2&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursorDark.svg?v=7"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursor.svg?v=7"><img alt="Fix in Cursor" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCursor.svg?v=7"></picture></a> <a href="https://app.greptile.com/api/ide/codex?prompt=IMPORTANT%3A%20Work%20in%20the%20repository%20%22hyperdxio%2Fhyperdx%22%20on%20the%20existing%20branch%20%22add-session-filters%22.%20Checkout%20that%20branch%20%E2%80%94%20do%20NOT%20create%20a%20new%20branch%20or%20open%20a%20new%20PR.%20Push%20your%20changes%20to%20%22add-session-filters%22.%0A%0AThis%20is%20a%20comment%20left%20during%20a%20code%20review.%0APath%3A%20packages%2Fapp%2Fsrc%2FSessionsPage.tsx%0ALine%3A%20396-405%0A%0AComment%3A%0AFacet%20search%20drops%20the%20query%0A%0AOn%20the%20sessions%20page%2C%20searching%20a%20facet's%20values%20or%20clicking%20%E2%80%9CLoad%20more%E2%80%9D%20drops%20the%20free-text%20query.%20%60filtersChartConfig%60%20stores%20that%20query%20in%20%60filters%60%2C%20but%20%60loadMoreFacetsForKey%60%20replaces%20them%20with%20sidebar%20selections%20alone.%20The%20sidebar%20then%20offers%20values%20outside%20the%20search%2C%20unlike%20its%20initial%20list.%20Selecting%20one%20can%20produce%20no%20results.%0A%0APreserve%20the%20free-text%20query%20when%20removing%20the%20selected%20field's%20filter.%0A%0A---%0A%0AFor%20each%20issue%20above%2C%20determine%20whether%20it%20is%20valid%20and%20should%20be%20fixed.%20If%20so%2C%20fix%20it%20directly.&repo=hyperdxio%2Fhyperdx&pr=2992&platform=github"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodexDark.svg?v=7"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodex.svg?v=7"><img alt="Fix in Codex" src="https://greptile-static-assets.s3.amazonaws.com/badges/FixInCodex.svg?v=7"></picture></a>

    vinzee vinzee commented on code on Oct 12, 2026 23:14 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +102,91 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM
    +      // sessions. `otel_traces` is sorted by (ServiceName, SpanName, Timestamp),
    +      // so with no ServiceName predicate the time filter can't prune via the
    +      // primary index — the query scans the whole table's marks (~100k) to
    +      // evaluate the `rum.sessionId` skip index. RUM traffic comes from a tiny
    +      // set of services, which we read cheaply from the session source (sorted
    +      // by time), turning the trace scan into a primary-key range (~50 marks,
    +      // ~20x faster cold). Purely an optimization: on any failure or when no
    +      // services resolve, we fall back to the unscoped (correct) scan.
    +      const serviceNameExpression =
    +        traceSource.serviceNameExpression || 'ServiceName';
    +      let rumServiceNames: string[] = [];
    +      try {
    +        const serviceNamesQuery = await renderChartConfig(
    +          {
    +            select: [
    +              {
    +                valueExpression: `DISTINCT ${serviceNameExpression}`,
    +                alias: 'serviceName',
    +              },
    +            ],
    +            from: sessionSource.from,
    +            dateRange,
    +            where: `notEmpty(${getSessionsSourceFieldExpression(
    +              sessionSource.resourceAttributesExpression ??
    +                'ResourceAttributes',
    +              'rum.sessionId',
    +            )})`,
    +            whereLanguage: 'sql',
    +            timestampValueExpression: sessionSource.timestampValueExpression,
    +            connection: sessionSource.connection,
    +          },
    +          metadata,
    +          sessionSource.querySettings,
    +        );
    +        const serviceNamesJson = await clickhouseClient
    +          .query({
    +            query: serviceNamesQuery.sql,
    +            query_params: serviceNamesQuery.params,
    +            connectionId: sessionSource.connection,
    +          })
    +          .then(res => res.json<{ serviceName: string }>());
    +        rumServiceNames = (serviceNamesJson.data ?? [])
    +          .map(row => row.serviceName)
    +          .filter((name): name is string => !!name);
    +      } catch {
    +        // Optimization only — fall back to an unscoped scan.
    +      }
    +
    +      // Applied to the main aggregation alongside any user search. Kept separate
    +      // from `hasSearchQuery` so it never flips the HAVING/CTE behavior below.
    +      const serviceScopeFilters: Filter[] =
    +        rumServiceNames.length > 0
    +          ? [
    +              {
    +                type: 'sql',
    +                condition: `${serviceNameExpression} IN (${rumServiceNames
    +                  .map(name => `'${name.replace(/'/g, "''")}'`)
    +                  .join(', ')})`,
    +              } as Filter,
    +            ]
    +          : [];

    Moved to #3358 to be discussed separately.

    vinzee vinzee commented on code on Oct 12, 2026 23:14 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +102,104 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM
    +      // sessions. `otel_traces` is sorted by (ServiceName, SpanName, Timestamp),
    +      // so with no ServiceName predicate the time filter can't prune via the
    +      // primary index — the query scans the whole table's marks (~100k) to
    +      // evaluate the `rum.sessionId` skip index. RUM traffic comes from a tiny
    +      // set of services, which we read cheaply from the session source (sorted
    +      // by time), turning the trace scan into a primary-key range (~50 marks,
    +      // ~20x faster cold). Purely an optimization: on any failure or when no
    +      // services resolve, we fall back to the unscoped (correct) scan.
    +      const serviceNameExpression =
    +        traceSource.serviceNameExpression || 'ServiceName';
    +      // Enumerate RUM services over a window wider than the selected range. A
    +      // session's row in the session source is timestamped at (near) its start,
    +      // which can fall *before* `dateRange` even though its trace spans land
    +      // inside it. Scoping to only services seen within the exact range would
    +      // then drop those sessions. Over-inclusion is safe — an extra ServiceName
    +      // only widens the primary-key range scanned; the `rum.sessionId`
    +      // predicate + HAVING still filter the rows — so we look back a generous
    +      // margin. Under-inclusion is the correctness bug we must avoid.
    +      const SERVICE_SCOPE_LOOKBACK_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
    +      const serviceScopeDateRange: [Date, Date] = [
    +        new Date(dateRange[0].getTime() - SERVICE_SCOPE_LOOKBACK_MS),
    +        dateRange[1],
    +      ];

    Moved to #3358 to be discussed separately.

    vinzee vinzee commented on code on Oct 12, 2026 23:14 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +134,110 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM

    Moved to #3358 to be discussed separately.

    vinzee vinzee commented on code on Oct 12, 2026 23:14 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +134,110 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM
    +      // sessions. `otel_traces` is sorted by (ServiceName, SpanName, Timestamp),
    +      // so with no ServiceName predicate the time filter can't prune via the
    +      // primary index — the query scans the whole table's marks (~100k) to
    +      // evaluate the `rum.sessionId` skip index. RUM traffic comes from a tiny
    +      // set of services, which we read cheaply from the session source (sorted
    +      // by time), turning the trace scan into a primary-key range (~50 marks,
    +      // ~20x faster cold).
    +      //
    +      // Correctness assumption: the session and trace sources report the same
    +      // `ServiceName` for RUM spans (the session source is the cheap,
    +      // time-sorted projection of the same RUM traffic, which is why we read the
    +      // list from there instead of re-scanning the trace table). If they diverge
    +      // — a service present in trace RUM spans but absent from the session-source
    +      // scan, or a differing service-name column — that service's sessions would
    +      // be dropped. On any query failure or an empty result we fall back to the
    +      // unscoped (correct) scan.
    +      const serviceNameExpression =
    +        traceSource.serviceNameExpression || 'ServiceName';
    +      // Enumerate RUM services over a window wider than the selected range. A
    +      // session's row in the session source is timestamped at (near) its start,
    +      // which can fall *before* `dateRange` even though its trace spans land
    +      // inside it. Scoping to only services seen within the exact range would
    +      // then drop those sessions. Over-inclusion is safe — an extra ServiceName
    +      // only widens the primary-key range scanned; the `rum.sessionId`
    +      // predicate + HAVING still filter the rows — so we look back a generous
    +      // margin. Under-inclusion is the correctness bug we must avoid.
    +      const SERVICE_SCOPE_LOOKBACK_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
    +      const serviceScopeDateRange: [Date, Date] = [
    +        new Date(dateRange[0].getTime() - SERVICE_SCOPE_LOOKBACK_MS),
    +        dateRange[1],
    +      ];
    +      // Resolve the scope AND serialize it inside the try: `ServiceName` is
    +      // ingested telemetry, so a value with a quote/backslash must be escaped
    +      // (see `buildServiceScopeFilters`). Keeping construction here means any
    +      // failure — query or serialization — falls back to the unscoped (correct)
    +      // scan rather than emitting broken/injectable SQL into the aggregation.
    +      let serviceScopeFilters: Filter[] = [];
    +      try {

    Moved to #3358 to be discussed separately.

    vinzee vinzee commented on code on Oct 12, 2026 23:14 UTC
    Code Review
    packages/app/src/sessions.ts:1
    @@ -93,6 +134,110 @@ export function useSessions(
             'rum.sessionId',
           );
     
    +      // Combine the free-text `where` with the sidebar's faceted filters into a
    +      // single filter list applied to the trace source. When either is present
    +      // we treat the query as an explicit user search (see `hasSearchQuery`).
    +      const searchFilters: Filter[] = [
    +        ...(where
    +          ? [
    +              {
    +                type:
    +                  (whereLanguage === 'promql' ? 'lucene' : whereLanguage) ??
    +                  'lucene',
    +                condition: where,
    +              } as Filter,
    +            ]
    +          : []),
    +        ...(filters ?? []),
    +      ];
    +      const hasSearchQuery = searchFilters.length > 0;
    +
    +      // Scope the trace aggregation to just the service(s) that emit RUM
    +      // sessions. `otel_traces` is sorted by (ServiceName, SpanName, Timestamp),
    +      // so with no ServiceName predicate the time filter can't prune via the
    +      // primary index — the query scans the whole table's marks (~100k) to
    +      // evaluate the `rum.sessionId` skip index. RUM traffic comes from a tiny
    +      // set of services, which we read cheaply from the session source (sorted
    +      // by time), turning the trace scan into a primary-key range (~50 marks,
    +      // ~20x faster cold).
    +      //
    +      // Correctness assumption: the session and trace sources report the same
    +      // `ServiceName` for RUM spans (the session source is the cheap,
    +      // time-sorted projection of the same RUM traffic, which is why we read the
    +      // list from there instead of re-scanning the trace table). If they diverge
    +      // — a service present in trace RUM spans but absent from the session-source
    +      // scan, or a differing service-name column — that service's sessions would
    +      // be dropped. On any query failure or an empty result we fall back to the
    +      // unscoped (correct) scan.
    +      const serviceNameExpression =
    +        traceSource.serviceNameExpression || 'ServiceName';
    +      // Enumerate RUM services over a window wider than the selected range. A
    +      // session's row in the session source is timestamped at (near) its start,
    +      // which can fall *before* `dateRange` even though its trace spans land
    +      // inside it. Scoping to only services seen within the exact range would
    +      // then drop those sessions. Over-inclusion is safe — an extra ServiceName
    +      // only widens the primary-key range scanned; the `rum.sessionId`
    +      // predicate + HAVING still filter the rows — so we look back a generous
    +      // margin. Under-inclusion is the correctness bug we must avoid.
    +      const SERVICE_SCOPE_LOOKBACK_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
    +      const serviceScopeDateRange: [Date, Date] = [
    +        new Date(dateRange[0].getTime() - SERVICE_SCOPE_LOOKBACK_MS),
    +        dateRange[1],
    +      ];

    Split out into #3358.

    vinzee vinzee commented on Oct 12, 2026 23:55 UTC
    Author

    @pulpdrew ready for another look. Your comments are addressed; the ServiceName scope optimization moved to #3358. The branch is rebased on main and squashed to one commit.

    Still open for your call:

  • keepDirtyValues keeps edited fields when the URL changes (e.g. browser Back after picking another source). Happy to rework how sidebar filters reach the form if you'd like.

  • Whether you want a full useSessions SQL test here; the search-condition helpers are unit-tested.
  • I'll hold off on further bot rounds until you've had a look.

    Reviewers
    Assignees
    vinzee vinzee
    Labels
    risk: low confidence: 85.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 66.1% (HIGH) · Higher = larger blast radius
    66.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 85.4% · Lower = rushed or shallow review
    85.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 9.7% · Safe to merge
    9.7%