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.
This commit is contained in:
Chris Scott committed 2026-11-05 16:08:22 -05:00
1 parent 58a9fcdc8e
commit 84aa8dbeac
2 files changed
+3 -1

No files matched your search

@@ -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<OpenCodeConfigFile>(['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())
})
@@ -199,6 +199,7 @@ export function OpenCodeConfigManager() {
const applyOpenCodeConfigSave = (result: OpenCodeConfigSaveResponse) => {
queryClient.setQueryData<OpenCodeConfigFile>(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<string, unknown>) => {