Skip to main content

Module session_closed

Module session_closed 

Source
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. None for 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), its workspaceid, "state": "closed" and closed_at_ms. One whose contents are gone or shown by a window is left out.
entries 🔒
forget 🔒
ws_id is 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_id closed, and no other window shows it (window: where it was). Stop what runs in it and keep its contents, listed as a closed window unless unlisted, 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. unlisted is the close that ends the session (it emptied Client.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_id deletes its contents.
mark_parked_in_record 🔒
Name the agent blocks a switch parked on the window entry for ws_id in the saved record of user workspace row_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 w is, its name and appearance: a record entry’s window.
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_id as closed at closed_at_ms, its window at window, 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 (its workspaceid, not shown by a window, not main_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 in skip (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_id is 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. None when 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_id holds anything of the user’s: a tab with a pane that isn’t the untouched default layout.