Skip to main content

AiConversationMode

Struct AiConversationMode 

Source
pub struct AiConversationMode { /* private fields */ }
Expand description

ai-conversation-mode – major mode for the *ai:opencode* buffer.

Holds the prompt’s editable-region anchor: the absolute line where the prompt begins (== the transcript line count). The drain updates it on each re-projection; editable_tail publishes it so the read-only gate lets the user edit a multi-line prompt (<C-j> inserts a newline) while the transcript above stays frozen. One instance backs the single (v1) conversation buffer, so one shared anchor suffices.

AUX‑2: headerline_version is bumped by the drain on each re-projection so the ConversationHeaderline widget republishes its row when usage changes.

Implementations§

Source§

impl AiConversationMode

Source

pub fn new() -> Self

Source

pub fn mode_id() -> ModeId

Trait Implementations§

Source§

impl Clone for AiConversationMode

Source§

fn clone(&self) -> AiConversationMode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for AiConversationMode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Mode for AiConversationMode

Source§

fn invocation_runner(&self) -> Option<ModeId>

AU‑3 gap fix: claim the invocation runner so vim operators respect the editable tail. The host registers Editor::run_editable_tail_invocation under this mode id (editor_boot.rs); it gates mutating operators (x / dd / dw) started in the frozen transcript and lets them through in the prompt. Without a runner, operators fell through to the ungated document path and mutated the read-only transcript.

Source§

fn implies(&self) -> &[ModeId]

Pull in repl-mode on the conversation buffer: it owns the generic insert-entry surface (i/a/o/… → jump-to-prompt-and-Insert). The activation cascade turns it on wherever this major is active and off when the buffer’s major changes, so the affordance is scoped to the REPL buffer without a bespoke keymap on this mode.

Source§

fn editable_tail(&self) -> Option<EditableTail>

AU‑3: the prompt is the single trailing line, editable only after the "> " marker (2 bytes). Consulted by the host’s read-only edit gate so Insert/operator keystrokes land only in the prompt; the transcript above stays owner-written.

Source§

fn keymap(&self) -> Keymap

AU‑3: the modal-input surface. Insert-entering chords relocate the cursor into the prompt first (so Insert only ever edits the prompt, and history is unreachable from Insert); <CR> sends; <C-c> interrupts. The host’s K.2.4 translate pass pushes these under MajorMode(ai-conversation-mode), gated by K.1.c to this buffer.

Source§

fn action_handlers(&self) -> Vec<ActionHandlerContribution>

AU‑3: the handler bodies for the chords above, mode-owned (no host Editor:: method, no Action variant). Bound at boot by the host’s register_mode_action_handlers walk. Each reads the buffer / services from the [ActionContext] and returns an [Effect] the host applies.

Source§

type Guard = Option<AiConversationGuard>

Owned cleanup token returned by [Self::on_activate]. Read more
Source§

fn id(&self) -> ModeId

Canonical identity. Same value every call. Read more
Source§

fn kind(&self) -> ModeKind

Major or minor. Read at registration and on every activation call (activate_major on a minor, or vice versa, is [ModeActivationError::WrongKind]).
Source§

fn options(&self) -> OptionOverrideSet

Option overrides this mode contributes. Pure declarative (same return value every call); the host merges these into the buffer’s option-resolution layer stack while the mode is active, at the mode’s layer (later-activated minors win ties), and drops them on deactivation. Build with lattice_config::overrides! { lattice_config::Wrap = true, … }.
Source§

fn required_capabilities(&self) -> CapabilitySet

Capabilities the mode requires. Validated at activation; missing capability ⇒ [ModeActivationError::MissingCapability], never silent skip.
Source§

fn on_activate(&self, ctx: ModeContext) -> LifecycleFuture<'_, Self::Guard>

Lifecycle. Called once per (buffer, activation) cycle after the registry has applied the declarative contributions. Returns an owned Guard carrying every resource the mode allocated. The dispatcher stashes the Guard until deactivation, at which point dropping it performs cleanup via the Guard’s Drop impl. Read more
§

fn target_buffer_kind(&self) -> Option<BufferKind>

For major modes, the [BufferKind] this mode is the default major for (H.2, 2026-05-31). ModeRegistry::register indexes this so ModeRegistry::find_major_for_kind can dispatch buffer-creation events to the right major without host-side match BufferKind { ... } blocks. Read more
§

fn target_language(&self) -> Option<&str>

For major modes, the language this mode is the default major for, by canonical name (Lang::name() — "rust", "org") (OM.1). The peer of target_buffer_kind for the dispatch path [BufferKind::Document] takes: language detection rather than kind dispatch. Read more
§

fn decorations(&self) -> Vec<DecorationProvider>

Decoration providers (gutter / inline / overlay / statusline). Stub — reserved for the WIT plugin path (M.10).
§

