Skip to main content

Module msg

Module msg 

Source
Expand description

Every input to the reducer.

Msg is an exhaustive sum over three categories:

  1. User intent — key presses, pastes, slash commands, submit, cancel, quit. Originates from app::event_source.
  2. Effect results — stream chunks, tool outcomes, MCP lifecycle, save/load completion. Originates from effect::EffectRunner when a spawned task finishes a unit of work.
  3. HousekeepingTick (timer-driven redraw), StatusDismiss, InstructionsChanged (mtime watcher).

Every effect-result variant carries a TurnId. The reducer’s first gate on any such message is if state.turn.accepts(msg.turn_id()) — messages for a cancelled / superseded turn are dropped without state change. This is the architectural guarantee that stale streaming events can never corrupt the current turn.

Structs§

Key
Bare key event — deliberately smaller than crossterm’s KeyEvent so the reducer doesn’t depend on crossterm. The app event source does the conversion.
KeyMods
StartupConfig
Helper for app::event_source — pass through the MCP config that effect::mcp needs to dispatch InitMcpServers as its first effect. Not a Msg because it’s startup-only.

Enums§

KeyCode
Msg
Single reducer input. Non-exhaustive is intentional: adding a new variant is a deliberate act that forces every reducer arm to consider it at compile time (the reducer’s match is NOT _ => — see reducer.rs).
MsgKind
Compact kind tag for tracing / replay indexing.
Paste
Paste payload. Images come in as raw bytes; text as UTF-8.
SlashCmd
Slash commands — a typed surface over what the user typed as /<name> [args]. Parsed in app::event_source against the single COMMAND_REGISTRY; unknown commands produce SlashCmd::Unknown so the reducer can issue a “no such command” status line.