latent.chat.controller¶
ChatController — pure-Python REPL logic with zero Textual imports.
Owns message list management, event-to-output processing, slash command
dispatch, usage aggregation, cost tracking, and session save orchestration.
Communicates with the UI through the ChatOutput protocol.
Classes¶
ChatController¶
ChatController(agent: BaseAgent, output: ChatOutput, session_id: str = new_session_id(), messages: list[Message] = list(), turn_count: int = 0, total_input_tokens: int = 0, total_output_tokens: int = 0, total_cost: float = 0.0, tools_visible: bool = True, pricing_data: list[dict] | None = None, _streaming: bool = False)
Pure-Python REPL controller — no Textual imports.
ChatOutput¶
UI-agnostic output sink. Textual App implements this; tests use a stub.
TurnMetrics¶
TurnMetrics(input_tokens: int = 0, output_tokens: int = 0, model_id: str | None = None, response_time_ms: float = 0, ttft_ms: float | None = None, cost: float | None = None)
Per-turn token and timing metrics.
Methods¶
ChatController.cancel_streaming¶
Called by UI on Ctrl+C to stop consuming the stream.
ChatController.handle_input¶
Entry point for user input. Routes to slash command or agent.