mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-10-19 15:33:54 +00:00
Reload model presets before the preset editor opens
The preset editor builds its draft as soon as it renders. The store's
loaded flags stay set after the first open, so later opens showed the
previous preset list and fell back to Default when the requested preset
was new. Saving that stale draft deleted presets created elsewhere:
another tab, the API, or a plugin.
Reload the global presets and resolve the initial preset in an
open_modal_before hook, so every open starts from fresh data, including
/presets, which opens the modal without openPresetEditor(). The modal
now appears after that reload; the editor still renders at once from the
fresh store data, so its footer stays pinned.
Verified with a behavioural regression test and the full suite (2171
passed, including the new test; the same 5 failures as 0efb0d4f).
Fixes #1928
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0efb0d4f8f
commit
b8905741d0
3 changed files with 83 additions and 0 deletions
|
|
@ -36,6 +36,7 @@
|
|||
- Repair provider-specific model-config aliases at the model-config read/build boundary; keep provider-specific repairs out of provider-agnostic core wrappers such as `models.py`.
|
||||
- The `Agent.read_prompt/end` Anthropic hook adapts only the two bundled thoughts instructions in main/communication/solving prompt results when the effective main provider or model name contains `anthropic` (case-insensitive, including OpenRouter). Keep prompt files, JSON fields, history, custom wording, and other models unchanged; standalone communication reads must match main-prompt rendering for native protocol projection. Verify with `tests/test_anthropic_thoughts_prompt.py`.
|
||||
- `modelConfig.createPresetEditor()` owns local preset drafts, row actions, and stable UI-only row keys so deletion or renaming cannot rebind nested model fields.
|
||||
- Presets may change outside the editor, so the `open_modal_before` hook reloads them before every preset-editor open, including `/presets`, and resolves the chat's active preset unless `openPresetEditor()` pinned one.
|
||||
- The preset editor maps each model provider's API-key field to the shared API-key store; saving the editor persists dirty keys separately and never writes secrets into preset YAML.
|
||||
- The compact chat selector label combines the effective preset with only the leaf name of its main model; utility and provider text stay out of the closed selector.
|
||||
- The compact selector strip exposes `model-context-strip-end` after the agent
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
import { store as modelConfigStore } from "/plugins/_model_config/webui/model-config-store.js";
|
||||
import { store as chatsStore } from "/components/sidebar/chats/chats-store.js";
|
||||
|
||||
const PRESET_EDITOR = "/plugins/_model_config/webui/main.html";
|
||||
|
||||
// The editor builds its draft as soon as it renders, and presets may have changed
|
||||
// outside it (another tab, the API, a plugin). Reload them before every open,
|
||||
// including /presets, which opens the modal without openPresetEditor().
|
||||
export default async function refreshPresetEditor(ctx) {
|
||||
if (ctx?.modalPath !== PRESET_EDITOR) return;
|
||||
await Promise.all([
|
||||
modelConfigStore.loadGlobalPresets(),
|
||||
modelConfigStore.preparePresetEditor(chatsStore?.selected || ""),
|
||||
]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue