# src/tui/state KNOWLEDGE BASE
## OVERVIEW
Display-only Mission Control state: event reducers, transient focus/layout/scroll/activity/transcript/modal projections; generic diff display remains activity behavior.
## WHERE TO LOOK
| Module boundary | `mod.rs` | `MissionControlState`, focus/layout enums, reducer surface, cache invalidation. |
| Output reducers | `mod.rs::apply_output_event` | `OutputEvent` -> transcript/tool/context display transitions. |
| Activity tree | `mod.rs`, `activity_state.rs` | nodes/roots/children, subagent rows, active tool transcript lines. |
| Transcript state | `transcript_state.rs` | context usage merge, tool row metadata, transient status filtering. |
| Modal state | `modal.rs` | model/login/custom-provider/session/skills/system-prompt picker structs. |
| Prompt run state | `prompt_state.rs` | running/canceling/canceled prompt lifecycle. |
| Primary agents | `primary_agent_state.rs` | display entries, selected profile projection, none-cycle behavior. |
| Regression coverage | `tests/` | activity, modals, pickers, transcript, generic diff context, layout/focus. |
## CONVENTIONS
- `MissionControlState` = UI projection, not execution truth.
- Reducers mutate display state from normalized events; no provider/tool/session policy here.
- `apply_output_event` handles output transcript, tool rows, assistant/thinking deltas, context usage.
- Final events reconcile complete text; delta/previews can be partial, missing, or dropped.
- Hard stream boundaries clear live assistant/thinking redaction buffers before non-stream rows.
- Activity IDs back tree selection, transcript links, active tool transcript replacement.
- Cache invalidation must follow changed transcript/activity rows; stale projection = wrong UI.
- Modal structs carry selection/scroll/input affordances only; commands live in controller/input.
- Session picker previews are summaries for navigation; JSONL session remains durable source.
- Tests live close to reducer behavior; add focused case for each state transition bug.
## ANTI-PATTERNS
- Do not serialize `MissionControlState` into JSONL, provider payloads, cache keys, or settings.
- Do not persist focus, layout mode, selected rows, scroll offsets, modal state, toast, cursor blink.
- Do not treat preview delta loss as data loss; final/critical events must reconstruct display.
- Do not add auth, provider request shape, tool dispatch, or session replay logic here.
- Do not mutate state without matching cache invalidation when render output can change.
- Do not leave selected indices unchecked after row removal/replacement.
- Do not render raw escape/control sequences from tool output, Git diff, prompts, diagnostics.
- Do not couple modal display structs to durable config writes; controller performs actions.