Skip to main content

Module user_workspace_files

Module user_workspace_files 

Source
Expand description

A workspace as a file (docs/specs/SPEC_WORKSPACES_2026_10_23.md §3.2, §4.2): ☰ → Workspaces → Export… and Import….

  • Export writes the open workspace, every window of it with its name and whether it is closed, as an agentmux.layout document with scope: "workspace" (layout_file::export_workspace) to a *.agentmux-workspace.json file the host’s Save dialog picked. The same per-view allowlist as a layout file: no session ids, and the machine-local resume references only when asked for.
  • Import reads an exported workspace, or an older *.agentmux-layout.json, as a new workspace and switches to it. It is opened as a template, as Open layout… opened a layout: every pane is new, each agent pane starts its agent afresh, and a terminal’s command runs only for a trusted file or when the user said so in the preview. The new workspace’s record holds the windows to build; the switch builds them (session_windows::restore_all, as for a record whose contents are gone).

Structs§

ImportTrust 🔒
What decides whether a file is trusted (layout files spec §3.5): saved by this install, in one of its own folders. Injected for tests.

Functions§

agent_placeholders 🔒
The agent panes a layout’s plan made in contents ws_id, waiting for their agent: (tab, block, agent definition).
definition_id 🔒
The id of the agent definition a layout names (its id, or a user agent’s name as agent.open reads it); what it names, as written, when none matches.
export 🔒
Export the open workspace to path (*.agentmux-workspace.json). Returns {path, warnings}: what the user should check before sharing it.
handle_export 🔒
workspace.ExportUserWorkspace(path, includeResume).
handle_import 🔒
workspace.ImportUserWorkspace on the HTTP service route: refused. Whether the file’s commands run and its agents start is the person’s answer in the preview, and this route cannot tell the person’s window from any other caller, so the import is the websocket command workspace.importuserworkspace, which only the window may call.
handle_preview 🔒
workspace.PreviewImport(path).
has_agent 🔒
import 🔒
Import the file at path as a new workspace and switch to it from window window_id. run_commands None means “as trusted”. Returns the switch and what the user should know.
import_for_window 🔒
workspace.importuserworkspace, after the caller was proven to be the person’s window: the switch plus notes, and the client’s new state sent to every window (the service route’s reply carried it back to the caller itself).
import_name 🔒
The name an imported workspace gets: the file’s, else its file name.
import_record 🔒
The record a new workspace starts with: one entry per planned window, in the session record’s shape without contents ids, so the switch builds each one (session_restore::restore_workspace). A plan with no open window opens its first.
plan_of 🔒
preview 🔒
What Import… shows before it opens a file: {name, trusted, windows, closed, tabs: [{name, panes}], commands, notes}, the shape of a layout preview plus the windows.
read_doc 🔒
Read a file Import… accepts: an exported workspace or a layout file.
start_agents 🔒
Start each agent the shown windows’ panes wait for (the window that asked, and those waiting to open beside it). Returns a note per agent that didn’t.
unique_name 🔒
name, or name 2, name 3, … when a workspace has it already.