graph_id button bug fix

This commit is contained in:
2026-03-05 15:31:58 +08:00
parent ae93ef37b6
commit 26fba706f2

View File

@@ -283,16 +283,27 @@ export default function App() {
if (!editor) { if (!editor) {
return; return;
} }
const targetEditorId = editor.id;
setBusy(true); setBusy(true);
setStatusMessage("Loading default prompts for selected graph..."); setStatusMessage("Loading default prompts for selected graph...");
try { try {
const defaults = await loadPromptDefaults(graphId); const defaults = await loadPromptDefaults(graphId);
setEditorAndSyncDraft((prev) => ({ setEditor((prev) => {
...prev, if (!prev || prev.id !== targetEditorId) {
graphId, // Selection changed while defaults were loading; do not mutate another agent.
prompts: { ...defaults.prompt_dict }, return prev;
toolKeys: defaults.tool_keys || [], }
})); const next: EditableAgent = {
...prev,
graphId,
prompts: { ...defaults.prompt_dict },
toolKeys: defaults.tool_keys || [],
};
if (next.isDraft) {
setDraftAgents((drafts) => drafts.map((draft) => (draft.id === next.id ? next : draft)));
}
return next;
});
setStatusMessage(""); setStatusMessage("");
} catch (error) { } catch (error) {
setStatusMessage((error as Error).message); setStatusMessage((error as Error).message);