# Mission Control agent guide
## Scope
Mission Control is the default conversation interface. It connects blocking workers to terminal input and Ratatui display projections; non-interactive clients use `../service/`. Repository-wide runtime and persistence rules remain inherited.
## Where to look
| Entry, event envelope, delivery helpers | `mod.rs` |
| Terminal setup and restoration | `terminal.rs` |
| Worker outcomes and final reconciliation | `worker.rs` |
| Main loop, input bridge, pacing, durable handoffs | `controller/` |
| Key, mouse, paste, completion classification | `input/` |
| Event reducers and display models | `state/` |
| Pane and modal drawing | `render/`, `layout.rs` |
| Session picker reads and history hydration | `sessions/` |
| Worker usage recording and session totals | `session_usage.rs`, `../sessions/usage.rs` |
| Card formatting, wrapping, copy coordinates | `transcript_cards/` |
| Selection-aware visible transcript | `transcript_projection.rs` |
| Bounded transcript store, typed entries, sanitizing, and caches | `transcript.rs` |
| Editable text and completion models | `prompt_editor.rs`, `single_line_field.rs`, `autocomplete.rs`, `selection.rs` |
| Initial primary-agent screen | `screens/primary_agent_startup.rs` |
## Event delivery
- `events/mod.rs` implements `TuiOutputSink`; `events/delivery.rs` classifies delivery. Event variants and send helpers live in `mod.rs`, not `events/mod.rs`.
- The main event channel holds 1024 events. Critical sends use a bounded timeout and report saturation/disconnection; never silently discard their failures.
- Assistant/thinking deltas and activity deltas are best effort. Lifecycle, final-preview, and completion events remain critical so final state can reconcile dropped previews.
- Best-effort delivery reserves 64 queue slots when capacity permits; preserve this protection against preview floods.
- Keep delivery synchronous. Preserve worker outcome reconciliation when final-event delivery fails; do not make preview traffic block execution.
- Record usage request starts and snapshots before event delivery. Reconcile worker usage before folding completed-run records; totals outlive the transcript and activity tree.
## Local boundaries
- Route semantic input through commands and controller reducers. Terminal event capture belongs in `controller/input_bridge.rs`, not key classifiers.
- Keep selection-aware window orchestration in `transcript_projection.rs`; card modules supply reusable projection and line primitives.
- Sanitize and redact display and copy text through existing helpers, including streamed fragments and modal details.
- Session previews are navigation data; hydration is a display projection, not provider replay or command execution.
- `TranscriptEntries` owns row ids, timestamps, activity links, and revisions. Move the whole store during hydration; decode historical tool text at ingestion, not in card rendering.
- Transcript history indexes are lazy and width-specific. Streaming reuses completed formatted/wrapped lines only after whole-input sanitization; preserve final Markdown and width/theme/focus invalidation.
- The subagent viewer caches tabs, selected-subtree cards, and row offsets. Invalidate old and new ancestry on reparenting; render only visible rows and retain bounded card projections.
- Scroll timing in `perf.rs` measures application apply-to-draw completion, not queue wait or physical display latency. Run synthetic scenarios with `cargo test --quiet --lib profile_scroll_ -- --ignored --nocapture --test-threads=1`.
- Use existing local tests and root verification commands. Do not add guides under test directories.
- Terminal restoration and cleanup must cover errors and panics. Backend layout tests do not establish physical-terminal behavior.