Skip to content

fix(cli): a theme warning prints as one line without control characters - #10764

Merged
cixzhang merged 1 commit into
mainfrom
lane4/cli-theme-warning-printable
Nov 9, 2026
Merged

cixzhang merged 1 commit into
mainfrom
lane4/cli-theme-warning-printable

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

User impact

Someone who runs astryx component in a checkout they do not control sees a theme warning when the configured theme does not load. That warning printed the checkout's astryx.theme value as written, so a value with a newline or a terminal escape sequence could add fake lines or rewrite the terminal. Now every theme warning prints as one inert line: control and format characters show as �.

Problem and solution fit

The warning interpolates a value the checkout controls straight into terminal output. The fix replaces only the characters that a terminal acts on, so the warning keeps its meaning and stays readable.

Smallest restoration

resolve-theme.mjs sends every theme warning through one warnTheme helper that replaces Unicode control (Cc) and format (Cf) characters with U+FFFD. This covers the astryx.theme field and the generated theme record, which also comes from the checkout. What loads, and when, is unchanged.

Expected behavior and authority

Consistency with spec:AST-050 FR3: the astryx.theme field keeps its released meaning, and only how a warning prints changes. No record change.

Evidence

  • Reproduction before the change: on main, astryx.theme: "@evil/<ESC>]0;owned<BEL> pkg" prints the warning with the raw escape sequence and a line break.
  • Result after the change: the same value prints ⚠ theme: could not resolve package "@evil/�]0;owned��pkg" on one line.
  • Representative unchanged path: a plain value such as ./legacy.cjs loads and warns exactly as before; the existing package-field and generated-record cases are unchanged.
  • Regression test or other mutation-sensitive proof: the new resolveTheme warnings cases fail if a warning bypasses warnTheme.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Credit

This carries the warning hardening from #5525 by @bhamodi (co-author), which Robohands flagged in review on that PR. #5525 was closed as superseded by #6874 and AST-050 FR3; this is the part that still applies.

Testing

  • New resolveTheme warnings cases cover a file path, a scoped package and a bare name with escape sequences, a newline, a carriage return and a bidi override. Each prints one warning with no control or format characters.
  • Checked directly in Node: @evil/<ESC>]0;owned<BEL>\npkg prints as ⚠ theme: could not resolve package "@evil/�]0;owned��pkg".
  • Provenance and changeset coverage checks pass. The CLI node suite runs in CI.

The configured astryx.theme value and the generated theme record come
from the checkout. Every theme warning now replaces control and format
characters with U+FFFD, so a newline or an escape sequence cannot
rewrite the terminal.

Carries the warning hardening from #5525.

Co-authored-by: Baraa Hamodi <[email protected]>
@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 9, 2026 8:45am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 9, 2026
@astracat-bot

astracat-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 9, 2026, 9:27 AM UTC

@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 7740d42

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: the test jobs are still running on this head.

Theme warnings from astryx component now print the configured astryx.theme value and a generated record's owner as one line, with control and format characters shown as �; which theme loads is unchanged. The new cases fail without the fix and pass with it.

  • Optional: the generated-record warning (resolve-theme.mjs:114) and the "could not find a theme object" warning (:91) have no test that keeps them on warnTheme; a case with a record owner that holds control characters would lock the path the changeset names.

[Automated review]

it.each([
['a file path', './\u001b[2Jmissing.cjs'],
['a scoped package', '@evil/\u001b]0;owned\u0007\npkg'],
['a bare name', 'theme\u202e\r\nnext'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking: these rows cover the three package-field warnings. The generated-record warning (resolve-theme.mjs:114) and the no-theme-object warning (:91) also go through warnTheme, but nothing fails if either goes back to console.warn. A case whose generated record names an owner such as '@evil/\u001b]0;x\u0007\npkg' would lock the record path the changeset mentions.

@cixzhang
cixzhang marked this pull request as ready for review November 9, 2026 09:16
@cixzhang
cixzhang merged commit 16436be into main Nov 9, 2026
115 checks passed
@github-actions
github-actions Bot deleted the lane4/cli-theme-warning-printable branch November 10, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 7740d424 Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant