Fix wave chunk 1: cross-surface settings signal, dialog scroll-lock, noneRow retired
- lh:settings-saved CustomEvent (the lh:chat-renamed pattern, owner ruling): every writer (composer save, SetupDialog save, the settings write seam — one dispatch point carrying the section) notifies after a successful PUT; every reader re-reads its own seam: ModelControl's record read, the Agent section's slots/catalog, and chat.tsx's configured state (clearing slots mid-session now surfaces the setup CTA without a reload). Self-notifications re-read idempotently. - MenuShell now announces lh:menu-open/lh:menu-close (still placement- only); the settings dialog's content column locks (overflow-hidden, count-based) while any menu is open — wheel-scrolling with a dropdown down is dead; the re-place-on-scroll fallback stays for un-lockable surfaces. - The settings thinking menus' 'Default' noneRow is retired (owner: the unset state can't re-enter once chunk 2's auto-populate lands; no unpin is needed). - Live-caught regression from the MenuShell migration fixed: the composer's outside-click handler never learned the portaled menu body isn't a container descendant — menu-row pointerdowns counted as outside and ATE THE PICK (composer picks have been dead for pointer users since 221c99d); rows now carve out via [data-lh-menu], the settings sections' discipline. - Item 4 (resolved-level display for legacy records) deferred to chunk 2 per owner ruling — the payload omits the level for legacy no-level records and DEFAULT_THINKING_ORDER was server-only (now in the core barrel via bd68486, exactly the seam chunk 2 needs).
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* The cross-surface settings signal (fix wave, owner ruling 2026-09-22):
|
||||
* writers dispatch lh:settings-saved {section} after a successful PUT,
|
||||
* readers re-read. These tests pin the SEAM's contract — delivery,
|
||||
* section detail, unsubscribe, and junk-event tolerance — against a bare
|
||||
* EventTarget standing in for window (Node has no DOM; the reader WIRING
|
||||
* is verified live per dev-verification.md).
|
||||
*/
|
||||
import assert from "node:assert/strict";
|
||||
import { afterEach, describe, it } from "node:test";
|
||||
|
||||
// A DOM-less window: EventTarget is all the seam touches. The module
|
||||
// imports react (harmless) and reads window at CALL time, not import time.
|
||||
const realWindow = (globalThis as { window?: unknown }).window;
|
||||
(globalThis as { window: unknown }).window = new EventTarget();
|
||||
|
||||
const {
|
||||
SETTINGS_SAVED_EVENT,
|
||||
notifySettingsSaved,
|
||||
onSettingsSaved,
|
||||
} = await import("../components/settings-signal.ts");
|
||||
|
||||
afterEach(() => {
|
||||
(globalThis as { window: unknown }).window = realWindow ?? new EventTarget();
|
||||
});
|
||||
|
||||
describe("settings-signal — the seam's contract", () => {
|
||||
it("a writer's notify reaches a reader with the section", () => {
|
||||
const got: string[] = [];
|
||||
const off = onSettingsSaved((section) => got.push(section));
|
||||
notifySettingsSaved("models");
|
||||
assert.deepEqual(got, ["models"]);
|
||||
off();
|
||||
});
|
||||
|
||||
it("unsubscribe stops delivery (a reader unmounting never leaks)", () => {
|
||||
const got: string[] = [];
|
||||
const off = onSettingsSaved((section) => got.push(section));
|
||||
off();
|
||||
notifySettingsSaved("models");
|
||||
assert.deepEqual(got, []);
|
||||
});
|
||||
|
||||
it("readers filter their own section — general doesn't reach a models reader", () => {
|
||||
const got: string[] = [];
|
||||
const off = onSettingsSaved((s) => {
|
||||
if (s === "models") got.push(s);
|
||||
});
|
||||
notifySettingsSaved("general");
|
||||
notifySettingsSaved("appearance");
|
||||
assert.deepEqual(got, []);
|
||||
notifySettingsSaved("models");
|
||||
assert.deepEqual(got, ["models"]);
|
||||
off();
|
||||
});
|
||||
|
||||
it("a foreign CustomEvent on the same name with no section detail is ignored", () => {
|
||||
const got: string[] = [];
|
||||
const off = onSettingsSaved((section) => got.push(section));
|
||||
// e.g. some other dispatch path that forgot the detail payload
|
||||
globalThis.window.dispatchEvent(
|
||||
new CustomEvent(SETTINGS_SAVED_EVENT, { detail: undefined }),
|
||||
);
|
||||
assert.deepEqual(got, []);
|
||||
off();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user