@@ -58,16 +58,25 @@ export class WorkspaceProvider implements vscode.TreeDataProvider<vscode.TreeIte
58
58
59
59
const resp = await getWorkspaces ( { q : this . getWorkspacesQuery } )
60
60
61
- // We could have logged out while waiting for the query.
62
- if ( ! url || ! token ) {
61
+ // We could have logged out while waiting for the query, or logged into a
62
+ // different deployment.
63
+ const url2 = this . storage . getURL ( )
64
+ const token2 = await this . storage . getSessionToken ( )
65
+ if ( ! url2 || ! token2 ) {
63
66
throw new Error ( "not logged in" )
67
+ } else if ( url !== url2 ) {
68
+ // In this case we need to fetch from the new deployment instead.
69
+ // TODO: It would be better to cancel this fetch when that happens,
70
+ // because this means we have to wait for the old fetch to finish before
71
+ // finally getting workspaces for the new one.
72
+ return this . fetch ( )
64
73
}
65
74
66
75
return resp . workspaces . map ( ( workspace ) => {
67
76
const showMetadata = this . getWorkspacesQuery === WorkspaceQuery . Mine
68
77
if ( showMetadata ) {
69
78
const agents = extractAgents ( workspace )
70
- agents . forEach ( ( agent ) => this . monitorMetadata ( agent . id , url , token ) ) // monitor metadata for all agents
79
+ agents . forEach ( ( agent ) => this . monitorMetadata ( agent . id , url , token2 ) ) // monitor metadata for all agents
71
80
}
72
81
return new WorkspaceTreeItem ( workspace , this . getWorkspacesQuery === WorkspaceQuery . All , showMetadata )
73
82
} )
0 commit comments