Skip to content

feat(site/src): use the search filter on the AI Gateway sessions list - #31040

Merged
aqandrew merged 14 commits into
mainfrom
ai-sessions-search-filter
Nov 24, 2026
Merged

aqandrew merged 14 commits into
mainfrom
ai-sessions-search-filter

Conversation

@tracyjohnsonux

@tracyjohnsonux tracyjohnsonux commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Replaces the AI Gateway sessions list filter (search box plus User, Provider, Client, and Model dropdowns) with the FilterBudugbox search filter used on the Workspaces page.

  • Each former dropdown is now a filter category: initiator (User), provider_name, client, model. Option loaders live in ListSessionsPage/categoryOptions.tsx and go through new React Query definitions in api/queries/aiBridge.ts. The User category reuses the Workspaces getUserFilterOptions (sessions are admin-only, so all users are listed).
  • The date range keeps its own DateTimeRangePicker, now to the right of the search input. started_after/started_before are stripped from the Budugbox value and merged back on change (withoutTimeRange, queryWithSearch, queryWithTimeRange in timeRange.ts). A bound typed in the search overrides only that bound.
  • Organization category (shown when the deployment shows organizations), defaulting to the default organization via fallbackFilter. Uses the sessions organization search key (feat: show and filter by organization in AI Gateway sessions API #32057) and replaces the Organization dropdown from feat(site/src): add organization filter to AI Gateway sessions list #32260; the now-unused dropdown code is removed: the AIBridgePage/filters/ components, components/Filter/UserFilter.tsx, components/Filter/menu.ts, MockMenu, and MenuSkeleton.
  • Non-validation errors render as an ErrorAlert above the filter, matching WorkspacesPageView. Validation errors show under the search input.
  • The old ProviderFilter/ClientFilter/ModelFilter components stay because the Spend page still uses them.

Known limitation (accepted for now): the sessions search backend has no default key, so typed free text returns no search key specified, shown under the input.

Decision log
  1. Date range stays a separate control; its tokens never appear in the search input.
  2. Free text: keep the backend validation error for now (no backend change, no FilterBudugbox change).
  3. Option loaders: plain async functions per category, as on the Workspaces page.
  4. User category lists all users without the viewDeploymentConfig gate, since only admins can view sessions.
  5. Page view shows ErrorAlert for non-validation errors.
  6. Bedrock model IDs with colons (...-v2:0) are quoted; covered by ListSessionsFilter.test.tsx.
  7. Organization filter added with a default org, backed by the sessions organization search key.
  8. Every former dropdown becomes a category; provider (type) and session_id are not added as categories.

Frontend review: frontend-review (FE1 to FE10) and frontend-deep-review pass after fixes. One DF6 finding (category array identity) was dropped because src/pages/AIBridgePage/ is compiled by React Compiler, which memoizes it.


Generated by Coder Agents on behalf of @tracyjohnsonux.

Replace the sessions list search box and User, Provider, Client, and
Model dropdowns with the FilterBudugbox search filter used on the
Workspaces page. Each former dropdown becomes a filter category. The
date range keeps its own picker; its bounds are kept out of the search
input and merged back into the query on change.
tracyjohnsonux added a commit that referenced this pull request Oct 20, 2026
Places the Columns menu beside the new search filter and updates the
view test for the filter's new props and auth requirement.
@linear-code

linear-code Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

CODAGT-1380

AIGOV-776

DEQ-190

…lter

# Conflicts:
#	site/src/api/queries/aiBridge.ts
…sessions list

The sessions search API does not filter by organization yet, so the
token defaults to the default organization, shows as a chip, and is left
out of the request.
Resolve the sessions filter story conflict and adapt its shared option loaders and cache keys to the current filter API.

Generated by Coder Agents on behalf of Jake Howell (@jakehwll).
mollymaefraser added a commit that referenced this pull request Nov 19, 2026
…32260)

Adds an organization filter to the AI Gateway sessions list, using the
`organization` search key added in #32057. Choosing an organization adds
`organization:<name>` to the sessions query, so the list shows sessions
with at least one interception attributed to that organization. The
filter is a new `OrganizationFilter` in `pages/AIBridgePage/filters/`,
shaped like the provider, client and model filters, with options from
the shared `getOrganizationFilterOptions` helper (the same source as the
Connection Logs and Audit filters). The shared
`useOrganizationsFilterMenu` it first reused was removed in #32367. It
is shown only when `useDashboard().showOrganizations` is true, so
single-organization deployments see no change. The AI Gateway audit docs
mention the new filter.

