Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Jan 1, 2026

Context

#1414 (merged) unified the review-base selector with the git status indicator so the diff view and divergence numbers use the same base.

However, mux workspaces can be created from git bundles, and those clones can inherit a stale refs/remotes/origin/HEAD (e.g. pointing at a feature branch). If we use origin/HEAD as the base (explicitly or implicitly), ahead/behind can be computed against the wrong remote ref.

What this PR changes (follow-up)

  • generateGitStatusScript()
    • Treats origin/HEAD as auto-detect even if configured as the base ref
    • Uses configured origin/<branch> when present (with main↔master fallback if the ref doesn't exist locally)
    • When auto-detecting, ignores suspicious origin/HEAD values and prefers origin/main or origin/master
  • GIT_FETCH_SCRIPT
    • Derives the remote default branch + SHA via git ls-remote --symref origin HEAD (instead of local origin/HEAD)
  • Storybook mock
    • Detects the consolidated git status script via output markers (less brittle)
  • Tests
    • Adds unit coverage for parseGitShowBranchForStatus

Regression risk

  • Auto-detection uses more heuristics; repos without origin/main or origin/master may fall back differently than before.
  • GIT_FETCH_SCRIPT now depends on git ls-remote --symref origin HEAD; if the remote is unreachable/slow, fetch will be skipped and statuses may remain stale until a later refresh/manual fetch.
  • If a user intentionally configured origin/HEAD as a base ref, it will now be treated as auto-detect (by design) to avoid stale/incorrect divergence.

Testing

  • make static-check

Generated with mux • Model: openai:gpt-5.2 • Thinking: xhigh

Copy link

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

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.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ammar-agent ammar-agent force-pushed the fix/git-status-primary-branch-detection branch 3 times, most recently from 8e59c66 to 9fdf9a6 Compare January 1, 2026 18:15
@ammar-agent
Copy link
Collaborator Author

@codex review

Addressed feedback:

  1. Simplified the review base logic - git status now just uses the global default (review-default-base, which defaults to origin/main)
  2. Removed the unnecessary project-scoping attempt since the review panel stores per-workspace and the global default is sufficient for the git status indicator

Copy link

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

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.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ammar-agent ammar-agent force-pushed the fix/git-status-primary-branch-detection branch 4 times, most recently from 4f30163 to f99c924 Compare January 2, 2026 21:19
@ammar-agent ammar-agent changed the title 🤖 fix: git status indicator showing wrong behind count 🤖 fix: ignore stale origin/HEAD in git status scripts Jan 2, 2026
@ammar-agent ammar-agent force-pushed the fix/git-status-primary-branch-detection branch 3 times, most recently from 51a1dde to 7b186e8 Compare January 7, 2026 15:30
#1414 unified the review base with git status, but fallback branch detection still trusted refs/remotes/origin/HEAD.

Workspaces created from bundles can inherit a stale origin/HEAD (e.g. pointing at a feature branch), causing ahead/behind to be computed against the wrong remote ref.

This follow-up:
- Treats origin/HEAD as "auto-detect" even if configured as the base ref
- Makes generateGitStatusScript() ignore suspicious origin/HEAD values and prefer origin/main or origin/master
- Adds main↔master fallback when a configured origin/<branch> does not exist
- Updates GIT_FETCH_SCRIPT to derive the remote default branch via `git ls-remote --symref origin HEAD`
- Updates Sidebar story mocks to detect the status script via output markers
- Adds unit tests for parseGitShowBranchForStatus
@ammar-agent ammar-agent force-pushed the fix/git-status-primary-branch-detection branch from 7b186e8 to 6935f0e Compare January 7, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant