Skip to content

feat(site/src/pages/AgentsPage/components): simplify the git panel header - #29699

Closed
tracyjohnsonux wants to merge 22 commits into
mainfrom
feat/git-panel-header
Closed

tracyjohnsonux wants to merge 22 commits into
mainfrom
feat/git-panel-header

Conversation

@tracyjohnsonux

@tracyjohnsonux tracyjohnsonux commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Simplifies the git panel header. Stacked on #29544 (per-ref views in the git panel) so the multi-PR switcher and this header change do not collide.

  • A lone view (one PR, one branch, or one working repo with nothing else) renders as a plain label instead of a bordered dropdown trigger.
  • The toolbar is [switcher] [refresh] ... [action]. The action follows the active view: a PR shows a small View PR link, a working repo shows a small Commit button. The unified/split toggle moves into the branch/stats sub-header as a shared DiffStyleToggle.
  • The toolbar's padding puts the switcher text on the same 16px gutter and first-line center as a Summary paragraph, so switching tabs does not jump.
  • The switcher follows the other agents dropdowns: rotating chevron, radio items with a check mark on the active view, compact item sizing, and a separator between remote and working entries instead of an indent.
Header states
State Header
Single PR only ⑂ PR #4847 label, refresh, View PR on the right
Working repo only ● coder label, refresh, Commit on the right
PR + working repo Open | PR #4847 ▾ dropdown, action swaps with the selected view
Branch-only ref ⑂ feat/branch label, no action
Decision log
  • Branch-only refs get no action: the server synthesizes /tree/<branch> URLs for them, so the link requires a PR number, not just a URL.
  • DiffStyleToggle lives in DiffViewer.tsx next to DiffStyle so both sub-headers can render it without a GitPanel/RemoteDiffPanel import cycle.
  • The plain single-view label keeps the trigger's (transparent) border box and inner padding so text does not shift when a second view appears.
  • LocalDiffPanel is mocked in the header tests because the @pierre/diffs web component cannot be constructed under jsdom.

Generated by Coder Agents on behalf of @tracyjohnsonux.

DanielleMaywood and others added 20 commits September 21, 2026 08:22
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. Existing rows satisfy the new
key without a rewrite: both columns are NOT NULL with '' defaults and
the old key capped rows at one per chat.

The worker claims stale rows by the full key. Retained refs keep
polling on their own schedule, so no pause state or resume protocol is
needed. Telemetry reports one diff row per chat via DISTINCT ON.

The diff GET's discovery write now keys its upsert to the stored ref.
Under the old single-row key an empty ref key was safe; under the
composite key it would create a stray row the worker ignores.

Old coderd instances must finish before this migration runs: their
ON CONFLICT (chat_id) writes have no arbiter under the new key.
The primary ref is the most recently reported one, but its
ordering column was updated_at, the generic mutation time. A
discovery GET that resolves a changed PR URL late could bump the
old ref's updated_at past a newer report and steal the primary
back.

The table now tracks reported_at, set only by reports. Primary
ordering, the chat-list tiebreak, and telemetry dedup read it.
Refreshes, claims, backoffs, and URL writes cannot reorder the
primary anymore. The discovery write uses a dedicated query that
never touches ordering columns.
The chat diff client and query cache now track every ref the chat
follows, not only the primary. The GET diff client accepts a ref
selector. The diff-contents query key includes the ref, so each ref
keeps its own cache entry. The watch merge keys rows by ref, so a
changed row for one ref leaves the other refs' rows intact, and a
tombstone row removes its ref. The diff-contents invalidation
prefix-matches every ref.
The factory took positional git_branch and additions arguments.
A const base with object spread states every field at each call
site, matching the mock fixture convention.
Single-letter loop variables now name their rows. The tombstone
and changed-row arguments are built before the merge call instead
of nested ternaries inside it. The diff-contents key prefix gets
a named family key that the invalidation reuses.
The merge phases and the event derivation groups ran together
without separation. Each phase and group now has its own comment
with a blank line between them.
The git panel now shows one view per tracked ref. Selecting a ref
loads that ref's diff. A chat tracks one status row per ref, and the
first row is the primary.

