Skip to content

feat: expose per-ref diff statuses - #29082

Draft
DanielleMaywood wants to merge 2 commits into
feat/chat-diff-ref-keyfrom
feat/chat-diff-ref-api
Draft

DanielleMaywood wants to merge 2 commits into
feat/chat-diff-ref-keyfrom
feat/chat-diff-ref-api

Conversation

@DanielleMaywood

@DanielleMaywood DanielleMaywood commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

The API now exposes the per-ref diff statuses that part 1 stores. The old diff_status field keeps its meaning, so no client breaks.

This is part 2 of 3. It stacks on the database change in part 1. Part 3 adds the git panel views.

Fix

  • Chat.diff_statuses is a new list of every ref the chat tracks, next to the existing diff_status.
  • diff_status is the first row of the updated_at DESC ordering. The selector-free diff GET and the git panel use the same row, so every surface agrees on which PR represents the chat.
  • Each status names its ref through remote_origin and git_branch.
  • diff_status_change events have a new changed_diff_status field that names the one ref that changed. The chat inside the event keeps the primary in diff_status.
  • GET /chats/{chat}/diff accepts optional origin and branch query parameters. Without them it behaves as before.

Notes for review

  • Every wire change is additive. No field was removed or changed.
  • A selector that matches nothing while the chat tracks other refs is an error. A chat with no refs at all falls through to inline resolution, as before.

Generated by Coder Agents.

@DanielleMaywood DanielleMaywood added the experimental Changes that might not necessarily be merged, until its approved to proceed with. label Sep 8, 2026
@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.

@DanielleMaywood DanielleMaywood changed the title feat(coderd): expose per-ref diff statuses feat: expose per-ref diff statuses Sep 8, 2026
@DanielleMaywood
DanielleMaywood force-pushed the feat/chat-diff-ref-api branch 2 times, most recently from e55688b to eae5fbe Compare September 10, 2026 09:14
@DanielleMaywood

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-15T15:54:09.130206Z 7b505d9 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +2145 to +2146
remoteOrigin := status.GitRemoteOrigin
result.RemoteOrigin = &remoteOrigin

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Redact credentials from exposed remote origins

When a Git remote uses an HTTPS URL with embedded credentials, agentgit.getRepoChanges reads remote.origin.url verbatim and gitsync persists that value, so returning it unchanged here exposes the password or token through chat GET/list responses. This also discloses the credential to users granted read access through the chat ACL, even if they cannot access the workspace. Expose a credential-free normalized origin or redact URL userinfo instead of serializing the database key directly.

Useful? React with 👍 / 👎.

Comment thread coderd/exp_chats.go Outdated
// A selector that matches nothing is an error only when the
// chat tracks other refs. A chat with no refs stays on inline
// resolution.
return result, xerrors.Errorf("no diff status for ref %s/%s", selector.RemoteOrigin, selector.GitBranch)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return a client error for unknown refs

When origin and branch do not exactly match a tracked ref, including when a caller supplies only one of the independently optional query parameters, this new error reaches getChatDiffContents and is always returned as HTTP 500. A malformed or stale selector is a client-side condition, so returning 500 misclassifies expected input errors and can trigger retries or server-error alerts; validate incomplete selectors and map unmatched refs to an appropriate 4xx response.

Useful? React with 👍 / 👎.

@DanielleMaywood
DanielleMaywood force-pushed the feat/chat-diff-ref-api branch 2 times, most recently from 4c58154 to e81202d Compare September 15, 2026 11:12
@DanielleMaywood

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdbbdf2d98

ℹ️ 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".

Comment thread codersdk/chats.go
Comment on lines +1599 to +1600
RemoteOrigin *string `json:"remote_origin,omitempty"`
GitBranch *string `json:"git_branch,omitempty"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Compare ref identity when merging diff-status events

When the primary moves between two refs whose other status fields match, such as two GitLab branches with no discovered PR, site/src/api/queries/chats.ts:489-514 still considers the statuses equal because it does not compare the newly exposed remote_origin or git_branch. mergeWatchedChatSummary can therefore treat the watch event as a no-op and retain the previous primary ref while the server and selector-free diff endpoint use the new one; include both identity fields in diffStatusEqual.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7b505d99b1: diffStatusEqual now compares remote_origin and git_branch before the other fields, so a primary move between two refs whose remaining fields coincide (e.g. two no-PR GitLab branches) no longer passes the merge no-op guard with a stale primary.

Comment thread coderd/exp_chats.go
Comment on lines +3536 to +3537
// @Param origin query string false "Remote origin selecting the ref to diff"
// @Param branch query string false "Git branch selecting the ref to diff"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Expose the ref selector through the Go SDK

The endpoint now accepts origin and branch, but a repo-wide search shows that codersdk.Client.GetChatDiffContents still always requests the bare /diff URL. Consequently Go SDK consumers cannot retrieve the diff for any non-primary entry returned in DiffStatuses; add a URL-encoding SDK method or options parameter for both selector fields while preserving the existing selector-free call.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7b505d99b1: GetChatDiffContents now accepts opts ...RequestOption, and WithChatDiffStatusRef(ref) sets the origin and branch query parameters through the SDK's existing WithQueryParam. Selector-free calls are unchanged. A test exercises the option against a chat with two tracked refs.

@DanielleMaywood

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 7b505d99b1

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

1 participant