Skip to content

[cardano-testnet] Modify renderStatusReportHumanReadable to return Doc Ann instead. #6746

Open

Description

@palas

renderStatusReportHumanReadable builds the report as a String: lines are joined with <> and unlines, and renderTable pads cells with pad and replicate. That one function decides the content, where lines break and how the output looks, so changing any of these (wrapping, colour, embedding a pretty-printed error) means rewriting string code. cardano-testnet already uses cardano-api's pretty-printing API (prettyError, docToString, docToText, pshow) and depends on prettyprinter, so the report could be a Doc Ann instead.

What prettyprinter gives here:

  • Layout is separate from content. A Doc describes the content and where lines may break. A layouter (layoutPretty, layoutSmart) turns it into a SimpleDocStream for a given page width, and a renderer turns that into Text. The report code no longer decides where lines end.
  • Line breaks depend on the available width. group, softline and flatAlt keep the summary line or the no-testnet explanation on one line when it fits, and break it when it does not. hang and align indent the continuation relative to the column where it started, so it lines up without counting the prefix length.
  • The renderer interprets annotations. Mark a node state as an error once with annotate. cardano-api's docToText uses the ANSI terminal renderer and shows it in colour, while unAnnotate gives plain text for goldens, pipes and log files. The layout code is the same for both.
  • It composes with existing Docs. cardano-api errors already render as Doc Ann (prettyError, prettyException), so a node's probe error could go into the report as it is, instead of being flattened to a String first. Pretty instances for NetworkStatus and NodeState can be reused the same way.

Today's report is short and has no colour, so these gains show once it grows, for example with the probe error from my comment on line 164.

A rough path:

  1. Return Doc Ann from renderStatusReportHumanReadable (both types come from Cardano.Api), and give NetworkStatus and NodeState Pretty instances.
  2. Build lines with pretty, <+> and vsep. Use group with softline, and hang, where a line can get long.
  3. In renderTable, keep the width calculation and replace pad width cell with fill width (pretty cell) from Prettyprinter. prettyprinter has no table combinator, so the borders stay hand-built.
  4. Render at the edges: docToText where Run.hs prints the report. If colour is added, apply unAnnotate before rendering in the golden test and when stdout is not a terminal.

Originally posted by @carbolymer in #6741 (comment)

Activity

  1. self-assigned this
    on Oct 26, 2026
  2. changed the title [-]Modify `renderStatusReportHumanReadable` to return `Doc Ann` instead.[/-] [+][cardano-testnet] Modify `renderStatusReportHumanReadable` to return `Doc Ann` instead.[/+] on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions