From b117dba1cd1fa80e1b0c18bae487dc632f4005ae Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Sun, 6 Sep 2026 15:43:37 +0900 Subject: feat(layout): re-probe the layout when the workspace's plugin states change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The backend now activates layout providers PER WORKSPACE (the workspace's per-workspace enablement state picks the ONE active layout plugin), so toggling a layout plugin in the workspace plugins modal changes which tree serves the workspace. The modal's toggle now refreshes the layout so the newly-enabled provider's tree (or the no-provider degrade) lands without a reload: - WorkspaceLayoutPort gains refresh(workspaceId) — the modal calls it after every state write (an attempted write re-probes either way: the probe is the idempotent catch-up; a refused write changed nothing, so it re-syncs the same tree). - App.svelte wires the port to the layout store's new onWorkspacePluginsChanged(workspaceId) — a guarded re-probe that only fires for the ACTIVE workspace (another workspace's toggle is picked up by its own probe on switch, exactly like the other §2.6 triggers). The per-workspace tree resolution itself is backend-side; the marker renderer, the probe triggers, and the WS push filtering are unchanged. Verification: typecheck (svelte-check 0 errors) / test (1528) / check / build all green. --- src/features/layout/store.test.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/features/layout/store.test.ts') diff --git a/src/features/layout/store.test.ts b/src/features/layout/store.test.ts index 73850ed..331af95 100644 --- a/src/features/layout/store.test.ts +++ b/src/features/layout/store.test.ts @@ -315,6 +315,44 @@ describe("layout store — edits PUT the whole tree + rollback (§2.6)", () => { }); describe("layout store — probe triggers (§2.6)", () => { + it("a per-workspace plugin-state change on the ACTIVE workspace re-probes (the plugins-modal toggle)", async () => { + let absent = true; + const served = overlaySidePanels(DEFAULT_LAYOUT, ["extensions"]); + const http = fakeHttp(() => + absent + ? { ok: false, notFound: true, error: "No layout plugin is enabled in this workspace" } + : { ok: true, tree: served }, + ); + const store = makeStore(http); + await store.probe("ws-a"); + expect(store.providerState).toBe("absent"); + + absent = false; // a layout plugin got enabled in THIS workspace + store.onWorkspacePluginsChanged("ws-a"); + await vi.advanceTimersByTimeAsync(0); + expect(store.providerState).toBe("present"); + expect(store.tree).toEqual(served); + }); + + it("a per-workspace plugin-state change on ANOTHER workspace is ignored (its probe fetches on switch)", async () => { + let absent = true; + const served = overlaySidePanels(DEFAULT_LAYOUT, ["extensions"]); + const http = fakeHttp(() => + absent + ? { ok: false, notFound: true, error: "No layout plugin is enabled in this workspace" } + : { ok: true, tree: served }, + ); + const store = makeStore(http); + await store.probe("ws-a"); + expect(store.providerState).toBe("absent"); + + absent = false; // a DIFFERENT workspace's toggle — nothing re-renders here + store.onWorkspacePluginsChanged("ws-other"); + await vi.advanceTimersByTimeAsync(0); + expect(http.getCalls).toEqual(["ws-a"]); // no second probe + expect(store.providerState).toBe("absent"); + }); + it("extensions-changed re-probes the active workspace", async () => { let absent = true; const served = overlaySidePanels(DEFAULT_LAYOUT, ["extensions"]); -- cgit v1.2.3