fix: save agent prompt and reload changes reliably

Agent settings now correctly save an emptied system prompt instead of silently keeping the old text.

After saving agent, command, or skill settings, OpenChamber refreshes the updated configuration instead of showing stale values from a short-lived cache.

Reload actions now surface refresh failures consistently while avoiding noisy background errors.
This commit is contained in:
Bohdan Triapitsyn
2026-06-08 13:43:45 +03:00
parent b2b71198ca
commit ef71a997a8
10 changed files with 103 additions and 14 deletions
+33
View File
@@ -1666,6 +1666,39 @@ export const updateAgent = (agentName: string, updates: Record<string, unknown>,
for (const [field, value] of Object.entries(updates || {})) {
if (field === 'prompt') {
if (value === null) {
if (mdExists || creatingNewMd) {
if (mdData) {
mdData.body = '';
mdModified = true;
}
continue;
}
if (isPromptFileReference(jsonSection?.prompt)) {
const promptFilePath = resolvePromptFilePath(jsonSection.prompt);
if (!promptFilePath) throw new Error(`Invalid prompt file reference for agent ${agentName}`);
writePromptFile(promptFilePath, '');
continue;
}
if (config.agent) {
const agentMap = config.agent as Record<string, unknown>;
const current = agentMap[agentName] as Record<string, unknown> | undefined;
if (current) {
delete current.prompt;
if (Object.keys(current).length === 0) {
delete agentMap[agentName];
}
if (Object.keys(agentMap).length === 0) {
delete config.agent;
}
jsonModified = true;
}
}
continue;
}
const normalizedValue = typeof value === 'string' ? value : value == null ? '' : String(value);
if (mdExists || creatingNewMd) {