Refs AIGOV-754. Stacked on #32057.

## Open questions for reviewers

- **Permission behind the org list:** the menu lists only organizations
where the user can read **audit logs** (`organizationCheck` in
`filters/OrganizationFilter.tsx`), not AI Gateway interceptions. Owners
and auditors, who can see this page today, have both. A custom role that
can see sessions but not audit logs would get an empty list. Connection
Logs has the same behavior. Is this acceptable, or should it check AI
Gateway interceptions instead (a one-line change)?
- **#31040 (Tracy):** that draft reworks this filter bar and already has
an Organization option. This PR adds the filter to the current bar; if
#31040 lands first, this moves into it.

## Notes for reviewers

- **Tests:** `ListSessionsPage.test.tsx` checks that picking an
organization sends `organization:<name>` in the request. The
`WithOrganizations` story shows the opened menu, and `Default` shows the
bar without it. Hiding the filter on single-org deployments has no
Vitest test, because FE1 does not allow presence assertions. It is the
same one-line `showOrganizations` check as Connection Logs.
- The filter starts at "All organizations", not the default
organization.
- The cost shown for a session is the whole session's cost, even with
the filter on, as agreed for AIGOV-754.

<details>
<summary>Decisions and plan</summary>

- **Scope (call with Sas and Susana, 13 Nov):** filter only, no
Organization column. No backend change for cost: show the whole
session's cost, not per org. Org logic is per page.
- **Approach:** build on the current filter bar rather than wait for
#31040, which is a draft and conflicts with `main`. Follow the
Connection Logs pattern (`ConnectionLogPage.tsx`,
`ConnectionLogFilter.tsx`).
- **Stack:** #32057 (backend) → this PR (list filter) → follow-up PR for
the organization row on the session detail page
(`SessionSummaryTable.tsx`).
- **Single-org:** no UI change on single-org deployments.
- **Checks run:** `pnpm lint:types`, Biome, the `ListSessionsPage`
Vitest suite, `frontend-review` (FE1 to FE10), `frontend-deep-review`
(all findings fixed), and doc-check on `audit.md` (no blocking
findings).

</details>

---

Code written by @mollymaefraser, with Coder Agents used as a guide:
explaining the existing code path, reviewing each step, running tests
and reviews, and writing parts of the test setup.
…lter

# Conflicts:
#	site/src/api/queries/aiBridge.ts
#	site/src/pages/AIBridgePage/ListSessionsPage/ListSessionsFilter.stories.tsx
#	site/src/pages/AIBridgePage/ListSessionsPage/ListSessionsFilter.tsx
#	site/src/pages/AIBridgePage/ListSessionsPage/ListSessionsPage.tsx
@tracyjohnsonux
tracyjohnsonux marked this pull request as ready for review November 24, 2026 17:49
value: provider.name,
startIcon: <ProviderIcon provider={provider.type} icon={provider.icon} />,
}));
return [...filterOptionsByText(options, query)];

@jeremyruppel jeremyruppel Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as of f683c53, getOptions expects the thunk to return a readonly FilterOption[]. if you use that return type here, this spread is probably unnecessary

getOptions: (query: string) => Promise<readonly FilterOption[]>;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in fdc8f56: getProviderFilterOptions now returns Promise<readonly FilterOption[]> and passes filterOptionsByText through without the spread.

Generated by Coder Agents on behalf of @tracyjohnsonux.

…lter

# Conflicts:
#	site/src/pages/AIBridgePage/ListSessionsPage/ListSessionsFilter.stories.tsx
#	site/src/pages/AIBridgePage/ListSessionsPage/ListSessionsFilter.tsx
@aqandrew
aqandrew merged commit f4a922d into main Nov 24, 2026
47 of 48 checks passed
@aqandrew
aqandrew deleted the ai-sessions-search-filter branch November 24, 2026 20:22
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026

This branch had an error being deployed

1 failed and 1 inactive (outdated) deployments
docs-preview — fdc8f56d Deployed Nov 24, 2026 by aqandrew via cleanup #454
main — e83ed61b Deployed Nov 18, 2026 by jakehwll via cla #259122
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants