mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add pr, repo, pr_title chat search filters (#25569)
Relates to CODAGT-432 Adds three new search filters to the chat list endpoint (`GET /api/experimental/chats/`): - `pr:<number>` - exact PR number match - `repo:<owner/repo>` - substring match against git remote origin or URL - `pr_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](https://coder.com/agents)
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
# Conversation Search Syntax
|
||||
|
||||
The chat list endpoint accepts a `q` query parameter for filtering
|
||||
conversations. All filters use `key:value` syntax. Bare search terms
|
||||
are rejected; use `title:` for title filtering.
|
||||
|
||||
## Filters
|
||||
|
||||
| Key | Values | Description |
|
||||
|--------------|-------------------------------------|----------------------------------------------------------------------------------------------------|
|
||||
| `title` | substring | Case-insensitive substring match. Quote multi-word values. |
|
||||
| `archived` | `true`, `false` | Filter by archived state. Default: `false`. |
|
||||
| `has_unread` | `true`, `false` | Conversations with unread assistant messages. |
|
||||
| `pr_status` | `draft`, `open`, `merged`, `closed` | Linked pull request state. Comma-separated for OR. |
|
||||
| `diff_url` | URL | Match by associated diff URL. Quote values containing colons. |
|
||||
| `pr` | positive integer | Exact PR number match. |
|
||||
| `repo` | substring | Case-insensitive substring match against git remote origin or URL. Quote values containing colons. |
|
||||
| `pr_title` | substring | Case-insensitive PR title substring match. Quote multi-word values. |
|
||||
|
||||
Multiple filters in one query combine with AND logic.
|
||||
|
||||
## Examples
|
||||
|
||||
```sh
|
||||
# Title substring (case-insensitive)
|
||||
?q=title:deploy
|
||||
|
||||
# Multi-word title (URL-encode the space or use +)
|
||||
?q=title:my+project
|
||||
|
||||
# Unread conversations
|
||||
?q=has_unread:true
|
||||
|
||||
# Conversations with open or draft PRs
|
||||
?q=pr_status:open,draft
|
||||
|
||||
# Filter by diff URL (quote values containing colons)
|
||||
?q=diff_url:"https://github.com/coder/coder/pull/123"
|
||||
|
||||
# Combine filters
|
||||
?q=title:refactor+has_unread:true+pr_status:merged
|
||||
|
||||
# Conversations linked to PR #42
|
||||
?q=pr:42
|
||||
|
||||
# Conversations for a specific repository
|
||||
?q=repo:coder/coder
|
||||
|
||||
# Conversations with a specific PR title
|
||||
?q=pr_title:"fix auth bug"
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- `title:`, `repo:`, and `pr_title:` use ILIKE matching. `%` and `_` act as wildcards.
|
||||
- `pr_status:draft` means the PR is open **and** marked as a draft.
|
||||
`pr_status:open` means the PR is open and not a draft.
|
||||
- Conversations without a linked diff status are excluded when `pr_status`, `pr`, `repo`, or `pr_title` is set. The `repo:` filter also matches chats tracking a branch with no PR.
|
||||
- Unrecognized keys or bare terms return HTTP 400 with a validation error.
|
||||
@@ -995,6 +995,12 @@
|
||||
"path": "./ai-coder/agents/getting-started.md",
|
||||
"state": ["beta"]
|
||||
},
|
||||
{
|
||||
"title": "Search Syntax",
|
||||
"description": "Filter conversations by title, status, and linked pull requests",
|
||||
"path": "./ai-coder/agents/chat-search-syntax.md",
|
||||
"state": ["beta"]
|
||||
},
|
||||
{
|
||||
"title": "Architecture",
|
||||
"description": "How the agent in the control plane communicates with workspaces",
|
||||
|
||||
Generated
+4
-4
@@ -17,10 +17,10 @@ Experimental: this endpoint is subject to change.
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | In | Type | Required | Description |
|
||||
|---------|-------|--------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `q` | query | string | false | Search query. Supports title:<substring> (case-insensitive, quote multi-word values), archived:bool, has_unread:bool, pr_status:<draft\|open\|merged\|closed> as repeated or comma-separated values, and diff_url:<url> (quote URLs). Bare terms are not supported; use title:<value> for title filtering. |
|
||||
| `label` | query | string | false | Filter by label as key:value. Repeat for multiple (AND logic). |
|
||||
| Name | In | Type | Required | Description |
|
||||
|---------|-------|--------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `q` | query | string | false | Search query. Supports title:<substring> (case-insensitive, quote multi-word values), archived:bool, has_unread:bool, pr_status:<draft\|open\|merged\|closed> as repeated or comma-separated values, diff_url:<url> (quote values containing colons), pr:<number> (exact PR number match), repo:<owner/repo> (case-insensitive substring match against git remote origin or URL), pr_title:<text> (case-insensitive PR title substring). Bare terms are not supported; use title:<value> for title filtering. |
|
||||
| `label` | query | string | false | Filter by label as key:value. Repeat for multiple (AND logic). |
|
||||
|
||||
### Example responses
|
||||
|
||||
|
||||
Reference in New Issue
Block a user