/review base-branch picker includes current branch (e.g. main -> main)

Open 💬 3 comments Opened Feb 26, 2026 by enriquemorenotent
💡 Likely answer: A maintainer (enriquemorenotent, contributor) responded on this thread — see the highlighted reply below.

Summary

When using /review -> Review against a base branch, the picker includes the currently checked out branch as a base option.

Example shown in UI while on main:

  • main -> main

Why this is a problem

Selecting the current branch as its own base is not a meaningful comparison target for PR-style review and is confusing in the picker.

Reproduction

  1. Checkout main (or any branch).
  2. Run /review in TUI.
  3. Choose Review against a base branch.
  4. Observe that the list contains <current> -> <current>.

Actual

Current branch is included in the base-branch options.

Expected

Current branch should be excluded from base-branch options (or clearly disabled as non-selectable).

View original on GitHub ↗

3 Comments

enriquemorenotent contributor · 6 months ago

I dug into this and found a concrete root cause in the TUI flow:

  • show_review_branch_picker builds options from all local branches returned by local_git_branches(cwd).
  • It does not filter out the currently checked out branch before rendering items.
  • So entries like main -> main are rendered and selectable.

Proposed fix (minimal scope):

  • Exclude current_branch from the base-branch options list before building picker items.
  • Keep branch ordering/search behavior unchanged.

If this approach matches maintainers’ intent, would a Codex team member invite me to open a PR for this?

enriquemorenotent contributor · 6 months ago

(and yes, the post has been AI-generated, but it has been human reviewed ;)

middleDuckAi · 5 months ago

Repro

  • Reproduced this on current main.
  • The /review base-branch picker was offering the current branch as a candidate base branch, so flows like main -> main could be selected.

Root Cause

  • show_review_branch_picker was using local_git_branches(cwd) unchanged in both tui/src/chatwidget.rs and tui_app_server/src/chatwidget.rs.
  • I prepared a small local patch that filters out current_branch before building the selection items in both copies and added deterministic regression coverage with a temporary git repo initialized on main plus a feature branch.

Validation

  • cargo test -p codex-tui review_branch_picker_excludes_current_branch
  • cargo test -p codex-tui-app-server review_branch_picker_excludes_current_branch
  • just fix -p codex-tui
  • just fix -p codex-tui-app-server
  • CARGO_TARGET_DIR=/tmp/codex-target-12942-tui-full cargo test -p codex-tui
  • CARGO_TARGET_DIR=/tmp/codex-target-12942-app-full cargo test -p codex-tui-app-server

Risk

  • Low. This is scoped to the picker candidates in both mirrored surfaces plus focused regression coverage.

Maintainer Pickup

gh pr create --repo openai/codex --base main --head middleDuckAi:middleDuck/codex-12942-review-base-branch-picker-includes-current --title "$(gh pr view 5 --repo middleDuckAi/codex --json title --jq .title)" --body "$(gh pr view 5 --repo middleDuckAi/codex --json body --jq .body)"