From eaefd1927a1ace0c219054048bf8e6aa9689e8a7 Mon Sep 17 00:00:00 2001 From: Jiang Bohan Date: Tue, 14 Apr 2026 19:52:16 +0800 Subject: [PATCH] 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. --- server/internal/daemon/daemon.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.go index be9a59209..acccc327a 100644 --- a/server/internal/daemon/daemon.go +++ b/server/internal/daemon/daemon.go @@ -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")