Repository navigation
fix(cli): figma commands print manifest and folder text with visible escapes - #8126
michaelwang11394 wants to merge 2 commits into
Conversation
…escapes figma asset prints a manifest row's id, path and description, and the <img> snippet built from them. These lines, the index.md regeneration warning and the tokens 'wrote' line now go through terminalText, so control characters show as visible escapes. The manifest file and the returned records are unchanged.
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 414211afc9b3dafcfec25e54c420f8ba02e8eecc.
Approve. The four print sites that can carry project text now go through terminalText from @hyperframes/core:
- the
reused/importedline - the
<img>snippet - the
index.md regeneration failedwarning - the
figma tokenswroteline
The escaping happens only when the line is printed. runAssetImport, runAssetImportMany and the manifest bytes are untouched, and the first test pins the manifest bytes.
Coverage, checked:
- I listed every
console.*call undercommands/figma. The other lines inasset.tsandtokens.tsprint counts or fixed text. - In
component.ts:- The rasterize warning already went through
terminalText. - The
imported componentline prints aslugifyd name and anhtmlPathrelative to the project folder. - The overwrite warning prints only the slug.
- The rasterize warning already went through
- Errors go through
withFigmaErrors→errorBox, which already escapes the title (terminalText) and the hint (terminalLines). - The PR body's claim that
figma componentneeded no change holds.
Need: real, since a received project's manifest row can rewrite the terminal on a reuse · Size: right, +8 source lines · Reuse: the existing terminalText · Simpler: no · Structure: fine
Risk: low. The change is output only, and plain text prints the same.
Tests (npx vitest run src/commands/figma in packages/cli, after the hf-oss build recipe):
- Head: 50/50.
- 4 mutants, one per site, each reverting that site to a raw print. Each one turns its own test red:
- The reuse line: red.
- The snippet alone: red. The
alt=assertion catches it even with the line above it escaped. - The index warning: red.
- The tokens line: red.
CI: 13 pass, 20 skipped, 26 still pending when I posted.
— Rames
|
The Windows lane failed twice on the three new tests in |
eddy-heygen
left a comment
There was a problem hiding this comment.
(Eddy's agent) Reviewed by Eddy's Claude agent at commit dc7558f.
Verdict: approved.
Summary. Three places in the design-import commands printed text taken from a manifest, a folder path or an error message straight to the terminal. I read the whole diff: each now passes through the existing helper that shows control characters as visible escapes, so a name cannot move the cursor, recolour or overwrite earlier output. The tests cover a manifest row, an index regeneration failure that names the project folder, and the tokens file path.
No blocker found.
Non-blockers:
- The new test file is skipped on Windows. The helper is platform-neutral, so the behaviour is the same there; the skip only means that platform does not exercise these three call sites.
- The JSON block printed after the tokens file path is produced by the JSON encoder, which already escapes control characters, so it does not need the helper.
CI: 51 pass, 19 skipped, none failing or pending.
How this was reviewed: I read the diff myself. Nothing was built or run.
What
hyperframes figma assetandhyperframes figma tokensnow print text that comes from the project with control characters shown as visible escapes, such as\x1b.Why
When
figma assetreuses an asset it already imported, it prints theid,pathanddescriptionfrom the project's.media/manifest.jsonl, plus an<img>snippet built from them. A project folder from someone else can put terminal control sequences in those fields. Printed raw, they can forge or overwrite earlier terminal lines or change the window title. The CLI already escapes other project text this way withterminalText.Related work
None.
How
figma assetpasses thereused/importedline and the snippet throughterminalTextfrom@hyperframes/corewhen it prints them.index.md regeneration failedwarning goes throughterminalTexttoo, because its message names paths under the project folder.figma tokenspasses itswrote <path>line throughterminalText, because that path starts from the project folder.index.mdand the records thatrunAssetImportandrunAssetImportManyreturn are unchanged.figma componentneeded no change. Its one warning built from Figma node names was already escaped, and the other lines print slugged names and paths relative to the project folder.No visible change
Output for normal text is the same. Only control characters, which print as visible escapes now, look different.
Test plan
New
packages/cli/src/commands/figma/terminalOutput.test.tsruns the real commands through citty with a stubbed Figma client:id,pathanddescriptioncontain ESC, BEL, CR and C1 bytes, with provenance that matches the request, takes the reuse path. The output has no raw control bytes, it shows the visible escapes, and the manifest bytes are unchanged..medialink that makesindex.mdregeneration fail, prints the warning with visible escapes.figma tokensrun in a project folder whose name contains control characters prints thewrotepath with visible escapes.fails without the fix: with the old
asset.tsandtokens.ts, all 3 new tests fail on raw control bytes in the output.Also run: figma command tests (50 pass), the
terminalTextparity test inmedia-useand the coreterminalTexttests,tsc --noEmitfor cli (no new errors), oxlint,oxfmt --check, the comment ratchet and fallow.