oc_chat
Loading...
Searching...
No Matches
oc_chat.scripts.render_turn_layout Namespace Reference

Functions

 _stat ()
 _status_state ()
None _frozen_clock (presenter, str ts)
str render (str kind, int width)
int main (list[str]|None argv=None)

Variables

str SESSION_START_TS = "02:13:32"
str TURN_TS = "02:13:37"
str TURN_END_TS = "02:13:40"
str MODEL = "z-ai/glm-5.3-flash"
tuple ANSWER
tuple SECURITY_LINE
tuple PROMPT_TOOLKIT_LINE

Detailed Description

Render one scripted chat turn to a file — the plan-218 acceptance capture.

Purpose
-------
Plan 218's acceptance target is the operator's layout mock at
``docs/architecture/Terminal output layout Improvements.txt``. Proving a
render matches it needs a DETERMINISTIC capture of the same event
sequence, taken twice: once on the pre-218 tree and once after, so the
report can show them side by side.

This script drives a presenter through exactly the mock's sequence —
welcome banner, the two pre-turn notices, the session-start rule, the
prompt echo, one streamed answer, the per-iteration metadata, and the
turn-end rule — with every clock-dependent value injected, so two runs
differ only where the LAYOUT differs.

It runs unchanged on a pre-218 tree: hooks plan 218 adds are called
through ``getattr`` guards, so the "before" capture is taken with the
same script as the "after" one.

Responsibilities
----------------
- :func:`render` — drive one presenter and return the captured text.
- :func:`main` — write the rich and plain captures to a UTF-8 file.

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 — lifecycle events
    L3 — semantic details
    L4 — deep tracing

Contracts
---------
- Deterministic: timestamps, token counts and durations are fixed
  literals; the only variable is terminal width, which is a parameter.
- Console output is ASCII-only (the capture itself is UTF-8 and goes to
  the ``--out`` file) so the script is safe under a cp1252 console.
- Read-only with respect to the app: it constructs presenters directly
  and never touches a session, the registry, or the network.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- rich.console (lazy; Console, which renders the rich capture into a string buffer at a fixed width)
- oc_chat.core.iteration_stat (lazy; IterationStat, the pinned record the per-iteration metadata line reports)
- oc_ui.terminal.statusline (lazy; StatusBarState, the pinned status snapshot bound to each presenter)
- oc_ui.terminal.rich_presenter (lazy; RichPresenter, the rich presenter under capture)
- oc_ui.terminal.presenter (lazy; ConsolePresenter, the plain presenter under capture)
- oc_ui.terminal.input (lazy; build_prompt_prefix for the prompt echo line)
- rich.text (lazy; Text, so the prompt echo prints without markup parsing)

Function Documentation

◆ _frozen_clock()

None oc_chat.scripts.render_turn_layout._frozen_clock ( presenter,
str ts )
protected
Pin the presenter's rule clock so timestamps are reproducible.

``_now_ts`` is the presenters' one wall-clock read for rule labels
(plan 218). On a pre-218 tree the attribute does not exist and the
capture simply carries real timestamps — the layout comparison the
"before" capture exists for is unaffected.

Definition at line 124 of file render_turn_layout.py.

Here is the caller graph for this function:

◆ _stat()

oc_chat.scripts.render_turn_layout._stat ( )
protected
The single iteration record the mock's metadata line reports.

Definition at line 93 of file render_turn_layout.py.

Here is the caller graph for this function:

◆ _status_state()

oc_chat.scripts.render_turn_layout._status_state ( )
protected
The bound status snapshot the running total and status bar read.

Definition at line 110 of file render_turn_layout.py.

◆ main()

int oc_chat.scripts.render_turn_layout.main ( list[str] | None argv = None)
Write the rich + plain captures to ``--out`` and report the path.

Definition at line 197 of file render_turn_layout.py.

Here is the call graph for this function:

◆ render()

str oc_chat.scripts.render_turn_layout.render ( str kind,
int width )
Drive *kind* (``"rich"`` / ``"plain"``) through the scripted turn.

Definition at line 136 of file render_turn_layout.py.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ANSWER

tuple oc_chat.scripts.render_turn_layout.ANSWER
Initial value:
1= (
2 "Hello. I'm ready to help with your Option C project - code, tests, git, "
3 "quality gates, or planning. What would you like to work on?\n"
4)

Definition at line 79 of file render_turn_layout.py.

◆ MODEL

str oc_chat.scripts.render_turn_layout.MODEL = "z-ai/glm-5.3-flash"

Definition at line 78 of file render_turn_layout.py.

◆ PROMPT_TOOLKIT_LINE

tuple oc_chat.scripts.render_turn_layout.PROMPT_TOOLKIT_LINE
Initial value:
1= (
2 "[prompt_toolkit enabled - Tab completes commands, up/down cycles history, "
3 "Alt+Enter inserts newline, Ctrl+P opens command palette]"
4)

Definition at line 87 of file render_turn_layout.py.

◆ SECURITY_LINE

tuple oc_chat.scripts.render_turn_layout.SECURITY_LINE
Initial value:
1= (
2 "[security] permissive profile: the agent runs in-process with your "
3 "account's authority. Use the 'guarded' profile for less-trusted projects."
4)

Definition at line 83 of file render_turn_layout.py.

◆ SESSION_START_TS

str oc_chat.scripts.render_turn_layout.SESSION_START_TS = "02:13:32"

Definition at line 75 of file render_turn_layout.py.

◆ TURN_END_TS

str oc_chat.scripts.render_turn_layout.TURN_END_TS = "02:13:40"

Definition at line 77 of file render_turn_layout.py.

◆ TURN_TS

str oc_chat.scripts.render_turn_layout.TURN_TS = "02:13:37"

Definition at line 76 of file render_turn_layout.py.