File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ export class DeploymentManager implements vscode.Disposable {
127127 // Register auth listener before setDeployment so background token refresh
128128 // can update client credentials via the listener
129129 this . registerAuthListener ( ) ;
130+ // Contexts must be set before refresh (providers check isAuthenticated)
130131 this . updateAuthContexts ( deployment . user ) ;
131132 this . refreshWorkspaces ( ) ;
132133
Original file line number Diff line number Diff line change @@ -124,10 +124,13 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
124124 ) ;
125125 ctx . subscriptions . push ( authInterceptor ) ;
126126
127+ const isAuthenticated = ( ) => contextManager . get ( "coder.authenticated" ) ;
128+
127129 const myWorkspacesProvider = new WorkspaceProvider (
128130 WorkspaceQuery . Mine ,
129131 client ,
130132 output ,
133+ isAuthenticated ,
131134 5 ,
132135 ) ;
133136 ctx . subscriptions . push ( myWorkspacesProvider ) ;
@@ -136,6 +139,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
136139 WorkspaceQuery . All ,
137140 client ,
138141 output ,
142+ isAuthenticated ,
139143 ) ;
140144 ctx . subscriptions . push ( allWorkspacesProvider ) ;
141145
@@ -316,11 +320,10 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
316320 output . info ( `Initializing deployment: ${ deployment . url } ` ) ;
317321 deploymentManager
318322 . setDeploymentIfValid ( deployment )
323+ // Failure is logged internally
319324 . then ( ( success ) => {
320325 if ( success ) {
321326 output . info ( "Deployment authenticated and set" ) ;
322- } else {
323- output . info ( "Failed to authenticate, deployment not set" ) ;
324327 }
325328 } )
326329 . catch ( ( error : unknown ) => {
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ export class WorkspaceProvider
5050 private readonly getWorkspacesQuery : WorkspaceQuery ,
5151 private readonly client : CoderApi ,
5252 private readonly logger : Logger ,
53+ private readonly isAuthenticated : ( ) => boolean ,
5354 private readonly timerSeconds ?: number ,
5455 ) {
5556 // No initialization.
@@ -61,7 +62,12 @@ export class WorkspaceProvider
6162 // Calling this while already refreshing or not visible is a no-op and will
6263 // return immediately.
6364 public async fetchAndRefresh ( ) {
64- if ( this . disposed || this . fetching || ! this . visible ) {
65+ if (
66+ this . disposed ||
67+ this . fetching ||
68+ ! this . visible ||
69+ ! this . isAuthenticated ( )
70+ ) {
6571 return ;
6672 }
6773 this . fetching = true ;
You can’t perform that action at this time.
0 commit comments