Repository navigation
Let UI themes declare matching Pierre code themes - #1459
Conversation
Code highlighting now follows the active appearance. Custom and plugin themes can ship Pierre / VS Code JSON; built-in palettes use a matching Shiki pair, with first-party light files for Nord and Dracula. Closes #1239
useAppTheme is eager. Registering custom code themes from that hook pulled @pierre/diffs into the boot payload and blew the bundle budget. Move registration next to the worker-pool sync, which already loads Pierre.
|
🚨 SLOP COP 🚨 · I am SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior. |
|
|
||
| // Register Pierre files during render so child File/FileDiff mounts and the | ||
| // worker-pool sync effect see the resolved names on the same pass. | ||
| if (appearance?.resolvedCodeTheme !== undefined) { |
There was a problem hiding this comment.
🚨 slopcop/review — This call changes shared state and the DOM during React render.
applyResolvedCodeTheme writes document attributes and synchronously notifies mounted external-store users. A live config update can therefore update children while the parent render is active. Please move this work to a layout effect or use a React-owned provider with a safe snapshot.
| function registerResolvedCodeThemeFiles(): void { | ||
| const resolved = getResolvedCodeTheme(); | ||
| for (const [name, theme] of Object.entries(resolved.files)) { | ||
| if (registeredFileNames.has(name)) continue; |
There was a problem hiding this comment.
🚨 slopcop/review — Custom code-theme edits keep the first registered file until the page restarts.
The server reuses a stable name after a user edits the JSON and runs bb theme set again. This permanent name set skips the new content. Pierre also rejects duplicate registrations. Please use a content-versioned registration name or another replacement mechanism, and add a two-update test.
| .strict(); | ||
| export type CodeThemePair = z.infer<typeof codeThemePairSchema>; | ||
|
|
||
| export const vscodeThemeJsonSchema = jsonObjectSchema.refine( |
There was a problem hiding this comment.
🚨 slopcop/review — A deeply nested theme file can make the system configuration route return 500.
jsonObjectSchema.safeParse can throw a RangeError during recursive validation. The server calls this parser outside its catch. I reproduced the failure with a 2,000-level object below the 256 KB limit. Please contain parser exceptions, limit object depth, and validate the actual VS Code theme fields before activation.
| }; | ||
| } | ||
|
|
||
| function useHostCodeTheme(): { dark: string; light: string } { |
There was a problem hiding this comment.
🚨 slopcop/review — Each open patch creates its own document observer.
The host writes both theme attributes before its equality check. Even same-value writes create mutation records. Every observer then stores a new object, so an unrelated config refresh can rerender every visible patch. Please subscribe once at the panel or SDK boundary and share one stable theme snapshot.
SawyerHood
left a comment
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
ELI5: This change lets each app palette choose matching code colors. Built-in themes work, but custom themes can fail or stay stale.
I found four main defects:
- P1: A deeply nested JSON file can throw a
RangeErrorand make/system/configreturn 500. - P2: A custom theme edit keeps the first registered JSON until the page restarts.
- P2: Theme application changes the DOM and an external store during React render.
- P2: Each open GitHub patch creates an observer, so same-value writes can rerender every visible patch.
The server also accepts malformed files and unknown bundled names. Pierre then rejects them and keeps the prior code theme active.
The configuration path reads theme files synchronously and sends them with every response. Nord added about 26.7 KB in my local check. Two custom files can add about 512,000 characters.
The change duplicates the worker-pool theme provider in two views. The GitHub plugin also duplicates the host theme reader and observer. A shared provider and an experimental SDK hook would reduce this duplication.
QA results:
- The browser changed Default, Nord, and Dracula without a reload. The host published the correct dark and light names.
- The affected Turbo type checks passed.
- The domain and SDK suites passed.
- The focused server and CLI tests passed.
- The desktop smoke test passed alone after a timeout during the parallel suite.
git diff --checkpassed.
I would not merge this revision until the P1 and P2 defects are fixed. I posted a comment-only review as required.
Move theme application out of render, version Pierre registrations by file content, reject oversized theme JSON without taking down config, and share one host theme subscription in the GitHub plugin.
The plugin bundle also loads outside a DOM, such as in the CLI bundle test. A module-eval `document` access threw a ReferenceError there. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Summary
themeoptionspierre-lightThis is a narrower product choice than the original issue: there is no independent user code-theme selector. Switching the UI theme is what selects the code colors.
Validation
pnpm exec turbo run test --filter=@bb/domain --filter=@bb/server --filter=@bb/cli --filter=@bb/sdkpnpm exec turbo run typecheck --filter=@bb/domain --filter=@bb/appRisks
Pierre custom themes must use a
namethat matches the registered id. The worker pool is a singleton, so a theme switch has to callsetRenderOptionsor File/FileDiff keep the previous pair.Closes #1239