Skip to content

TUI rich display mode: type glyphs for descriptions and tables for data rows #15

Description

@sunng87

Goal

Add a TUI-only rich display mode that renders selected message types with a custom, structured style instead of the flat line form. A toggle switches between the current line view and the rich view.

Rich rendering

  1. RowDescription / ParameterDescription — render each columns data type with a type glyph/icon alongside the type name, keyed on the OIDs in FieldSummary.type_oid (src/decode.rs:35). Map well-known OIDs to glyphs, e.g.:

    • int2/int4/int8#-like numeric glyph
    • float4/float8/numeric → decimal glyph
    • text/varchar/bpchar/name → text glyph
    • bool → checkmark
    • json/jsonb → braces glyph
    • uuid → fingerprint/uuid glyph
    • bytea → byte/hex glyph
    • timestamp/timestamptz/date/time/interval → clock glyph
  2. DataRow — render consecutive rows sharing a column set as an aligned table/grid using ratatuis Table widget, with the column headers and type glyphs coming from the preceding RowDescription.

Glyph reliability (must address)

Terminals cannot render FontAwesome glyphs reliably — it depends on the users font having the codepoints. Decisions to make and document in this issue:

  • Whether to target Nerd Font codepoints (common in dev fonts) or plain Unicode symbols, or both with a config/env override.
  • A fallback for missing glyphs (font detection is unreliable, so prefer a safe textual abbreviation, e.g. int4, when the glyph is disabled or a --no-glyphs/env flag is set).
  • Do not depend on the glyph for correctness — the type name/OID must still be present.

Table batching (design point)

Rendering DataRow as a table requires grouping consecutive DataRow messages that share the same column set (the most recent RowDescription). Today each DataRow is emitted as an independent event (src/decode.rs:667), so the rich renderer must accumulate DataRows under their current RowDescription until the set ends (next RowDescription, CommandComplete, EmptyQueryResponse, portal suspended, or connection close). Note column sets can change mid-stream (a new query reuses the portal); the grouping logic must reset on a new RowDescription. This is the main behavioural difference from the line view.

Wide data

Tables can exceed terminal width. Decide on behaviour: truncate cells with an ellipsis, allow horizontal scroll, or fall back to the line view when the table does not fit. Keep it simple initially.

Toggle

  • A new normal-mode keybinding (e.g. r) to toggle rich mode, plus a --tui-rich startup flag (or --rich).
  • Since TUI command bar: interactive command/input line in the bottom section #14 introduces input mode and slash commands, also expose this as a :set rich / :set norich slash command. The keybinding is the primary entry point; the slash command is the consistent one.
  • Default: off, so existing behaviour is unchanged.

Scope

TUI only. The line-oriented stdout output (pcap/mitm without --tui) is unaffected.

Notes

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions