From 84aa8dbeac3e4b03ed4e5e218807208e260cbd93 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Thu, 5 Nov 2026 16:08:22 -0500 Subject: [PATCH] fix: refresh the managed config after a raw config save (OM-179) A raw editor save now refetches the managed view like a structured save does, so the Settings lists never hand a stale agent, command or provider to the next entity patch when the event stream does not deliver config.updated. --- frontend/src/components/settings/OpenCodeConfigManager.test.tsx | 2 ++ frontend/src/components/settings/OpenCodeConfigManager.tsx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/settings/OpenCodeConfigManager.test.tsx b/frontend/src/components/settings/OpenCodeConfigManager.test.tsx index a37b32d5..2db8c8d4 100644 --- a/frontend/src/components/settings/OpenCodeConfigManager.test.tsx +++ b/frontend/src/components/settings/OpenCodeConfigManager.test.tsx @@ -320,6 +320,7 @@ describe('OpenCodeConfigManager', () => { const editIcon = container.querySelector('.lucide-square-pen') as SVGElement const editButton = editIcon.closest('button') as HTMLButtonElement await user.click(editButton) + const managedReadsBeforeSave = mockGetManagedOpenCodeConfig.mock.calls.length const textarea = await screen.findByLabelText('Config content') as HTMLTextAreaElement const next = configWithRaw.rawContent + ' ' @@ -336,6 +337,7 @@ describe('OpenCodeConfigManager', () => { const cached = queryClient.getQueryData(['opencode-config', 'file']) expect(cached?.revision).toBe('rev-2') expect(cached?.rawContent).toBe('{\n "theme": "dark"\n}') + await waitFor(() => expect(mockGetManagedOpenCodeConfig.mock.calls.length).toBeGreaterThan(managedReadsBeforeSave)) await waitFor(() => expect(screen.queryByText('Edit opencode.json')).not.toBeInTheDocument()) }) diff --git a/frontend/src/components/settings/OpenCodeConfigManager.tsx b/frontend/src/components/settings/OpenCodeConfigManager.tsx index 5c234a02..d0517b14 100644 --- a/frontend/src/components/settings/OpenCodeConfigManager.tsx +++ b/frontend/src/components/settings/OpenCodeConfigManager.tsx @@ -199,6 +199,7 @@ export function OpenCodeConfigManager() { const applyOpenCodeConfigSave = (result: OpenCodeConfigSaveResponse) => { queryClient.setQueryData(OPEN_CODE_CONFIG_QUERY_KEY, result) + queryClient.invalidateQueries({ queryKey: OPEN_CODE_MANAGED_CONFIG_QUERY_KEY }) applyOpenCodeSaveFeedback({ appliedMessage: 'Configuration updated', restartRequired: result.restartRequired, @@ -211,7 +212,6 @@ export function OpenCodeConfigManager() { )?.revision const result = await settingsApi.patchOpenCodeConfig({ patch, expectedRevision }) applyOpenCodeConfigSave(result) - queryClient.invalidateQueries({ queryKey: OPEN_CODE_MANAGED_CONFIG_QUERY_KEY }) } const patchManagedConfigSafely = (patch: Record) => {