Skip to main content

Module conversation

Module conversation 

Source
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.
ConversationProjected
Fired by the ai-conversation mode’s drain AFTER a re-projection edit has LANDED in the buffer. Boot wakes the editor actor on this (via wake_on_event) so a streamed agent response repaints WITHOUT a keystroke, and the per-tick prompt-focus callback runs.
ConversationStore
Shared, mutable conversation state plus a bus publisher. The supervisor holds one clone and calls ConversationStore::apply; the ai-conversation mode reads ConversationStore::snapshot on each ConversationUpdated.
ConversationUpdated
Fired after the ConversationStore mutates. The ai-conversation mode subscribes to it and re-projects (mirrors AiLogPushed).
Cost
AUX‑2: token usage snapshot from a UsageUpdate notification.
PendingPermissionView
PU-B.2b: a pending permission request projected for the popup menu. ai-permission-mode’s on_activate reads [ConversationStore:: oldest_pending_permission] and renders title, optional description, and one line per options entry (wire order); the select handler maps the chosen line back to options[i].option_id.
Turn
One turn: a role and its ordered blocks.
UsageSnapshot
AUX‑2: latest token and cost snapshot from the ACP usage_update.

Enums§

Block
One renderable unit within a turn.
EditStatus
Review state of an agent-proposed file edit. AU‑4 drives the transitions and attaches the review_diff session; AU‑1 only defines the shape.
PermissionStatus
AUX‑1: status of an inline permission request shown in the conversation.
Role
Who produced a turn.
SessionStatus
AUX‑3: global processing status of the current agent session — shown in the conversation buffer’s headerline.
ToolStatus
Execution state of a tool call, mapped from ACP’s ToolCallStatus.