Repository navigation
[KS] API: window workspaces (#191) - #448
Merged
Merged
Conversation
sethwebster
force-pushed
the
seth/ks-191-workspaces
branch
from
October 13, 2026 04:41
860b99e to
308800b
Compare
createWindowWorkspaces saves a navigator's session and the connected displays as named workspaces in the app's data directory (versioned workspaces.json, validated on every read; a corrupt file rejects E_INVALID_DATA until clear()). restore() checks the saved session, closes the navigator's windows through their guards and reopens the workspace adapted to the displays connected now (exact, moved or scaled), and puts fullscreen windows back into fullscreen. An optional Window > Workspaces menu saves and restores with shortcuts. macOS only; Windows reports unsupported-platform (#445). Spaces and Stage Manager have no public API; the contract says what is and isn't possible.
…s, flows and goldens (#191)
- restoreSession releases parked pooled windows that hold saved IDs. - Restore skips closed windows, counts natively gone ones as closed, and reopens what it closed when it stops or fails (typed failed result). - Every operation re-reads the file; writes use compare and swap. - Load limits: file size, workspace and window counts, duplicate fullscreen IDs, negative savedAt. - Menu item IDs are per controller and per name; setMenuLabels relabels. - Displays without persistent IDs match by display ID. - A navigator instance close on a natively gone window ends it (E_CLOSED).
sethwebster
force-pushed
the
seth/ks-191-workspaces
branch
from
October 13, 2026 05:39
308800b to
2f0b0af
Compare
This was referenced Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #191
Window workspaces in
@legendapp/spark/windows: named window layouts built on navigator sessions (#188), saved in the app's data directory and restored onto the displays connected now.createWindowWorkspaces(navigator, { menu?, onError? }):list,save,restore,rename,delete,clear,subscribe,remove.getWindowWorkspaceAvailability().<getDirectory('data')>/workspaces.json,{ version: 1, workspaces }, written atomically. Every read checks the whole file. JSON that does not parse, an unknown version or a malformed entry rejectsE_INVALID_DATAwith the path, and the file is never overwritten untilclear().{ restored: false, reason, windowId }) and reopens the windows adapted to the current displays. Each window is placedexact(same display),moved(a display of the same size) orscaled(proportional within the work area). Windows saved in fullscreen enter fullscreen again.setMenuLabelsfor language changes.macos.spacesentry options apply again, and fullscreen windows get their own Spaces. The contract spells this out.unsupported-platform;createWindowWorkspacesrejectsE_UNSUPPORTED_PLATFORMbefore any native call ([KS][MW] Windows: window workspaces #445). There is no new native code: this uses the existing window, display, files and menu modules.multiwindow/workspaces(en + ar,titles: { ar }), checks MW-WORKSPACE-01…07, and flowsworkspaces-*.yaml(save/restore, relaunch, displays, menu, corrupt file, Windows unsupported, manual Spaces/Stage Manager/fullscreen). The screen is added to the multiwindow visual and accessibility flows.Review fixes
restoreSessionreleases a parked pooled window that holds a saved ID (failsE_ALREADY_EXISTSwithout it; test intests/windows-pool.test.ts, session and workspace).close()on a gone window now ends it withE_CLOSED). A veto or a failure after closing reopens what was closed (rolledBack); failures resolve{ restored: false, reason: "failed", error, rolledBack }.writeTextIfUnchanged(compare and swap; a missing file is created withcreateNew), retried, thenE_BUSY.savedAt.Verification (run in this session)
bun run typecheck: passes.bun run test(after rebasing on bc15fee): 1995 passed, 2 failed, both accepted:node-runtime(asdf shim) andmotion-nativeframes (display asleep).tests/windows-workspaces.test.ts14/14,tests/windows-pool.test.ts18/18.bun run e2e:validate/e2e:lint: 0 problems.ks-lock native … --backend driver):workspaces-save-restore,-relaunch,-displays,-menuand-corrupt: 5/5 passed.multiwindow/visual(4 matrix runs),accessibility/audit-multiwindow(4),infra/catalog-driver(4; catalog goldens unchanged) andinternationalization/native-strings(3): passed. The final run of the five workspace flows plus these was 20/20.native-stringsfailed for ar and fr while the menu overlaid Window (it replaced the localized title); it passes with the menu as its own menu.e2e/flows/multiwindowdirectory: the only failures are the flows that usefocusWindow(black-box only), as before.workspaces-manualandworkspaces-unsupported(Windows) were not run.⌃⌘Sgot no key equivalent in the driver's menu snapshot, so Save Workspace… uses⌥⌘S. Filed as [KS][MENU] Menu item shortcut ⌃⌘S silently has no key equivalent #446.Goldens (new)
multiwindow-workspaceslight/dark × en/ar.Follow-ups: #445 (Windows), #446 (menu shortcut silently dropped), #449 (location-targeted menus replace localized menu titles).