Expand description
Structured conversation model for the ACP agent UI (AU‑1).
The ACP supervisor receives structured SessionUpdates (message chunks,
thought chunks, tool calls, tool-call updates). AU‑1 stops flattening the
conversation ones to text AiLogger records and instead folds them into a
Conversation — a turn/block tree the ai-conversation mode (AU‑2)
projects into the *ai:opencode* buffer. Trace sources (Client /
Lifecycle) still flow to AiLogger; this completes the conversation/trace
split.
Conversation::apply is pure and unit-testable (no I/O, no locks).
ConversationStore wraps it with a shared mutex + a ConversationUpdated
bus publish so the mode can live-tail.
Structs§
- Conversation
- The full conversation as a turn/block tree. Streaming extends the last block; earlier turns are never rewritten.
- Conversation
Projected - Fired by the
ai-conversationmode’s drain AFTER a re-projection edit has LANDED in the buffer. Boot wakes the editor actor on this (viawake_on_event) so a streamed agent response repaints WITHOUT a keystroke, and the per-tick prompt-focus callback runs. - Conversation
Store - Shared, mutable conversation state plus a bus publisher. The supervisor holds
one clone and calls
ConversationStore::apply; theai-conversationmode readsConversationStore::snapshoton eachConversationUpdated. - Conversation
Updated - Fired after the
ConversationStoremutates. Theai-conversationmode subscribes to it and re-projects (mirrorsAiLogPushed). - Cost
- AUX‑2: token usage snapshot from a
UsageUpdatenotification. - Pending
Permission View - PU-B.2b: a pending permission request projected for the popup menu.
ai-permission-mode’son_activatereads [ConversationStore:: oldest_pending_permission] and renderstitle, optionaldescription, and one line peroptionsentry (wire order); the select handler maps the chosen line back tooptions[i].option_id. - Turn
- One turn: a role and its ordered blocks.
- Usage
Snapshot - AUX‑2: latest token and cost snapshot from the ACP
usage_update.
Enums§
- Block
- One renderable unit within a turn.
- Edit
Status - Review state of an agent-proposed file edit. AU‑4 drives the transitions and
attaches the
review_diffsession; AU‑1 only defines the shape. - Permission
Status - AUX‑1: status of an inline permission request shown in the conversation.
- Role
- Who produced a turn.
- Session
Status - AUX‑3: global processing status of the current agent session — shown in the conversation buffer’s headerline.
- Tool
Status - Execution state of a tool call, mapped from ACP’s
ToolCallStatus.