fix: preserve sessions and restore native window interactions - #336
Conversation
There was a problem hiding this comment.
This PR adds session preservation across window closes and app restarts, with a startup handoff mechanism to wait for previous instances. The changes are largely sound, but one data-loss path exists: resumeStartupSessionAfterHandoff ignores the return value of saveSessionSnapshot, which could silently lose session state if the write fails. No other P0 or P1 issues are visible in the supplied diff.
Review coverage: 500/3806 diff lines supplied. Partial input (truncated: diff, standards). Inline comments are limited to fully visible, valid right-side hunks. Reviewed commit: d1c8d3a9479e6992f08542eecbc204754917c37b.
| guard !isTerminatingApp else { return } | ||
| prepareStartupSessionSnapshotIfNeeded() | ||
| let primary = mainWindowContexts.values.first(where: { $0.windowId == startupHandoffPrimaryWindowId }) | ||
| ?? mainWindowContexts.values.first |
There was a problem hiding this comment.
Ignoring the return value of saveSessionSnapshot discards a potential write failure. If the save fails, session state will be lost on next quit without any user notification. This is a data-loss path per the code review standards.
Closing a window now keeps its workspaces and live terminal sessions available from the Dock or New Window. Autosave acknowledges completed disk writes, retries failures, and cancels quit when sessions cannot be saved. Replacement instances wait for the prior process to exit before restoring or writing snapshots.
Validation on
d1c8d3a9479e6992f08542eecbc204754917c37b: PR CI, macOS 15/26 compatibility, both close/reopen UI tests, and the native window-drag UI test all pass. Tagged builds and 156 focused unit tests pass with no failures or skips. Full CI retains three existing headless first-responder test skips; main-only lag/UI jobs are conditionally skipped on the PR. No measured CPU or memory delta is claimed.The close-window tests intentionally change from destructive-close confirmation to preserving the same shell PID and shell-local state after reopening.