Skip to content

Branch change totals time out at 30 s on every refresh when the base branch is far behind, and turn completion waits for it #37437

Closed

Description

@jdev111

What happened

After a turn ends, RunFinalizationService.finalize waits on VcsStatusBroadcaster.refreshLocalStatus. In a workspace whose branch has drifted far from the base branch, the change totals inside that refresh time out at 30 s on every call. So every turn in that workspace finishes about 30 s late, and the totals are never shown.

Environment

  • T3 Code (Beta) desktop, server bundle version 0.1.0, installed build as of 2026-11-15
  • macOS 26.6.2, Apple M5, git 2.39.2
  • Thread running in place in the repository root, with no remote. The checked-out branch has no gh-merge-base, so resolveBaseBranchForNoUpstream falls back to main.
  • main is a stale local line: not an ancestor of HEAD, 518 commits behind, 55,203 files different.

Diagnosis

readBranchChangeTotals runs git diff --find-renames --minimal --numstat -z <merge-base> -- against the merge base with main, with untracked files added through prepareUntrackedReviewIndex. With 55,000 changed files, including large binaries, that diff can't finish within the 30 s git timeout.

The failure is caught (orElseSucceed), so it fails silently. Nothing remembers it, so the next refresh runs the same 30 s diff again. Worktree threads in the same repository set gh-merge-base to their parent branch and finish the same call in about 0.1 s.

Evidence

Server trace spans, real provider turns:

  • GitVcsDriver.readBranchChangeTotals in the repository root: n=61, 43 of them ended in GitCommandError: Git command timed out; p50 30.0 s, max 31.0 s.
  • The same diff run by hand without --find-renames --minimal still takes 30.6 s, so the size of the range is the cost, not the flags.
  • The same span in 9 worktree workspaces of the same repository: p50 0.1 s, max 1.5 s.
  • Inside RunFinalizationService.finalize (n=66): refreshLocalStatus p50 29.1 s, max 62.4 s. checkpointCapture.execute p50 4.0 s.

Suggested fix

  1. Don't make run completion wait on refreshLocalStatus. Refresh status after the run is marked complete. This overlaps with [BUG] V2 waiting run keeps showing Agent is working and offers Stop for finished work when checkpoint capture stalls #15124.
  2. When readBranchChangeTotals times out, cache that result per (cwd, HEAD, base) and stop retrying until one of them changes. Better still, skip the numstat entirely when git diff --name-only (or rev-list --count) shows the range is above a size cap, and show "too many changes" the way prepareUntrackedReviewIndex already does for untracked files.
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