diff --git a/INTERFACE.md b/INTERFACE.md index a3a4efca..d69c305f 100644 --- a/INTERFACE.md +++ b/INTERFACE.md @@ -2759,8 +2759,8 @@ has no parts. this project — and on the prompt response, which §7A.6 already makes the authority for turn completion — the client invalidates `keys.project`, `keys.parts`, `keys.build(part)`, `keys.script(part)`, -`keys.properties(part)`, `keys.checks(part)`, `keys.dfm(part)` and -`keys.gitStatus()`. +`keys.params(part)`, `keys.properties(part)`, `keys.checks(part)`, +`keys.dfm(part)` and `keys.gitStatus()`. **TIGHTENING (binds §1).** The invalidation is a **refetch of the server projection**, never a client-side merge of tool results. A composer that patched diff --git a/web/src/api/refresh.ts b/web/src/api/refresh.ts index 5c041b4f..15bf0866 100644 --- a/web/src/api/refresh.ts +++ b/web/src/api/refresh.ts @@ -41,15 +41,14 @@ import { keys } from "./queries"; * The keys §7A.11 enumerates, resolved for one part. * * Exported as data so the test asserts the **list** rather than the effect of - * calling it: §7A.11 names eight keys, and a key quietly dropped from an + * calling it: §7A.11 names nine keys, and a key quietly dropped from an * invalidation is a panel that quietly goes stale. * * `part === null` is the blank canvas — no part is selected, so the * part-scoped keys have no argument to resolve against. The three * project-scoped keys still fire, and they are the ones that matter in exactly * that case: `keys.parts()` is how a part the agent has just created appears in - * the tree. `keys.params` is the ninth key: §10's sliders read a projection - * §7A.11 did not name because the panel had not shipped. + * the tree. */ export function refreshKeys(part: string | null): readonly (readonly unknown[])[] { const projectScoped: readonly (readonly unknown[])[] = [ @@ -79,7 +78,7 @@ export function refreshKeys(part: string | null): readonly (readonly unknown[])[ * this function computed. * * Deliberately fire-and-forget: the caller has already rendered the turn, and a - * composer that waited for eight refetches before re-enabling its textarea would + * composer that waited for nine refetches before re-enabling its textarea would * make the agent's own latency the operator's. */ export function refreshAfterTurn(client: QueryClient, part: string | null): void { diff --git a/web/src/components/stage/ParamSliders.tsx b/web/src/components/stage/ParamSliders.tsx index 3b3c427a..e688f7bc 100644 --- a/web/src/components/stage/ParamSliders.tsx +++ b/web/src/components/stage/ParamSliders.tsx @@ -14,6 +14,7 @@ import { useEffect, useRef, useState } from "react"; import { useQueryClient } from "@tanstack/react-query"; import { postBuild, postParams } from "../../api/params"; import { keys, useParams } from "../../api/queries"; +import { refreshKeys } from "../../api/refresh"; import { uuid7 } from "../../api/idempotency"; import type { ParamRejection, ParamRow, ParamsDocument } from "../../api/types"; import { copy } from "../../copy"; @@ -60,6 +61,20 @@ export function isIntegerParam(row: ParamRow): boolean { return Number.isInteger(row.default); } +/** + * Keys to refetch after a slider write. + * + * A rebuild is the same mutation surface as an agent turn: Results / Checks / + * DFM / properties go stale with the mesh. A conflict rebuilt nothing, so only + * the params projection is reread. + */ +export function keysAfterParamCommit( + part: string, + rebuilt: boolean, +): readonly (readonly unknown[])[] { + return rebuilt ? refreshKeys(part) : [keys.params(part)]; +} + function rejectionText(entry: ParamRejection): string { const parts = [entry.reason]; if (entry.value !== undefined) parts.push(String(entry.value)); @@ -176,7 +191,9 @@ export function ParamSliders(): React.JSX.Element { rejected: [], conflict: true, })); - void client.invalidateQueries({ queryKey: keys.params(part) }); + for (const queryKey of keysAfterParamCommit(part, false)) { + void client.invalidateQueries({ queryKey }); + } return; } if (result.rejected.length > 0) { @@ -189,8 +206,9 @@ export function ParamSliders(): React.JSX.Element { return; } return postBuild(part, uuid7()).then(() => { - void client.invalidateQueries({ queryKey: keys.params(part) }); - void client.invalidateQueries({ queryKey: keys.build(part) }); + for (const queryKey of keysAfterParamCommit(part, true)) { + void client.invalidateQueries({ queryKey }); + } }); }) .finally(() => { diff --git a/web/test/params.test.tsx b/web/test/params.test.tsx index 5ea13f07..cf83bae1 100644 --- a/web/test/params.test.tsx +++ b/web/test/params.test.tsx @@ -9,10 +9,13 @@ import { renderToStaticMarkup } from "react-dom/server"; import type { ReactElement } from "react"; import paramsJson from "./fixtures/params.json"; +import { keys } from "../src/api/queries"; +import { refreshKeys } from "../src/api/refresh"; import type { ParamRejection, ParamsDocument } from "../src/api/types"; import { controlStep, isIntegerParam, + keysAfterParamCommit, ParamSlidersView, } from "../src/components/stage/ParamSliders"; import { Slider } from "../src/system"; @@ -105,3 +108,22 @@ describe("G5.3 — rejected[] is verbatim, and the primitive does not clamp", () expect((number as HTMLInputElement | null)?.value).toBe("11.00"); }); }); + +describe("a slider write refreshes the inspector, not just params and build", () => { + it("a successful rebuild invalidates the refreshKeys set", () => { + // The two ad-hoc keys (params + build) would leave Results / Checks / DFM + // / properties showing the pre-rebuild projection. + expect(keysAfterParamCommit("tread", true)).toEqual(refreshKeys("tread")); + expect(keysAfterParamCommit("tread", true)).toEqual( + expect.arrayContaining([ + keys.properties("tread"), + keys.checks("tread"), + keys.dfm("tread"), + ]), + ); + }); + + it("a conflict invalidates only the params projection", () => { + expect(keysAfterParamCommit("tread", false)).toEqual([keys.params("tread")]); + }); +}); diff --git a/web/test/stream/composer.test.tsx b/web/test/stream/composer.test.tsx index f597b091..609579ce 100644 --- a/web/test/stream/composer.test.tsx +++ b/web/test/stream/composer.test.tsx @@ -189,7 +189,7 @@ describe("the chip row", () => { // §7A.11 — the read-refresh boundary describe("the read-refresh boundary", () => { - it("names the §7A.11 keys plus the PARAMS projection for a selected part", () => { + it("names exactly the keys §7A.11 enumerates for a selected part", () => { expect(refreshKeys("tread")).toEqual([ keys.project(), keys.parts(),