Skip to content

Offer an appearance-aware comparison for screen goldens #105

In review

Description

@tony

Summary

Changing a named terminal color from red to teal produces different HTML and immutable appearance state. The boxed golden still says the screen is unchanged.

Motivation

Theme changes use OSC 4 without repainting individual cells. A visual assertion using only the symbolic color tokens cannot distinguish two different displayed colors.

From the tagged libvt checkout, install the locked development dependencies with uv sync --frozen --python 3.14 --all-groups --all-extras. Use the checkout root as the working directory.

Save the following as case.py at the checkout root and run uv run --no-sync python case.py.

from libvt import Terminal
from libvt.terminal import OutputFormat
from libvt.testing import serialize_vt_snapshot, vt_screen

terminal = Terminal(rows=1, cols=6)
terminal.feed(b"\x1b[31mBOARD")
original = terminal.committed
terminal.feed(b"\x1b]4;1;#16b3cd\x07")
new = terminal.committed
assert original.appearance != new.appearance
assert original.format(OutputFormat.HTML) != new.format(OutputFormat.HTML)
print("token golden equal", serialize_vt_snapshot(original) == serialize_vt_snapshot(new))
print("visual diff", serialize_vt_snapshot(vt_screen(new, diff=original)))

Evidence

libvt v0.0.1a4 and trunk 0864aa2, CPython 3.14.6, Linux ARM64 on WSL2.

Observed output
token golden equal True
visual diff (unchanged)

Proposal

Offer a selectable appearance check for committed default colors and palette overrides, or document a concise assertion of the resolved colors alongside the golden.

  • Developer experience — Theme tests can express visual intent without hand-comparing palette state separately for every snapshot.
  • Immediate benefit — An OSC 4-only update supplies an immediate regression case and a corresponding OSC 104 reset control.
  • Longer-term benefit — Stable symbolic snapshots and tests of user-visible theme rendering can coexist.
  • End-user experience — A theme regression that makes a team’s warning color unreadable can be caught before release.

References

Activity

  1. added
    enhancement
    p2
    on Nov 30, 2026
  2. tony commented on Dec 3, 2026

    @tony
    MemberAuthor

    The guide shows how to compare an effective color through the committed snapshot's palette. The fg=red cell resolves to (205, 0, 0), then (22, 179, 205) after the override, and back after reset. The retained middle snapshot keeps its color. PR #190

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions