feat: add pr, repo, pr_title chat search filters by johnstcn · Pull Request #25569 · coder/coder
Relates to CODAGT-432
Adds three new search filters to the chat list endpoint (GET /api/experimental/chats/):
pr:<number>- exact PR number matchrepo:<owner/repo>- substring match against git remote origin or URLpr_title:<text>- case-insensitive PR title substring match
Includes SQL filter clauses (EXISTS against chat_diff_statuses), parser with validation, handler wiring, unit tests, swagger annotation update, and a new search syntax documentation page.
🤖 Generated with Coder Agents
johnstcn
changed the title
docs: add chat search syntax documentation
feat: add pr, repo, pr_title chat search filters
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First-pass review (Netero). 1 P1, 1 P3.
The PR cleanly adds three new search filters with correct SQL parameter ordering, proper validation, and solid parser test coverage. The manual strconv.ParseInt + zero-rejection for pr: is a deliberate choice over PositiveInt32 (which accepts zero), and the error handling follows the existing diff_url validation pattern.
The blocking issue is that the swagger annotation's escaped quotes break the generated API docs. The swag generator truncates at the embedded \", so swagger.json, docs.go, and docs/reference/api/chats.md all lose the new filter descriptions. The markdown table row in the reference docs is structurally malformed as a result.
This is a first-pass review only: these are mechanical findings from Netero. The full review panel has not yet reviewed this PR. The panel will review after these findings are addressed.
"The three filters this PR adds (pr:, repo:, pr_title:) are not documented in any generated API output." - Netero
🤖 This review was automatically generated with Coder Agents.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second-pass review (Netero). 1 P2 new. Prior findings addressed.
DEREM-1 (P1) and DEREM-2 (P3) verified fixed in d938c05. The swagger annotation no longer uses escaped quotes, all eight filters appear in the generated docs, and diff_url is in the filters table.
The remaining gap is database-level test coverage for the three new SQL filter clauses. The existing test suite in querier_test.go has table-driven cases for every other filter on this query (TitleQuery, PullRequestStatuses, HasUnread, composed filters), but the new @pr_number, @repo_query, and @pr_title_query clauses are only exercised through parser-level tests that never execute SQL.
This is a first-pass review only: these are mechanical findings from Netero. The full review panel has not yet reviewed this PR. The panel will review after these findings are addressed.
"a typo in the column name, a wrong parameter position, or a broken ILIKE expression in the SQL would not be caught by any test" - Netero
🤖 This review was automatically generated with Coder Agents.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Panel review (15 reviewers). 4 P3, 5 Nit. All prior findings (DEREM-1 P1, DEREM-2 P3, DEREM-3 P2) verified fixed.
Clean, well-structured PR. The three new filters follow the established CASE/WHEN/EXISTS pattern against chat_diff_statuses with correct parameter binding ($11-$15), proper parser validation, and the same root-only scoping as the existing pr_status filter. The linkPRFull test helper correctly mirrors the two-step upsert flow used in production. The ILIKE wildcard behavior is honestly documented.
The remaining findings are documentation precision (two items in the search syntax docs), test coverage gaps (composed filters and the repo OR branch), and naming consistency. Nothing that affects correctness or safety.
CI shows test-e2e and required failures that appear unrelated to this PR's changes.
"I tried to build a case against this and couldn't. The problem is correctly understood, the solution is proportional, and the fix is at the right level." - Pariston
🤖 This review was automatically generated with Coder Agents.
johnstcn
marked this pull request as ready for review
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds additional chat list (GET /api/experimental/chats) search capabilities for narrowing conversations by linked PR metadata (PR number, repository, PR title), including end-to-end wiring from query parsing through SQL filters, plus docs and tests.
Changes:
- Extend
q=search parsing to supportpr:,repo:, andpr_title:(with validation forpr:). - Add corresponding SQL filter clauses and plumb new parameters through the chat list handler and database querier.
- Add unit coverage (parser + DB filtering) and document the new search syntax (including manifest/nav + Swagger updates).
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| docs/reference/api/chats.md | Updates endpoint parameter docs for new q filters. |
| docs/manifest.json | Adds the new “Search Syntax” documentation page to the docs navigation. |
| docs/ai-coder/agents/chat-search-syntax.md | New page describing supported chat search filters and examples. |
| coderd/searchquery/search.go | Implements parsing/validation for pr, repo, and pr_title chat search terms. |
| coderd/searchquery/search_test.go | Adds unit tests for the new search terms and validation behavior. |
| coderd/exp_chats.go | Wires new parsed fields into GetChats params and updates Swagger annotation text. |
| coderd/database/queries/chats.sql | Adds SQL EXISTS clauses for PR number, repo substring, and PR title substring filters. |
| coderd/database/queries.sql.go | Regenerates sqlc outputs for new GetChatsParams fields and placeholder ordering. |
| coderd/database/querier_test.go | Adds DB-level coverage ensuring new filters return the expected chats. |
| coderd/database/modelqueries.go | Updates authorized query wrapper to pass new GetChatsParams fields. |
| coderd/apidoc/swagger.json | Updates generated Swagger description for the q parameter. |
| coderd/apidoc/docs.go | Updates embedded Swagger template description for the q parameter. |
Files not reviewed (1)
- coderd/apidoc/docs.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
johnstcn
deleted the
cian/codagt-432-chat-search-docs
branch