Skip to content

feat(coderd/x/chatd): add the search_chats chat tool - #52

Merged
ibetitsmike merged 4 commits into
mainfrom
mike/todo-transcripts-7-search-chats
Nov 9, 2026
Merged

ibetitsmike merged 4 commits into
mainfrom
mike/todo-transcripts-7-search-chats

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #10. Independent of #48 (read_chat_transcript); the two touch the same line in fork_tools.go, so whichever merges second needs a one-line merge.

Adds search_chats, a chat tool that finds chats with the chat list search syntax (docs/coder-agents/chat-search-syntax.md), so an agent can find a past chat to read. Behind fork-chat-todos, like the todo tools; appendForkTools adds it.

  • Arguments: query (the q syntax of GET /api/v2/chats, parsed by searchquery.Chats, so the same filters, defaults and errors apply), after_id cursor and limit (1 to 50, default 20). A page returns chat_id, title, status, created_at, updated_at and shared (owned by another user) per chat, plus next_after_id and has_more.
  • The query runs as the chat owner (httpmw.UserRBACSubject and dbauthz.As, like asOwner in chattool/listtemplates.go), never as chatd, and with the owner as the viewer, so it finds what the owner's chat list finds: their own chats by default, and chats shared with them (user or group ACL) with source:shared_with_me.
  • Like the chat list, it returns top-level chats only, in the chat list order (pinned first, then most recently updated); the tool description says both, and that search cannot be combined with title, pr_title or pr.
  • ARCHITECTURE.md: one TODO line for the new tool.

Validation: TestSearchChats passes against Postgres 17 with the store wrapped in dbauthz, running the tool from appendForkTools the way a turn does: the owner's top-level chats (a child and another user's chat are not found) with paging, a chat shared with the owner found only after it is shared and marked shared, and argument errors (bare words, search with title, limit, cursor). A negative control that drops the shared field fails the sharing subtest. ./coderd/x/chatd/... passes; go vet is clean.

UAT on a dev instance with a local model (fc17b34, the head of #53 before review fixes, which contains this PR's code; fork-chat-todos on), from chats owned by a plain member:

  • title:<word> returned the member's two matching chats with titles, status and timestamps, and not the admin's chat with the same word.
  • With source:created_by_me,shared_with_me, the admin's chat was absent until the admin shared it with the member; then it came back with shared: true.
  • A bare word returned invalid query: q: unsupported search term: "deploy".

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T13:09:40.461983Z aee4a03 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dddaee44ea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/fork_search_chats.go Resolved
Comment thread coderd/x/chatd/fork_search_chats.go Resolved
Comment thread coderd/x/chatd/fork_search_chats.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: aee4a039e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…-7-search-chats

# Conflicts:
#	coderd/x/chatd/fork_chat_todos_internal_test.go
#	coderd/x/chatd/fork_tools.go
@ibetitsmike
ibetitsmike merged commit 7d90a21 into main Nov 9, 2026
9 checks passed
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merged at 4e4b2fe after these checks:

  • 4e4b2fe merges main 1a00411 (feat: resolve custom agent types in spawn_agent #51) into the accepted head 9f43756. With index and @@ lines removed, git diff origin/main...4e4b2fe4da matches the accepted patch byte for byte.
  • fork-ci run 42635064771 passes all checks on the exact head.
  • Codex found no major issues at 13:09:38Z on aee4a03. The accepted head adds nothing beyond that review, and 0 review threads are unresolved.
  • Lead diff review: search_chats is registered only under the fork-chat-todos experiment (appendForkTools). It queries as the chat owner's RBAC subject (dbauthz.As(ctx, owner)), with the viewer and shared-with filters set to the owner.
  • git merge-tree against main is clean. The local deployment of 1a00411 (feat: resolve custom agent types in spawn_agent #51) is healthy, so the merge slot is open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant