From 4fe54c87c88b761da93eb3df5872369db06904d3 Mon Sep 17 00:00:00 2001 From: iris Date: Mon, 23 Nov 2026 19:34:53 +0100 Subject: [PATCH] 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. --- .../packages/swarm-ui/src/agent/detail/AgentInference.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/packages/swarm-ui/src/agent/detail/AgentInference.tsx b/frontend/packages/swarm-ui/src/agent/detail/AgentInference.tsx index 67ab1964d..b4ec0fd5c 100644 --- a/frontend/packages/swarm-ui/src/agent/detail/AgentInference.tsx +++ b/frontend/packages/swarm-ui/src/agent/detail/AgentInference.tsx @@ -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;