Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DNM: feat(coderd/searchquery): parse search filter for chats - #27090

Closed
johnstcn wants to merge 3 commits into
cian/codagt-724-add-search-parameter-and-recency-ordering-to-getchatsfrom
cian/codagt-723-add-search-parsing-to-searchquerychats
Closed

DNM: feat(coderd/searchquery): parse search filter for chats#27090
johnstcn wants to merge 3 commits into
cian/codagt-724-add-search-parameter-and-recency-ordering-to-getchatsfrom
cian/codagt-723-add-search-parsing-to-searchquerychats

Conversation

@johnstcn

@johnstcn johnstcn commented Jul 8, 2026

Copy link
Copy Markdown
Member

Adds search: parsing to searchquery.Chats, populating GetChatsParams.Search. The filter is single-valued, rejects empty values, and is mutually exclusive with title:, pr_title:, and pr: (the substring filters it replaces); the validation error names the conflicting filter(s) regardless of term order. Quoted values reuse the existing tokenizer. Parser only; SQL and handler wiring land separately.

Stack: #26968 <- #26995 <- #27009 <- this.

Refs https://linear.app/codercom/issue/CODAGT-723

Implementation plan

CODAGT-723: Add search: parsing to searchquery.Chats

Issue: https://linear.app/codercom/issue/CODAGT-723
Depends on: GetChatsParams.Search generated in CODAGT-724 (PR #27009).
Branch: cian/codagt-723-add-search-parsing-to-searchquerychats, stacked on the 724 branch (stack: #26968 <- #26995 <- #27009 <- this).
Deliverable: one draft PR. Parser only; no SQL, no handler, no frontend.

Requirements

Extend Chats(query string) in coderd/searchquery/search.go (~:522):

  1. Parse search:<value> into params.Search. Quoted values (search:"foo bar") must work exactly as they do for title: (the existing tokenizer handles quoting; reuse it).
  2. Single-value rule: repeated search: terms return a validation error on field search (check how the existing parser reports repeated params; mirror it).
  3. Mutual exclusion: search: combined with any of title:, pr_title:, pr: returns a validation error on search naming the conflicting filter(s). Check after parsing all terms so the error is deterministic regardless of term order.
  4. Empty value (search: or search:"") returns a validation error on search.
  5. Composes silently with archived, repo, diff_url, has_unread, pr_status, source.
  6. Bare terms remain rejected (existing behavior, unchanged).

Out of scope, per ticket: the websearch_to_tsquery emptiness preflight (725's handler concern).

Red: tests first

Table-driven cases in the existing parser test file, mirroring its style:

  1. search:foo -> Search == "foo", no error.
  2. search:"foo bar" -> Search == "foo bar".
  3. repo:coder/coder archived:true search:"foo bar" -> Search set, Repo and Archived set, no error.
  4. All structural filters together with search: -> no error.
  5. search:foo search:bar -> validation error on search.
  6. search:foo title:bar, search:foo pr_title:bar, search:foo pr:12 -> validation error each; error message names the conflict.
  7. Order independence: title:bar search:foo -> same error as 6.
  8. search: and search:"" -> validation error on search.
  9. Regression: existing non-search: queries parse identically.

Green: implementation

  1. Add the parse + validations per Requirements; keep the change small and local to Chats.
  2. make gen (expect no diff; parser only), make fmt, make lint, make test RUN=<parser tests>.

Refactor

  • If the mutual-exclusion validation duplicates an existing pattern in the file, align with it.
  • Error message wording: match the file's existing voice; no novel phrasing.

Verification


Generated by Coder Agents on behalf of @johnstcn.

@linear-code

linear-code Bot commented Jul 8, 2026

Copy link
Copy Markdown

CODAGT-723

@johnstcn

johnstcn commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-07-08 23:02 UTC by @johnstcn
Spend: $48.89 / $100.00

Review history
  • R1 (2026-07-08): 14 reviewers, 3 Nit, 1 P2, 1 P3, COMMENT. Review
  • R2 (2026-07-08): 14 reviewers, 4 Nit, 1 P2, 2 P3, COMMENT. Review
  • R3 (2026-07-08): 12 reviewers, 4 Nit, 1 P2, 2 P3, APPROVE. Review

deep-review v0.9.0 | Round 3 | 4904714..388bac7

Last posted: Round 3, 7 findings (1 P2, 2 P3, 4 Nit), APPROVE. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P2 Author fixed (3e6ec5b) search.go:616 Repeated search: produces spurious "cannot be empty" error R1 Bisky P3, Chopper P3, Hisoka P3, Kite P3, Mafuuu P3, Meruem P3, Pariston P3, Ryosuke P2, Knov P3 Yes
CRF-2 Nit Author fixed (3e6ec5b) search.go:522 Doc comment says "single-valued" when no other param mentions it R1 Gon Yes
CRF-3 P3 Author fixed (3e6ec5b) search.go:611 Comment says "replaces" but FTS and ILIKE have different matching semantics; verbose R1 Gon P2, Pariston Note Yes
CRF-4 Nit Author fixed (3e6ec5b) search_test.go:1665 Test comment can be shortened R1 Gon Yes
CRF-5 Nit Author fixed (3e6ec5b) search_test.go:1672 Test name "SearchConflictOrderIndependent" uses singular; siblings use "Conflicts" R1 Gon Yes
CRF-6 P3 Author fixed (7262cc4) search.go:611 Comment says "substring filters" but pr is exact integer match R2 Gon P3, Razor Nit Yes
CRF-7 Nit Author fixed (7262cc4) search_test.go:1241 Comment starts with field name the code already shows R2 Gon Yes
CRF-8 Note Dropped by orchestrator (scope creep, pre-existing issue in untouched line) search.go:518 Doc comment says source:all valid; parser rejects it R2 Leorio No

Round log

Round 1

Panel (14 reviewers). 1 P2, 1 P3, 3 Nit. Netero: no findings. Reviewed against d06ddf4..82f50b6.

Round 2

Panel (14 reviewers). CRF-1 through CRF-5 addressed. 1 P3, 1 Nit, 1 Note new. 1 dropped. Netero: no findings. Reviewed against 2a4e560..e740826.

Round 3

Panel (12 reviewers). CRF-6, CRF-7 addressed. No new findings. Netero: no findings. All findings resolved. Reviewed against 4904714..388bac7.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

coder-agents-review[bot]

This comment was marked as resolved.

@johnstcn
johnstcn force-pushed the cian/codagt-724-add-search-parameter-and-recency-ordering-to-getchats branch from d06ddf4 to 98a120b Compare July 8, 2026 14:28
@johnstcn
johnstcn force-pushed the cian/codagt-723-add-search-parsing-to-searchquerychats branch from 3e6ec5b to 8504a14 Compare July 8, 2026 14:30
@johnstcn
johnstcn force-pushed the cian/codagt-724-add-search-parameter-and-recency-ordering-to-getchats branch from 98a120b to 71399d8 Compare July 8, 2026 14:52
@johnstcn
johnstcn force-pushed the cian/codagt-723-add-search-parsing-to-searchquerychats branch from 8504a14 to fc7c727 Compare July 8, 2026 14:52
@johnstcn
johnstcn force-pushed the cian/codagt-724-add-search-parameter-and-recency-ordering-to-getchats branch from 71399d8 to f17ee99 Compare July 8, 2026 18:39
@johnstcn
johnstcn force-pushed the cian/codagt-723-add-search-parsing-to-searchquerychats branch from fc7c727 to 5384a41 Compare July 8, 2026 18:39
@johnstcn
johnstcn force-pushed the cian/codagt-724-add-search-parameter-and-recency-ordering-to-getchats branch from f17ee99 to 30d3b97 Compare July 8, 2026 19:17
@johnstcn
johnstcn force-pushed the cian/codagt-723-add-search-parsing-to-searchquerychats branch from 5384a41 to 688db9b Compare July 8, 2026 19:17
@johnstcn
johnstcn force-pushed the cian/codagt-724-add-search-parameter-and-recency-ordering-to-getchats branch from 30d3b97 to 2a4e560 Compare July 8, 2026 19:34
@johnstcn
johnstcn force-pushed the cian/codagt-723-add-search-parsing-to-searchquerychats branch from 688db9b to e740826 Compare July 8, 2026 19:34
@johnstcn

johnstcn commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All five R1 findings addressed cleanly. The CRF-1 fix is well-crafted: replacing the manual empty check with parser.RequiredNotEmpty("search") leverages existing infrastructure (20+ uses across the codebase) rather than patching the symptom. The ExpectedErrorCount addition to the test harness is a good generalization that catches the error class, not just the instance.

Severity summary: 1 P3, 1 Nit new. Both are about the comment at line 611, which was rewritten to fix CRF-3 but introduced a new inaccuracy.

"The chart says the patient can take three medications; the pharmacist only stocks two." (Leorio, on a pre-existing doc issue that made us smile but is out of scope)

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/searchquery/search.go Outdated
}
}

// search is mutually exclusive with the substring filters.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3 [CRF-6] "substring filters" is inaccurate for this conflict set. title: and pr_title: use ILIKE (substring matching), but pr: uses cds.pr_number = @pr_number (exact integer match). The label groups three filters under a shared property that only two of them have.

Options:

  1. Delete the comment. The conflict checks and the "cannot be combined with" error message on the next 15 lines name each filter explicitly; the code is self-documenting.
  2. Name the filters: // search is mutually exclusive with title, pr_title, and pr. (matches the doc comment at line 522).

(Gon P3, Razor Nit)

🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fix: addressed in 7262cc4, deleted the comment; the conflict checks and error message name each filter.

Generated by Coder Agents on behalf of @johnstcn.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified fixed in 388bac7. Comment deleted; the conflict checks and error message are self-documenting.

🤖

Comment thread coderd/searchquery/search_test.go Outdated
Query string
Expected database.GetChatsParams
ExpectedErrorContains string
// ExpectedErrorCount, when non-zero, asserts the exact number of

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit [CRF-7] Comment starts with the field name, which the next line already shows:

// When non-zero, asserts the exact number of validation errors.
ExpectedErrorCount int

(Gon)

🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fix: addressed in 7262cc4, adopted the trimmed comment.

Generated by Coder Agents on behalf of @johnstcn.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified fixed in 388bac7. Comment trimmed.

🤖

@johnstcn
johnstcn force-pushed the cian/codagt-723-add-search-parsing-to-searchquerychats branch from ab9672d to 7262cc4 Compare July 8, 2026 22:33
@johnstcn
johnstcn force-pushed the cian/codagt-724-add-search-parameter-and-recency-ordering-to-getchats branch from f14b054 to 4904714 Compare July 8, 2026 22:43
@johnstcn
johnstcn force-pushed the cian/codagt-723-add-search-parsing-to-searchquerychats branch from 7262cc4 to 388bac7 Compare July 8, 2026 22:43

johnstcn commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/coder-agents-review

All prior findings addressed and replied to inline. Requesting a convergence pass.

🤖 Requested via Coder Agents on behalf of @johnstcn.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All 7 posted findings (1 P2, 2 P3, 4 Nit) from R1 and R2 are resolved. No new findings from the R3 panel (12 reviewers) or Netero. The CRF-1 fix using RequiredNotEmpty was verified by tracing both the duplicate and empty paths through parseQueryParamSet/parseSingle, and the ExpectedErrorCount harness addition catches the error class going forward.

Clean, well-scoped parser addition. 26 lines of production code, 89 lines of tests, 77.4% test density. Ready to merge.

"I tried to build a case against this and couldn't." (Pariston, rounds 2 and 3)

🤖 This review was automatically generated with Coder Agents.

@johnstcn
johnstcn force-pushed the cian/codagt-723-add-search-parsing-to-searchquerychats branch from 388bac7 to ed6453d Compare July 9, 2026 07:20
@johnstcn johnstcn changed the title feat(coderd/searchquery): parse search filter for chats DNM: feat(coderd/searchquery): parse search filter for chats Jul 9, 2026
@github-actions github-actions Bot added the stale This issue is like stale bread. label Jul 25, 2026
@github-actions github-actions Bot closed this Jul 29, 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.

1 participant