Repository navigation
fix: don't hydrate a headless mobile session for a repo that no longer exists - #9343
Conversation
📝 WalkthroughWalkthroughWorkspace session tab hydration now builds a set of live repository IDs from the store, parses persisted worktree keys, and skips entries associated with repositories no longer present. Unparseable worktree keys continue through hydration unchanged. Comments document the 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
…r exists
`hydrateHeadlessMobileSessionTabsFromWorkspaceSession` iterates
`workspaceSession.tabsByWorktree` with no repo gate. Those keys are
`${repoId}::${path}` and are not pruned when a repo disappears from this
client's view, so a stale key re-materializes a phantom "unknown"/duplicate
workspace with no live repo behind it, on boot, with no `session-created` event.
Skip entries whose parsed repoId is not in the live `repos`; leave unparseable
keys alone (conservative). Defensive complement to the delete-path (stablyai#9025) and
load-time (stablyai#9200) fixes — this closes the mobile/headless hydration path.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
3f690d8 to
d72a458
Compare
|
Thanks so much for this, @PannenetsF — don't hydrate a headless mobile session for a repo that no longer exists. Verified (fail-on-main/pass-on-branch), rebased on latest |
Main's headless tab hydrate (#9343) skips worktree keys whose repo is not in getRepos. Retirement tests that rebuild mobile tabs from a persisted session now advertise the fixture repo as live so PR Checks merge stays green.
…10429) * Fix fork PR/MR worktree creation race via durable review-head refs When creating a fork PR/MR worktree, concurrent `git fetch origin` operations clobber the shared FETCH_HEAD, causing the wrong commit to be checked out. Fetch PR/MR heads into dedicated per-review refs (`refs/orca/pull/<N>`, `refs/orca/merge-requests/<N>`) that persist and isolate each head from other fetches. Gracefully keep the compare-base when the fetch fails but the local ref already exists, avoiding silent fallback to the wrong branch on transient network errors. * Bound PR/MR head fetches with 60s timeout Prevent PR/MR creation from hanging when a remote is stalled or unreachable. Both GitHub and GitLab head fetches now enforce a 60-second timeout, matching the bound used in the create-path fetch. Durable refs (refs/orca/pull/*, refs/orca/merge-requests/*) decouple the ref from FETCH_HEAD, preserving legacy client semantics. * test: align CI expectations with main PowerShell/sparse regressions PR checks merge into main, which recently changed PowerShell launch args (cwd restore after profiles) and sparse-checkout detection (require core.sparseCheckout). Derive PowerShell spawn args from the production resolver, mock the sparse config flag, reset shared worktree list scan cache between tests, and stop requiring floating polls to avoid getRepos hydration. * Address review follow-ups on durable review-head refs - Unify PR review-head remote selection: local and SSH GitHub paths share resolveGitHubReviewHeadRemote, which prefers the remote mapping to the hosting GitHub project (upstream before origin, matching work-item/API candidate order) so contributor clones fetch refs/pull from the repo that actually hosts the PR. - Soft-keep durable review heads: when the PR/MR head fetch fails but refs/orca/pull/<N> / refs/orca/merge-requests/<iid> still resolves, keep the pinned SHA (warn) instead of failing resolve, mirroring the compare-base fallback. Extracted shared compare-base soft-keep into compare-base-ref-fetch.ts. - Extract fetchGitLabMergeRequestHeadRef (local + SSH) parallel to the GitHub helper; bound its local fetch with the shared 60s timeout. - Share relay-style fetch validation (positive safe-integer id, remote not starting with "-") between relay and local helpers via review-head-tracking-ref.ts; move REVIEW_HEAD_FETCH_TIMEOUT_MS there. - Drop the githubPullRequestHeadLocalRef re-export; resolve head SHAs via rev-parse --verify <ref>^{commit}. - Add GitLab anti-FETCH_HEAD regression test plus durable-head soft-keep and remote-selection unit tests. Co-authored-by: Orca <[email protected]> * test: supply live getRepos for terminal-retirement hydrates Main's headless tab hydrate (#9343) skips worktree keys whose repo is not in getRepos. Retirement tests that rebuild mobile tabs from a persisted session now advertise the fixture repo as live so PR Checks merge stays green. * fix(editor): extract RichMarkdownEditor props to stay under max-lines Main's SSH external-image wiring (#10323) pushed RichMarkdownEditor.tsx over the 400-line tsx budget, failing PR Checks lint on every merge into main. Move the props type into a sibling module so the component stays under the limit without disabling max-lines. * Make durable review-head refs remote-identity scoped Embed remote name + URL hash into refs/orca/pull|merge-requests refs to prevent soft-keep from serving wrong project's PR/MR when FETCH_HEAD is clobbered by concurrent fetch. Fetch functions now return the written ref path (writer-authoritative) so callers rev-parse exactly what was fetched, not re-derive identity. Soft-keep only applies to transient errors (timeout, network); fails hard on missing refs, auth failures, and stale relay. Relay returns localRef so client avoids re-hashing (URL normalization can disagree). --------- Co-authored-by: Orca <[email protected]>
…ry tab (#10437) * fix(runtime): stop the headless hydration repo gate from dropping every tab #9343 gated headless mobile-session hydration on the live repo list, but read it as `this.store?.getRepos?.() ?? []`. A store that cannot report repos then yields an empty set, which reads as "every repo is gone" and skips every parseable session key — so no tabs hydrate at all. It also called getRepos on every hydrate, including the hot floating-tab poll path that is contractually free of repo/provider inventory work. Resolve the inventory lazily and only for keys that parse to a repoId, and keep `null` (unavailable) distinct from an empty list (all repos really gone). An absent list now fails open; a known list still prunes as #9343 intended. Fixes 3 tests that have been failing on main since #9343 landed: orca-runtime-terminal-retirement (2) and orca-runtime (1). * refactor(editor): extract the pending-focus effect to clear the max-lines cap #8083 pushed RichMarkdownEditor.tsx to 404 counted lines against the 400-line .tsx cap, failing lint for every PR that merges current main. The Explorer find-focus request is self-contained, so it moves to its own hook.
…10443) #9343 broke two contracts at once and #10437 fixed both, but neither is asserted: #10429 repaired the failing tests by deleting the poll assertion and by handing the retirement store a live repo, so a revert would land silently. Restore `expect(getRepos).not.toHaveBeenCalled()` on the floating-tab poll, and add a hydrate case for a store that cannot report repos. Verified both fail against the pre-#10437 code: the poll assertion reports getRepos "called 2 times", and the hydrate case returns [] instead of the persisted tab.
…r exists (stablyai#9343) `hydrateHeadlessMobileSessionTabsFromWorkspaceSession` iterates `workspaceSession.tabsByWorktree` with no repo gate. Those keys are `${repoId}::${path}` and are not pruned when a repo disappears from this client's view, so a stale key re-materializes a phantom "unknown"/duplicate workspace with no live repo behind it, on boot, with no `session-created` event. Skip entries whose parsed repoId is not in the live `repos`; leave unparseable keys alone (conservative). Defensive complement to the delete-path (stablyai#9025) and load-time (stablyai#9200) fixes — this closes the mobile/headless hydration path. Co-authored-by: fanyunqian.1 <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…tablyai#10429) * Fix fork PR/MR worktree creation race via durable review-head refs When creating a fork PR/MR worktree, concurrent `git fetch origin` operations clobber the shared FETCH_HEAD, causing the wrong commit to be checked out. Fetch PR/MR heads into dedicated per-review refs (`refs/orca/pull/<N>`, `refs/orca/merge-requests/<N>`) that persist and isolate each head from other fetches. Gracefully keep the compare-base when the fetch fails but the local ref already exists, avoiding silent fallback to the wrong branch on transient network errors. * Bound PR/MR head fetches with 60s timeout Prevent PR/MR creation from hanging when a remote is stalled or unreachable. Both GitHub and GitLab head fetches now enforce a 60-second timeout, matching the bound used in the create-path fetch. Durable refs (refs/orca/pull/*, refs/orca/merge-requests/*) decouple the ref from FETCH_HEAD, preserving legacy client semantics. * test: align CI expectations with main PowerShell/sparse regressions PR checks merge into main, which recently changed PowerShell launch args (cwd restore after profiles) and sparse-checkout detection (require core.sparseCheckout). Derive PowerShell spawn args from the production resolver, mock the sparse config flag, reset shared worktree list scan cache between tests, and stop requiring floating polls to avoid getRepos hydration. * Address review follow-ups on durable review-head refs - Unify PR review-head remote selection: local and SSH GitHub paths share resolveGitHubReviewHeadRemote, which prefers the remote mapping to the hosting GitHub project (upstream before origin, matching work-item/API candidate order) so contributor clones fetch refs/pull from the repo that actually hosts the PR. - Soft-keep durable review heads: when the PR/MR head fetch fails but refs/orca/pull/<N> / refs/orca/merge-requests/<iid> still resolves, keep the pinned SHA (warn) instead of failing resolve, mirroring the compare-base fallback. Extracted shared compare-base soft-keep into compare-base-ref-fetch.ts. - Extract fetchGitLabMergeRequestHeadRef (local + SSH) parallel to the GitHub helper; bound its local fetch with the shared 60s timeout. - Share relay-style fetch validation (positive safe-integer id, remote not starting with "-") between relay and local helpers via review-head-tracking-ref.ts; move REVIEW_HEAD_FETCH_TIMEOUT_MS there. - Drop the githubPullRequestHeadLocalRef re-export; resolve head SHAs via rev-parse --verify <ref>^{commit}. - Add GitLab anti-FETCH_HEAD regression test plus durable-head soft-keep and remote-selection unit tests. Co-authored-by: Orca <[email protected]> * test: supply live getRepos for terminal-retirement hydrates Main's headless tab hydrate (stablyai#9343) skips worktree keys whose repo is not in getRepos. Retirement tests that rebuild mobile tabs from a persisted session now advertise the fixture repo as live so PR Checks merge stays green. * fix(editor): extract RichMarkdownEditor props to stay under max-lines Main's SSH external-image wiring (stablyai#10323) pushed RichMarkdownEditor.tsx over the 400-line tsx budget, failing PR Checks lint on every merge into main. Move the props type into a sibling module so the component stays under the limit without disabling max-lines. * Make durable review-head refs remote-identity scoped Embed remote name + URL hash into refs/orca/pull|merge-requests refs to prevent soft-keep from serving wrong project's PR/MR when FETCH_HEAD is clobbered by concurrent fetch. Fetch functions now return the written ref path (writer-authoritative) so callers rev-parse exactly what was fetched, not re-derive identity. Soft-keep only applies to transient errors (timeout, network); fails hard on missing refs, auth failures, and stale relay. Relay returns localRef so client avoids re-hashing (URL normalization can disagree). --------- Co-authored-by: Orca <[email protected]>
…ry tab (stablyai#10437) * fix(runtime): stop the headless hydration repo gate from dropping every tab stablyai#9343 gated headless mobile-session hydration on the live repo list, but read it as `this.store?.getRepos?.() ?? []`. A store that cannot report repos then yields an empty set, which reads as "every repo is gone" and skips every parseable session key — so no tabs hydrate at all. It also called getRepos on every hydrate, including the hot floating-tab poll path that is contractually free of repo/provider inventory work. Resolve the inventory lazily and only for keys that parse to a repoId, and keep `null` (unavailable) distinct from an empty list (all repos really gone). An absent list now fails open; a known list still prunes as stablyai#9343 intended. Fixes 3 tests that have been failing on main since stablyai#9343 landed: orca-runtime-terminal-retirement (2) and orca-runtime (1). * refactor(editor): extract the pending-focus effect to clear the max-lines cap stablyai#8083 pushed RichMarkdownEditor.tsx to 404 counted lines against the 400-line .tsx cap, failing lint for every PR that merges current main. The Explorer find-focus request is self-contained, so it moves to its own hook.
…tablyai#10443) stablyai#9343 broke two contracts at once and stablyai#10437 fixed both, but neither is asserted: stablyai#10429 repaired the failing tests by deleting the poll assertion and by handing the retirement store a live repo, so a revert would land silently. Restore `expect(getRepos).not.toHaveBeenCalled()` on the floating-tab poll, and add a hydrate case for a store that cannot report repos. Verified both fail against the pre-stablyai#10437 code: the poll assertion reports getRepos "called 2 times", and the hydrate case returns [] instead of the persisted tab.
Summary
Stops a deleted project from reappearing in the mobile/headless sidebar as a phantom "unknown" or duplicate workspace on boot.
ELI5: When you delete a project, some leftover bookkeeping could quietly bring it back the next time the app started up. This makes the app skip that stale leftover so the deleted project stays gone.
Root cause & fix:
hydrateHeadlessMobileSessionTabsFromWorkspaceSessionrebuilt session tabs by iterating everyworkspaceSession.tabsByWorktreeentry with no repo gate. Those keys (${repoId}::${path}) are not pruned when a repo disappears from the client's view (e.g. removed on another client, or a stale browser-persisted session), so a leftover key re-materialized a phantom workspace with no live repo behind it. The fix computesliveRepoIdsfromstore.getRepos()and early-continues on any entry whose parsedrepoIdis no longer live; unparseable keys (no::, wheresplitWorktreeIdForFilesystemreturnsnull) are left alone. This mirrors the pre-existinggetKnownWorkspaceSessionWorktreeIds()gate in the same file — same source of truth, established pattern.Scope: one file changed,
src/main/runtime/orca-runtime.ts(+10 lines). Pure fix, no trade-offs; the guard is a local, conservative early-continue.Original fix by @PannenetsF. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.
Screenshots
No visual change. This is a main-process hydration-logic change (
src/main/runtime/orca-runtime.ts); no renderer UI is touched.Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAuthor's reported validation (not the full
pnpmgates above):npx oxlint src/main/runtime/orca-runtime.tsexited 0 with no warnings.graph-sync-mobile-snapshot-gating.test.ts— 21 passedorca-runtime.test.ts -t "hydrate"— 22 passedgetRepos()-gate pattern rather than a new test.AI Review Report
I reviewed this diff directly. The change adds a repo-liveness guard inside the
tabsByWorktreeiteration loop:liveRepoIdsis built fromthis.store?.getRepos?.() ?? [](optional-chained, empty-array fallback — no crash if store/method is absent). Each entry'srepoIdcomes fromsplitWorktreeIdForFilesystem(entryWorktreeId)?.repoId. The guardif (ownerRepoId && !liveRepoIds.has(ownerRepoId)) continueonly skips entries whose repo is confirmed missing. I verified insrc/shared/worktree-id.tsthatsplitWorktreeIdForFilesystemreturnsnullfor keys without the::separator, soownerRepoIdisundefinedfor unparseable keys and the guard falls through — they hydrate as before. Consistent with the description.liveRepoIds, so all parseable entries would be skipped — acceptable, since with no live repos there is no legitimate workspace to hydrate. Folder-workspace UUID-suffixed IDs still parse to the correctrepoId(the suffix only affectsworktreePath), so those are gated by repo identity as intended.No fabricated results; the two test runs cited above are the author's, not re-run here.
Security Audit
Reviewed against the diff. No new input handling, command execution, path handling, authentication, secret, dependency, or IPC surface changes. The change reads existing in-memory repo IDs and filters an existing iteration; it is strictly more restrictive (it can only skip entries, never add or widen access). No security concerns.
Notes
🤖 Generated with Claude Code