Skip to main content

Module render

Module render 

Source
Expand description

Pure, unit-tested formatting for the tcode CLI’s human-readable output (#2060).

Why: every subcommand handler in the binary needs to turn a wire-shaped Session/SessionEventEnvelope/TranscriptRecord into something a terminal user can read. Keeping the formatting logic here (rather than inline println!s scattered across the binary’s subcommand handlers) makes it independently unit-testable without spawning a subprocess, and keeps each handler a thin “call the client, print the result” wrapper. What: render_session_table (a fixed-width table for session list), render_event_line (one line per streamed SessionEventEnvelope, used by attach/run-task), render_transcript_human (a readable turn-by-turn view for transcript), and exit_code_for_status (maps a terminal SessionStatus onto the SAME run_task::ExitCode values the legacy in-process run-task path already used, so scripts checking $? see a consistent contract regardless of which path produced the run). Test: render::tests::*.

Functions§

exit_code_for_status
Map a terminal SessionStatus onto the CLI process exit code.
render_event_line
Render one line for a single streamed event, for attach/run-task.
render_session_table
Render a fixed-width table of sessions for tcode session list.
render_transcript_human
Render a TranscriptRecord as a readable turn-by-turn view for tcode transcript (human mode; --json bypasses this entirely and pretty-prints the raw result).