yera.console.console_renderer
ConsoleRenderer: owns all console output — lifecycle panels and content blocks.
Handles all inter-block whitespace, lifecycle panel printing, and content
block rendering so that the caller (stream_handler) never needs to call
console.print() directly.
Symbols
ConsoleRenderer
Owns all console output: lifecycle panels and content blocks.
Uses type-based match on BlockData for dispatch. Returns collected user input (if any) so the caller can decide how to handle it — no event stream side effects.
Whitespace contract
- Startup panel — printed first with no preceding whitespace.
- App panel — preceded by a blank line (terminating any pending content line first) and followed by a blank line before content.
- Between content blocks — a blank line is emitted whenever the
block_idchanges (i.e. a new block starts). - Markdown streaming — successive chunks with the same
block_idare printed withend=""so they concatenate on one line. - Non-markdown informational blocks (tables, actions, …) — printed with
the default
end(newline) which terminates the line. - Await-user blocks — the prompt prints with
end=""(the line is left unterminated), so_pending_newlineis set toTrue. - Exit panel — :meth:
print_exitterminates any pending content line, emits a blank separator, prints the panel, and adds a trailing blank line.
Methods
ConsoleRenderer.print_startup
print_startup(
start_time: datetime,
top_level_app_name: str | None = None,
) → NonePrint the Startup panel. No surrounding whitespace — it is the first output.
ConsoleRenderer.print_app
print_app(
app_id: str,
) → NonePrint the app Identity panel if the app has changed.
No-op when called with the same app_id that is already current.
Otherwise terminates any pending content line, emits a blank-line
separator, prints the panel, then emits another blank line before
subsequent content. Handles both the first-app case (after Startup)
and subsequent-app transitions.
ConsoleRenderer.print_exit
print_exit(
exit_data: ExitEventData,
run_time_seconds: float,
failing_app_name: str | None,
) → NoneFinalise content output and print the Exit panel with a trailing blank line.
ConsoleRenderer.print_event
print_event(
event: OutputEvent,
) → str | NoneRender an output event to the console.
Handles between-block blank lines, markdown streaming (end="" so
chunks stay on one line), and line termination for non-markdown blocks.
The caller must not emit any extra newlines after calling this.
ConsoleRenderer.finalise
finalise() → NoneTerminate any pending line and emit a blank line.
Called by :meth:print_exit before the Exit panel, or can be called
directly if the caller needs to insert a gap after the last content
block.