Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: compute the inference editor's stored boxes once per read, not every render

The remember effect ran on every render because the stored draft was
rebuilt each time. It is now memoised on the read.
This commit is contained in:
iris 2026-11-23 19:34:53 +01:00
commit 4fe54c87c8

View file

@ -13,7 +13,7 @@
// Its state belongs to one agent: callers key it by agent name, so switching
// agents remounts it instead of showing the previous agent's settings.
import type { ComponentChildren } from "preact";
import { useEffect, useRef, useState } from "preact/hooks";
import { useEffect, useMemo, useRef, useState } from "preact/hooks";
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
import { readApiError, type ProblemDetails } from "@hive/shared/api-error.js";
import { ActionRow } from "../../ui/action-row/ActionRow.js";
@ -329,7 +329,10 @@ export function AgentInference({ agent }: { agent: string }) {
};
}, [agent, reload]);
const base = view === null ? null : draftOf(view.configured);
const base = useMemo(
() => (view === null ? null : draftOf(view.configured)),
[view],
);
const dirty = draft !== null && base !== null && !sameDraft(draft, base);
useEffect(() => {
if (draft === null || base === null) return;