Expand description
Shared helpers used by all block controllers (persistent, subprocess, acp).
Extracted to avoid copy-paste across the four controller files. Each controller keeps only its transport-specific logic (PTY / stream-json / ACP) and delegates the common mechanics here.
Constants§
- META_
LAST_ FAILURE - Block metadata key for the last classified agent failure. Written on every non-zero / in-band-error exit; cleared on clean success. The frontend reads this on pane mount so the recovery banner survives tab switches and page reloads without requiring the MPS event to be received in real time.
- META_
SESSION_ ID - Block metadata key for the persisted agent session ID.
Used by the “My Agents” reattach path on the frontend: after a tab reload
the picker reads
block.meta["agent:sessionid"]and passes it as the--resumevalue so the CLI picks up the prior conversation.
Functions§
- broadcast_
block_ update - Broadcast the block’s current state as a
waveobj:updateonblock:<id>, so an open pane sees a meta write live. Does nothing if the block can’t be read. - expand_
home_ dir - Expand a leading
~/or bare~to the user’s home directory. - forget_
saved_ session - Forget the session a pane would resume, for a pane with no controller (a stopped agent): its next start has no id
to resume and begins a new session. A running pane’s controller does this itself in
start_fresh_session, which also stops its process; this is for the pane that has nothing to stop. - persist_
last_ failure - Persist or clear the last agent failure in block metadata.