Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(vcs): share in-flight status refreshes per repository #7185

Closedmaslinedwin(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/7185/headopened View on GitHub

Fixes #7076. Concurrent vcs.refreshStatus calls for the same cwd share one local+remote refresh. Interrupting one waiter does not cancel the shared work.

Overlapping explicit refreshes each invalidated the repo status cache and started another local+remote Git computation. Concurrent windows/clients stacked 15–24s refreshes.

VcsStatusBroadcaster.refreshStatus now keeps one in-flight fiber per normalized working directory. Later callers join that fiber instead of starting another invalidate+recompute. The work is forked into the broadcaster scope, so cancelling one waiter does not abort the shared refresh. A request that starts after that work completes still runs a new refresh.

Client-side vcs.refreshStatus stays on the shared serial VCS command lane. That queue is not refresh-only (pull/worktree/ref mutations share it), and window-focus already debounce-coalesces. The server-side single-flight is what stops concurrent environments from stacking Git work.


Note

Medium Risk Touches core VCS refresh/coalescing semantics and WS-triggered git status updates; behavior changes around interruption and post-mutation freshness, though heavily covered by new unit tests.

Overview Fixes stacked concurrent Git status work by deduplicating refreshStatus per normalized cwd in VcsStatusBroadcaster: one in-flight fiber runs in the broadcaster scope, concurrent callers await it, and interrupting a waiter no longer cancels the shared refresh.

Adds invalidateStatus(cwd), which invalidates workflow caches, bumps a per-repo generation, and marks any in-flight refresh stale so waiters join a follow-up refresh instead of reusing pre-mutation results. Post-mutation paths in ws.ts (refreshGitStatus) and ProviderCommandReactor (worktree branch rename) now call invalidateStatus then refreshStatus.

New VcsStatusBroadcaster tests cover single-flight sharing, survival after waiter interrupt, isolation across repos, and invalidation during an in-flight refresh; test mocks gain invalidateStatus stubs.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 09083c355c4ed096bbdcf74e482f175d023b1716. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Share in-flight VCS status refreshes per repository and add invalidateStatus API

  • VcsStatusBroadcaster.refreshStatus now shares a single in-flight fiber per repository path, so concurrent callers join the same refresh rather than triggering duplicate work.
  • A new invalidateStatus(cwd) method invalidates cached workflow status and increments a generation counter; if called mid-refresh, the in-flight refresh is flagged to rerun after completion.
  • ProviderCommandReactor and the WebSocket RPC layer (ws.ts) are updated to call invalidateStatus before refreshStatus after branch renames and manual refresh requests.
  • Waiter interruption is handled safely: failures from stale in-flight runs are not surfaced to late joiners.
  • Behavioral Change: refreshStatus callers now share results from an in-progress refresh rather than each starting their own, which may reduce latency but changes the timing of cache updates under concurrent load.
Macroscope summarized 09083c3.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: d68a1441-f6bc-433a-987f-a9ddaea6ea86

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This PR introduces new concurrency control logic for VCS status refreshes, including fiber coordination, generation-based invalidation tracking, and retry loops. The complexity of coordinating in-flight requests with invalidation events warrants human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 5344bb38ee8811f07721c5c8a23b0b6914ae7f69. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -381,0 +482,21 @@
      482+ return Effect.succeed([joined, next] as const);
      483+ }
      484+
      485+ return startRefreshFiber(cwd, requestGeneration).pipe(
      486+ Effect.map((started) => {
      487+ const created: InFlightRefresh = {
      488+ fiber: started,
      489+ startedGeneration: requestGeneration,
      490+ pendingRerun: false,
      491+ };
      492+ const next = new Map(current);
      493+ next.set(cwd, created);
      494+ return [created, next] as const;
      495+ }),
      496+ );
      497+ });
      498+ const result = yield* Fiber.join(inFlight.fiber);
      499+ const latestGeneration = yield* invalidateGenerationOf(cwd);
      500+ if (inFlight.startedGeneration >= latestGeneration) {
      501+ return result;
      502+ }

      Failed refresh skips generation retry

      Low Severity

      The refreshStatus retry loop only continues after a successful Fiber.join. If the shared in-flight refresh fails after invalidateStatus bumped the generation, waiters exit with that error instead of joining the follow-up fiber settleRefreshFiber may still start.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 5344bb38ee8811f07721c5c8a23b0b6914ae7f69. Configure [here](https://www.cursor.com/dashboard/bugbot).

      This was real against the earlier Fiber.join loop, but it is already handled at HEAD (09083c35). refreshStatus now Fiber.awaits the shared run and only propagates a failure after the generation check, so a stale failure cannot skip the follow-up fiber settleRefreshFiber starts. No further change.

    5. Thanks for the PR. We're not taking changes to the orchestration and provider layers right now: that part of the server is being rewritten for V2, and merging into the current code would either conflict with or be thrown away by that work.

      Closing for now. If this is still an issue once V2 lands, please reopen (or open a fresh PR against the new code) and we'll take a proper look.

    6. juliusmarminge closed this

Sign in to join this conversation.