feat(dev-host): persist the auto-reload preference across restarts

Auto-reload lived only in the dev host process, so every restart reset
it to off and re-enabling it cost a confirmation dialog each session.
The setting now persists to settings.json in the development data
directory (same atomic write pattern as connections.json) and is
restored — and re-armed — at startup.
This commit is contained in:
t8y2 committed 2026-09-16 15:29:39 +08:00
1 parent 197ba97f73
commit 0239d2c56b
2 files changed
+51 -3

No files matched your search

@@ -262,6 +262,30 @@ test("source watching is opt-in and automatic restarts preserve saved connection
await new Promise((resolve) => setTimeout(resolve, 650));
assert.equal(builds, 1);
});
test("auto-reload preference persists across dev host restarts", async (t) => {
const first = await fixture(t);
assert.equal((await first.request("auto-reload", { enabled: true })).value.enabled, true);
await first.host.close();
const second = await createMockHost({
project: first.root,
uiRoot: "ui",
backend: process.execPath,
diagnostics: new Diagnostics(() => {}),
backendArgs: [fileURLToPath(new URL("./echo-sidecar.mjs", import.meta.url))],
dataDir: join(first.root, "data"),
shellHtml: join(first.root, "ui/index.html"),
port: 0,
backendWatch: first.root,
buildBackend: async () => {},
});
t.after(async () => {
await second.close();
await rm(first.root, { recursive: true, force: true });
});
const bootstrap = await (await fetch(`${second.origin}/api/bootstrap`)).json();
assert.equal(bootstrap.autoReload, true);
});
test("agent diagnostics is read-only, bounded and does not log its own polling", async (t) => {
const { host } = await fixture(t, true);
const url = `${host.origin}/api/diagnostics`,