mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-05 21:39:54 +02:00
fix(daemon): sync workspaces from API before failing on empty runtime list
When the CLI config has no watched workspaces (e.g. fresh desktop app install), loadWatchedWorkspaces returns successfully but registers zero runtimes. The runtime check immediately after fails with "no runtimes registered" before workspaceSyncLoop gets a chance to discover workspaces from the API. Run one sync cycle inline when the watched list is empty so the daemon can bootstrap itself without a pre-configured workspace list.
This commit is contained in:
@@ -86,6 +86,17 @@ func (d *Daemon) Run(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// If no runtimes yet (empty watched list), run one sync cycle to discover
|
||||
// workspaces from the API before giving up. workspaceSyncLoop normally
|
||||
// handles this, but the runtime check below would fail before it runs.
|
||||
if len(d.allRuntimeIDs()) == 0 {
|
||||
d.syncWorkspacesFromAPI(ctx)
|
||||
// syncWorkspacesFromAPI writes to config; reload and register.
|
||||
if err := d.loadWatchedWorkspaces(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
runtimeIDs := d.allRuntimeIDs()
|
||||
if len(runtimeIDs) == 0 {
|
||||
return fmt.Errorf("no runtimes registered")
|
||||
|
||||
Reference in New Issue
Block a user