Skip to content

feat: implement <ClientFilter /> to AI Bridge request logs#22694

Merged
jeremyruppel merged 5 commits intomainfrom
jakehwll/aibridge-client-filter
Mar 27, 2026
Merged

feat: implement <ClientFilter /> to AI Bridge request logs#22694
jeremyruppel merged 5 commits intomainfrom
jakehwll/aibridge-client-filter

Conversation

@jakehwll
Copy link
Copy Markdown
Contributor

@jakehwll jakehwll commented Mar 6, 2026

Closes AIGOV-20

This pull-request implements a <ClientFilter /> to our Request Logs page for AI Bridge. This will allow the user to select a client which they wish to filter against. Technically the backend is able to actually filter against multiple clients at once however the frontend doesn't currently have a nice way of supporting this (future improvement).

image

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27e0dc70ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +33 to +35
const clientsRes = await API.getAIBridgeClients({
q: query,
limit: 25,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Quote client lookup queries before requesting options

getOptions sends raw text as q (API.getAIBridgeClients({ q: query, ... })), but backend parsing splits unquoted queries on spaces (coderd/searchquery/search.go, searchTerms) and then raises a validation error when client appears more than once (coderd/httpapi/queryparams.go, parseSingle). For client names containing spaces (for example VS Code), the request becomes invalid and the combobox returns no matches; the same unquoted pattern in getSelectedOption also prevents restoring saved filters with spaced client names.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

image

This actually works as expected when selecting, not sure why this thinks it will be a problem.

Comment on lines +23 to +27
if (firstClient) {
return {
label: firstClient,
value: firstClient,
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Ensure selected client exactly matches the filter value

getSelectedOption currently trusts the first result from /aibridge/clients and returns it as selected even if it differs from value. The SQL for that endpoint uses prefix matching (LIKE @client || '%' in coderd/database/queries/aibridge.sql), so shared prefixes can hydrate the wrong option (e.g. cursor vs cursor-pro), which makes the UI show a different active client than the actual filter query.

Useful? React with 👍 / 👎.

r.Use(middlewares...)
r.Get("/interceptions", api.aiBridgeListInterceptions)
r.Get("/models", api.aiBridgeListModels)
r.Get("/clients", api.aiBridgeListClients)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: just a random thought, and a bit late, but maybe /models and /clients endpoints (maybe even interceptions ?) should be under some /logs path.

// @Tags AI Bridge
// @Success 200 {array} string
// @Router /aibridge/clients [get]
func (api *API) aiBridgeListClients(rw http.ResponseWriter, r *http.Request) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pawbana I fixed this up and added some tests for aiBridgeListClients. Please lmk if you see any issues!

@github-actions github-actions bot added the stale This issue is like stale bread. label Mar 14, 2026
@github-actions github-actions bot closed this Mar 18, 2026
@mtojek mtojek reopened this Mar 18, 2026
@github-actions github-actions bot removed the stale This issue is like stale bread. label Mar 19, 2026
@jeremyruppel jeremyruppel force-pushed the jakehwll/aibridge-client-filter branch from 74ca4c4 to fcc3409 Compare March 19, 2026 14:52
@mtojek
Copy link
Copy Markdown
Member

mtojek commented Mar 24, 2026

Hey @jeremyruppel @jakehwll ! Could you both work together to get this PR across the finish line?

Copy link
Copy Markdown
Contributor

@pawbana pawbana left a comment

Choose a reason for hiding this comment

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

Sorry for late review. From golang I think it looks generally ok.

@matifali
Copy link
Copy Markdown
Member

@jakehwll we also want to add the same on /aibridge/sessions page.

@jeremyruppel jeremyruppel force-pushed the jakehwll/aibridge-client-filter branch from 75a340a to d8076c6 Compare March 27, 2026 18:38
@coder-tasks
Copy link
Copy Markdown
Contributor

coder-tasks bot commented Mar 27, 2026

Documentation Check

Updates Needed

  • docs/ai-coder/ai-bridge/monitoring.md — The client filter section (line 28–46) maintains a hardcoded list of possible client values. Now that GET /api/v2/aibridge/clients returns this list dynamically, consider replacing or supplementing the static list with a reference to that endpoint so the docs stay current as new clients are added.

Automated review via Coder Tasks

@jeremyruppel jeremyruppel requested a review from pawbana March 27, 2026 18:43
Copy link
Copy Markdown
Contributor

@pawbana pawbana left a comment

Choose a reason for hiding this comment

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

Genaraly LGTM.
Would be nice to have no-license test back and unused code removed.

…gle test

Collapse six subtests (each spinning up an expensive coderdenttest server)
into one flat test with a single NewWithDatabase call.

Removed:
- RequiresLicenseFeature: already covered by TestAIBridgeListInterceptions
- EmptyDB: trivially guaranteed by the SQL query
- InvalidLimit: generic pagination validation
- Authorized: broken (members lack ActionRead on aibridge_interception)
- ExcludesInflight: merged — in-flight CopilotCLI asserted absent via ElementsMatch

Co-authored-by: Claude <noreply@anthropic.com>
@jeremyruppel jeremyruppel force-pushed the jakehwll/aibridge-client-filter branch from d8076c6 to 0999463 Compare March 27, 2026 20:52
Co-authored-by: Claude <noreply@anthropic.com>
@jeremyruppel jeremyruppel merged commit 71a492a into main Mar 27, 2026
29 of 31 checks passed
@jeremyruppel jeremyruppel deleted the jakehwll/aibridge-client-filter branch March 27, 2026 21:18
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2026
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.

5 participants