feat(coderd): add q search parameter to chats endpoint (#22913)

Replace the standalone `?archived=` query parameter on the chats listing
endpoint with a `?q=` search parameter, consistent with how workspaces,
tasks, templates, and other list endpoints work.

The `q` parameter uses the standard `key:value` search syntax parsed by
the `searchquery` package. Currently supports:

- `archived:true/false` (default: `false`, hides archived chats)

When `q` is empty or omits the archived filter, archived chats are
excluded by default. This is a behavioral change — the previous API
returned all chats (including archived) when no filter was specified.

### Changes

**Backend:**
- Add `searchquery.Chats()` parser following the same pattern as
`Tasks()`, `Workspaces()`, etc.
- Update `listChats` handler to read `q` instead of `archived`
- Update `codersdk.ListChatsOptions` to use `Q string` instead of
`Archived *bool`

**Frontend:**
- Update `getChats` API method to accept `q` parameter
- Update `infiniteChats` query to pass `q` instead of `archived`

**Tests:**
- Add `TestSearchChats` unit tests for the parser
- Update existing archive/unarchive integration tests to use `Q:
"archived:true"` syntax
This commit is contained in:
Kyle Carberry
2026-03-11 10:21:47 -04:00
committed by GitHub
parent bb59477648
commit 196c6702fd
8 changed files with 135 additions and 36 deletions
+3 -3
View File
@@ -551,7 +551,7 @@ type chatStreamEnvelope struct {
// ListChatsOptions are optional parameters for ListChats.
type ListChatsOptions struct {
Archived *bool
Query string
Pagination
}
@@ -560,10 +560,10 @@ func (c *Client) ListChats(ctx context.Context, opts *ListChatsOptions) ([]Chat,
var reqOpts []RequestOption
if opts != nil {
reqOpts = append(reqOpts, opts.Pagination.asRequestOption())
if opts.Archived != nil {
if opts.Query != "" {
reqOpts = append(reqOpts, func(r *http.Request) {
q := r.URL.Query()
q.Set("archived", fmt.Sprintf("%t", *opts.Archived))
q.Set("q", opts.Query)
r.URL.RawQuery = q.Encode()
})
}