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:
parent
e4cab003d1
commit
4fe54c87c8
1 changed files with 5 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue