Repository navigation
feat(site): fetch and merge diff statuses per ref - #29543
Conversation
f23c58a to
e827956
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 742f398220
ℹ️ 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".
| ...cachedChat, | ||
| status: nextStatus, | ||
| title: nextTitle, | ||
| diff_status: nextDiffStatus, | ||
| diff_statuses: nextDiffStatuses, |
There was a problem hiding this comment.
Keep the primary diff status synchronized
On every diff_status_change, this writes only diff_statuses while the spread preserves the old diff_status. Current consumers such as ChatTopBar, AgentChatPageView, and the sidebar status configuration still read chat.diff_status, and this event path invalidates only diff contents rather than the chat entity, so PR state, statistics, and even a deleted primary PR remain stale until an unrelated refetch. Continue updating diff_status from the watched primary or the first merged row until those consumers are migrated.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 42f4e28. On diff_status_change the merge now writes diff_status: nextDiffStatuses?.[0], so the legacy field always matches the merged primary: it follows the fresher-than-snapshot merge decisions, and it clears when a tombstone deletes the primary. The field is also part of the no-op guard now. The source is the merged first row rather than the embedded watchedChat.diff_status, so the two fields can never disagree. Layers 4-6 of this stack migrate every production consumer (AgentChatPageView in the GitPanel PR, ChatTopBar in the top-bar PR, the sidebar config in the sidebar PR); after those merge, no production code reads diff_status and the field can be deleted.
Generated by Coder Agents
3606027 to
78e23f4
Compare
78e23f4 to
fa1f49c
Compare
fa1f49c to
c0e01e3
Compare
c0e01e3 to
d509327
Compare
d509327 to
4f81bf1
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42f4e280d2
ℹ️ 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".
| git_branch: "feature-a", | ||
| }, | ||
| // The server sends only chat_id when the ref has no row. | ||
| status: { chat_id: "chat-1" } as TypesGen.ChatDiffStatus, |
There was a problem hiding this comment.
Model the tombstone without an unsafe cast
Replace this assertion with a complete generated ChatDiffStatus fixture. The server serializes required zero-valued fields such as pull_request_title, pull_request_draft, and the diff counts, so { chat_id } is not an actual wire payload; the cast both bypasses the generated contract and leaves the tombstone test exercising an inaccurate shape.
AGENTS.md reference: site/AGENTS.md:L8-L8
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ba8fd59. The test now builds the tombstone without a cast, with the required fields at their zero values, which is the payload the server serializes.
This reply was generated by Coder Agents.
| return cached.every((status, index) => | ||
| diffStatusEqual(status, incoming[index]), | ||
| ); |
There was a problem hiding this comment.
Preserve author-only diff status updates
When a non-primary ref changes only author_login or author_avatar_url, mergeDiffStatuses installs the new row but this equality check calls diffStatusEqual, which omits both author fields. With the primary and other chat fields unchanged, the no-op guard returns the old cached chat, so the newly supported diff_statuses cache retains stale author data until an unrelated refetch. Include both author fields in the equality comparison.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ba8fd59. diffStatusEqual now compares author_login and author_avatar_url, so the no-op guard no longer keeps stale author data. Covered by new rows in the existing adopts diff status when only $field changes table test.
This reply was generated by Coder Agents.
ba8fd59 to
e619485
Compare
e619485 to
92da57a
Compare
92da57a to
3bcd5ba
Compare
| removedRef?: TypesGen.DiffStatusRef, | ||
| ): TypesGen.ChatDiffStatus[] | undefined => { | ||
| const merged = new Map( | ||
| (cached ?? []).map((status) => [diffStatusRefKey(status), status]), |
There was a problem hiding this comment.
nit: I HATE this pattern of ?? []
There was a problem hiding this comment.
Fixed in 76d7c04. mergeDiffStatuses has no ?? [] now. cached defaults to [], and incoming is a required array that its caller starts as []. The behavior is the same, because diff_statuses is never null.
This reply was generated by Coder Agents.
56cafce to
b985b69
Compare
76d7c04 to
c0ef5fc
Compare
c0ef5fc to
a7b5e0f
Compare
a7b5e0f to
c29d3eb
Compare
c29d3eb to
cdc7d3d
Compare
| ); | ||
| if (primaryIndex > 0) { | ||
| const [primaryRow] = statuses.splice(primaryIndex, 1); | ||
| statuses.unshift(primaryRow); |
There was a problem hiding this comment.
Minor: this moves the event's embedded primary to the front unconditionally. The comment above says the embedded primary can be stale by delivery delay, but that only guards adding the row. If events for A then B arrive as B then A, the cache shows A as primary until the next event or refetch. Not reproduced. Exposing the report time (see #29082) would let this drop stale events.
🤖
cdc7d3d to
8ecc197
Compare
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 server now keeps diff_statuses in a stable order and marks the primary with diff_status. The watch merge no longer moves the primary to the front. It replaces each row in place, adds new refs at the end, and takes diff_status from the merged row of the primary ref.
8ecc197 to
bea1de5
Compare
Part 3 of 6. Depends on #29082. No visible UI change.
The frontend API client and React Query cache now handle per-ref diff statuses.
getChatDiffContentstakes an optional ref, and the diff-contents query key includes it, so each ref has its own cache entry. Invalidation clears every ref's entry for the chat.When a
diff_status_changeevent arrives, the cache mergeschanged_diff_statusintodiff_statusesby ref. Other refs stay untouched, and an event with onlychat_idremoves its ref. The primary ref stays first in the list.diff_statusis set from that first entry, so older consumers stay consistent with the list. The equality check that skips no-op updates now also compares ref and author fields.Generated by Coder Agents.