Expand description
Closed windows: closing a window keeps it in the open workspace
(docs/specs/SPEC_WORKSPACES_2026_10_23.md §2, §5; closing is not
deleting, SPEC_OFFLINE_RESILIENCE_2026_10_20.md G8).
A window’s close stops what runs in its contents (its shells, the ordinary
graceful close) and keeps them: its tabs, its panes with their ids and meta,
and their layout. Its agents keep running (agents:always_available): their
blocks are parked, and a reopen puts them back in their tabs. The window is then a closed window of
the workspace, listed in the client’s meta (workspace:closed_windows,
newest first) with when it closed, where it was, its name and appearance.
- The workspace record keeps each one as a
"state": "closed"entry (with_closed). A cold start keeps it closed (restore_closed): its contents are reused when they are still here and rebuilt from the entry when not, and no window opens for it. - The status bar panel lists them (
ListClosedWindows), reopens one where it was (TakeClosedWindow) and deletes one (DeleteClosedWindow). An open window is deleted by marking its close (DiscardWorkspaceOnClose), which then deletes its contents instead of keeping them.
They stay until the user deletes them: no cap. Not listed: the close that
ends the session (the last window’s, or one of a quit’s), whose window
stays open in the workspace and reopens at the next launch; a workspace
switch’s closes (user_workspace_switch), whose windows stay open in the
workspace they leave and open again with it; and a window
with nothing of the user’s in it (no pane, or only the untouched default
layout), whose contents are deleted at its close.
Constants§
- CLOSED_
META_ 🔒KEY - The open workspace’s closed windows, newest first:
{workspaceid, closed_at_ms, window}. - DISCARD_
FOR 🔒 - How long a delete waits for its window’s close to reach srv. A close that never comes (the window stayed open) must not make a later, ordinary close delete the window’s contents.
- STATE_
CLOSED 🔒 - A workspace record entry’s
state: closed, kept to reopen. - STATE_
OPEN 🔒 - A workspace record entry’s
state: shown now, or reopened at the next launch.
Statics§
- DISCARD 🔒
Functions§
- agent_
of 🔒 - The agent running in block
block_id: its name, and whether it is mid-turn.Nonefor a block that is not an agent’s, or has no controller. - agents_
in 🔒 - The agents running in window contents
ws_id, each{block_id, name, working}(working: mid-turn). - client 🔒
- closed_
at 🔒 - closed_
entries 🔒 - The closed windows as workspace record entries, newest first: each one’s
contents (
snapshot_workspace), where its window was (window), itsworkspaceid,"state": "closed"andclosed_at_ms. One whose contents are gone or shown by a window is left out. - entries 🔒
- forget 🔒
ws_idis open again, or deleted: drop it from the list. Returns its entry.- handle_
delete_ 🔒closed_ window window.DeleteClosedWindow(workspaceId): remove a closed window from the workspace without reopening it. Its contents are deleted; its agents stay in My Agents.- handle_
discard_ 🔒workspace_ on_ close window.DiscardWorkspaceOnClose(windowId): remove an open window from the workspace. Its close, which the window starts next, deletes its contents instead of keeping them. The only open window can’t be removed.- handle_
list_ 🔒closed_ windows window.ListClosedWindows: the open workspace’s closed windows, newest first, each{workspaceid, closed_at_ms, name, tabs, panes, agents, running}for the status bar panel (running: its agents that keep running, parked). One whose contents are gone or shown again is left out.- handle_
take_ 🔒closed_ window window.TakeClosedWindow(workspaceId): reopen a closed window. Waits for its close to finish, puts its parked agents back in their tabs and returns where it was ({workspaceid, x, y, width, height}) for the host to open it there; its name and appearance wait for that window (CreateWindow). It stays listed until that window registers, so a window that fails to open can be reopened again and is still saved (#5359). Errors when it isn’t a closed window any more.- handle_
window_ 🔒agents window.WindowAgents(windowId): the agents running in the window, each{block_id, name, working}(working: mid-turn), for the close warning and the panel’s delete.- is_
closed 🔒 - Whether a workspace record entry is a closed window’s.
- keep_
workspace 🔒 - A window onto
ws_idclosed, and no other window shows it (window: where it was). Stop what runs in it and keep its contents, listed as a closed window unlessunlisted, or a quit is closing every window: then the window stays open in its workspace’s record and opens again with it. A listed window’s agents are not stopped but parked (agents:always_available), and its record names them, so a reopen puts them back.unlistedis the close that ends the session (it emptiedClient.windowids) and a workspace switch’s closes. Contents with nothing of the user’s in them are deleted instead. - mark_
discard 🔒 - Delete an open window: the next close of
window_iddeletes its contents. - mark_
parked_ 🔒in_ record - Name the agent blocks a switch parked on the window entry for
ws_idin the saved record of user workspacerow_id, so that opening the workspace again reattaches them (restore_all). The record was saved before the close parked them; nothing else rewrites it until the workspace is open again. - open_
window_ 🔒count - How many full windows are open (a subwindow belongs to its parent’s).
- open_
workspaces 🔒 - The window contents a window shows now.
- parked_
blocks 🔒 - The agent blocks a closed window parked that are still parked, each with the tab it was parked from. The window’s list entry counts them: parked, they are in none of its tabs.
- parked_
of 🔒 - The block ids a closed window’s entry names as parked at its close.
- parked_
summary 🔒 - What a closed window’s parked agents add to its list entry: the tabs they alone keep, and their names.
- placement_
of 🔒 - Where window
wis, its name and appearance: a record entry’swindow. - quit_
under_ 🔒way - Whether a quit is closing the windows: its record is the session record, saved within the last two minutes.
- remember 🔒
- List
ws_idas closed atclosed_at_ms, its window atwindow, keeping the list newest first. - restore_
closed 🔒 - A cold start’s closed windows:
record’s"state": "closed"entries, kept closed. An entry whose contents are still here (itsworkspaceid, not shown by a window, notmain_ws, not waiting to open) is listed as it is; one whose contents are gone (a new version’s first start, which copied the record) is rebuilt from the entry, with new ids. No window opens for either. An entry naming contents inskip(an open window’s in the record that was restored) is left out. Returns how many are listed. - set_
parked 🔒 - Name the agent blocks a closed window parked, on its entry: what a reopen puts back.
- snapshot_
counts 🔒 - The tabs and panes a window snapshot holds.
- take_
discard 🔒 - Whether this close of
window_idis a delete’s. Asked once. - update 🔒
- Read, change and write back the list in one transaction: closes, reopens
and deletes run concurrently. A change counts as one to the workspace’s
windows, so the saver saves it.
Nonewhen the store couldn’t be written. - with_
closed 🔒 - A session record (the open windows) as the workspace’s record: each of its
windows marked
"state": "open", then the closed windows (closed_entries) it doesn’t already hold. A record with closed entries already comes back the same. - workspace_
of 🔒 - worth_
keeping 🔒 - Whether
ws_idholds anything of the user’s: a tab with a pane that isn’t the untouched default layout.