Expand description
Every window comes back after a quit, an upgrade’s included
(docs/specs/SPEC_UPGRADE_FOR_USERS_AND_AGENTS_2026_10_15.md §6.1).
The session record (session_restore, Client.meta["session:last_topology"])
held one workspace: the last window’s, saved by the close that emptied
Client.windowids. A quit closes the windows one by one and each close
deletes its workspace, so with several windows open only the last came back.
Now:
- a quit asks srv for the whole session before any window closes
(
SaveSessionSnapshotwithfor_quit, from the host’squit_app), and so does the OS-shutdown flush: one entry per window inwindows, the main window first, each the shapesnapshot_workspacemakes plus the window’s position and size underwindow; - the close that then empties
Client.windowidskeeps a quit’s record instead of replacing it with its own workspace (save_on_last_close); - restore rebuilds the first entry into the window being created, as
before, and every other entry into a workspace of its own, which the main
window then opens each where it was (
TakeRestoredWindows, then the host’sopen_restored_window).
Names come back too: each window’s own (window:displayname, under
window.name) and its workspace’s (name). The restore names each
workspace as it creates it.
So does each window’s appearance: its own theme and opacity
(window:theme, window:opacity, INHERITED_KEYS), under window.meta.
They live only on the Window row, and a quit deletes the row, so without
this every quit and relaunch put them back to the defaults
(RCA_UPGRADE_0_59_30_TO_0_59_34_ISSUES_2026_10_19.md §2). window:transparent
is not among them: it is a setting of the whole app, in settings.json.
A window’s name and appearance wait in the client’s meta
(session:restored_window_names, by workspace) for the window that opens
onto that workspace, which CreateWindow writes onto its row
(restored_window_meta), and is forgotten only once that is written
(forget_restored_window_meta). The value is the window’s meta patch;
the bare name an earlier version left still reads.
The record keeps the main window’s tabs at its top level too, the shape it
always had, so an older AgentMux reading it still restores that window. A
record without windows reads as one window.
Constants§
- NAMES_
META_ 🔒KEY - Restored windows’ names and appearance, by workspace, waiting for their windows. (Named for what it first held: a name.)
- NAME_
KEY 🔒 - The Window meta key of the name the user gave the window.
- OPENING_
META_ 🔒KEY - Restored workspaces the main window took (
TakeRestoredWindows) and is opening: kept for saves until a window shows each, so a save in between doesn’t drop one that opens slowly or not at all (#5358). - QUIT_
RECORD_ 🔒KEPT_ FOR_ MS - How long a quit’s record outranks the last close’s: a quit closes every window within seconds, and one that stalls longer than this was abandoned.
- RESTORE_
LIST_ 🔒KEYS - The client meta keys of the restored windows’ queues.
- WAITING_
META_ 🔒KEY - Restored workspaces waiting for the main window to open them.
Functions§
- forget_
restore_ 🔒lists - Forget the restored windows waiting to open, those opening, and their
names: they belong to the workspace that was open, which a switch closes
(
user_workspace_switch). - forget_
restored_ 🔒window_ meta ws_id’s window has its meta: forget it, once. Read, remove and write back in one transaction: restored windows open together, and two of these must not each write back the entry the other removed.- forget_
windows_ 🔒left_ by_ quit - At startup, before anything reads the windows: when the last run ended in
a quit that saved every window (the record is a quit’s), a window still
listed is one whose close didn’t reach srv before it stopped. The host
closes windows concurrently and srv can exit first; seen in a simulated
upgrade, where the second window’s row survived and the main window then
took it instead of restoring the session. The record holds that window, so
forget its row: the first window then restores every window as designed.
Its workspace stays when the record names it (the restore reopens it), and
goes with its tabs and panes when it doesn’t (a record an older build
wrote, which rebuilds it instead). Only the windows the quit saved (its
window_ids) are forgotten: a record left from an older quit never costs a later run its windows. Returns how many it forgot. - handle_
take_ 🔒restored_ windows window.TakeRestoredWindows: the workspaces a restore rebuilt beside the main window’s, each with its saved placement (workspaceid,x,y,width,height), for the main window to open. Handed out once; one whose workspace is gone since is left out.- has_
live_ 🔒window - Whether any live window has a workspace to capture.
- is_
recent_ 🔒quit_ record - Whether
recordis a quit’s, saved within the last two minutes: the closes of that quit are still arriving. - live_
windows 🔒 - The live full windows, the main one first, each with its workspace. Subwindows belong to their parent’s window; a window whose workspace is gone, or an id with no window row, is skipped.
- open_
workspace_ 🔒ids - The workspaces some open window shows, a subwindow’s included: a pane in one of them is on screen.
- patch_
of 🔒 - The meta patch a record entry’s
windowsection gives its restored window: the name, and the appearance that is a theme (a string) and an opacity (a number). Nothing else a record says reaches a row. - queue_
restored_ 🔒windows - Add restored workspaces for the main window to open beside it
(
entries: placement plusworkspaceid, asrestore_allqueues them) and their windows’ meta patches, keeping any already waiting. - restore_
all 🔒 - Restore every window in
record: the first that comes back is the one being created (returned, asrestore_last_sessionalways did); each other one gets a workspace of its own, published and left forhandle_take_restored_windows. A workspace record’s closed windows ("state": "closed") stay closed (session_closed::restore_closed), once a window came back. - restored_
window_ 🔒meta - The name and appearance a restored window had, as the meta patch for the
window now opening onto its workspace
ws_id(CreateWindow). It stays untilforget_restored_window_meta: a window whose meta couldn’t be written (srv stopped in between, a failed write) gets it on its next try. - restored_
window_ 🔒name - The name a restored window had, for the window now opening onto
ws_id. - restored_
window_ 🔒opened - A window now shows restored workspace
ws_id: saves take it from the live windows from here on. - reusable_
workspace 🔒 - The workspace a record entry names, when it is still there to reopen as it
was: the reducer and the store have it, it holds a pane, no window shows
it, and no earlier entry of this restore took it.
Nonemeans rebuild the entry from the record. - save_
on_ 🔒last_ close - The close that empties
Client.windowids, beforews_idis kept or deleted: saves that workspace as the session, with the closing window’snameandappearance(read before its row was pruned), unless this close is one of a quit’s that already saved every window. - saved_
appearance 🔒 - The appearance a session record keeps for window
w: its own theme and opacity, or those a restore still holds for it, whose write to the window failed (the next save keeps them, as it keeps a name). - saved_
name 🔒 - The name window
wgoes by in a session record: the user’s, or one a restore still holds for it, whose write to the window failed: the next save keeps it, so the restore after names it. - set_
client_ 🔒meta - Set (or, with
None, remove) one of the client’s meta keys. - snapshot_
session 🔒 - The whole session: every live window’s workspace and placement, the main
window’s tabs also at the top level.
Nonewhen no window has anything to capture.for_quitmarks it as a quit’s, which the closes that follow keep. - waiting_
patch 🔒 - What waits for one workspace, as a patch: an object of meta, or the bare name an earlier version left.
- waiting_
windows 🔒 - The restored windows still waiting for the main window to open them
(
restore_all), as record entries: their workspaces exist, but no window shows them yet, so a snapshot of the live windows alone would drop them (#5358). - waiting_
workspaces 🔒 - The contents of the restored windows still waiting for the main window to open them.
- window_
name 🔒 - The name the user gave window
w, if any. - windows_
of 🔒 - The windows a record holds: its
windows, or the record itself for one saved before records held several.