Repository navigation
fix(server): theme files saved with a UTF-8 BOM are published instead of rejected - #32405
Conversation
… of rejected A theme JSON file that starts with a UTF-8 byte-order mark is skipped by the themes watcher and refused by `t3 theme set <file>` as "not a valid theme file". The guarded theme reader decoded bytes with Buffer#toString, which keeps the BOM, so JSON.parse failed. settings.json, keybindings.json and t3.json read through FileSystem.readFileString, whose TextDecoder drops the BOM, so the same JSON loads there. The theme reader now decodes with TextDecoder too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
commented
Nov 7, 2026
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Theme files with a UTF-8 BOM can now load through both the watcher and CLI. Existing validation and file safeguards remain intact, and product defaults are unchanged. You can add or adjust custom eligibility rules. Learn more. |
commented
Nov 7, 2026
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Problem
A theme JSON file that starts with a UTF-8 byte-order mark (BOM) is never published. The themes watcher skips it, and
t3 theme set <file>rejects it as "not a valid theme file". Windows PowerShell 5 and editors set to "UTF-8 with BOM" write such files.readThemeFileGuardeddecodes the bytes withBuffer#toString("utf8"), which keeps the BOM, soJSON.parsefails.settings.json,keybindings.jsonandt3.jsonload the same bytes fine, becauseFileSystem.readFileStringusesTextDecoder, which drops the BOM.Change
The theme reader now decodes with
TextDecodertoo.Scope and approval
This is a one-line fix for an obvious bug, and it makes theme files behave like the server's other JSON files. I searched issues and PRs for "theme BOM", "readThemeFileGuarded", "environmentTheme", "theme file byte order mark" and "theme json BOM" and found nothing related.
Verification
notepad.json(a theme prefixed with\uFEFF) in the existing caseskips invalid files while keeping valid onesinapps/server/src/environmentTheme.test.ts.vp test run apps/server/src/environmentTheme.test.tswith the fix: 5 passed.environmentTheme.tsreverted to main:AssertionError: expected [ 'nightfall' ] to deeply equal [ 'nightfall', 'notepad' ].apps/server/src/cli/theme.test.tspasses.vp run check:changedpasses.--base-dirand a theme file startingef bb bf 7b: on main,node apps/server/src/bin.ts theme set nightfall.jsonfails withSchemaError(Expected a valid JSON string). With the fix it printsPublished … as "nightfall" and set it as the environment theme.Not checked: Windows itself, with files saved by real Windows editors.
Written by Claude Opus 5.5 (
claude-opus-5-5) in the Claude Code harness, run from T3 Code.🤖 Generated with Claude Code