Skip to content

Commit 53ab27b

Browse files
committed
fix(restore): recover inactive tabs after hydration failure
Continue restoring saved workspace state when the initial session-list request fails transiently. The direct saved-session hydration path can recover after reconnect, preserving selection, runtime markers, scroll position, and the original tab order instead of appending the unresolved workspace after the active tab. This behavior is shared by Electron and Tauri. Validated with the UI typecheck, production build, 65 restoration and reconciliation tests, and 13 instance runtime authority tests.
1 parent d30449b commit 53ab27b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/ui/src/lib/hooks/use-app-session-restore.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
} from "../../stores/sessions"
2828
import { messageStoreBus, type MessageScrollSnapshotSeed } from "../../stores/message-v2/bus"
2929
import { hydrateWorkspacePromptState } from "../../stores/app-session-prompt-hydration"
30+
import { waitForSettledPrerequisite } from "../trailing-resync"
3031
const log = getLogger("actions")
3132
const MESSAGE_SCROLL_SCOPE = "message-stream"
3233
const NO_SESSION_DRAFT_SESSION_ID = "__no_session_draft__"
@@ -153,7 +154,11 @@ async function restoreTabs(context: RestoreContext): Promise<void> {
153154
const created = creation?.reused === false
154155
if (created) createdId = id
155156
try {
156-
await runAbortable(() => waitForInstanceInitialSessionHydration(id), { signal: operationSignal })
157+
// A reconnect can recover the list; saved IDs still restore directly after an initial failure.
158+
await runAbortable(
159+
() => waitForSettledPrerequisite(waitForInstanceInitialSessionHydration(id)),
160+
{ signal: operationSignal },
161+
)
157162
const tabId = getInstanceAppTabId(id)
158163
const isCurrentBinding = () => capture.hasRestoredTabBinding(match.tabIndex, tabId)
159164
if (!isCurrentBinding()) return id

0 commit comments

Comments
 (0)