Skip to content

[Bug]: Shared-worktree threads show conflicting branches without a warning #5496

Closed

Description

@sunrakerr

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Start thread A in a worktree on branch feature/a.
  2. Create or attach thread B to the same existing worktree.
  3. In thread B, create or switch the physical worktree to branch feature/b.
  4. Keep both threads active and switch between them in the sidebar.
  5. Compare each sidebar branch label with the branch shown in the composer toolbar.

A real occurrence on the latest nightly produced two running Codex sessions with this state:

thread A: branch=feature/a, worktreePath=<shared-worktree>
thread B: branch=feature/b, worktreePath=<shared-worktree>
provider cwd for both threads: <shared-worktree>
physical Git HEAD: feature/a

The event history showed both records repeatedly retaining different branch values while pointing at the same worktreePath.

Expected behavior

When a worktree is shared, T3 should make it clear that its live Git HEAD is checkout-scoped rather than thread-scoped. A thread whose recorded branch differs from the shared worktree HEAD should receive the same visible mismatch protection as a local-checkout thread before another turn can be sent.

T3 should not present the recorded sidebar branch and live toolbar branch as two equally-current values without a warning.

Actual behavior

The sidebar renders each thread’s persisted thread.branch, while the composer toolbar renders the physical worktree’s live Git branch. The labels can therefore show opposite branches as users switch between sibling threads.

More importantly, both provider sessions use the same physical cwd, so a thread labeled feature/b can continue editing or commit while the worktree is actually checked out on feature/a.

resolveLocalCheckoutBranchMismatch currently returns null whenever activeWorktreePath !== null, so no mismatch warning is shown for this case. The server-side dedicated-worktree drift fix also deliberately skips shared worktrees, leaving this exact state uncovered.

Impact

Major degradation or frequent failure

Version or commit

0.0.32-nightly.20260806.1014 (a483337a02d4)

Environment

macOS desktop app, Codex provider, GPT-5.6 Sol. Two running threads attached to one Codex-managed Git worktree.

Logs or stack traces

# Sanitized projection/runtime evidence
thread A  saved branch=feature/a  worktree=<same path>  runtime cwd=<same path>
thread B  saved branch=feature/b  worktree=<same path>  runtime cwd=<same path>
git -C <same path> branch --show-current
feature/a

Workaround

Stop one thread and move it to a separate physical worktree before continuing. Verify uncommitted changes before switching the shared checkout.

Proposed focused fix

Generalize the existing branch-mismatch detection so it also covers worktree-backed threads. For worktree mismatches, warn that the checkout is shared/current and do not offer an automatic restore action that could disrupt sibling threads. Sending the next turn can use the existing metadata update path to acknowledge the live branch.

Related but not duplicate:

Activity

  1. maria-rcks commented on Oct 9, 2026

    @maria-rcks
    Collaborator

    Note

    This is an automated response from a bot acting on maria's behalf.
    This issue has had no activity since 2026-08-06.
    Is it still relevant on the current version? If so, your version and OS would help.

  2. juliusmarminge commented on Oct 19, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    This landed in #14883: threads in an established (including shared) worktree now get the branch-change notice when the checkout's branch differs from the thread's recorded branch, and the next send adopts the observed checkout branch while keeping the worktree attachment. Worktrees intentionally don't offer Restore branch, since switching a shared checkout would affect sibling threads.

    One caveat: it relies on the cached Git status, so a branch switch made from an external terminal may not show up until status refreshes. Closing as fixed; if you still see sibling threads send on the wrong branch on a build that includes #14883, please open a new issue with your version.

  3. t3dotgg commented on Oct 20, 2026

    @t3dotgg
    Member

    Note

    🤖 Claude Opus 5.5 responding on behalf of Theo

    Not planned, and the fix is being reverted. Direct quote from Theo:

    This is stupid and not our problem. They should use agents better. They are stupid and this should not have merged.

    Two threads sharing one worktree, where one thread switches its branch, is not a workflow T3 Code supports. Give each thread its own worktree. The worktree branch warning from #14883 showed on normal work (agents switch branches in their own worktree to build PR stacks) and could not be acted on, so it is being removed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions