Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions INTERFACE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions web/src/api/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[])[] = [
Expand Down Expand Up @@ -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 {
Expand Down
24 changes: 21 additions & 3 deletions web/src/components/stage/ParamSliders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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) {
Expand All @@ -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(() => {
Expand Down
22 changes: 22 additions & 0 deletions web/test/params.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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")]);
});
});
2 changes: 1 addition & 1 deletion web/test/stream/composer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Loading