Expand description
ai-conversation major mode (AU‑2).
The read-only *ai:opencode* buffer backing the agent conversation view.
Mirrors lattice_agent::log::modes::AiLogMode: on_activate reads the
ConversationStore service,
seeds the buffer from the current snapshot, subscribes to
ConversationUpdated, and
spawns a drain task that re-projects on every change. The returned
Subscription guard unsubscribes on drop.
render_conversation is pure and unit-testable. Projection is a
line-granular suffix replace: unchanged leading lines are never
rewritten, so streaming appends touch only the tail and a tool-call status
change rewrites only from its line down (AU‑2 shows status inline as text; a
decoration-based in-place update is a follow-up).
Structs§
- AiConversation
Guard - AU‑3+ activation guard: the
ConversationUpdatedsubscription. Dropping it on deactivation unsubscribes, so a stopped mode contributes no further work. - AiConversation
Mode ai-conversation-mode– major mode for the*ai:opencode*buffer.- Line
Suffix Replace - Result of
suffix_replace: replace linesfirst_diff_line..old_line_count(0-based, the split-on-\nline grid) withreplacement.
Functions§
- conversation_
buffer_ name - The synthetic buffer name for the (single, v1) opencode conversation.
- project_
conversation - TCF: project the conversation to
(transcript_text, fold_spans)in a single pass, so a fold’s line range can never drift from the rendered layout. The text half is what the drain diffs into the buffer; the span half is what theToolCallFoldSourceandReasoningFoldSourceread. - register_
ai_ conversation_ actions - AU‑3: register the
ai-conversationaction commands so the mode’s keymapcmdnames resolve (the diff subsystem’sregister_diff_actionspattern). The specs are pure shells returningEffect::None: the real bodies live inAiConversationMode::action_handlers, consulted before the CommandSpec. - render_
conversation - Render the whole conversation to plain text. Pure; the projection diffs this
against the buffer to compute a minimal edit. Thin wrapper over
project_conversation— the text half. - suffix_
replace - The minimal line-granular replacement turning
oldintonew: the index of the first differing line, and the replacement text for everything from that line onward.Nonewhen the texts are already equal.