Repository navigation
fix(cli): preserve Unicode edge whitespace in Markdown tables - #8915
Conversation
[Medium impact] The PR appears safe to merge; no new actionable issue was found. SummaryPreserves Unicode whitespace at Markdown table edges through the shared cell encoder.
Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." · Reviewed by Greptile |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
CI triage for
I cannot re-run the failed jobs from this account ( |
|
Refreshed onto On the red at Local check after the merge (Windows 11 x64, Node 22.22.2, |
|
Checked that this is still needed against current Method: clean worktree on The seven failures are exactly the ones this PR adds or tightens — five parameterised edge-spacing cases in So the other two fixes touch different paths and the gap this PR closes is still open on CI on the current head is green after the refresh to |
Summary
Fixes #8913. Preserve Unicode edge whitespace in rendered Markdown table headers and values instead of collapsing distinct caller-supplied facts.
Problem and expected behavior
"\u00a0name"and"name"previously both rendered asname; values with leading/trailing U+00A0, U+202F, or U+2003 also lost those characters. Rendered table text should retain the original spelling, just like existing ASCII-space/tab protections.Change and scope
Use the shared table-cell encoder to protect edge whitespace with numeric entities after escaping literal input. Protect Unicode separators (
\p{Z}) and BOM alongside the existing ASCII spaces/tabs. Leave other ASCII control characters unchanged rather than introducing character references the renderer may reject. Keep internal whitespace, literal entity strings, JSON output, and paragraph matching unchanged. Locate the two whitespace edges with one forward/backward scan after escaping, rather than retrying a trailing regular-expression match at every suffix. No new dependency or downstream repair path.Contract and boundary impact
src/cli/cliOutputFormatter.ts; consumers are table headers/body cells, standalone reports, and validation-error field cells through the existing shared encoder.Evidence and regression coverage
Extended existing compiled CLI → VitePress → parse5 regression: distinct Unicode/plain keys and values (NBSP, narrow NBSP, em space, line/paragraph separators, and BOM), all-whitespace cells, mixed whitespace, internal NBSP, literal
 , and unchanged saved Evidence/JSON. The same test checks standalone reports.Extended the shared validation-error/redaction regression with NBSP/tab/narrow-NBSP edges while preserving secret redaction and JSON values.
Before the production fix: compiled CLI selection had 1 failed / 8 passed, showing stripped Unicode and key/value collisions. The updated validation-error consumer separately failed on the unprotected NBSP/tab edge (1 failed / 3 passed).
Applicable boundary regressions: raw identity/normalization, empty and unusual source names, and public result/error projection. No lifecycle behavior changes.
Representative outcome: rendered
"\u00a0name"now remains distinct from"name";"\u202fvalue\u202f"retains both edge characters.Added 10 shared-encoder cases for empty/all-whitespace input, internal spacing, emoji, escaped entity text, NUL/CRLF, and VT/FF barriers.
P1 performance follow-up: added a compiled CLI → VitePress → parse5 regression with 240,000 internal mixed NBSP/narrow-NBSP/em-space characters in both a header and a value. The parent process enforces a 20-second CLI deadline, so a synchronously blocked child cannot swallow the timeout. The previous head exceeded that deadline; the fixed regression passed in 610 ms locally, retaining the exact header/value and saved Evidence.
Local producer measurement on Node 24.22.1: an 80,000-NBSP internal run took 3,516 ms before and 0.046 ms after, with unchanged encoded output. These are individual local observations, not a portable timing guarantee or the test's performance threshold.
Validation performed
Node 24.22.1 / npm 11.16.0, macOS 26.6.2 arm64. Validated commit:
f62a9ad7eddac21a2ba897e945bfa86463088ade(pre-commit hooks left the tested file contents unchanged).npm run test:focused -- tests/boundary/cli/cliOutputFormatter.test.ts tests/boundary/cli/markdownLiteralCells.test.ts tests/boundary/cli/markdownArgumentErrors.test.ts tests/boundary/cli/markdownNestedFacts.test.ts tests/acceptance/markdownMissingSelectionWindow.test.ts— 34 passed, 5 files; builds the current runtime first.npm run check— passed: typecheck, lint, formatting, Knip, metadata, architecture guards, production reachability report, and typed lint (no errors; repository warnings/advisories remain).git diff --check— passed.Compatibility, safety, and release
No API/schema migration, generated metadata, dependency, or release-version change. No external reverse-engineering provider is involved. Windows/Linux and the full repository test suite were not run locally; CI remains authoritative for those lanes. AI assistance was used. The human owner has completed the review and author readiness declaration; no maintainer approval is claimed.
Author readiness
Human owner: @gongfpp
Before merge
type(scope): outcome.