Skip to content

Codex Desktop remote diff counter stays stale until manual git fetch updates origin/main #31534

Open

Description

@thisislvca

What version of the Codex App are you using?

Codex Desktop 26.623.141536 (build 4753)

CLI also installed: codex-cli 0.142.5

What subscription do you have?

ChatGPT Pro

What platform is your computer?

macOS 15.7.7 (24G720), arm64

What issue are you seeing?

Codex Desktop's remote/base diff counter appears to be computed from the local remote-tracking ref, for example origin/main.

If the upstream branch moves on GitHub but the local refs/remotes/origin/main ref has not been refreshed yet, the counter can stay stale. Running git fetch origin main manually updates the local origin/main ref, and then the Codex UI counter updates.

The confusing part is that the UI reads like it is comparing the current branch against the current remote branch, but the observed behavior matches a comparison against the locally cached origin/main ref.

What steps can reproduce the bug?

A minimal Git-level repro of the stale ref state:

rm -rf /tmp/codex-origin-counter-repro
mkdir -p /tmp/codex-origin-counter-repro
cd /tmp/codex-origin-counter-repro

git init --bare remote.git
git clone remote.git clone-a
cd clone-a
git config user.email [email protected]
git config user.name Repro
printf 'one\n' > file.txt
git add file.txt
git commit -m 'initial'
git branch -M main
git push -u origin main

cd ..
git clone remote.git clone-b
cd clone-b
git checkout main
git config user.email [email protected]
git config user.name Repro
printf 'two\n' >> file.txt
git commit -am 'advance remote'
git push origin main

cd ../clone-a

git rev-parse --short HEAD
git rev-parse --short origin/main
git ls-remote origin refs/heads/main | cut -f1 | cut -c1-7
git rev-list --left-right --count HEAD...origin/main

Before fetching, clone-a reports HEAD == origin/main and rev-list reports 0 0, even though git ls-remote shows that the live remote branch has advanced.

Then:

git fetch --quiet origin main
git rev-parse --short origin/main
git rev-list --left-right --count HEAD...origin/main

After the fetch, the local origin/main ref updates and the ahead/behind/diff state changes.

In Codex Desktop, this same stale-ref state shows up as the line/diff counter not updating until a manual git fetch is run in the repository.

What is the expected behavior?

For UI that represents a comparison against the remote branch, Codex should either:

  1. Refresh the relevant upstream remote-tracking ref before computing the counter, or
  2. Clearly label the value as based on the locally cached origin/main ref and provide a refresh/fetch action.

A conservative implementation could check the configured upstream branch and fetch just that ref before computing the remote diff.

What actually happened?

The counter stayed stale until I manually ran git fetch. Once the local origin/main ref changed, the counter updated.

Additional information

I checked the packaged Codex Desktop binary and found strings pointing at the app-server git processor path and local git commands used for this area:

app-server/src/request_processors/git_processor.rs
failed to compute git diff to remote for cwd:
rev-list
merge-base
for-each-ref
symbolic-ref
branch --show-current

I did not find evidence in that packaged binary inspection that this git processor path runs git fetch before computing the remote diff.

Activity

  1. added
    bug
    app
    app-server
    on Jul 8, 2026
  2. thisislvca commented on Jul 8, 2026

    @thisislvca
    Author

    Small clarification / update after more testing: Codex Desktop already has a Review -> Refresh action, but that action does not appear to refresh the remote/base ref used by the diff counter.

    Current behavior I’m seeing:

    • Review header shows main -> origin/main.
    • The Review menu includes Refresh.
    • Clicking Refresh reloads/re-runs the review view, but the remote/base line diff counter remains stale if local refs/remotes/origin/main is stale.
    • Running git fetch origin main manually updates local origin/main, after which the counter updates correctly.

    So I think the issue is narrower than my original wording: this is not just a missing refresh affordance. The existing Refresh action appears to refresh local app/git query state, but not the remote-tracking ref that the counter depends on.

    From a user perspective, the counter reads like “diff against current origin/main”, but in practice it is “diff against whatever local origin/main happened to be the last time something fetched it.” That distinction is surprising in the Review UI because the base label is remote-looking and there is already a Refresh action nearby.

    A reasonable expected behavior would be one of:

    1. Review -> Refresh fetches the relevant upstream/base ref before recomputing the counter.
    2. Codex periodically refreshes remote refs in a VS Code-like way, ideally opt-in/configurable. VS Code’s Git extension has git.autofetch plus git.autofetchPeriod and, when enabled, periodically runs git fetch while the repo is idle/focused.
    3. If Codex intentionally does not want networked git operations here, the UI should make that explicit, e.g. label this as a local/cache refresh and provide a separate “Fetch remote” / “Refresh remote base” action.

    The smallest product fix might be: when the user explicitly clicks Review -> Refresh, run a bounded fetch of only the selected/current base ref, then recompute the remote diff counter. That avoids surprising background network behavior while making the visible Refresh action do what users likely expect in this Review context.

  3. CJavierSaldana commented on Nov 3, 2026

    @CJavierSaldana

    We encountered a closely matching stale-origin/main counter incident in a new Codex Cloud task.

    Observed in a newly created Codex Cloud task, viewed through the desktop app. Repository identifiers, commit hashes, source files, screenshots, task IDs, and session links are intentionally omitted.

    Timeline and read-only findings (all timestamps UTC):

    • Task created: 2026-11-03 06:59:27 UTC.
    • Shortly after starting, the Branch counter showed +67,285 / -11,761.
    • The task's checked-out HEAD matched the live main on GitHub, verified separately through the GitHub API. That main commit was dated 2026-10-31 13:28:46 UTC.
    • However, the workspace's origin/main still pointed to an older commit; its reflog entry was dated 2026-10-21 09:16:56 UTC.
    • Comparing the stale origin/main with HEAD yielded 773 files, +67,167 / -11,756, across 64 existing commits. Those commits were already present on the live GitHub main. This accounts for almost the entire displayed counter.
    • The configuration files we inspected had modification times around 2026-11-03 07:04:01–07:04:54 UTC, after task creation. We do not have a working-tree snapshot from the exact instant the task was created.

    Relevant official documentation:

    Using Codex Cloud, says a new task gets a separate workspace and “does not recover another task’s uncommitted changes”.

    Cloud environments, under “Reuse and update saved state,” explains that new tasks start from the published environment's prepared filesystem, while existing tasks continue with their own saved files. This describes isolated workspaces based on reusable setup; it does not promise a completely fresh Git clone for every task.

    To be precise, we have not established that uncommitted files leaked between independent tasks. The verified finding is stale Git comparison metadata in a fresh cloud task. The resulting counter makes already-published history look like a large set of changes associated with the new task.

    Expected behavior: initialize or refresh the relevant remote-tracking comparison reference when preparing a new cloud task, or clearly identify an outdated comparison base and separate that historical diff from actual working-tree changes.

    This also relates to the misleading Changes-counter experience reported in #42775. We have not run a fetch as part of this investigation, so we are not claiming that workaround has been verified in our environment.

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

    appapp-serverbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions