fix(server): start-from-origin worktrees no longer wait on a full git fetch - #8393
fix(server): start-from-origin worktrees no longer wait on a full git fetch#8393gsimone wants to merge 5 commits into
Conversation
… fetch A hanging `git fetch origin` aborted new worktree threads even when origin/<branch> already existed locally. Resolve that tracking commit first, and fetch only that one branch when it is missing. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused server-side fix that avoids blocking on a full origin fetch by reusing cached tracking refs and fetching only the requested branch when necessary. Its runtime impact is confined to start-from-origin worktree bootstrap, with targeted tests covering fallback and failure paths. You can add or adjust custom eligibility rules. Learn more. |
Remote-qualified base branches like origin/release were fetched as refs/heads/origin/release, so bootstrap aborted when the tracking ref was missing. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
| .pipe( | ||
| Effect.matchEffect({ | ||
| onSuccess: () => Effect.succeed(true), | ||
| onFailure: (error) => | ||
| error instanceof GitCommandError && | ||
| error.exitCode !== undefined && | ||
| error.exitCode !== 0 | ||
| ? Effect.succeed(false) | ||
| : Effect.fail(error), | ||
| }), | ||
| ); |
There was a problem hiding this comment.
fetchRemoteTrackingBranch is typed Effect<void, GitCommandError>, so the instanceof GitCommandError guard can never be false and this hand-rolls recovery (match + re-fail) for a statically known tagged failure. The convention for a structural predicate on an underlying platform code is Effect.catchIf, which is also the existing idiom for GitCommandError recovery in this codebase (GitManager.ts uses Effect.catchIf(isNotGitRepositoryError, ...)). Consider:
.pipe(
Effect.as(true),
Effect.catchIf(
(error) => error.exitCode !== undefined && error.exitCode !== 0,
() => Effect.succeed(false),
),
);That also lets the now-unused GitCommandError value import added at line 31 be dropped (the type is already implied by the error channel).
Posted via Macroscope — Effect Service Conventions
|
Unhappy with this, closing but maybe someone will find this as evidence for a similar change later |
Summary
git fetch origin(every remote branch) under the default 30s timeout. A slow full fetch aborted the new thread even whenorigin/<branch>was already on disk.fetchRemoteTrackingBranch). A failed narrow fetch still fails the dispatch and rolls the provisional thread back — it does not silently fall back to localmain.Test plan
origin/mainpresent: worktree is created without waiting on a fullgit fetch originorigin/mainmissing locally: only that branch is fetched, then the worktree is createdoriginremote still uses the local base branchFocused:
vp test run apps/server/src/server.test.ts -t "bases a start-from-origin|fetches only the requested origin|fails start-from-origin|falls back to the local base|bootstraps first-send worktree"Generated with Cursor Grok 4.6.
Made with Cursor
Note
Fetch only requested branch for start-from-origin worktrees in
ws.tsthread.turn.startbootstrap handler in ws.ts now resolves the local origin tracking commit first, skipping any fetch when it is already available.GitWorkflowService.fetchRemoteTrackingBranchoperation instead of doing a whole-remote fetch.thread.turn.starthandler in ws.ts and the newfetchRemoteTrackingBranchdelegation in GitWorkflowService.ts.Macroscope summarized eb64f29.