Skip to content

fix(platform): give code and text previews an editor's line rhythm - #3524

Merged
yannickmonney merged 2 commits into
mainfrom
fix/code-preview-typography
Sep 27, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
fix/code-preview-typography

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Problem

Backlog TALE-6 (triage 2026-09-27, T19): the document text preview and the skill asset viewer did not read like an editor.

  • Both viewers set leading-relaxed on the inline code, so the row height came out of the surrounding block instead. The highlighted path drew 12px text on 19.5px rows. The document preview's plain path (a .txt, or a code file over the highlight cap) drew 14px text, and the skill viewer's plain path drew 12px text on 24px rows. When the highlight landed, the file changed size. The preview-pane.tsx text skeleton used a third size.
  • The root cause of the loose look was in the .code-line-numbers gutter itself. It made every Shiki .line a block, but Shiki joins its lines with a literal newline. That newline became an empty line box after every source line, so a highlighted file was double-spaced: about 40px per row, measured in Chromium. With wrap on, a long line continued under the line numbers.
  • Both viewers passed the historical github-dark / github-light aliases to the highlighter.

Change

  • preview-pane.tsx exports previewCodeTextClasses (font-mono text-xs leading-5). It is set on the block, never on the inline code, in:
    • the highlighted and plain paths of document-preview-text.tsx
    • the highlighted and plain paths of skill-asset-viewer.tsx
    • the kind="text" skeleton
  • packages/ui/src/globals.css: a .code-line-numbers .line is now an inline-block row as wide as the pane (display: inline-block; width: 100%). The row ends at Shiki's newline, so there is no empty line box between rows. It carries a 3rem hanging indent (2rem gutter plus a 1rem gap), so a wrapped line continues under its own text. The only users of .code-line-numbers are these two viewers.
  • The two viewers and the chat code block (shared/markdown/code-block.tsx, which renders the fences of a .md asset or document) now pass min-light / min-dark. The resolved theme does not change.

Verification

  • New document-preview-text.browser.test.tsx and skill-asset-viewer.browser.test.tsx (vitest browser, Chromium, real Tailwind CSS). All 11 tests fail on origin/main with, for example:
    • expected '19.5px' to be '20px'
    • expected '14px' to be '12px'
    • expected 22.75 to be 20 (skeleton)
    • expected 72 to be 60 (3 plain rows)
    • expected +0 to be 48 (the wrapped continuation sits under the numbers)
    • the theme-name calls
  • With only the CSS reverted, the gutter tests still fail (expected 40 to be 20, expected +0 to be 48), so the CSS change is load-bearing on its own.
  • I also checked visually: screenshots of .ts, .json, .md and .txt in light and dark, with wrap on and off.
  • Other runs:
    • oxlint --type-aware on the changed files: clean
    • tsc --noEmit for @tale/platform: clean
    • UI-lane (jsdom) tests for documents, skills and shared markdown: 23 + 12 files pass
    • browser tests for documents, skills and page skeletons: pass
    • @tale/ui globals.test.ts and markdown tests: pass
    • bun run lint:manual and check-guide.ts on both suites: OK

Manual layer

  • KNOW-F30 (knowledge) and SKILL-F14 (skills) cover how both viewers look in light and dark.
  • reference/automation.md has a row naming the two specs that own the geometry.

Open

  • The gutter numbers keep their existing muted-foreground at 50% opacity. That contrast is low, and whether to raise it is a design decision this change does not take.
  • @tale/ui's highlightCode still accepts the github-* aliases for other consumers. No caller in this repo passes them any more.

The document text preview and the skill asset viewer set their type on
the inline `code` with leading-relaxed: the highlighted path drew 12px
text on 19.5px rows, the document preview's plain path 14px text, and
the skill viewer's plain path 12px text on the block's own 24px rows.
Worse, `.code-line-numbers` made each Shiki `.line` a block while Shiki
joins them with a literal newline, so every source line was followed by
an empty line box and a highlighted file read double-spaced (about 40px
per row); with wrap on, a long line continued under the numbers.

Both viewers, their highlighted and plain paths and the text skeleton
now share one `previewCodeTextClasses` (mono text-xs, leading-5) set on
the block. A `.line` is an inline-block row that ends at Shiki's newline
and hangs its wrapped continuation 3rem in, past the gutter. The
highlighter is asked for `min-light` / `min-dark` by name in both
viewers and the chat code block instead of the github aliases.

Browser specs pin the 20px row, one row per line, the hanging indent
with wrap on and off, the skeleton's row height and the theme names;
KNOW-F30 and SKILL-F14 keep the light/dark look manual.
@yannickmonney
yannickmonney merged commit 0bd041d into main Sep 27, 2026
50 checks passed
@yannickmonney
yannickmonney deleted the fix/code-preview-typography branch September 27, 2026 22:24
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