GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(coderd): key chat diff statuses by ref by DanielleMaywood · Pull Request #29001 · coder/coder

Conversation

@DanielleMaywood

@DanielleMaywood DanielleMaywood commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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_statuses table 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

  • The table key is now (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.
  • The worker polls only the ref that the chat last reported. Older refs of the same origin stop polling but keep their data. They resume when the agent reports them again.
  • The worker looks for a new open pull request when the stored one is merged or closed. If no new one exists, the old data stays.
  • The API has a new diff_statuses list next to the old diff_status field. 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_change events have a new changed_diff_status field that names the ref that changed. The chat in the event keeps the primary pick in diff_status.
  • GET /chats/{chat}/diff has new optional origin and branch query parameters. When you do not send them, the endpoint acts as before. The endpoint no longer writes to the database on read.
  • The git panel shows one view per tracked ref. Each view loads its own diff with the ref selector.

Notes for review

  • Migration 000590 swaps 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 CONCURRENTLY is not possible because all migrations run in one transaction. Deployments must stop old coderd instances before the migration runs: their ON CONFLICT (chat_id) writes fail once the old key is gone.
  • The frozen rows use a far-future stale_at instead of 'infinity': the pq driver in this repo cannot read 'infinity' into time.Time.
  • The acquisition query now claims rows by the full key. The old query claimed every row of a chat when any one of them went stale.
  • Multi-repo workspaces only track refs that reach the askpass flow. Full coverage of repos that never prompt for credentials needs separate agent-side work.
Design decisions (from the investigation plan)
  1. One watch event per ref, because PostgreSQL NOTIFY payloads are limited to 8000 bytes.
  2. No SDK break: diff_statuses was added next to diff_status; the API was just declared stable.
  3. The primary pick rule: most recently refreshed open pull request, fallback to the most recently refreshed merged or closed one.
  4. Retention by freezing: non-current rows keep their data but stop polling.
  5. The /diff selector is optional and backwards compatible; the same-branch replacement self-heal moved into the worker.
  6. The chat list returns the primary only; the single-chat GET returns the full list.
  7. The refresh endpoint (when built) should use the array response shape from day one.
  8. Askpass-only ref detection for now; agent-side periodic reporting is a follow-up.
  9. Telemetry deduplicates by chat with the most recently updated ref.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot assigned DanielleMaywood Sep 4, 2026
@DanielleMaywood DanielleMaywood added the experimental Changes that might not necessarily be merged, until its approved to proceed with. label Sep 4, 2026 — with Coder
DanielleMaywood added 2 commits September 8, 2026 08:59
@DanielleMaywood
feat(coderd): track multiple pull requests per chat
d10fbf4
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.
@DanielleMaywood
refactor(coderd): simplify multi-PR implementation and tighten comments
bdbdf0a
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
DanielleMaywood force-pushed the feat/chat-multi-pr-tracking branch from d9f6cc5 to bdbdf0a Compare September 8, 2026 09:46
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Docs preview

Check 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.

  • docs/reference/api/chats.md
  • docs/reference/api/schemas.md
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielleMaywood DanielleMaywood changed the title feat(coderd): track multiple pull requests per chat feat(coderd): key chat diff statuses by ref Sep 8, 2026
@DanielleMaywood
DanielleMaywood changed the base branch from main to feat/chat-diff-ref-key September 8, 2026 10:25
@DanielleMaywood
DanielleMaywood changed the base branch from feat/chat-diff-ref-key to main September 8, 2026 10:25
@DanielleMaywood

DanielleMaywood commented Sep 8, 2026

Copy link
Copy Markdown
Contributor 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielleMaywood DanielleMaywood closed this Sep 8, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@DanielleMaywood DanielleMaywood

Labels

experimental Changes that might not necessarily be merged, until its approved to proceed with.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@DanielleMaywood
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.