Skip to content

feat(mcp): add close_session tool to close terminals and reclaim slots#335

Open
roba-adnew wants to merge 2 commits into
forketyfork:mainfrom
roba-adnew:add-close-session-tool
Open

feat(mcp): add close_session tool to close terminals and reclaim slots#335
roba-adnew wants to merge 2 commits into
forketyfork:mainfrom
roba-adnew:add-close-session-tool

Conversation

@roba-adnew

Copy link
Copy Markdown

Adds a close_session MCP tool — the symmetric counterpart to the existing spawn_session. Where spawn_session creates a terminal in a requested directory, close_session terminates a session's shell and removes its pane via the same close/relayout path as the close-pane keybinding (despawnSessionAtIndex), so the grid slot is reclaimed rather than left as a dead pane.

API

Pass exactly one identifier — the session_id returned by spawn_session, or a slot_index:

{ "session_id": 12 }

On success it returns structured content with status: "closed" and the session_id. An unknown identifier returns an MCP tool error with code not_found.

Changes

  • src/app/control.zigCloseRequest/Response/Queue/Completion, not_found error code, op:"close" wire discrimination, connectAndSendCloseRequest, failPendingClose.
  • src/app/runtime.zig — extract the DespawnSession body into a shared despawnSessionAtIndex, add handleExternalCloseRequest, drain a parallel close queue in the main loop.
  • src/mcp/main.zig — register close_session in tools/list + tools/call.
  • Docs: README, ARCHITECTURE, ai-integration.

Based directly on current main — a single commit, no conflicts.

Symmetric to spawn_session: close_session terminates a session's shell and
removes its pane via the same close/relayout path as the close-pane keybinding
(despawnSessionAtIndex), so the slot is reclaimed instead of left as a dead pane.

- control.zig: CloseRequest/Response/Queue/Completion, not_found error code,
  op:"close" wire discrimination, connectAndSendCloseRequest, failPendingClose
- runtime.zig: extract DespawnSession body into shared despawnSessionAtIndex,
  add handleExternalCloseRequest, drain a parallel close queue in the main loop
- mcp/main.zig: register close_session in tools/list + tools/call
- docs: README, ARCHITECTURE, ai-integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant