Skip to content

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

Open
jakehwll wants to merge 2 commits intomainfrom
jakehwll/aibridge-client-filter
Open

feat: implement <ClientFilter /> to AI Bridge request logs#22694
jakehwll wants to merge 2 commits intomainfrom
jakehwll/aibridge-client-filter

Conversation

@jakehwll
Copy link
Contributor

@jakehwll jakehwll commented Mar 6, 2026

Closes #22136

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

@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,

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
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,
};

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
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
Contributor

Choose a reason for hiding this comment

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

Please add test.

@github-actions github-actions bot added the stale This issue is like stale bread. label Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue is like stale bread.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add possibility to filter interceptions by multiple clients

2 participants