feat: implement <ClientFilter /> to AI Bridge request logs#22694
feat: implement <ClientFilter /> to AI Bridge request logs#22694
<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) { |

Closes #22136
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).