From e263064e8743ab5d140bdc8e0ed21f5684e9e03d Mon Sep 17 00:00:00 2001 From: yushen Date: Thu, 26 Mar 2026 17:32:37 +0800 Subject: [PATCH] fix(daemon): remove dead code and improve UX feedback Remove unused ListWorkspaces/Workspace from daemon client, add log when default workspace is set implicitly, document token reload limitation. Co-Authored-By: Claude Opus 4.6 (1M context) --- server/cmd/multica/cmd_workspace.go | 1 + server/internal/daemon/client.go | 15 --------------- server/internal/daemon/daemon.go | 2 ++ 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/server/cmd/multica/cmd_workspace.go b/server/cmd/multica/cmd_workspace.go index 9f50b990..85600bcf 100644 --- a/server/cmd/multica/cmd_workspace.go +++ b/server/cmd/multica/cmd_workspace.go @@ -123,6 +123,7 @@ func runWatch(cmd *cobra.Command, args []string) error { if cfg.WorkspaceID == "" { cfg.WorkspaceID = ws.ID + fmt.Fprintf(os.Stderr, "Set default workspace to %s (%s)\n", ws.ID, ws.Name) } if err := cli.SaveCLIConfig(cfg); err != nil { diff --git a/server/internal/daemon/client.go b/server/internal/daemon/client.go index 26540fbe..a80b0beb 100644 --- a/server/internal/daemon/client.go +++ b/server/internal/daemon/client.go @@ -36,12 +36,6 @@ func isWorkspaceNotFoundError(err error) bool { return strings.Contains(strings.ToLower(reqErr.Body), "workspace not found") } -// Workspace represents a workspace from the API. -type Workspace struct { - ID string `json:"id"` - Name string `json:"name"` -} - // Client handles HTTP communication with the Multica server daemon API. type Client struct { baseURL string @@ -62,15 +56,6 @@ func (c *Client) SetToken(token string) { c.token = token } -// ListWorkspaces fetches the user's workspaces using the auth token. -func (c *Client) ListWorkspaces(ctx context.Context) ([]Workspace, error) { - var ws []Workspace - if err := c.getJSON(ctx, "/api/workspaces", &ws); err != nil { - return nil, err - } - return ws, nil -} - func (c *Client) ClaimTask(ctx context.Context, runtimeID string) (*Task, error) { var resp struct { Task *Task `json:"task"` diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.go index e770a6e3..f0ac56de 100644 --- a/server/internal/daemon/daemon.go +++ b/server/internal/daemon/daemon.go @@ -204,6 +204,8 @@ func (d *Daemon) configWatchLoop(ctx context.Context) { } // reloadWorkspaces reconciles the active workspace set with the config file. +// NOTE: Token changes (e.g. re-login as a different user) are not picked up; +// the daemon must be restarted for a new auth token to take effect. func (d *Daemon) reloadWorkspaces(ctx context.Context) { d.reloading.Lock() defer d.reloading.Unlock()