Files
workdsh/patches/[email protected]
T
JunkaiWang-TheoPhy 6c26c4e22a Preserve restart selection until the session baseline is authoritative
Desktop can project a persisted session before the first session.list baseline has arrived. Preserve that durable target only while the list phase is pending; once a successful baseline confirms it missing, clear the stale target and let the existing recent-workspace startup policy select its default.

The runtime fix ships as a Desktop-owned Yarn patch, with paired regressions for the temporary pre-baseline mask and a deleted session missing from an authoritative baseline.

Constraint: deepseek-harness submodule must remain unmodified; compatibility fixes ship through Desktop-owned patches

Rejected: Treat every absent selected id as pending | deleted or permanently invisible sessions would block startup forever

Rejected: Add an elapsed-time timeout | time does not establish session-list authority and would make restoration nondeterministic

Confidence: high

Scope-risk: narrow

Directive: Preserve a missing persisted selection only while session.list phase is pending; ready is the authority boundary for stale-selection cleanup

Tested: corepack yarn workspace dsh-plugin-desktop test tests/client-runtime-startup-restore.spec.ts; corepack yarn check; git diff --check

Not-tested: Packaged Windows GUI restart on a live machine
2026-08-25 00:03:53 +08:00

14 lines
925 B
Diff

diff --git a/lib/client.js b/lib/client.js
index ba3cb21f72..782a387b46 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -9266,7 +9266,7 @@ Set the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.
}
const persisted = this.selection.getSnapshot().sessionId;
if (current === void 0) {
- if (persisted !== void 0) this.selection.set({});
+ if (phase === "ready" && persisted !== void 0) this.selection.set({});
} else if (byId[current] !== void 0 && (persisted !== current || this.selection.getSnapshot().subagentAddress?.childSessionId !== currentAddress?.childSessionId || this.selection.getSnapshot().subagentAddress?.parentSessionId !== currentAddress?.parentSessionId || this.selection.getSnapshot().subagentAddress?.mode !== currentAddress?.mode)) this.selection.set({
sessionId: current,
...currentAddress === void 0 ? {} : { subagentAddress: currentAddress }