Skip to content

feat(acp): terminal streaming lifecycle events in tool call _meta #1009

@bug-ops

Description

@bug-ops

Part of epic: #1007

Problem

AcpShellExecutor blocks until the command completes, then returns the full output. IDEs receive terminal output only after execution finishes — no real-time streaming visible in the tool card.

Solution

Introduce a per-call streaming output sink. For each shell tool call, emit:

  1. ToolCall with _meta.terminal_info = { terminal_id } on start
  2. ToolCallUpdate with _meta.terminal_output = { terminal_id, data } per stdout/stderr chunk
  3. ToolCallUpdate with _meta.terminal_exit = { terminal_id, exit_code, signal } on finish

Protocol shape (from Zed claude-agent-acp):

// ToolCall
{ "_meta": { "terminal_info": { "terminal_id": "<uuid>" } } }

// ToolCallUpdate (streaming)
{ "_meta": { "terminal_output": { "terminal_id": "<uuid>", "data": "chunk" } } }

// ToolCallUpdate (final)
{ "_meta": { "terminal_exit": { "terminal_id": "<uuid>", "exit_code": 0, "signal": null } } }

Tasks

  • Generate terminal_id (UUID) in agent.rs before shell tool dispatch
  • Refactor AcpShellExecutor::execute() to accept output_sink: impl Fn(String) + Send callback in crates/zeph-acp/src/terminal.rs
  • Sink emits ToolCallUpdate { _meta: terminal_output { data } } via ACP client per chunk
  • On command exit: emit ToolCallUpdate { _meta: terminal_exit } with exit code
  • Integration test: verify terminal_output chunks arrive before final ToolCallUpdate

Files

  • crates/zeph-acp/src/terminal.rs — AcpShellExecutor streaming refactor
  • crates/zeph-acp/src/agent.rs — terminal_id generation + _meta serialization in prompt()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions