Conversation
Greptile SummaryThis PR adds an interactive Key findings:
The core logic and state management are solid. The component correctly resolves schema references and renders the appropriate field types for the configuration builder. Confidence Score: 4/5
Sequence DiagramsequenceDiagram
participant User
participant ConfigBuilder
participant SectionForm/ProvidersSection
participant SchemaField
participant toml-utils
participant TomlPreview
participant Shiki
User->>ConfigBuilder: Select tab / change field
ConfigBuilder->>SectionForm/ProvidersSection: Pass section schema + value
SectionForm/ProvidersSection->>SchemaField: Resolve schema (fullyResolve)
SchemaField-->>SectionForm/ProvidersSection: Render typed field component
SectionForm/ProvidersSection-->>ConfigBuilder: onChange(newValue)
ConfigBuilder->>ConfigBuilder: dispatch SET_VALUE → useReducer
ConfigBuilder->>toml-utils: generateToml(state, rootSchema)
toml-utils->>toml-utils: stripEmpty → coerceTypes → smol-toml stringify
toml-utils-->>ConfigBuilder: TOML string
ConfigBuilder->>TomlPreview: toml prop update
TomlPreview->>Shiki: codeToHtml(toml) [debounced 150ms]
Shiki-->>TomlPreview: highlighted HTML
TomlPreview-->>User: Render syntax-highlighted preview
User->>TomlPreview: Copy / Download
TomlPreview-->>User: Clipboard write / Blob download
Last reviewed commit: d0612ef |
| useEffect(() => { | ||
| clearTimeout(debounceRef.current); | ||
| debounceRef.current = setTimeout(() => { | ||
| getHighlighter().then((hl) => { | ||
| setHtml(hl.codeToHtml(toml, { lang: "toml", theme })); | ||
| }); | ||
| }, 150); | ||
| return () => clearTimeout(debounceRef.current); | ||
| }, [toml, theme]); |
There was a problem hiding this comment.
The getHighlighter().then(...) call has no .catch() handler. If the Shiki highlighter fails to initialize (network issues, missing Wasm bundle, etc.), the error becomes an unhandled promise rejection, which triggers React Strict Mode warnings and may suppress the fallback plain-text display.
| useEffect(() => { | |
| clearTimeout(debounceRef.current); | |
| debounceRef.current = setTimeout(() => { | |
| getHighlighter().then((hl) => { | |
| setHtml(hl.codeToHtml(toml, { lang: "toml", theme })); | |
| }); | |
| }, 150); | |
| return () => clearTimeout(debounceRef.current); | |
| }, [toml, theme]); | |
| getHighlighter() | |
| .then((hl) => { | |
| setHtml(hl.codeToHtml(toml, { lang: "toml", theme })); | |
| }) | |
| .catch(() => { | |
| // Shiki failed to load; the plain-text fallback will remain visible | |
| }); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/components/ConfigBuilder/TomlPreview.tsx
Line: 27-35
Comment:
The `getHighlighter().then(...)` call has no `.catch()` handler. If the Shiki highlighter fails to initialize (network issues, missing Wasm bundle, etc.), the error becomes an unhandled promise rejection, which triggers React Strict Mode warnings and may suppress the fallback plain-text display.
```suggestion
getHighlighter()
.then((hl) => {
setHtml(hl.codeToHtml(toml, { lang: "toml", theme }));
})
.catch(() => {
// Shiki failed to load; the plain-text fallback will remain visible
});
```
How can I resolve this? If you propose a fix, please make it concise.
No description provided.