Rich-based presenter for OC Chat (Phase 1.A — skeleton).
Purpose
-------
Implements the :class:`~oc_ui.presenter_base.Presenter` contract
using the `rich <https://rich.readthedocs.io/>`_ library. This first
slice (PR 1.A) ships:
* Styled welcome banner via ``rich.panel.Panel``.
* Pretty tables for ``/models``, ``/session list``, ``/help`` via
``rich.table.Table`` — auto column-widths, overflow handling,
borders.
* Consistent colour theme for info/error/compressed/turn-summary
lines.
* No streaming overlay yet — :meth:`turn` is a no-op contextmanager
and :meth:`show_reasoning` / :meth:`show_content` print each chunk
via ``Console.print(end="")``. Live streaming + Markdown post-commit
arrive in PR 1.B.
To enable, install the optional dep::
pip install -e .[rich]
Then run::
python OC Chat.py --ui rich
If ``rich`` is missing, ``oc_chat.main`` lazy-imports this module and
falls back to :class:`~oc_ui.terminal.presenter.ConsolePresenter`
with a warning.
Responsibilities
----------------
- :class:`RichPresenter` — concrete :class:`Presenter` backed by
``rich.console.Console``.
- Themed output via :class:`rich.panel.Panel` and
:class:`rich.table.Table` for the structured commands.
- Plain ``Console.print`` fallback for streaming chunks pending
the PR 1.B Live overlay.
Diagnostics
-----------
Domain: OC_UI.TERMINAL
Levels:
L2 — lifecycle events
L3 — semantic details
L4 — deep tracing
Contracts
---------
- Importing this module without ``rich`` installed raises
:class:`ImportError`; ``main.py`` is responsible for the optional-
dep gate.
- Theme colours are taken from one ``rich.theme.Theme`` instance so
callers can override centrally.
- Behavioural parity with :class:`ConsolePresenter` for any non-
streaming hook — the rich version only adds visual polish.
Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- rich.console (terminal rendering — panels, tables, syntax highlighting)
- rich.live (terminal rendering — panels, tables, syntax highlighting)
- rich.markdown (terminal rendering — panels, tables, syntax highlighting)
- rich.padding (terminal rendering — panels, tables, syntax highlighting)
- rich.panel (terminal rendering — panels, tables, syntax highlighting)
- rich.status (terminal rendering — panels, tables, syntax highlighting)
- rich.table (terminal rendering — panels, tables, syntax highlighting)
- rich.text (terminal rendering — panels, tables, syntax highlighting)
- oc_ui.presenter_base (Presenter ABC contract)
- oc_ui.terminal._render (RenderBatcher for batched Live refreshes while streaming)
- oc_ui.terminal.activity (plan_progress_from_result for the plan progress line under planner results)
- oc_ui.terminal.diffview (mutation argument pairing and the diff model for write_file and edit_file results)
- oc_ui.terminal.statusline (StatusBarState and status line rendering for the Live status bar)
- oc_ui.terminal.turn_layout (turn indent, rule composition and answer box titles)
- oc_chat.core.commands (lazy; _fmt_tokens_display for the session list table)
- oc_chat.core.config (lazy; REASONING_EFFORT_LEVELS for the welcome panel)
- oc_chat.core.formatting (lazy; format_duration for the turn summary)
- oc_chat.core.iteration_stat (lazy; iteration_stat_human_line for the answer box bottom border and stats line)
- oc_chat.core.persistence (lazy; save_tool_artifact for spilling long tool results to a file)
- oc_chat.core.session (lazy; ChatSession type hint for bind_session and show_welcome)
- oc_chat.core.tool_activity (lazy; TOOL_ACTIVITY snapshot of the in-flight tool call for the status bar)
- oc_ui.terminal.presenter (lazy; ConsolePresenter._fmt_turn_cost for the shared turn cost segment)
- rich.spinner (animated spinners for the waiting indicator and dispatch chrome)