fn gutter_decorations(&self, _ctx: &DecorationCtx<'_>) -> Vec<GutterDecoration>

Gutter sign decorations this mode contributes while active. Called once per pane per frame with a [DecorationCtx] carrying relevant render-state snapshots (diff sign map, LSP diagnostics arc). Returns per-line GutterDecoration values; the renderer partitions them by variant into the appropriate gutter column. Default: empty (no contribution).
§

fn completion_sources(&self) -> Vec<CompletionSourceContribution>

Insert-mode completion sources this mode contributes while active on a buffer. Empty by default; minors that own a completion source (lsp-completion-mode, snippet-completion-mode, buffer-words-mode, tree-sitter-completion-mode, path-completion-mode, plugin sources) override.
§

fn conflicts_with(&self) -> &[ModeId]

Modes this one cannot be active alongside. Read more
§

fn presents_extensions(&self) -> &[&'static str]

File extensions (lowercase, no dot) this major PRESENTS rather than edits — the file is never loaded as text. Read more
§

fn mirrors_option(&self) -> Option<&'static str>

Declarative mirror hint for “this mode is the on/off switch for a typed option of the same observable state”. Some(canonical_name) ⇒ a host-driven cascade keeps the mode’s active state and the option’s value in sync.
§

fn refresh_action(&self) -> Option<&'static str>

Which of this mode’s own actions refreshes its view, or None (the default) when the mode backs nothing refreshable (RV.1, 2026-08-10). Read more
§

fn fold_toggle_action(&self) -> Option<&'static str>

Which of this mode’s actions <Tab> fires, and the declaration that pulls in foldable-view-mode — the shared minor owning the chord. Read more
§

fn refresh_on_open(&self) -> bool

Should re-opening this view re-run its refresh? Read more
§

fn activation_policy(&self) -> ActivationPolicy

A minor mode’s default auto-activation policy (MA.1; mode-architecture.md §7.4). The host’s minor-activation resolver reads this for every registered minor when a buffer enters a major mode, and activates those whose policy admits the entered major. The default is [ActivationPolicy::Manual] — auto-activate nowhere until the mode or the user opts in. Ignored for major modes (a buffer’s major is chosen by the major resolver, not this allowlist).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<M> DynMode for M
where M: Mode,

§

fn id(&self) -> ModeId

Forwards to [Mode::id].
§

fn kind(&self) -> ModeKind

Forwards to [Mode::kind].
§

fn target_buffer_kind(&self) -> Option<BufferKind>

Forwards to [Mode::target_buffer_kind].
§

fn target_language(&self) -> Option<&str>

Forwards to [Mode::target_language].
§

fn options(&self) -> OptionOverrideSet

Forwards to [Mode::options].
§

fn keymap(&self) -> Keymap

Forwards to [Mode::keymap].
§

fn decorations(&self) -> Vec<DecorationProvider>

Forwards to [Mode::decorations].
§

fn gutter_decorations(&self, ctx: &DecorationCtx<'_>) -> Vec<GutterDecoration>

Forwards to [Mode::gutter_decorations].
§

fn completion_sources(&self) -> Vec<CompletionSourceContribution>

Forwards to [Mode::completion_sources].
§

fn action_handlers(&self) -> Vec<ActionHandlerContribution>

Forwards to [Mode::action_handlers].
§

fn required_capabilities(&self) -> CapabilitySet

Forwards to [Mode::required_capabilities].
§

fn conflicts_with(&self) -> &[ModeId]

Forwards to [Mode::conflicts_with].
§

fn implies(&self) -> &[ModeId]

Forwards to [Mode::implies].
§

fn presents_extensions(&self) -> &[&'static str]

Forwards to [Mode::presents_extensions].
§

fn mirrors_option(&self) -> Option<&'static str>

Forwards to [Mode::mirrors_option].
§

fn invocation_runner(&self) -> Option<ModeId>

Forwards to [Mode::invocation_runner].
§

fn refresh_action(&self) -> Option<&'static str>

Forwards to [Mode::refresh_action].
§

fn fold_toggle_action(&self) -> Option<&'static str>

Forwards to [Mode::fold_toggle_action].
§

fn refresh_on_open(&self) -> bool

Forwards to [Mode::refresh_on_open].
§

fn activation_policy(&self) -> ActivationPolicy

Forwards to [Mode::activation_policy].
§

fn editable_tail(&self) -> Option<EditableTail>

Forwards to [Mode::editable_tail].
§

fn on_activate_dyn<'a>( &'a self, ctx: ModeContext, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Any + Send>, ModeActivationError>> + Send + 'a>>

Type-erased lifecycle entry. Returns a future whose output is the typed Guard erased to Box<dyn Any + Send>. The dispatcher stashes this box keyed by (BufferId, ModeId); deactivation drops it.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoMaybeUndefined<T> for T

§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
§

impl<T> IntoOption<T> for T

§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more