diff --git a/apps/x/apps/main/src/ipc.ts b/apps/x/apps/main/src/ipc.ts index 52562af3..6efd48df 100644 --- a/apps/x/apps/main/src/ipc.ts +++ b/apps/x/apps/main/src/ipc.ts @@ -390,13 +390,21 @@ export function setupIpcHandlers() { // Agent schedule handlers 'agent-schedule:getConfig': async () => { const repo = container.resolve('agentScheduleRepo'); - await repo.ensureConfig(); - return repo.getConfig(); + try { + return await repo.getConfig(); + } catch { + // Return empty config if file doesn't exist + return { agents: {} }; + } }, 'agent-schedule:getState': async () => { const repo = container.resolve('agentScheduleStateRepo'); - await repo.ensureState(); - return repo.getState(); + try { + return await repo.getState(); + } catch { + // Return empty state if file doesn't exist + return { agents: {} }; + } }, 'agent-schedule:updateAgent': async (_event, args) => { const repo = container.resolve('agentScheduleRepo'); diff --git a/apps/x/apps/renderer/src/App.tsx b/apps/x/apps/renderer/src/App.tsx index d03748d5..3d01eee3 100644 --- a/apps/x/apps/renderer/src/App.tsx +++ b/apps/x/apps/renderer/src/App.tsx @@ -547,12 +547,17 @@ function App() { const cleanup = window.ipc.on('workspace:didChange', async (event) => { loadDirectory().then(setTree) - // Reload current file if it was changed externally - if (!selectedPath) return - const changedPath = event.type === 'changed' ? event.path : null const changedPaths = (event.type === 'bulkChanged' ? event.paths : []) ?? [] + // Reload background tasks if agent-schedule.json changed + if (changedPath === 'config/agent-schedule.json' || changedPaths.includes('config/agent-schedule.json')) { + loadBackgroundTasks() + } + + // Reload current file if it was changed externally + if (!selectedPath) return + const isCurrentFileChanged = changedPath === selectedPath || changedPaths.includes(selectedPath) @@ -567,6 +572,7 @@ function App() { } }) return cleanup + // eslint-disable-next-line react-hooks/exhaustive-deps }, [loadDirectory, selectedPath, editorContent]) // Load file content when selected