mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
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:
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>) => {
|
||||
|
||||
Reference in new issue
Block a user