Uh oh!
There was an error while loading. Please reload this page.
fix(server): fall back to local worktree base when origin fails - #7667
fix(server): fall back to local worktree base when origin fails#7667saphid wants to merge 3 commits into
Conversation
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 bug fix that preserves healthy-origin and existing local paths while recovering from origin check, fetch, and ref-resolution failures. Targeted integration tests cover each failure stage and verify local-base worktree creation and continued bootstrap without rollback. You can add or adjust custom eligibility rules. Learn more. |
6b266b7 to
4bd76c7Compare4bd76c7 to
03d8d3cCompareDismissing prior approval to re-evaluate 03d8d3c
There was a problem hiding this comment.
One finding on the new origin-fallback logging in apps/server/src/ws.ts. The rest of the change (namespaced effect/* imports, Effect.catch over an error channel that is entirely GitCommandError, typed fallback kept inside Effect, and the parameterized it.effect.each coverage for each failure stage) matches the service conventions.
Posted via Macroscope — Effect Service Conventions
Uh oh!
There was an error while loading. Please reload this page.
Dismissing prior approval to re-evaluate 66158c3
Ready for human review at current head |
1. Observed problem and reproduction
With Start from origin enabled, creating a worktree-backed thread aborts if checking
origin, fetching it, or resolving the selected remote branch fails. This can happen while offline, with an unavailable remote, or when the selected branch has not been pushed. The provisional thread is then rolled back even when the explicitly selected local base is valid.2. Cause
The setting is a persisted preference, but the server treated every origin-preparation step as mandatory. A recoverable remote failure therefore escaped the worktree-base selection boundary and failed the entire bootstrap.
3. Change and owning boundary
The server now attempts origin availability, fetch, and remote-ref resolution as one optional source-selection step. If any of those operations returns a typed Git error, it records a structured warning and creates the worktree from the explicitly selected local base. A successful origin path still uses the resolved remote commit.
This stays in the existing WebSocket bootstrap and Git workflow boundary. The fresh extraction preserves the old head's core fallback behavior for unavailable, check-failure, fetch-failure, and ref-resolution cases while removing unrelated earlier draft-recovery work already shipped in #7664.
4. Intentionally unchanged and deferred
worktree.origin-fallbackactivity and per-stage reason taxonomy are intentionally omitted from this smaller server reliability change.5. Affected surfaces
6. Validation
Current base:
33b650a5b3b27382b35d2182dec6b22438c3da56.CI=true vp test run apps/server/src/server.test.ts: 134 passed, 0 failed.CI=true vp fmt --check apps/server/src/ws.ts apps/server/src/server.test.ts: passed.CI=true vp lint apps/server/src/ws.ts apps/server/src/server.test.ts: passed.CI=true vp run --filter t3 typecheck: passed; it reported only existing Effect suggestions in unrelated files.git diff --check origin/main...HEAD: passed.The focused server seam exercises the real typed WebSocket RPC bootstrap boundary. It covers an absent origin plus check, fetch, and remote-ref failures, asserts the selected local base, successful turn continuation, short-circuit call ordering, and no rollback. The adjacent existing case verifies the successful-origin path still uses the fetched commit.
7. Risks, limitations, and untested paths
origin; after a transient remote failure this intentionally starts from that older local base instead of failing.origin, the local fallback can still fail at worktree creation. The client then sees the worktree-add failure, while the original origin failure stage and exit status remain in the server log.8. Evidence
This is server-only behavior with no UI, layout, or interaction change. Screenshots and video are not applicable. The observable proof is the focused RPC integration coverage and successful local-base worktree selection described above.
9. Owning issue and overlap
The original stuck-draft symptom in #4647 was fixed by merged #7664. This PR retains only the distinct reliability outcome: an optional origin failure no longer aborts an otherwise valid local worktree bootstrap. Related overlap: #7610.
Generated with GPT-5.6 Sol in the Codex harness through T3 Code.
Note
Medium Risk
Changes new-thread worktree bootstrap only, but silently using a stale local base after remote errors could surprise users who expected origin; failures after fallback still abort as before.
Overview
Start from origin during thread bootstrap no longer fails the whole turn when Git cannot use
origin. The server still tries remote check, fetch, and remote-tracking resolution when the preference is on; any typed Git error in that path is logged as a structured warning and the worktree is created from the selected localbaseBranchinstead of rolling back the thread.Integration tests now run the same fallback scenario for four cases—missing origin, failed remote check, failed fetch, and failed ref resolve—and assert bootstrap completes (
response.sequence3), worktree uses the local base, and nothread.deletecleanup runs.Reviewed by Cursor Bugbot for commit acb73db. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fall back to local base branch when origin check, fetch, or resolve fails in
thread.turn.startbootstrap.prepareWorktree.startFromOriginis true, the origin path (check availability, fetch, resolve remote-tracking commit) is now wrapped inEffect.catch. Any failure logs a structured warning (threadId, baseBranch, remoteName, error details) and falls back to the localbaseBranchinstead of aborting.unavailable,check,fetch, andresolve, assertingresponse.sequenceequals 3 and nothread.deleteis dispatched.Macroscope summarized acb73db.