Teach parent agents to clean up the processes they spawn
Add a `lifecycle` help topic spelling out that the caller owns the
processes it spawns and should `close_process` when a sub-agent or
spawned child is no longer needed. The `spawn_agent` and `spawn_process`
descriptions advertised via `tools/list` now restate the same duty
inline (with a pointer to `help('lifecycle')`), so vendor TUIs see the
expectation at the moment they reach for the tool. The `spawning` topic
and `topics` index cross-reference the new content.
Bundles two already-staged improvements that fall in the same area:
- OnChildSpawned primes the snapshot-replay budget for new panes so
diff-based vendor TUIs come up clean without a manual Ctrl+W/Ctrl+S
refresh.
- TODO drops the three items now actioned (prompt-injection preface,
agent cleanup duty, opencode→claude view corruption) and keeps the
unicode `<?>` entry with the investigation notes.
This commit is contained in:
@@ -330,6 +330,18 @@ func (st *uiState) OnChildSpawned(c *Child) {
|
||||
st.palette.rebuild()
|
||||
st.renderPaletteLocked()
|
||||
}
|
||||
// Prime the snapshot-replay budget for the new child. Diff-based
|
||||
// vendor TUIs (claude/codex/opencode) emit incremental updates that
|
||||
// assume the host display already matches their internal "last
|
||||
// frame" model. On a fresh spawn the host viewport was just cleared,
|
||||
// so incremental ops target cells that aren't populated yet —
|
||||
// leaving the corrupted pane the user works around by toggling
|
||||
// focus (which routes through repaintFocused). Setting the budget
|
||||
// here makes the next ~8 PTY chunks render from the full styled
|
||||
// emulator grid, so the host display tracks the emulator state
|
||||
// without needing a manual focus cycle.
|
||||
st.repaintNextPTY = c.ID
|
||||
st.repaintNextPTYBudget = 8
|
||||
st.mu.Unlock()
|
||||
|
||||
// Wipe the viewport area so the previous focused child's PTY
|
||||
|
||||
Reference in New Issue
Block a user