Repository navigation
feat(coderd): key chat diff statuses by ref - #29001
Closed
DanielleMaywood wants to merge 2 commits into
Closed
DanielleMaywood wants to merge 2 commits into
DanielleMaywood wants to merge 2 commits into
Conversation
chat_diff_statuses held one row per chat, so a chat could only track
one pull request at a time and a branch switch carried the previous
PR's URL onto the new branch's data.
Re-key the table to (chat_id, git_remote_origin, git_branch) so every
ref the agent reports keeps its own row. The worker polls only the
ref a chat most recently reported; older refs of the same origin are
frozen with a far-future stale_at and resume when reported again. The
worker also re-resolves a branch when its stored PR was merged or
closed, so a replacement PR is picked up.
The API keeps the existing diff_status field as the primary pick (the
most recently refreshed open PR) and adds diff_statuses with the full
list, plus changed_diff_status on diff_status_change events to name
the ref that changed. GET /chats/{chat}/diff accepts optional origin
and branch query parameters and no longer writes to the database on
read.
The git panel lists one view per tracked ref and fetches each ref's
diff with its selector.
Wire the per-ref view selection in GitPanel to the selected ref id instead of always showing the first ref. Show the server-picked primary PR in the chat top bar instead of a client-side pick that could disagree with the server rule. Move the per-ref event graft into mergeWatchedChatSummary so ref keying lives in one place. Drop unreachable fallback logic in PrimaryChatDiffStatus, the unused ChatDiffStatusRef helper, duplicated pubsub publish code, and a test recorder that was never asserted. Order the plural diff status query the same as the single-chat query. Tighten or delete comments that restated the code.
DanielleMaywood
force-pushed
the
feat/chat-multi-pr-tracking
branch
from
September 8, 2026 09:46
d9f6cc5 to
bdbdf0a
Compare
Contributor
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
Collaborator
Author
|
Closing in favor of a three-PR stack. The single PR was too large to review well. The same change is split by layer: database ref key, API surface, and frontend. New PRs follow in this comment thread. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A chat can now track more than one pull request. Each git ref that the agent reports gets its own row. The git panel shows one view per ref.
Problem
The
chat_diff_statusestable had one row per chat. Because of this, a chat could show data for only one pull request at a time. When a chat switched from one branch to another, the old branch's pull request data stayed with the new branch. The old data also hid pull requests for other repos in the same workspace.Fix
(chat_id, git_remote_origin, git_branch). Each ref keeps its own row and its own pull request data. A branch switch adds a new row. It does not change the old row.diff_statuseslist next to the olddiff_statusfield. The old field keeps its meaning: the server picks the most recently refreshed open pull request, and falls back to a merged or closed one. No API field was removed or changed.diff_status_changeevents have a newchanged_diff_statusfield that names the ref that changed. The chat in the event keeps the primary pick indiff_status.GET /chats/{chat}/diffhas new optionaloriginandbranchquery parameters. When you do not send them, the endpoint acts as before. The endpoint no longer writes to the database on read.Notes for review
000590swaps the primary key. No data rewrite is needed: the old key allowed only one row per chat, so all rows satisfy the new key. The index build takes an ACCESS EXCLUSIVE lock for its duration.CREATE INDEX CONCURRENTLYis not possible because all migrations run in one transaction. Deployments must stop old coderd instances before the migration runs: theirON CONFLICT (chat_id)writes fail once the old key is gone.stale_atinstead of'infinity': the pq driver in this repo cannot read'infinity'intotime.Time.Design decisions (from the investigation plan)
diff_statuseswas added next todiff_status; the API was just declared stable./diffselector is optional and backwards compatible; the same-branch replacement self-heal moved into the worker.These were verified by a high-effort review pass, which also found and led to fixes for: the chat-wide acquisition bug, the pq infinity limitation, and the mixed-version rollout constraint.
Generated by Coder Agents.