The view switcher lists one entry per ref from diff_statuses. Each
entry shows the PR state and number, or the branch name when no PR
exists. Selecting an entry fetches that ref's diff with its origin
and branch selector. The diff body, PR title, and stats follow the
selection. A selection that resolves to nothing falls back to the
newest ref. The inline comment box resets when the ref switches, so
a comment draft cannot leak from one PR into another.
Every mock data fixture now starts with mock: mockDiffStatus,
mockChatWithDiffStatus, and mockDiffContents. Factory helpers keep
their make prefix: makePrStatus and makeRepo.
Every call site passed the same chat id. A const removes the
argument that no caller varied.
The effective view was a four-level ternary chain. It is now a
reconcile function whose branches read in order: hidden remote
tab, untracked ref, gone repo root, then the fallbacks. The
selector object for the selected ref is a named variable instead
of an inline JSX object, and the closure predicates use named
variables instead of re-narrowing the union.
The query enable conditions are named variables: hasPrUrl and
hasRefSelector state what the enable rule checks.
The component mixed its derivation logic inline: diff line counting,
repo set unions, switcher item building, view reconciliation, and
the selected-ref lookup each lived as nested code inside the
component body. Each is now a module-level helper with a name,
and the component reads as wiring between them. The diff fetch
enable check states its contract in one line.
The view selection, the selected row, and its PR metadata were one
unbroken run of declarations. Each group now sits under its own
comment with a blank line between groups.
…ader

A lone view (one PR, one branch, or one working repo with nothing
else) renders as a plain label instead of a bordered menu trigger.

The primary action moves into the toolbar and follows the view: a
PR shows a View PR link, a working repo shows a Commit button. The
per-view sub-headers keep the branch and stats but drop their
buttons.
…er with the summary tab

The refresh control sits beside the view switcher, the primary action
takes the far right, and the unified/split toggle moves into the
branch/stats sub-header as a shared DiffStyleToggle.

The toolbar's padding puts the switcher text on the same 16px gutter
and first-line center as a summary paragraph. The plain single-view
label keeps the trigger's border box so text does not shift when a
second view appears.

The switcher now follows the other agents dropdowns: a rotating
chevron, radio items with a check mark on the active view, compact
item sizing, and a separator between remote and working entries.
…ke the terminal selector

The trigger is h-8 in a px-3 gutter with the terminal selector's
padding, chevron size, and w-56 menu. The refresh button and Commit
button scale up with it. pt-3 keeps the control centered on the
summary tab's first line.
@DanielleMaywood
DanielleMaywood force-pushed the feat/chat-diff-ref-gitpanel branch 7 times, most recently from 96fbdeb to 93f2d37 Compare September 24, 2026 08:32
@DanielleMaywood
DanielleMaywood force-pushed the feat/chat-diff-ref-gitpanel branch 10 times, most recently from 8994071 to a9210b7 Compare October 1, 2026 09:59
@DanielleMaywood
DanielleMaywood force-pushed the feat/chat-diff-ref-gitpanel branch 3 times, most recently from 045fbb8 to 2ade5e8 Compare October 6, 2026 10:14
@linear-code

linear-code Bot commented Oct 8, 2026

Copy link
Copy Markdown

CODAGT-990

@DanielleMaywood
DanielleMaywood force-pushed the feat/chat-diff-ref-gitpanel branch from 2ade5e8 to cb0dbd0 Compare October 9, 2026 09:36
Base automatically changed from feat/chat-diff-ref-gitpanel to main October 9, 2026 10:27
@tracyjohnsonux tracyjohnsonux added the experimental Changes that might not necessarily be merged, until its approved to proceed with. label Oct 13, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants