feat: implement <ClientFilter /> to AI Bridge request logs#22694
feat: implement <ClientFilter /> to AI Bridge request logs#22694jeremyruppel merged 5 commits intomainfrom
<ClientFilter /> to AI Bridge request logs#22694Conversation
There was a problem hiding this comment.
💡 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".
| const clientsRes = await API.getAIBridgeClients({ | ||
| q: query, | ||
| limit: 25, |
There was a problem hiding this comment.
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 👍 / 👎.
| if (firstClient) { | ||
| return { | ||
| label: firstClient, | ||
| value: firstClient, | ||
| }; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
@pawbana I fixed this up and added some tests for aiBridgeListClients. Please lmk if you see any issues!
74ca4c4 to
fcc3409
Compare
|
Hey @jeremyruppel @jakehwll ! Could you both work together to get this PR across the finish line? |
pawbana
left a comment
There was a problem hiding this comment.
Sorry for late review. From golang I think it looks generally ok.
|
@jakehwll we also want to add the same on /aibridge/sessions page. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
75a340a to
d8076c6
Compare
Documentation CheckUpdates Needed
Automated review via Coder Tasks |
pawbana
left a comment
There was a problem hiding this comment.
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>
d8076c6 to
0999463
Compare
Co-authored-by: Claude <noreply@anthropic.com>

Closes AIGOV-20
This pull-request implements a
<ClientFilter />to ourRequest Logspage 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).