Skip to content

fix(model): line the card's values up in one column - #46

Merged
stanlyzoolo merged 2 commits into
mainfrom
fix/card-info-alignment
Jul 28, 2026
Merged

fix(model): line the card's values up in one column#46
stanlyzoolo merged 2 commits into
mainfrom
fix/card-info-alignment

Conversation

@stanlyzoolo

Copy link
Copy Markdown
Owner

The [info] and [notes] sections each indented their values differently — [notes] labels were padded to 8 by ui.MetaDetailLabelStyle, [info] labels were not padded at all — so every line started its value at its own column.

Before / after (the two-space gap on installed:/latest: is the version glyph, invisible without a nerd font):

repo: github.com/BurntSushi/ripgrep      repo:        github.com/BurntSushi/ripgrep
stars: 52.3k                             stars:       52.3k
installed:  14.1.0                       installed:    v14.1.0
latest:  v14.1.1 ↑ (2026-01-02)          latest:       v14.1.1 ↑ (2026-01-02)
languages: rust 95%                      languages:   rust 95%  shell 5%
maintenance: ● active                    maintenance: ● active

status:  ● active                        status:      ● active
note:    recursive search, use inste     note:        recursive search, use instead
ad of grep                                            of grep
tags:    search                          tags:        search

What changed

  • One value column. cardLabel pads every label to cardLabelWidth (len("maintenance:")+1, the widest label the card can print) — the single definition of the column. ui.MetaDetailLabelStyle lost its Width(8) so the two cannot drift.
  • Wrapped values fit and hang. note/tags wrap to inner - cardLabelWidth instead of the full inner: the first line used to run a label's worth of cells past the panel edge, where the viewport truncates (it does not soft-wrap). Continuations go through hangIndent and sit under the value column instead of column 0.
  • installed: and latest: spell versions the same way. Both print through the new version.DisplayVersion, which puts a v in front of a bare version number — a tool's --version says 1.10.2 where its release is tagged v1.10.2. It edits nothing else: canonSemver only decides whether the string is a version number (nightly, cli-2.0 pass through), and its own output is deliberately not displayed since it drops zero-padding, a 4th segment and build metadata.

Accepted cost

At the 80×24 baseline the brief panel is 30 cells wide, so the column spends 13 of them and a long repo: value is truncated sooner than before (the latest: line with its date suffix already overflowed at that width).

Tests

  • TestCardValuesShareOneColumn — walks every label: line of a fully-populated card, fails on any value starting elsewhere; a completeness check keeps the fixture covering every gated line.
  • TestCardNoteWrapsUnderItsLabel — wrap width and hanging indent.
  • TestDisplayVersion — the v is the only edit; zero-padding, a 4th segment and build metadata survive verbatim, non-versions pass through.
  • Both new render tests were mutation-checked (hardcoding one label back, restoring the full-width wrap) — each fails as intended.

Preflight green: go build / go vet / go test -race ./... / golangci-lint run (0 issues).

🤖 Generated with Claude Code

stanlyzoolo and others added 2 commits July 28, 2026 12:12
Every "label: value" line in [info] and [notes] pads its label through
cardLabel to the single cardLabelWidth, so the values stop stepping in
and out by a few cells each. ui.MetaDetailLabelStyle lost its Width(8):
it padded the [notes] labels while [info] had no padding at all, which
is exactly what made the two sections disagree.

The two wrapped values (note, tags) wrap to inner-cardLabelWidth instead
of the full inner width — the first line used to run one label's worth
of cells past the panel edge, where the viewport truncates it — and
their continuations hang under the value column via hangIndent instead
of falling back to column 0.

installed: and latest: both print through version.DisplayVersion, which
puts a v in front of a bare version number: a tool's --version says
1.10.2 where its release is tagged v1.10.2, so the same binary read as
two different things. It edits nothing else — canonSemver only decides
whether the string is a version number at all, and its own output is
deliberately not what gets displayed, since it drops zero-padding, a 4th
segment and build metadata.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The value column costs 13 of the 28 cells the brief panel has at the
80x24 baseline, which is where "repo: github.com/owner/name" was cut
mid-name. The host is implied, so the value now shows the bare
owner/repo from loader.NormalizeRepo and the line comes out 4 cells
shorter than it was before the column existed.

The link is untouched: it stays "https://" + t.GitHub, exactly what [o]
opens. A ref NormalizeRepo rejects — an unsupported or spoofed host like
github.com.evil.com/x/y — renders in full instead, since shortening
exactly there would hide the host that makes the link not what it looks
like.

Also names a known gap in TestCardNoteWrapsUnderItsLabel: it measures
display cells while wrapText counts runes, so its ASCII fixture is
deliberate — a CJK note still overflows, which is wrapText's limitation
and not the value column's.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@stanlyzoolo
stanlyzoolo merged commit 11b44a8 into main Jul 28, 2026
3 checks passed
@stanlyzoolo
stanlyzoolo deleted the fix/card-info-alignment branch July 28, 2026 10:44
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.

1 participant