Skip to content

feat(ui): Colorize Ledger Diffs (Green/Red) with Legend - Issue #1010#1092

Open
ezedike-evan wants to merge 4 commits intodotandev:mainfrom
ezedike-evan:feat/Colorize-ledger-diffs
Open

feat(ui): Colorize Ledger Diffs (Green/Red) with Legend - Issue #1010#1092
ezedike-evan wants to merge 4 commits intodotandev:mainfrom
ezedike-evan:feat/Colorize-ledger-diffs

Conversation

@ezedike-evan
Copy link
Copy Markdown
Contributor

feat(ui): Colorize Ledger Diffs (Green/Red) with Legend - Issue #1010

DESCRIPTION:

Overview

Extends the State Diff panel with full-row ANSI colour coding that is legible
on both light and dark terminal themes, and adds a persistent legend line at
the bottom of the panel.

Changes

Core Implementation

  • styles.go (internal/ui/styles.go): New centralised styling module

    • Bold + colour combined SGR sequences (\033[1;32m etc.) — the same codes
      tcell uses internally, compatible with any tcell-capable terminal
    • DiffLegend() returns a colour-coded one-line legend string
    • NoColor global for piped/non-TTY output
    • styleMap makes adding new styles a one-line change
  • StatePanel (internal/ui/widgets/state_panel.go): Full-row colouring

    • DiffKind.valueStyles() — returns (oldStyle, newStyle) per kind:
      • DiffAdded: old empty, new bold-green
      • DiffRemoved: old bold-red, new empty
      • DiffChanged: old dim-red (secondary/was), new bold-green (primary/now)
      • DiffSame: both dim (recedes visually, not a change)
    • Bold variants (bold-green, bold-red, bold-yellow) ensure legibility
      on light-background terminals where plain colours wash out
    • dim-red for "before" values in changed rows provides clear visual
      hierarchy without losing the information
    • Lines() updated: oldVal and newVal colourised via valueStyles();
      selected row uses bold-cyan for high-contrast highlight
    • Legend row always rendered as the last line of the panel; when entries
      overflow, scroll position is prepended: ─ 1–20 of 47 Legend: [+]…
    • dataRows reduced by 1 (maxRows - 3) to permanently reserve the legend
    • Local Colorize() re-export extended with bold-* and dim-* variants
      to match styles.go without introducing a circular import

Colour Scheme

  • key_a │ │ "new_value" ← bold green (added)
  • key_b │ "old" │ ← bold red (removed) ~ key_c │ "was" │ "now" ← dim-red / bold-green (changed) key_d │ "same" │ "same" ← dim (unchanged)

## Related Issues
Closes #1010

Type of Change

  • New feature

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • No new linting issues
  • Changes verified locally

- Add internal/ui/keys.go — Key type, KeyReader parsing raw stdin bytes
  and ANSI CSI escape sequences; TermSize() with $COLUMNS/$LINES fallback
- Add internal/ui/layout.go — SplitLayout with ToggleFocus (Tab), left/right
  pane widths from SplitRatio, SIGWINCH listener via ListenResize(), side-by-
  side Render() zipping pre-built pane lines with │ divider; focused pane
  marked in border header
- Add internal/ui/trace_view.go — TraceView wiring TreeRenderer to a state
  key-value table; HandleKey dispatches to focused pane; refreshState rebuilds
  table from selected node on every tree navigation event
- Add internal/ui/widgets/state_panel.go — DiffKind (added/removed/changed/same),
  ComputeDiff() diffs ExecutionState.HostState maps; StatePanel renders a
  3-column table (indicator│Key│Old Value│New Value) with colour coding,
  proportional column widths, scrolling, and a Summary() status line
- Add internal/ui/styles.go — centralised ANSI colour constants, Colorize(),
  NoColor global, DefaultBorder; widgets package exports its own copy to
  keep the dependency graph acyclic
- Update internal/ui/layout.go — add PaneDiff pane constant, ShowDiff field,
  ToggleDiff(), MiddleWidth()/RightWidth() for three-pane column arithmetic,
  extend Render() signature to accept leftLines/middleLines/rightLines
- Update internal/ui/trace_view.go — add diffPanel field and etrace param to
  NewTraceView; refreshDiff() wires ExecutionTrace steps to StatePanel.SetStates;
  HandleKey routes KeyDiff to ToggleDiff and PaneDiff nav to panel scroll
- Update internal/ui/keys.go — add KeyDiff constant, map 'd'/'D' to it
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 30, 2026

@ezedike-evan Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Copy link
Copy Markdown
Owner

@dotandev dotandev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.

@dotandev
Copy link
Copy Markdown
Owner

fix ci.

@ezedike-evan
Copy link
Copy Markdown
Contributor Author

looks good.

than you chief

@ezedike-evan
Copy link
Copy Markdown
Contributor Author

fix ci.
i have resolved the CI error

Screenshot From 2026-03-30 13-05-05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants