Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/adr/0041-tui-is-an-acp-client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 0041. The fullscreen TUI is an in-process ACP client

Status: accepted 2026-08-27

## Context

`graff acp` and `apps/native` already share one mid-turn protocol (ADR 0032):
`session/prompt` in, `session/update` thought / tool / text out. The TUI was
a sibling frontend on the same agent loop (`tui_sink` typed events), so a
tool row or thought chunk had two translations. Spawning `graff acp` from
the pager would fork a second Agent and drop the in-process seams (images,
`/debug`, idle wake, shared conversation).

## Decision

`graff tui` (and TTY `graff repl`) is an ACP **client in the same process**.
It speaks initialize / session/new / session/prompt / session/cancel through
`acp_engine` and renders thought, tools, and answer text from `session/update`.
No child `graff acp`. Live coding still uses the existing `ReplCtx` turn
(`replTurnCb`); the ACP envelopes are the client wire, not a second runtime.

TUI-only extras ACP does not name — meters, notices, raw bash tail, failover
— stay on `tui_sink`. Local slashes (`/theme`, `/model` picker, `/rewind`)
stay local. `session/request_permission` is still off (`--yolo` / unattended).

## Consequences

Zed, the native app, and the pager share one session/update vocabulary.
Do not spawn a child agent to "make the TUI use ACP." Revisit a subprocess
only if the pager and the agent must be separate binaries.
1 change: 1 addition & 0 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ record only when you need the evidence or the edge cases.
| [0036](0036-computer-use-keeps-the-signed-codex-bridge.md) | Codex Computer Use keeps its authenticated node_repl process chain: Graff launches it through the signed Codex sandbox wrapper, never embeds V8 or spoofs the service. |
| [0037](0037-experiment-pool-is-opt-in.md) | `--experiment N` / `/experiment N` pre-mints a child worktree pool; default isolation stays `shared_cwd`. 279 continuation — not on main until a later cut. |
| [0038](0038-in-process-acp-core.md) | Same-process embed is `libgraff` + `graff-core.wasm` + `createGraffAgent()` (ACP core, echo turn). Live coding stays `graff acp`. 279 continuation — not on main until a later cut. |
| [0041](0041-tui-is-an-acp-client.md) | The fullscreen TUI is an in-process ACP client: session/prompt in, session/update thought/tool/text out. No child `graff acp`. |

## When to write one

Expand Down
1 change: 1 addition & 0 deletions src/test_hooks.zig
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,5 @@ test {
_ = @import("commands_experiment.zig");
_ = @import("acp_engine.zig");
_ = @import("libgraff.zig");
_ = @import("tui_acp.zig");
}
Loading