Files
coder/coderd/database
Michael Suchacz e4682343e6 feat: match PR number prefixes in chat search (#30404)
Chat search now matches PR numbers by prefix, so typing `3028` already
finds the chat for PR `30281` instead of showing zero results
mid-typing.

The free-text `search:` branch in `GetChats` switches from `pr_number =
@search::bigint` to `pr_number::text LIKE @search || '%'`, still guarded
by a digits-only regex so the value can never carry LIKE wildcards. The
lookup stays a correlated per-chat EXISTS on the `chat_diff_statuses`
primary key, which leads with `chat_id`, so the cost is the same as
before and no new index is needed. The explicit `pr:` filter stays
exact, and ordering is unchanged (no exact-match ranking) so cursor
pagination is unaffected.

Behavior note: values with leading zeros (`030281`) no longer match PR
`30281`, since the old bigint cast normalized them. PR numbers never
have leading zeros, so this seemed fine.

Closes CODAGT-1342

## Testing

- `TestGetChatsSearch` gains prefix (`4` -> PR 42), no-infix (`2` ->
none), and LIKE-wildcard (`4%` -> none) cases; the prefix case fails on
the old predicate.
- Dogfood UAT through Coder Agents on the branch: searching `3`, `302`,
`3028`, `30281` all surface the PR-linked chat; `0281` and `302810` do
not; `pr:3028` stays exact.

> [!NOTE]
> This PR was created by Xum acting on behalf of @ibetitsmike.
2026-10-06 22:42:56 +02:00
..
…