mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 00:03:52 +00:00
Reported from a 60-second manual test: reconnect an SSH workspace and the app drops to the home screen, a second tab running pnpm install is gone entirely, and one launched agent is listed twice. Three symptoms, one cause. The snapshot is applied as the whole truth for the reconnecting target. The tab merge iterates only the host's worktrees, then the result is spread over a gap where every local tab for that worktree has just been dropped — so a tab created locally whose upload has not landed has no branch that keeps it. Not a race: it cannot survive. Same for the pointers, where a snapshot that names no active worktree nulls activeWorktreeId and activeWorkspaceKey, which is the home screen while the user's terminals are still running. So the host is now authoritative for what it knows and not for what it has never been told. A local tab absent from the snapshot is kept, the worktree union is used so a snapshot with no entry for it at all cannot erase it, and a null active worktree only defers to local state when that workspace demonstrably still exists in the merged result. Two guards this change had to earn rather than assume. A null activeTabId is NOT missing information — it is a deliberate deselect that arms the duplicate-tab repair, and my first attempt defeated it and broke that test; it is honoured verbatim now. And preserving by tab id alone reintroduces the duplicate agent, because the host can carry the same session under a new tab id, so the preserve also checks the remote session id — the identity that survives a tab-id change. Testing, which is the part that failed here before. Eight tests fail on the unfixed code and pass on this one, at two levels: the merge decision table, and the real apply path driven through a store. The end-to-end version of the same scenario is deliberately NOT the guard and now says so in its header — measured against unfixed code it only reproduces about one run in three, because the destruction needs the tab created inside the debounced upload's suppression window and nothing external can force that. Its earlier green run is exactly why this shipped.