fix(cli): daemon reads server_url from config file (#187)
* fix(cli): daemon reads server_url from config file The daemon only checked CLI flags and env vars for server_url, ignoring the persisted config in ~/.multica/config.json. Now falls back to the config file when neither flag nor env var is set. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(cli): reset workspace data when server_url changes on login When logging in to a different server, stale workspace_id and watched_workspaces from the previous server caused 404 errors in the daemon. Now both browser and token login paths clear workspace data when the server URL changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(cli): reset workspace data on every login, not just server change A different user logging in on the same machine would inherit stale workspace data. Always clear workspace_id and watched_workspaces on login so autoWatchWorkspaces repopulates them fresh. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
40aa3f6bd9
commit
16e0645c75
2 changed files with 13 additions and 2 deletions
|
|
@ -203,8 +203,11 @@ func runAuthLoginBrowser(cmd *cobra.Command) error {
|
|||
return fmt.Errorf("token verification failed: %w", err)
|
||||
}
|
||||
|
||||
// Save to config.
|
||||
// Save to config. Reset workspace data on every login — the user or
|
||||
// server may have changed, so stale workspaces must not persist.
|
||||
cfg, _ := cli.LoadCLIConfig()
|
||||
cfg.WorkspaceID = ""
|
||||
cfg.WatchedWorkspaces = nil
|
||||
cfg.Token = patResp.Token
|
||||
cfg.ServerURL = serverURL
|
||||
cfg.AppURL = appURL
|
||||
|
|
@ -245,6 +248,8 @@ func runAuthLoginToken(cmd *cobra.Command) error {
|
|||
}
|
||||
|
||||
cfg, _ := cli.LoadCLIConfig()
|
||||
cfg.WorkspaceID = ""
|
||||
cfg.WatchedWorkspaces = nil
|
||||
cfg.Token = token
|
||||
cfg.ServerURL = serverURL
|
||||
if err := cli.SaveCLIConfig(cfg); err != nil {
|
||||
|
|
|
|||
|
|
@ -201,8 +201,14 @@ func buildDaemonStartArgs(cmd *cobra.Command) []string {
|
|||
}
|
||||
|
||||
func runDaemonForeground(cmd *cobra.Command) error {
|
||||
serverURL := cli.FlagOrEnv(cmd, "server-url", "MULTICA_SERVER_URL", "")
|
||||
if serverURL == "" {
|
||||
if c, err := cli.LoadCLIConfig(); err == nil && c.ServerURL != "" {
|
||||
serverURL = c.ServerURL
|
||||
}
|
||||
}
|
||||
overrides := daemon.Overrides{
|
||||
ServerURL: cli.FlagOrEnv(cmd, "server-url", "MULTICA_SERVER_URL", ""),
|
||||
ServerURL: serverURL,
|
||||
DaemonID: flagString(cmd, "daemon-id"),
|
||||
DeviceName: flagString(cmd, "device-name"),
|
||||
RuntimeName: flagString(cmd, "runtime-name"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue