Repository navigation
fix(server): a zero Git fetch interval also stops the status upstream fetch - #33845
chomamateusz wants to merge 1 commit into
Conversation
… fetch Settings → Source Control → Git fetch interval = 0 promises no automatic Git prompts. VcsStatusBroadcaster honours it (pingdotgg#13253 for pingdotgg#13235), but the Git driver core still fetched on its own: refreshStatusUpstreamIfStale runs `git fetch --quiet --no-tags --no-auto-gc <remote>` from every statusDetails() call and from statusDetailsRemote() unless the caller passes refreshUpstream: false, with a 15 s success TTL and a failure backoff capped at 15 minutes. GitManager.status / remoteStatus without options, the git action flows, startup auto-pull and repository publishing all reached it. With an SSH remote and a GUI SSH agent every attempt raised an approval prompt although the setting was 0 (pingdotgg#13912 describes the same loop against a Keychain prompt). refreshStatusUpstreamIfStale now returns before spawning Git when the configured interval is zero. VcsAutomaticFetchInterval and its settings-backed layer move into their own module so the driver core can read them without importing the broadcaster, and server.ts provides the layer at the root of the runtime dependencies so the memoised GitVcsDriver.layer captures it wherever it is first built. Non-zero intervals keep the same cache, timeouts and backoff. Test: GitVcsDriverCore.test.ts "does not fetch for status when the automatic fetch interval is zero" (fails on main: one fetch spawned).
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Git status refresh now honors a zero automatic-fetch interval instead of contacting the upstream remote. The existing default remains unchanged, and the change is limited to suppressing automatic fetch activity. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Problem
Settings ‚Üí Source Control ‚Üí Git fetch interval says "Set to 0 to avoid automatic Git prompts". With
0,VcsStatusBroadcasterskips the upstream fetch (poller,getStatus,refreshStatus; #13253 added the window-focus half for #13235). The Git driver core still fetches on its own:refreshStatusUpstreamIfStalerunsgit --git-dir <common-dir> fetch --quiet --no-tags --no-auto-gc <remote>from everystatusDetails()call and fromstatusDetailsRemote()whenever the caller does not passrefreshUpstream: false, with a 15 s success TTL and a failure backoff capped at 15 minutes.Paths that reached that fetch with the interval at
0(line numbers onmainbefore this change):apps/server/src/vcs/GitVcsDriverCore.ts:2392statusDetails(cwd)refreshes unconditionally;:2405statusDetailsRemote(cwd, options)refreshes unlessoptions.refreshUpstream === false.apps/server/src/git/GitManager.ts:1463remoteStatusResultCache‚ÜíreadRemoteStatus(cwd)with no options, reached byGitManager.remoteStatus(input)without options (:2433) andGitManager.status(:2437, viaGitWorkflowService.status:324).apps/server/src/git/GitManager.ts:1959buildCompletionToast,:2294runPrStep,:2873preparePullRequestThread,:2894ensureExistingWorktreeUpstream,:2948reuseExistingWorktree,:3153runStackedAction‚ÜígitCore.statusDetails.apps/server/src/vcs/GitVcsDriverCore.ts:2669pushCurrentBranch‚ÜístatusDetails(fromGitManager.pushCurrentBranch:747,runStackedAction:3282,SourceControlRepositoryService.publishRepository:506).apps/server/src/serverRuntimeStartup.ts:209auto-pull projects at startup;apps/server/src/sourceControl/SourceControlRepositoryService.ts:495publishing a repository without commits.Environment where it shows: a project whose
originis an SSH remote and whose key lives in a GUI SSH agent that asks for approval per use (1Password SSH agent, macOS). Each attempt raises an approval dialog attributed to T3 Code; unattended attempts time out after 60 s and are retried on the backoff schedule. The agent's log on the reporting machine shows 25 to 63 unattended prompts per day with the interval at0. #13912 (accepted) describes the same fetch retrying every 15 minutes against a macOS Keychain prompt for an HTTPS remote.Expected: with the interval at
0, no automaticgit fetchruns anywhere in the server, as the setting copy promises and as #13253 established for the window-focus path.Change
refreshStatusUpstreamIfStalereturns before spawning Git when the configured automatic fetch interval is zero.VcsAutomaticFetchInterval(theContext.Referenceholding the settings-backed interval) and its layer move fromVcsStatusBroadcaster.tsintoapps/server/src/vcs/VcsAutomaticFetchInterval.ts, so the driver core can read the interval without importing the broadcaster (which would cycle throughGitWorkflowServiceandGitManager).server.tsprovides the layer once at the root oflayerRuntimeDependencies:GitVcsDriver.layeris memoised and some of its build sites live outsideserver.ts(orchestration-v2/runtimeLayer.ts, per-connection inws.ts), so the interval has to be in context before the first build captures it. The broadcaster's own provision becomes redundant and is removed. Every non-zero interval keeps today's behaviour: same cache, same timeouts, same backoff.Behaviour note for maintainers: with the interval at
0, the implicit upstream refresh inside git action flows (runStackedAction,runPrStep, worktree reuse) is skipped too, so acreate_praction decideswantsPushfrom the last knownorigin/<branch>. Push, pull, explicit fetch, PR checkout and thread launch fetches are unaffected (they do not go throughrefreshStatusUpstreamIfStale).Scope and approval
One underlying defect: the
0setting is honoured by the broadcaster but not by the driver core's staleness fetch. The intended behaviour is already established by the triaged issue #13235 and its fix #13253 ("a zero Git fetch interval also stops the fetch on window focus"); this change closes the remaining paths of the same defect and removes the retry loop of #13912 for users who set the interval to0. No new behaviour, no new setting, no change to defaults.Verification
apps/server/src/vcs/GitVcsDriverCore.test.ts, "does not fetch for status when the automatic fetch interval is zero", next to "does not fetch for status when the branch tracks a local branch": a repo whose branch tracks a bareorigin, driver built with the interval at zero,statusDetailsthenstatusDetailsRemote; assertsupstreamRef === origin/<branch>and nofetchspawn. Againstmain'sGitVcsDriverCore.tsit fails withexpected [ [ '--git-dir', …(7) ] ] to deeply equal [](one fetch spawned); with the change it passes. The existing case "can read cached remote divergence without fetching upstream" keeps covering the default interval (one fetch).pnpm exec vp test run src/vcs/GitVcsDriverCore.test.ts(246 tests; two pre-existing cases need an unsandboxed run and a canonical TMPDIR on this machine, identical onmain),src/vcs/VcsStatusBroadcaster.test.ts26/26.node scripts/check-changed.ts: format, lint, knip 1/2 and 2/2, graphql (apps/server), typecheck (3 packages), test (3 files, 274 tests) all pass.0against the 1Password SSH agent. The build with this change is being installed on the reporting machine; the before/after count of agent prompts will be added here. Also not checked: Windows, Linux desktop.Code written with Claude Opus 5.5 in Claude Code (T3 Code harness); reviewed by Claude Opus 5.5 and GPT-6.1 Sol.