Skip to content

fix(media): keep each index.md row on one line and show control characters as escapes - #8127

Merged
andybpan merged 1 commit into
mainfrom
fix/media-index-cells
Nov 18, 2026
Merged

andybpan merged 1 commit into
mainfrom
fix/media-index-cells

Conversation

@andybpan

Copy link
Copy Markdown
Contributor

What

.media/index.md cells now turn every line-ending character into a space, and show other control characters as visible \xNN escapes. Tabs are unchanged.

Why

The index generators turned only CR and LF in a record into a space. Vertical tab, form feed, NEL, U+2028 and U+2029 still split a row for readers that treat them as line breaks, and NUL, ESC, BEL and C1 characters reached the file as raw bytes.

Related work

Follows the line-break handling added to both generators in #8111.

How

  • One LINE_BREAKS pattern (\r \n \v \f U+0085 U+2028 U+2029) collapses to a single space, as CR/LF already did.
  • The result goes through the existing terminalText helper (core's terminalText.ts, and media-use's copy terminal-text.mjs), which writes control characters as \xNN and keeps tabs.
  • figma's mediaIndex.ts, media-use's index-gen.mjs and the skill copy skills/media-use/scripts/lib/index-gen.mjs change together, so their output stays byte-identical. skills-manifest.json picks up the skill's new hash.

Test plan

  • Unit tests added/updated
    • mediaIndex.test.ts: rows with U+2028, U+2029, NEL, VT and FF stay one line each; NUL, ESC, BEL, DEL and C1 appear as \xNN and tabs stay. Both fail before this change.
    • The existing byte-for-byte comparison with media-use's index-gen.mjs runs on the new rows and passes.
  • Manual testing performed: generated an index from rows carrying each of these characters; every row stays on one line and the output carries no raw control characters.
  • core figma suites (179 tests), media-use manifest and resolve suites, and check-media-use-copy-parity pass; lint, format, typecheck and both comment checks pass.
  • Documentation updated (if applicable): n/a, no command or flag changes.
  • Comments follow CONTRIBUTING.md "Comments".

…cters as escapes

The .media/index.md generators (figma's mediaIndex.ts and media-use's
index-gen.mjs) turned only CR and LF in a record into a space. Vertical
tab, form feed, NEL, U+2028 and U+2029 still ended a row early for
readers that treat them as line breaks, and other control characters
(NUL, ESC, BEL, C1) reached the file as raw bytes.

- Every line-ending character now becomes a space.
- Other control characters are written as visible \xNN escapes through
  the existing terminalText helper; tabs stay as they are.
- Both generators and the skill copy change together, so their output
  stays byte-identical.
@andybpan
andybpan marked this pull request as draft November 18, 2026 00:58
@andybpan
andybpan marked this pull request as ready for review November 18, 2026 01:00
@andybpan
andybpan marked this pull request as draft November 18, 2026 01:01
@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 44 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (2)

  • seqrepeat-none-center-r0-root-z100: tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true
  • seqfastkeys-none-px-r0-root-z100: error / tracking 0.06, pressJump 0.05, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0.05, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true

@andybpan
andybpan marked this pull request as ready for review November 18, 2026 01:01

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at 6b5ad36.

The copies match. The two index-gen.mjs copies (packages/cli/src/media-use/lib and skills/media-use/scripts/lib) have the same blob (2e6cf0a6ad5). The terminal-text.mjs they import is also the same blob in both places (7cd7d9b8). Its isControlCode is character-for-character core's terminalText.ts. mediaIndex.ts uses the same LINE_BREAKS pattern and core's terminalText, and the existing byte-for-byte test keeps the core and media-use outputs identical. The skills-manifest hash bump matches the changed skill file.

Escaping is right.

  • LINE_BREAKS folds CR, LF, VT, FF, NEL, U+2028 and U+2029 (plus surrounding whitespace) into one space before escaping, so none of them can start a new line of the index.
  • terminalText then escapes every remaining C0 control except tab, plus DEL and the whole C1 range (0x7f–0x9f). So ESC, BEL, NUL and the 8-bit CSI (\x9b) all come out as visible \xNN.
  • The new tests cover each line-break kind and each of those escapes, including a CSI colour sequence.

Nits, not blocking:

  • Bidi controls (U+202A–U+202E, U+2066–U+2069) and zero-width characters pass through unescaped. They aren't line breaks or C0/C1, so they're outside this PR's scope. But a description holding U+202E can still reorder how a row reads in a terminal or editor. If the index is meant to be safe to show as-is, adding those ranges to isControlCode in all three copies would cover it.
  • A | in a value still splits a markdown table cell. That predates this PR, and the index is read as text, so it's cosmetic.

@andybpan
andybpan added this pull request to the merge queue Nov 18, 2026
@andybpan
andybpan removed this pull request from the merge queue due to a manual request Nov 18, 2026
@andybpan
andybpan added this pull request to the merge queue Nov 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 18, 2026
@andybpan
andybpan added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit ebddc42 Nov 18, 2026
97 checks passed
@andybpan
andybpan deleted the fix/media-index-cells branch November 18, 2026 03: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.

2 participants