Skip to main content

Module user_workspace_switch

Module user_workspace_switch 

Source
Expand description

Several workspaces, one open at a time (docs/specs/SPEC_WORKSPACES_2026_10_23.md §3.2, §6): list them, make a new one, switch, delete one. Not the srv Workspace object, which is one window’s contents.

Switching (workspace.SwitchUserWorkspace, and the switch that ends CreateUserWorkspace and Import…), all in srv:

  1. the open workspace is saved, then saves wait (LayoutWrites::hold_saves) until the windows have moved, so no save stores a mix of the two;
  2. its windows other than the one the user acted from close here: their rows go, their contents stay, and their windows stay open in its record. The host closes the OS windows afterwards (the reply names them);
  3. the other workspace becomes the open one (workspace:current, workspace:name, its opened_at), and the closed windows, the restored windows waiting to open and the session record of the one before are forgotten: its record holds them;
  4. its record is restored as a cold start restores one (session_windows::restore_all): contents still here are reused, those that are gone are rebuilt from the record, its closed windows are listed closed. A record with nothing to restore (a new workspace) gets the default panes;
  5. the window the user acted from shows the first window’s contents, with its name and appearance; the rest wait for that window to open them (TakeRestoredWindows);
  6. the contents the closed workspace showed have their shells stopped and their agents parked (they keep running, agents:always_available; the saved record names them, and switching back puts them in their tabs), after the reply, one switch at a time. The next switch waits for that.

The next launch opens the workspace that was open last: it is the one the client names.

Structs§

SavesHeld 🔒
Holds saves for as long as it lives.
Switched 🔒
What a switch did, for the window that asked.

Constants§

SWITCH_META_KEYS 🔒
The client meta keys a switch changes: the open workspace, its closed windows, the restored windows’ queues and the quit’s session record.

Statics§

SWITCH_LOCK 🔒
One switch at a time, held until the closed workspace’s agents have stopped: the next switch may reopen those contents.

Functions§

apply 🔒
Apply events to the store and publish them; the first error the reducer returned, if any, instead.
arg_str 🔒
client 🔒
client_meta_of 🔒
client_update 🔒
The client, whose meta names the open workspace, as an object update.
handle_agents 🔒
workspace.UserWorkspaceAgents(): the agents running in the open workspace’s windows, each {block_id, name, working}, for the warning before a switch closes it.
handle_create 🔒
workspace.CreateUserWorkspace(name, windowId): a new workspace, switched to at once; its first window shows the default panes. The same reply as SwitchUserWorkspace. A switch that fails leaves no workspace behind.
handle_delete 🔒
workspace.DeleteUserWorkspace(workspaceId): delete a workspace that isn’t open: its row, and the contents of its windows still kept here. Its agents stay in My Agents.
handle_list 🔒
workspace.ListUserWorkspaces: every workspace, the most recently opened first, each {id, name, current, opened_at, windows, closed} (its open and closed windows, as last saved).
handle_switch 🔒
workspace.SwitchUserWorkspace(workspaceId, windowId): switch to another workspace from window windowId. Returns {id, name, closed: [{window_id, label}], beside}: the windows for the host to close, and how many wait to open beside this one (TakeRestoredWindows).
insert_workspace 🔒
A new, empty workspace named name.
kept_contents 🔒
The window contents workspace row keeps (its record’s), less any that a window shows, that the open workspace lists as closed, or that wait to open.
open_target 🔒
Make target the open workspace and show its first window in acting; returns that window’s contents.
reply 🔒
restore_client_meta 🔒
Put saved (from client_meta_of) back, in one transaction.
set_current 🔒
Make row the open workspace: the client names it, and forgets what belonged to the one before (its closed windows, its restored windows waiting to open, the session record), which that one’s record holds.
switch_to 🔒
Switch to workspace target_id, reusing window window_id for its first window. See the module doc for the steps.
window_counts 🔒
The windows a record holds, open and closed.
window_patch 🔒
The meta patch that makes a window the one a record entry describes: its name, theme and opacity, and none of the window’s own where the entry has none.