Plain-ANSI console presenter for OC Chat.
Purpose
-------
:class:`ConsolePresenter` implements the
:class:`~oc_ui.presenter_base.Presenter` contract using simple
``print`` calls and ANSI escape codes from
:mod:`oc_chat.core.config`. It is the default presenter and the
fallback used by CI, headless runs, and any environment without
optional ``rich`` / ``textual`` dependencies installed.
The Phase 0 quick wins live here:
- Horizontal rule + turn number + timestamp at :meth:`start_turn`.
- :meth:`show_waiting` indicator that is cleared by the first
reasoning / content chunk.
- Compact :meth:`show_turn_summary` (one dim line) — full
per-iteration breakdown only when ``verbose`` is set.
- ``NO_COLOR`` / ``FORCE_COLOR`` honoured via the STYLE_* constants
in :mod:`oc_chat.core.config`.
Responsibilities
----------------
- :class:`ConsolePresenter` — concrete :class:`Presenter`
implementation backed by ``print``.
- :func:`_color_enabled` — env-var-based ANSI gating.
- All ``show_*`` event hooks for reasoning / content / tool / usage
/ turn-summary / compressed / welcome.
- :meth:`turn` returns a no-op ``contextmanager`` (no live region).
Diagnostics
-----------
Domain: OC_UI.TERMINAL
Levels:
L2 — lifecycle events
L3 — semantic details
L4 — deep tracing
Contracts
---------
- Output goes to ``stdout`` exclusively; diagnostics and warnings
live on ``stderr`` via ``oc_diagnostics``.
- ``NO_COLOR`` set (any value) disables every ANSI sequence.
- ``FORCE_COLOR`` overrides ``NO_COLOR`` and forces ANSI on.
- ``show_*`` hooks are append-only — the presenter never rewinds.
- Safe to use under CI / non-TTY: ``shutil.get_terminal_size`` is
used with a fallback when the size is undetermined.
Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_ui.presenter_base (Presenter ABC contract)
- oc_ui.terminal.activity (plan_progress_from_result for the plan progress line under planner results)
- oc_ui.terminal.diffview (mutation argument pairing and plain unified diff rendering for write_file and edit_file)
- oc_ui.terminal.turn_layout (turn indent, rule labels, answer box markers and line indenters)
- oc_chat.core.commands (lazy; _fmt_tokens_display for the session list table)
- oc_chat.core.formatting (lazy; format_duration for the turn summary)
- oc_chat.core.iteration_stat (lazy; iteration_stat_human_line for the per-iteration stats line)
- oc_chat.core.session (lazy; ChatSession type hint for show_welcome)
- oc_ui.terminal.statusline (lazy; StatusBarState type hint for bind_status)