mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
refactor: replace OpenCode server restarts with config reloads for faster updates (#70)
This commit is contained in:
1 parent
8be0bbd8a0
commit
2bd2b024b8
11 files changed
+183
-107
No files matched your search
@@ -10,14 +10,14 @@ import { subscribeToSSE, reconnectSSE, addSSEDirectory, removeSSEDirectory } fro
|
||||
import { parseOpenCodeError } from '@/lib/opencode-errors'
|
||||
|
||||
const handleRestartServer = async () => {
|
||||
showToast.loading('Restarting OpenCode server...', {
|
||||
showToast.loading('Reloading OpenCode configuration...', {
|
||||
id: 'restart-server',
|
||||
})
|
||||
|
||||
|
||||
try {
|
||||
const result = await settingsApi.restartOpenCodeServer()
|
||||
const result = await settingsApi.reloadOpenCodeConfig()
|
||||
if (result.success) {
|
||||
showToast.success(result.message || 'OpenCode server restarted successfully', {
|
||||
showToast.success(result.message || 'OpenCode configuration reloaded successfully', {
|
||||
id: 'restart-server',
|
||||
duration: 3000,
|
||||
})
|
||||
@@ -25,13 +25,13 @@ const handleRestartServer = async () => {
|
||||
window.location.reload()
|
||||
}, 2000)
|
||||
} else {
|
||||
showToast.error(result.message || 'Failed to restart OpenCode server', {
|
||||
showToast.error(result.message || 'Failed to reload OpenCode configuration', {
|
||||
id: 'restart-server',
|
||||
duration: 5000,
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
showToast.error(error instanceof Error ? error.message : 'Failed to restart OpenCode server', {
|
||||
showToast.error(error instanceof Error ? error.message : 'Failed to reload OpenCode configuration', {
|
||||
id: 'restart-server',
|
||||
duration: 5000,
|
||||
})
|
||||
@@ -282,7 +282,7 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string,
|
||||
showToast.info(`OpenCode v${event.properties.version} is available`, {
|
||||
description: 'A new version is ready to install.',
|
||||
action: {
|
||||
label: 'Restart to Update',
|
||||
label: 'Reload to Update',
|
||||
onClick: handleRestartServer
|
||||
},
|
||||
duration: 10000,
|
||||
|
||||
@@ -31,19 +31,19 @@ export function useServerHealth(enabled = true) {
|
||||
|
||||
const restartMutation = useMutation({
|
||||
mutationFn: async () => {
|
||||
return await settingsApi.restartOpenCodeServer()
|
||||
return await settingsApi.reloadOpenCodeConfig()
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['health'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['opencode', 'agents'] })
|
||||
toast.success('Server restarted successfully')
|
||||
toast.success('Server configuration reloaded successfully')
|
||||
},
|
||||
onError: (error: unknown) => {
|
||||
const errorMessage = error && typeof error === 'object' && 'response' in error
|
||||
? ((error as { response?: { data?: { details?: string; error?: string } } }).response?.data?.details
|
||||
|| (error as { response?: { data?: { details?: string; error?: string } } }).response?.data?.error
|
||||
|| 'Failed to restart server')
|
||||
: 'Failed to restart server'
|
||||
|| 'Failed to reload configuration')
|
||||
: 'Failed to reload configuration'
|
||||
toast.error(errorMessage)
|
||||
},
|
||||
})
|
||||
@@ -81,7 +81,7 @@ export function useServerHealth(enabled = true) {
|
||||
toast.error(health.error || 'OpenCode server is currently unhealthy', {
|
||||
duration: Infinity,
|
||||
action: {
|
||||
label: 'Restart',
|
||||
label: 'Reload',
|
||||
onClick: () => restartMutation.mutate(),
|
||||
},
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user