Windows app appears unstable around branch/worktree state

Open 💬 2 comments Opened Mar 31, 2026 by mccartyflame
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

26.325.31654

What subscription do you have?

Pro

What platform is your computer?

_No response_

What issue are you seeing?

The Windows app appears unstable around branch/worktree state. I was switched from the task branch to main, could not switch back, and had to migrate to a new branch. After that, generated diffs in a large monolith file became hard to trust because duplicate/conflicting changes may have been introduced by branch/context instability rather than intentional edits. Separately, menu popups are unreliable and clip off-screen, which makes recovery harder. During coding, I’m seeing repeated PowerShell runtime errors including null dereference on .Trim() and malformed \ command execution. Combined with branch/worktree instability, this makes generated diffs in large files hard to trust because partial or corrupted edits may be introduced by execution failures rather than intended code changes.

What steps can reproduce the bug?

Open Codex desktop app on Windows.
Load a repo with an existing feature branch
Start a task and allow Codex to operate on that branch.
Continue working for several iterations (code generation, apply patches, run tests).
Observe branch context in the app.
Attempt to switch back to the original task branch after context changes.

What is the expected behavior?

Stable branch context
Reliable menu interactions
Clean command execution
Small, surgical diffs aligned to task scope

Additional information

_No response_

View original on GitHub ↗

2 Comments

github-actions[bot] contributor · 5 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #14575
  • #15308
  • #14703

Powered by Codex Action

DisabledAbel · 4 months ago

Why this happens

Codex creates its branch from a snapshot of main at task start. If main moves forward before Codex finishes (even a README edit or an auto-generated commit), the PR lands with conflicts — even though you never touched those files. It's a race condition between Codex's branch base and the current main.

Workaround that worked for me

I created a GitHub Actions workflow that auto-resolves conflicts by merging main into the Codex branch with -X theirs (keeping Codex's changes):

name: Auto Fix Conflicts

on:
  pull_request:
    types: [opened, synchronize, reopened]
  workflow_dispatch:
    inputs:
      branch:
        description: "Branch to fix"
        required: false
        default: ""

jobs:
  auto-fix:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write

    steps:
      - name: Checkout repo
        uses: actions/checkout@v5
        with:
          ref: ${{ github.event.inputs.branch || github.head_ref }}
          token: ${{ secrets.GITHUB_TOKEN }}
          fetch-depth: 0

      - name: Configure git identity
        run: |
          git config user.name "conflict-bot"
          git config user.email "bot@example.com"

      - name: Fetch base branch
        run: git fetch origin main

      - name: Try auto-merge (prefer incoming changes)
        run: git merge -X theirs origin/main || true

      - name: Detect conflicts
        id: conflicts
        run: |
          files=$(git diff --name-only --diff-filter=U)
          echo "files=$files" >> $GITHUB_OUTPUT

      - name: Auto resolve conflicts (fallback)
        if: steps.conflicts.outputs.files != ''
        run: |
          for file in ${{ steps.conflicts.outputs.files }}; do
            echo "Resolving $file"
            git checkout --theirs $file
            git add $file
          done

      - name: Commit & push changes
        run: |
          git add .
          git commit -m "🤖 Auto-resolved merge conflicts" || echo "No changes"
          git push

Key things that tripped me up:

  • permissions: contents: write is required or the push silently fails with 403
  • git config must come before the merge step, not just before the commit
  • Use actions/checkout@v5 to avoid the Node 20 deprecation warning

Would love to see Codex handle this natively — maybe by rebasing its branch on main right before opening the PR.