[eric] settings: broadcast settings:changed on agent write so the UI reflects it instantly (no focus wait)

This commit is contained in:
ciregenz
2026-06-20 03:22:03 -07:00
parent c722641fec
commit 2e2fff0869
2 changed files with 16 additions and 0 deletions
+8
View File
@@ -840,6 +840,14 @@ async def settings_meta(action: str, request: Request):
for f in staged:
outcomes[f] = {"status": "error", "reason": f"write failed: {e}"}
if any(o.get("status") == "applied" for o in outcomes.values()):
# An agent wrote settings (not the user via the modal), so nudge every
# open window to refetch instead of waiting for the next window-focus.
# Pure signal: the renderer refetches the authoritative state, so nothing
# (least of all a secret) needs to ride the broadcast.
from backend.apps.agents.core.ws_manager import ws_manager as _wsm
await _wsm.broadcast_global("settings:changed", {})
return JSONResponse({"outcomes": outcomes})
return JSONResponse({"error": f"unknown action: {action}"}, status_code=400)
@@ -26,6 +26,7 @@ import {
import { streamStart, streamDelta, streamEnd, clearStreamingForSession } from '../state/streamingSlice';
import { addBrowserCardFromBackend, markBrowserCardEnding, keepBrowserCardOpen, placeInParentColumn, setBrowserCardPosition, setGlowingBrowserCards } from '../state/dashboardLayoutSlice';
import { upsertOutput } from '../state/outputsSlice';
import { fetchSettings } from '../state/settingsSlice';
import { displaySessionName } from '../state/sessionDisplay';
import { getAuthToken } from '../config';
import { notifyAgentCompletion } from '../notifications';
@@ -822,6 +823,13 @@ class WebSocketManager {
}
}
break;
case 'settings:changed':
// An agent wrote settings under us (not the user via the modal), so refetch
// now instead of waiting for the next window-focus. The slice's latestWriteId
// guard drops this if a newer user save is already in flight.
store.dispatch(fetchSettings());
break;
}
// Notify any custom listeners