Repository navigation
Prevent deleted workspace browser snapshot resurrection - #17779
Conversation
Greptile SummaryThe PR adds main-process deletion fencing, propagates workspace incarnation identity through renderer snapshots, and routes folder-workspace deletion through runtime teardown.
Confidence Score: 3/5The PR is not yet safe to merge because valid recreated or host-colliding workspaces can lose all published mobile browser and session state. The new legacy epoch fence rejects a valid same-renderer successor after recreation, while the cross-host ambiguity guard permanently skips snapshots whenever local and remote rows share a bare locator. Files Needing Attention: src/main/runtime/orca-runtime-sync-mobile-session-tabs.ts; src/renderer/src/runtime/sync-runtime-graph.ts
|
| Filename | Overview |
|---|---|
| src/main/runtime/orca-runtime-sync-mobile-session-tabs.ts | Adds instance and epoch-based deletion fencing, but rejects valid identity-less same-generation recreation snapshots. |
| src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts | Records removal identity and epoch state and clears cached browser/mobile session state at the deletion boundary. |
| src/renderer/src/runtime/sync-runtime-graph.ts | Publishes incarnation identity and invalidates snapshot caching on identity changes, but suppresses all snapshots for same-ID cross-host collisions. |
| src/main/runtime/runtime-project-group-controller.ts | Routes folder-workspace deletion through PTY teardown and runtime-owned state cleanup before catalog removal. |
| src/renderer/src/store/folder-workspaces/folder-workspace-mutations.ts | Adds host-qualified deletion routing and browser guest teardown before purging the final renderer workspace state. |
| src/shared/runtime-session-contracts.ts | Extends the renderer snapshot contract with optional worktree incarnation identity for compatibility with older clients. |
Sequence Diagram
sequenceDiagram
participant UI as Renderer
participant Main as Main Runtime
participant Store as Workspace Store
participant Mobile as Mobile Client
UI->>Main: Delete workspace
Main->>Store: Read occupant metadata
Main->>Main: Record instance/epoch fence
Main->>Store: Remove workspace state
UI->>Main: Publish later graph snapshot
Main->>Main: Compare instance or renderer epoch
alt Snapshot admitted
Main->>Mobile: Publish recreated workspace state
else Snapshot rejected
Main-->>UI: Request resync when applicable
end
Reviews (11): Last reviewed commit: "fix: avoid publishing ambiguous worktree..." | Re-trigger Greptile
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change adds optional worktree instance identities to mobile-session snapshots. The renderer creates new snapshot versions when a worktree identity changes. The main runtime records removal fences, cancels queued updates, rejects stale snapshots, and accepts valid snapshots after recreation. Folder deletion shuts down worktree browsers after state reconciliation. Tests cover tombstones, stale identities, recreated worktrees, PTY rescue prevention, and publication-epoch gating. Merge Risk: 🟡 Moderate · up to Deleted workspace browser state can still be restored through one mobile-session recovery path, so the PR is not fully merge-ready until that path is fenced. The removal tracking state also grows for the lifetime of the runtime and needs an explicit bound or cleanup strategy. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the change, motivation, evidence, and tests, but it omits several template requirements. It has no Linked Issue, Visual Proof or N/A statement, AI Disclosure, Review, Agent skill upstream boundary, Notes, or Checklist sections. Resolution Add the missing template sections. Provide a linked issue after Full details: Docstring CoverageExplanation Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files. (2 skipped: 2 too large.) ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: e4a91483-e9ad-475d-9cd1-4801c9176194
📥 Commits
Reviewing files that changed from the base of the PR and between 406bd0e and 68b32b819f04a622c1b1c73b4ce14707b5c4055f.
📒 Files selected for processing (5)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/renderer/src/runtime/sync-runtime-graph-workspace-publication.test.tssrc/renderer/src/runtime/sync-runtime-graph.tssrc/shared/runtime-session-contracts.ts
Files not reviewed due to moderation or processing errors (1)
- src/main/runtime/orca-runtime.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| private readonly removedMobileSessionWorktreeIds = new Map< | ||
| string, | ||
| { | ||
| removedInstanceId?: string | ||
| removedPublicationEpoch?: string | ||
| acceptedPublicationEpoch?: string | ||
| blockedPublicationEpochs: Set<string> | ||
| } | ||
| >() |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Bound or evict entries in removedMobileSessionWorktreeIds.
removedMobileSessionWorktreeIds gets a new entry on every worktree removal (removeWorktreeMetadataAndHistory, line 29534), but no code path ever calls .delete() on this map. Search the file: .get, .has, and .set are the only operations against it.
For a long-running runtime (headless orca serve, or a desktop session left open for days), repeated create/delete cycles on differently-named worktrees (the documented agent/automation workflow this PR targets) accumulate one entry per distinct worktree ID forever. Each entry also owns a blockedPublicationEpochs Set that keeps growing for a given worktree ID across repeated recreate cycles at the same path, since legacy-epoch entries are also never pruned.
The codebase already has precedent for bounding equivalent long-lived state, for example MAX_TRACKED_PTY_LIVENESS_VERDICTS combined with pruneDisconnectedPtyRecords. Apply the same pattern here: cap the map size with LRU eviction, or clear the fence once a snapshot with a matching current instanceId has been durably accepted (at that point the recreation race window has closed and the guard has served its purpose).
♻️ Sketch of a bounded fix
+ private static readonly MAX_TRACKED_REMOVED_MOBILE_SESSION_WORKTREES = 256
+
private readonly removedMobileSessionWorktreeIds = new Map<
string,
{
removedInstanceId?: string
removedPublicationEpoch?: string
acceptedPublicationEpoch?: string
blockedPublicationEpochs: Set<string>
}
>()And, once a snapshot's worktreeInstanceId matches the current metadata's instanceId and is accepted, remove the fence for that worktree id (or evict the oldest entry once the map exceeds a cap), mirroring pruneDisconnectedPtyRecords.
Also applies to: 29532-29540
68b32b8 to
a4bca50
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Deletion-boundary fence (main) —
removeWorktreeMetadataAndHistorynow records the removed worktree'sinstanceIdand publication epoch intoremovedMobileSessionWorktreeIds, deletes the stored snapshot, cancels any queued coalesced notification, and emits the removal tombstone immediately instead of waiting for a later graph prune to do it. - Snapshot acceptance gate (main) —
syncMobileSessionTabsfilters incoming snapshots against the fence: frames carrying the removed occupant'sworktreeInstanceId(or a mismatched current instance id) are dropped, and legacy frames without an identity are gated by publication epoch. Removed worktrees are also excluded from hydration and resync. - Renderer identity publication —
buildMobileSessionTabSnapshotsnow carries each worktree'sinstanceId, includes it in the snapshot-reuse comparison, and re-publishes an identity-only snapshot with a fresh version when tab content is unchanged but the instance changed. - Contract + tests —
RuntimeMobileSessionTabsSnapshotgains an optionalworktreeInstanceId(a new optional field, wire-safe), plus three main-process tests and one renderer test covering the resurrection, recreation, and legacy-epoch paths.
The new tests are meaningful — each would fail against the pre-PR behavior (verified by running the focused suites: renderer publication suite 5/5, and the three new orca-runtime cases in isolation).
ℹ️ Fence map grows without eviction
removedMobileSessionWorktreeIds is keyed by worktree id and entries are never removed, so a long-lived serve process that creates and deletes many worktrees accumulates entries indefinitely. The legacy path's blockedPublicationEpochs set also only grows (each newly accepted epoch pushes the previous one into the blocked set). Each entry is small and the fence is deliberately persistent — a delayed frame from the removed occupant must keep being blocked even after a recreation is accepted — so this is informational rather than a bug, but it may be worth a future eviction strategy for long-running hosts.
ℹ️ Legacy (pre-identity) renderers stay fenced across same-epoch recreation
For renderers that omit worktreeInstanceId, fencing keys on the per-renderer-session publicationEpoch. Since that epoch does not change when a worktree is recreated at the same path without a renderer restart, a recreated worktree's frames from such a renderer stay fenced until the epoch rotates. This only affects pre-PR renderers in mixed-version deployments, and it errs on the safe side (no resurrection), matching the code comment "same-epoch frames are ambiguous and stay fenced."
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No blocking issues — one minor perf note on the follow-up commit, anchored inline.
Reviewed changes (delta since the prior pullfrog review at 68b32b8)
- Renderer instance-id lookup moved to a local helper — the
@/store/selectorsimport was dropped in favor ofgetWorktreeInstanceIdFromState, a manual linear scan overstate.worktreesByRepo, avoiding a store ↔ runtime import cycle.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta since the prior pullfrog review at a4bca50)
- Cached worktree identity lookup —
getWorktreeInstanceIdFromStatenow resolves the worktree throughgetIndexedWorktreesByIdfrom@/store/worktree-repo-index, replacing the per-syncO(worktrees × repo rows)scan with the module's WeakMap-cached index. The leaf-module import avoids the store ↔ runtime cycle that motivated the earlier@/store/selectorsswap, and the.find(w => w.instanceId !== undefined)?.instanceIdfallback preserves the multi-row semantics the index documents.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 4abfeefe-f101-4fc6-b5f4-680eae0bf751
📒 Files selected for processing (4)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/renderer/src/store/folder-workspaces/folder-workspace-mutations.tssrc/renderer/src/store/slices/folder-workspace-owner-routed-mutations.test.ts
Files not reviewed due to moderation or processing errors (1)
- src/main/runtime/orca-runtime.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta since the prior pullfrog review at 59fd0fe)
- Fenced the paired-PTY rescue path —
restoreLivePairedRendererSessionOwnedMobileTerminalsnow skips a worktree when the graph-sync rescue (missingSnapshotOnly) hits a removal tombstone with no current worktree metadata, closing the remaining resurrection vector where a still-connected renderer-owned PTY could repopulate a deleted worktree's mobile-session entry. - Regression test — a new
orca-runtime.test.tscase registers a connected paired PTY, marks it renderer-owned, removes the worktree, then runs a graph sync and asserts the worktree is not repopulated.
The new test is meaningful: without the guard the syncWindowGraph path would re-insert the deleted worktree via the paired PTY, so it fails against the pre-fix behavior. The guard is correctly scoped to missingSnapshotOnly (the graph-sync resume), leaving the explicit listMobileSessionTabs / collectAllMobileSessionTabs restore calls unaffected for worktrees that still have metadata.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta since the prior pullfrog review at 3df7285)
- Fenced pre-publication deletion —
removeWorktreeMetadataAndHistorynow falls back tothis.rendererGenerationwhen computingremovedPublicationEpoch, so a worktree deleted before any snapshot was ever published still fences an identity-less legacy snapshot that arrives afterward. - Folder workspace browser teardown —
deleteFolderWorkspacenow awaitsshutdownWorktreeBrowsers(folderWorkspaceKey(id))beforepurgeWorktreeTerminalState, matching the worktree teardown ordering (Chromium guests unregister before terminal state is purged). The call is correctly scoped to the no-sibling-row branch.
Both new tests are meaningful: the pre-publication case would previously accept the recreated worktree's first identity-less snapshot, and the folder-deletion cases assert shutdownWorktreeBrowsers fires on full removal but not when a colliding sibling-host row keeps the ID alive.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No blocking issues — one minor note on duplicate repo-change notifications inline.
Reviewed changes (delta since the prior pullfrog review at 6a04877)
- Folder deletion routed through runtime cleanup — the local
folderWorkspaces:deleteIPC handler now callsruntime.deleteFolderWorkspace(fencing the deleted folder key, tearing down headless and client-hosted browser pages, and emitting the removal tombstone) instead of mutating the store directly, withregisterRepoHandlers/registerFolderWorkspaceHandlersthreading the runtime through. - Owner host preserved in delete intents — the sidebar quick action and context-menu delete intent now carry the row's
executionHostIdintodeleteFolderWorkspace, and both only clear the active worktree when the deleted row's host matches the active host. - Tests — a new runtime case asserts the folder path closes client-hosted pages, emits the tombstone, and fences the key; a new intent test asserts
executionHostIdis preserved.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
dae08d5 to
e1845ed
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta since the prior pullfrog review at 5e01a54)
- Folder PTY sweep on runtime deletion —
deleteFolderWorkspacenow sweeps the folder's PTYs viakillAllProcessesForWorktreebefore removing metadata, resolving the SSH provider throughconnectionIdand falling back to the runtime-local provider, mirroring the existingremoveFolderWorkspaceteardown. - Stale legacy-epoch fence —
syncMobileSessionTabsaccepts arendererGenerationand drops identity-less snapshots whosepublicationEpochno longer matches the current renderer generation, closing the hole where an unseen epoch from a superseded renderer could repopulate a removed worktree. - Paired-PTY rescue fence widened to inventory — the deletion-tombstone fence in
restoreLivePairedRendererSessionOwnedMobileTerminalsno longer applies only to graph sync (missingSnapshotOnly);listAllMobileSessionTabscan no longer repopulate a removed worktree either. - Prior feedback addressed — the local
folderWorkspaces:deletehandler now notifies only in the no-runtimefallback (if (deleted && !runtime)), so a local folder deletion no longer double-notifies the renderer and remote clients.
All three touched tests are meaningful and pass in isolation (sweeps folder PTYs…, rejects an unseen legacy epoch…, does not rescue a paired PTY… or inventory).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| function getWorktreeInstanceIdFromState(state: AppState, worktreeId: string): string | undefined { | ||
| return getIndexedWorktreesById(state.worktreesByRepo ?? {}, worktreeId).find( | ||
| (worktree) => worktree.instanceId !== undefined | ||
| )?.instanceId |
There was a problem hiding this comment.
When local and SSH workspaces share a path-derived worktree ID but have different instance IDs, this lookup publishes the first indexed instance without checking host ownership. The main deletion fence then rejects the recreated workspace's valid browser snapshot as an identity mismatch, leaving its browser tabs and pages absent.
Knowledge Base Used: Workspace and worktree lifecycle
There was a problem hiding this comment.
Important
The rebase onto the modular runtime refactor restored the production fences but dropped this PR's main-process regression tests. The fence behavior is now entirely untested, and the PR body's test claims are stale.
Reviewed changes (delta since the prior pullfrog review at dae08d5)
- Rebased onto the modular runtime refactor — the monolithic
orca-runtime.ts/orca-runtime.test.tswere split into per-concern mixins andorca-runtime-tests/*.spec.ts. - Deletion fences restored in the new structure — the fence map moved to
orca-runtime-runtime-id.ts, the accept gate plusrendererGenerationepoch fence toorca-runtime-sync-mobile-session-tabs.ts, the removal fence + browser teardown toorca-runtime-resolve-worktree-removal-target.ts, the paired-PTY rescue fence toorca-runtime-restore-live-paired-renderer-session-owned-mobile-terminals.ts, and folder deletion toRuntimeProjectGroupController.deleteFolderWorkspace(PTY teardown viateardownFolderWorkspacePtys, thencleanupRemovedFolderWorkspaceState→removeWorktreeMetadataAndHistory).
⚠️ Main-process regression tests dropped in the rebase
Every main-process test this PR added in earlier revisions is gone. The production fences were re-applied correctly, but nothing in the tree verifies them anymore.
Technical details
# Main-process fence tests lost during the modular refactor rebase
## Affected sites
- `git diff main...HEAD` lists 18 files and no main-process test file; the three remaining test files are all renderer-side (`worktree-context-menu-delete-intent.test.ts`, `sync-runtime-graph-workspace-publication.test.ts`, `folder-workspace-owner-routed-mutations.test.ts`).
- No `removedMobileSessionWorktreeIds` / `blockedPublicationEpochs` / `removedPublicationEpoch` / `acceptedPublicationEpoch` / `removedInstanceId` reference exists in any `*.spec.ts` — they appear only in the four production mixin files.
- The previously-added cases are all absent: folder deletion tombstone + PTY sweep + client-hosted browser close, `does not republish a removed worktree's client tabs to a same-id recreate`, `ignores a renderer graph that arrives after worktree removal`, `accepts an identity-less recreated snapshot only after a renderer epoch changes`, `fences an identity-less snapshot when deletion precedes the first publication`, `rejects an unseen legacy epoch from a different renderer generation`, and `does not rescue a paired PTY … during graph sync or inventory`.
## Required outcome
- Re-add these regression tests into the new `orca-runtime-tests/` layout (the natural homes are `worktree-removal-and-reconciliation*.spec.ts` and `mobile-session-tabs*.spec.ts`) so the accept gate, the `rendererGeneration` epoch fence, the paired-PTY rescue fence, and the folder-deletion fence/tombstone/PTY-sweep are each exercised.
- Update the PR body's "Tests" section, which still cites `orca-runtime.test.ts (1223 passed)` and the focused suites from the pre-rebase tree.
## Suggested approach (optional)
- The production mixins carry `@ts-nocheck -- mechanically split` headers; the restored fences in `orca-runtime-sync-mobile-session-tabs.ts`, `orca-runtime-resolve-worktree-removal-target.ts`, and `runtime-project-group-controller.ts` are the ground truth to mirror into tests.DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| if (fence.blockedPublicationEpochs.has(snapshot.publicationEpoch)) { | ||
| blockedRecreatedWorktreeIds.add(snapshot.worktree) | ||
| return false | ||
| } |
There was a problem hiding this comment.
Same-generation recreation stays blocked
When an identity-less client deletes and recreates a workspace during one renderer generation, deletion blocks the renderer's publication epoch and the recreated workspace reuses that same epoch. This check therefore rejects every valid successor snapshot until the renderer reloads, leaving the recreated workspace's browser tabs and pages absent.
Knowledge Base Used:
| if (getIndexedWorktreesById(state.worktreesByRepo ?? {}, worktreeId).length > 1) { | ||
| mobileSessionSnapshotCacheByWorktree.delete(worktreeId) | ||
| continue | ||
| } |
There was a problem hiding this comment.
Host collisions suppress valid snapshots
When local and SSH workspaces share a path-derived worktree ID, this branch removes the cached snapshot and skips the worktree on every publication instead of selecting its owning host. Mobile clients consequently receive no terminal, editor, or browser state for the affected workspace while both host rows exist.
Knowledge Base Used: Workspace and worktree lifecycle
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta since the prior pullfrog review at e1845ed)
- Fail-closed renderer guard for ambiguous worktree ids —
buildMobileSessionTabSnapshotsnow skips any worktree id with more than one indexed row ingetIndexedWorktreesById, refusing to publish a snapshot when local and remote hosts share the same id rather than attaching the wrong host'sworktreeInstanceId. The guard is precise: folder workspace keys and single-row worktrees pass through unchanged. - Re-added main-process accept-gate test —
graph-sync-mobile-snapshot-gating.test.tsnow coversrejects a delayed renderer snapshot from the deleted occupant after recreation, exercising theremovedInstanceIdfence insyncMobileSessionTabs. - Renderer ambiguity test —
does not publish an ambiguous worktree id across hostslocks in the new guard.
Both new tests pass in isolation, and the fail-closed guard is scoped to genuinely duplicated (multi-host) rows — single-row and folder-workspace publications are unaffected.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
f208090 to
3ae73b3
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta since the prior pullfrog review at f208090b)
- Paired-PTY fence at the deletion boundary —
removeWorktreeMetadataAndHistorynow drops anypairedRendererSessionOwnedPtyIdsentry whose PTY belongs to the removed worktree (scoped to the!preservesSameIdOwnerbranch), so a still-connected renderer-owned PTY that outlives the delete acknowledgement can no longer be rescued throughrestoreLivePairedRendererSessionOwnedMobileTerminalsinto a recreated occupant of the same path-derived id. This closes the gap the earlierremovedMobileSessionWorktreeIdsfence left open, since that fence only fires when worktree metadata is absent, not when it has been recreated. - Regression test — a new
browser-capabilities.spec.tscase registers a paired PTY, marks it renderer-owned, removes the worktree, and asserts the PTY is dropped from ownership tracking, which fails against the pre-fix behavior.
The guard is precise: identity matching uses the same runtimeWorktreeIdsEqual path-identity comparator as the rescue path, and the cleanup is gated identically to the existing tombstone so a same-id owner on another host (preservesSameIdOwner) is not torn down.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
- Folder-group delete no longer fails on a mixed-host group: an ambiguous connection skips the PTY sweep instead of rejecting the delete. - Share one folder-workspace PTY teardown helper between the runtime removal path and the project-group controller. - Simplify the mobile snapshot fence: identity-carrying frames are judged against the live catalog instanceId and clear the fence once the successor is accepted; identity-less frames are fenced by renderer generation. Drops the unbounded epoch bookkeeping. - A fenced frame no longer triggers a resync request on every sync while the renderer still lists it as unchanged. - Cross-host id collisions publish without an instanceId rather than blanking the mobile session for that workspace. - Folder delete IPC always routes through the runtime; the store-only fallback and double notify are gone. - Drop the redundant rescue-path tombstone check; ownership is purged at removal. - Fence tests drive removeWorktreeMetadataAndHistory + syncWindowGraph instead of seeding the fence map, and add accept-after-recreate, no-resync, and ambiguous-host folder delete cases.
…e-browser-cleanup-audit
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta since the prior pullfrog review at 8afc766)
- Simplified the deletion fence —
removedMobileSessionWorktreeIdsdropped theremovedInstanceIdmemory and theacceptedPublicationEpoch/blockedPublicationEpochsepoch machinery in favor of{ removedPublicationEpoch?, rejectedPublication? }. The accept gate now rejects any identity-carrying frame whoseworktreeInstanceIdmismatches the live catalog row'sinstanceId, and clears the fence on the first matching successor frame. This is sound because recreation always mints a freshinstanceId(randomUUID()), so "mismatch against live meta" is exactly "not the current occupant" — no removed-id memory needed. - Anti-resync-spiral flag — a rejected frame sets
rejectedPublication, which suppresses resync requests for a worktree the renderer still lists as unchanged, so a fenced frame no longer ping-pongs a republish → reject loop. - Ambiguous cross-host ids publish identity-less instead of blanking —
resolveWorktreeInstanceIdreturnsundefinedwhengetIndexedWorktreesByIdhas more than one row, andbuildMobileSessionTabSnapshotsno longer skips those worktrees. This is a deliberate reversal of the earlier fail-closed guard: main's generation fence still gates identity-less frames, so resurrection safety is unchanged while the session is no longer blanked for the STA-4343 multi-host case. - Folder-delete teardown hardened —
teardownFolderWorkspacePtyswas extracted tofolder-workspace-pty-teardown.ts;RuntimeProjectGroupController.deleteFolderWorkspacenow catches thefolder_workspace_connection_ambiguousthrow (skips only the PTY sweep, still deletes); andregisterRepoHandlers/registerFolderWorkspaceHandlersmakeruntimerequired, so the delete handler drops the deadstore.removeFolderWorkspacefallback and always routes through runtime. - Regression tests restored — new
graph-sync-deletion-fence.test.ts(5 cases) andruntime-project-group-controller-folder-delete.test.ts(2 cases) cover the accept gate, fence clearing, legacy-epoch fencing, resync suppression, and folder teardown ordering. All pass in isolation.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
* Prevent deleted workspace browser snapshot resurrection * fix: tear down folder workspace browser tabs * fix: fence pre-publication browser snapshots * fix: route folder deletion through runtime cleanup * chore: retrigger CI * fix: sweep folder PTYs on runtime deletion * fix: restore deletion fences after runtime refactor * test: cover deleted renderer snapshot after recreation * fix: avoid publishing ambiguous worktree snapshots * fix: preserve optional worktree index state * fix: fence paired PTYs on worktree removal * fix: harden deletion fence and folder-delete teardown - Folder-group delete no longer fails on a mixed-host group: an ambiguous connection skips the PTY sweep instead of rejecting the delete. - Share one folder-workspace PTY teardown helper between the runtime removal path and the project-group controller. - Simplify the mobile snapshot fence: identity-carrying frames are judged against the live catalog instanceId and clear the fence once the successor is accepted; identity-less frames are fenced by renderer generation. Drops the unbounded epoch bookkeeping. - A fenced frame no longer triggers a resync request on every sync while the renderer still lists it as unchanged. - Cross-host id collisions publish without an instanceId rather than blanking the mobile session for that workspace. - Folder delete IPC always routes through the runtime; the store-only fallback and double notify are gone. - Drop the redundant rescue-path tombstone check; ownership is purged at removal. - Fence tests drive removeWorktreeMetadataAndHistory + syncWindowGraph instead of seeding the fence map, and add accept-after-recreate, no-resync, and ambiguous-host folder delete cases. Mirror-Of: bed9734
* Prevent deleted workspace browser snapshot resurrection * fix: tear down folder workspace browser tabs * fix: fence pre-publication browser snapshots * fix: route folder deletion through runtime cleanup * chore: retrigger CI * fix: sweep folder PTYs on runtime deletion * fix: restore deletion fences after runtime refactor * test: cover deleted renderer snapshot after recreation * fix: avoid publishing ambiguous worktree snapshots * fix: preserve optional worktree index state * fix: fence paired PTYs on worktree removal * fix: harden deletion fence and folder-delete teardown - Folder-group delete no longer fails on a mixed-host group: an ambiguous connection skips the PTY sweep instead of rejecting the delete. - Share one folder-workspace PTY teardown helper between the runtime removal path and the project-group controller. - Simplify the mobile snapshot fence: identity-carrying frames are judged against the live catalog instanceId and clear the fence once the successor is accepted; identity-less frames are fenced by renderer generation. Drops the unbounded epoch bookkeeping. - A fenced frame no longer triggers a resync request on every sync while the renderer still lists it as unchanged. - Cross-host id collisions publish without an instanceId rather than blanking the mobile session for that workspace. - Folder delete IPC always routes through the runtime; the store-only fallback and double notify are gone. - Drop the redundant rescue-path tombstone check; ownership is purged at removal. - Fence tests drive removeWorktreeMetadataAndHistory + syncWindowGraph instead of seeding the fence map, and add accept-after-recreate, no-resync, and ambiguous-host folder delete cases.

Summary
Evidence
Current
origin/mainreproduced a red oracle: after renderer teardown, a late host graph snapshot recreated the deleted worktree's browser rows/pages. Real Electron right-click deletion also confirmed browser teardown itself is ordered and clean; a separate successor sleeping-workspace terminal wake remains tracked by open PR #14705 and is out of scope.Tests
pnpm test src/main/runtime/orca-runtime.test.ts(1223 passed, 1 skipped)pnpm tcpnpm run check:code-quality:changedgit diff --checkNo issues/comments were created, and nothing was merged or deployed.