fix(host-service): stop background git fetches from opening a sign-in window
Fixes #10149.
Summary
- Git calls the host-service makes on its own now run with
GCM_INTERACTIVE=never, so Git Credential Manager fails at once instead of opening a sign-in window. - Covers the base-branch refresh (every 5 min), the New Workspace branch list, the PR-stack branch warm-up, and the
git credential filltoken lookup. - Fetches the user starts (push, pull, checkout, workspace creation) still prompt as before.
Why / Context
For an HTTPS remote that uses Git Credential Manager (credential.helper = manager, e.g. Azure DevOps), an expired login, or one GCM cannot renew while offline, made GCM open a Microsoft sign-in window from these background fetches. Users saw it every few minutes with no action of their own. Each unanswered prompt also left a git-credential-manager get process waiting forever after the 30 s worker timeout.
GIT_TERMINAL_PROMPT=0 (already set) only stops git's own terminal prompt; GCM's window needs GCM_INTERACTIVE=never.
How It Works
withoutSignInPrompt(env)(runtime/git/non-interactive-env.ts) addsGCM_INTERACTIVE=never.GitFactorytakes{ interactive?: boolean }(defaulttrue);searchBranchesasks forinteractive: false.git/fetchBaseRefandgit/fetchBranchesworker tasks take a requiredinteractiveflag. The status-path base-ref refresh passesfalse(with its own dedupe key, so it never coalesces with a workspace-creation fetch, which passestrue).- Host-service
git.fetchBranchesgets an optionalinteractiveinput (defaulttrue); theuseOpenStackLayerwarm-up effect sendsfalse. Additive: older clients and older hosts keep the old behaviour. LocalGitCredentialProviderrunsgit credential fillnon-interactively. The env it returns for real git commands is unchanged, so user-started commands can still prompt.
Manual QA Checklist
Dev app on macOS, a real Azure DevOps HTTPS repo whose GCM login no longer works silently:
- Before the fix: opening the workspace ran
git fetch origin develop; GCM started and waited for sign-in indefinitely. The New Workspace branch list (git fetch --prune) did the same. - After the fix: the same fetch runs with
GCM_INTERACTIVE=never; GCM exits in 1-3 s with "Cannot prompt because user interactivity has been disabled", the host logs "Background base-ref fetch failed", and no process is left waiting. - After the fix: New Workspace branch search fails quietly and the branch picker still loads (
develop). - Not exercised in the app: the PR-stack warm-up (test repo has no stack) and the token lookup (covered by a test below).
Testing
bun testinpackages/host-serviceforruntime/git,workers,providers/git,trpc/router/git,trpc/router/workspace-creation,trpc/router/workspaces: 675 pass- New tests:
workers/tasks/git-fetch-base-ref.test.tsand a token-lookup case inLocalGitCredentialProvider.test.ts. Each fails with its fix reverted. They use a fakecore.sshCommand/ credential helper, so there is no network access. bun run typecheckinpackages/host-serviceandapps/desktopbunx biome checkon the changed paths
Known Limitations
- A failed token lookup is still not cached, so a repo with no usable token runs the credential helper on every git call (now fast, since it no longer waits). This was already true before this change.
Summary by cubic
Stops background host-service git calls from opening a Microsoft sign-in window when a saved Git Credential Manager login has expired or can't be renewed (for example while offline). These calls now run with GCM_INTERACTIVE=never, so GCM fails immediately instead of prompting.
- Covers the 5-minute base-branch refresh, the New Workspace branch list, the PR-stack branch warm-up, and the
git credential filltoken lookup. - Fetches the user starts (push, pull, checkout, workspace creation) still prompt as before.
- The base-ref refresh uses its own dedupe key so it never coalesces with a workspace-creation fetch, which stays interactive.
- The
git fetchBranchesinput and worker task options are additive; older clients and hosts keep the old behavior. GIT_TERMINAL_PROMPT=0alone was not enough: GCM's window is only blocked byGCM_INTERACTIVE=never.
Testing
- New tests cover the non-interactive base-branch fetch and the credential-fill token lookup; each fails with its fix reverted.
- 675 host-service tests pass, plus typecheck and biome.
- A failed token lookup is still not cached, so a repo with no usable token runs the credential helper on every git call (now fast, since it no longer waits).
Summary by CodeRabbit
- Bug Fixes
- Background Git fetches and branch searches no longer open sign-in windows unexpectedly. If authentication is required, these operations can fail without prompting.
- Git operations initiated interactively continue to allow sign-in prompts.