Skip to content

Commit f705263

Browse files
committed
fix(ui): fill raw pending-changes diff once the lazy JSON5 parser lands
First diff open could race the parser chunk and render an empty list with nothing scheduling a retry; renderConfig now re-renders when the warm completes, and the browser test warms the parser in setup to assert the steady state the view module guarantees in prod.
1 parent bcf5c0c commit f705263

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

ui/src/pages/config/view.browser.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
// Control UI tests cover config behavior.
22
import { render } from "lit";
3-
import { describe, expect, it, vi } from "vitest";
3+
import { beforeAll, describe, expect, it, vi } from "vitest";
44
import "../../styles.css";
55
import type { ThemeMode, ThemeName } from "../../app/theme.ts";
6+
import { warmJson5 } from "../../lib/json5-runtime.ts";
67
import { createConfigViewState, renderConfig, type ConfigProps } from "./view.ts";
78

89
describe("config view", () => {
10+
// The view module warms the lazy JSON5 parser on load; tests assert the
11+
// steady state where raw diffs parse synchronously.
12+
beforeAll(async () => {
13+
await warmJson5();
14+
});
15+
916
const baseProps = () => ({
1017
raw: "{\n}\n",
1118
originalRaw: "{\n}\n",

ui/src/pages/config/view.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,13 @@ export function renderConfig(props: ConfigProps) {
17931793
formMode === "raw" && hasRawChanges && viewState.rawDiffOpen
17941794
? computeRawDiff(viewState, props.originalRaw, props.raw)
17951795
: [];
1796+
if (formMode === "raw" && hasRawChanges && viewState.rawDiffOpen && !isJson5Warm()) {
1797+
// First diff open can race the lazy JSON5 parser; re-render when it lands
1798+
// so the pending-changes list fills in instead of staying empty.
1799+
void warmJson5()
1800+
.then(() => requestUpdate())
1801+
.catch(() => undefined);
1802+
}
17961803
// Includes the app updater: writes are suspended while it runs, so raw
17971804
// Save/Discard must read busy instead of silently no-opping.
17981805
const configBusy = props.loading || props.saving || props.applying || props.updating;

0 commit comments

Comments
 (0)