fix(cli): ASCII glyph fallback for Windows console mojibake (#168)#178
Merged
Conversation
The shimmer progress renderer writes from a worker thread via `fs.writeSync(1, ...)` to keep the animation smooth while the main thread is busy in SQLite. That path bypasses Node's TTY-aware UTF-8->codepage conversion on Windows, so glyphs like `|`/`<>`/`-` were emitted as raw UTF-8 bytes and reinterpreted by the console's OEM codepage (CP437, CP936, ...), producing strings like `鋍?[0m 鉒?[0m Scanning files 鈥?N found`. Add `src/ui/glyphs.ts` with `supportsUnicode()` detection plus matched Unicode + ASCII glyph sets, and route all CLI/shimmer output through `getGlyphs()`. Defaults: ASCII on Windows and on Linux kernel consoles (`TERM=linux`), Unicode everywhere else. `CODEGRAPH_UNICODE=1` and `CODEGRAPH_ASCII=1` are escape hatches. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/ui/glyphs.tswithsupportsUnicode()detection and matched Unicode / ASCII glyph sets✓✗ℹ⚠,│ ◆ — █ ░, tree chars, banner separators) throughgetGlyphs()CODEGRAPH_UNICODE=1to opt into Unicode (e.g. pwsh 7 with UTF-8),CODEGRAPH_ASCII=1to force ASCIIWhy
#168 reports garbled output during
codegraph indexon Windows PowerShell:The shimmer progress renderer writes from a worker thread via
fs.writeSync(1, …)to keep the animation smooth while the main thread is blocked in SQLite — see the existing comment inshimmer-worker.ts. That path bypasses Node's TTY-aware UTF-8→codepage conversion on Windows, so glyphs like│ ◆ —were emitted as raw UTF-8 bytes and reinterpreted by the console's active OEM codepage (CP437, CP936, …), producing the mojibake above. Clack output rendered fine in the same screenshot because clack writes throughprocess.stdout.write, which Node TTY-encodes correctly.Why not #174
#174 was on the right track but didn't touch
src/ui/shimmer-worker.ts— which is the actual source of the mojibake in the issue's screenshot. It also swapped glyphs unconditionally, degrading the macOS/Linux experience. This PR builds on the same idea (ASCII markers) but adds detection so non-Windows terminals keep the Unicode rendering, and extends coverage to every glyph in the CLI/installer/shimmer.@Bortlesboat — thank you for the initial PR, credited in the CHANGELOG entry.
Test plan
npx vitest run __tests__/glyphs.test.ts— 13 new tests pinning detection + glyph contractnpm test— all 590 tests pass (no regressions innode-version-check,installer,mcp-initialize)npm run build— clean tsc│ ◆ —glyphs;CODEGRAPH_ASCII=1switches to| * -ASCII fallbackCloses #168
🤖 Generated with Claude Code