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) {
return;
}
const targetEditorId = editor.id;
setBusy(true);
setStatusMessage("Loading default prompts for selected graph...");
try {
const defaults = await loadPromptDefaults(graphId);
setEditorAndSyncDraft((prev) => ({
...prev,
graphId,
prompts: { ...defaults.prompt_dict },
toolKeys: defaults.tool_keys || [],
}));
setEditor((prev) => {
if (!prev || prev.id !== targetEditorId) {
// Selection changed while defaults were loading; do not mutate another agent.
return prev;
}
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("");
} catch (error) {
setStatusMessage((error as Error).message);