Repository navigation
feat: expose per-ref diff statuses - #29082
Conversation
9169278 to
5cb2c01
Compare
5cb2c01 to
064d2a7
Compare
064d2a7 to
f7f3b28
Compare
f7f3b28 to
7def130
Compare
e55688b to
eae5fbe
Compare
eae5fbe to
c66b95b
Compare
c66b95b to
d86382c
Compare
|
@codex review |
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: 10e9ca4d69
ℹ️ 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".
4c58154 to
e81202d
Compare
5344c6c to
fdbbdf2
Compare
543e51e to
d0e4266
Compare
|
Re the documentation check: we will not add This reply was generated by Coder Agents. |
2ae28cc to
e50e145
Compare
e50e145 to
6f60ed0
Compare
6f60ed0 to
19afa16
Compare
7c4c61b to
8795d37
Compare
8795d37 to
0e4de64
Compare
0e4de64 to
a9226da
Compare
a9226da to
ef531c0
Compare
|
|
||
| var sdkStatus *codersdk.ChatDiffStatus | ||
| var changed *codersdk.ChatDiffStatus | ||
| var primarySDK *codersdk.ChatDiffStatus |
There was a problem hiding this comment.
Maybe we could drop "SDK" here? It's a bit confusing, considering changed doesn't have it, etc.
| } | ||
| if (selector.RemoteOrigin == "") != (selector.GitBranch == "") { | ||
| httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ | ||
| Message: "The origin and branch query parameters must be set together.", |
mafredri
left a comment
There was a problem hiding this comment.
One design question here and two points inline, all about how diff_statuses is ordered. I only looked at ordering; didn't review tests or the rest of the diff.
The primary is the last ref the git credential helper reported, so it moves on every authenticated git operation in a different branch. An agent pushing a stack (push A, push B, push A) flips diff_status and reorders diff_statuses three times. A git fetch on main, or from a detached HEAD (branch "HEAD"), becomes the primary. Is "last git operation wins" the intended policy?
🤖 This review was automatically generated with Coder Agents.
| // Deprecated: use DiffStatuses, which lists every pull request | ||
| // the chat tracks. | ||
| DiffStatus *ChatDiffStatus `json:"diff_status,omitempty"` | ||
| DiffStatuses []ChatDiffStatus `json:"diff_statuses,omitempty"` |
There was a problem hiding this comment.
Suggestion: the stack's frontend treats this order as contract ("the first row is the primary" in site/src/api/queries/chats.ts, #29543), but the field has no doc comment, so Swagger and typesGenerated.ts don't say so. ChatDiffStatus also lacks the sort key, so clients can't sort the list or tell which of two events is newer.
Could we document the order here and expose the report time on ChatDiffStatus? Alternatively: a stable list order (e.g. created_at) with an explicit primary marker would also stop the top bar and sidebar PR menus from reshuffling on every report.
PS. DiffStatusRef and ChangedDiffStatus need doc comments too.
🤖
There was a problem hiding this comment.
Made the order stable
| // branch info even before the worker refreshes PR data. | ||
| if w.publishDiffStatusChangeFn != nil { | ||
| if pubErr := w.publishDiffStatusChangeFn(ctx, chatID); pubErr != nil { | ||
| if pubErr := w.publishDiffStatusChangeFn(ctx, chatID, codersdk.DiffStatusRef{RemoteOrigin: origin, GitBranch: branch}); pubErr != nil { |
There was a problem hiding this comment.
Check: the broadcast path in MarkStale also reaches this. Git run outside a chat process (terminal, IDE, startup script) has no CODER_CHAT_ID, so the ref is upserted into every non-archived chat on the workspace. Before #29081 that overwrote one row; now it adds a row and makes it primary, and rows are never pruned. A terminal git pull on main over HTTPS makes main the primary of every chat on the workspace, and this PR returns it in diff_statuses. Should the broadcast path still write refs now that chats keep several?
🤖
The primary status in PublishDiffStatusChange is now named primary, the same as the changed status next to it. The 400 error for an incomplete ref selector now tells the user to set both query parameters or omit both.
diff_statuses now lists refs by first report, so the list does not change order when a ref gets a new git report. diff_status is still the ref with the most recent git report. One helper picks it, with the same tie order as before. diff_status is the primary marker and is no longer deprecated. The SDK types for the ref list, the ref selector, and the changed ref event now have doc comments.
A git report without a chat ID comes from outside a chat process, for example a terminal. MarkStale added the ref to every chat on the workspace, and the ref became the primary of each chat. Rows are not pruned, so the chats collected refs they never used. MarkStale now refreshes only the chats that already track the reported ref, and adds no rows. Reports with a chat ID do not change.
Part 2 of 6. Depends on #29081.
The API now exposes every ref a chat tracks. All API changes are additive.
Chat.diff_statuseslists every ref on the chat GET and in chat lists (including child chats). The order is stable: refs are listed by first report, so the list does not change order when a ref gets a new git report.Chat.diff_statusis the primary: the ref with the most recent git report. It is the same rule as before. Use it to find the primary, not the list position.ChatDiffStatusgainsremote_originandgit_branch.diff_status_changewatch events carrychanged_diff_status({ref, status}) naming the ref that changed. If that ref's row is gone,statuscontains onlychat_id.GET /chats/{chat}/diffaccepts optionaloriginandbranchquery parameters. Set both or omit both (otherwise 400). A selector that matches no stored ref returns 404. Without a selector the endpoint returns the primary, as before. The Go SDK addsWithChatDiffStatusReffor this.Generated by Coder Agents.