Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb342a11

Browse files
committed
Review comments
1 parentbc4ba72 commitb342a11

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

‎src/remote/remote.ts‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ export class Remote {
291291
this.vscodeProposed,
292292
this.contextManager,
293293
);
294-
disposables.push(monitor);
295294
disposables.push(
295+
monitor,
296296
monitor.onChange.event((w)=>(this.commands.workspace=w)),
297297
);
298298

@@ -310,7 +310,7 @@ export class Remote {
310310
disposables.push(stateMachine);
311311

312312
try{
313-
awaitthis.vscodeProposed.window.withProgress(
313+
workspace=awaitthis.vscodeProposed.window.withProgress(
314314
{
315315
location:vscode.ProgressLocation.Notification,
316316
cancellable:false,
@@ -320,10 +320,8 @@ export class Remote {
320320
letinProgress=false;
321321
letpendingWorkspace:Workspace|null=null;
322322

323-
awaitnewPromise<void>((resolve,reject)=>{
323+
returnnewPromise<Workspace>((resolve,reject)=>{
324324
constprocessWorkspace=async(w:Workspace)=>{
325-
workspace=w;
326-
327325
if(inProgress){
328326
// Process one workspace at a time, keeping only the last
329327
pendingWorkspace=w;
@@ -340,26 +338,19 @@ export class Remote {
340338
);
341339
if(isReady){
342340
subscription.dispose();
343-
resolve();
341+
resolve(w);
344342
return;
345343
}
346-
347-
if(pendingWorkspace){
348-
constisReadyAfter=awaitstateMachine.processWorkspace(
349-
pendingWorkspace,
350-
progress,
351-
);
352-
if(isReadyAfter){
353-
subscription.dispose();
354-
resolve();
355-
}
356-
}
357344
}catch(error){
358345
subscription.dispose();
359346
reject(error);
360347
}finally{
361348
inProgress=false;
362349
}
350+
351+
if(pendingWorkspace){
352+
processWorkspace(pendingWorkspace);
353+
}
363354
};
364355

365356
processWorkspace(workspace);
@@ -373,6 +364,9 @@ export class Remote {
373364
stateMachine.dispose();
374365
}
375366

367+
// Mark initial setup as complete so the monitor can start notifying about state changes
368+
monitor.markInitialSetupComplete();
369+
376370
constagents=extractAgents(workspace.latest_build.resources);
377371
constagent=agents.find(
378372
(agent)=>agent.id===stateMachine.getAgentId(),

‎src/remote/workspaceStateMachine.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ export class WorkspaceStateMachine implements vscode.Disposable {
9595
case"pending":
9696
case"starting":
9797
case"stopping":
98+
// Clear the agent ID since it could change after a restart
99+
this.agentId=undefined;
98100
progress?.report({message:"Waiting for workspace build..."});
99101
this.logger.info(`Waiting for${workspaceName}...`);
100102

‎src/workspace/workspaceMonitor.ts‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class WorkspaceMonitor implements vscode.Disposable {
2929
privatenotifiedDeletion=false;
3030
privatenotifiedOutdated=false;
3131
privatenotifiedNotRunning=false;
32-
privateisReady=false;
32+
privatecompletedInitialSetup=false;
3333

3434
readonlyonChange=newvscode.EventEmitter<Workspace>();
3535
privatereadonlystatusBarItem:vscode.StatusBarItem;
@@ -111,6 +111,10 @@ export class WorkspaceMonitor implements vscode.Disposable {
111111
returnmonitor;
112112
}
113113

114+
publicmarkInitialSetupComplete():void{
115+
this.completedInitialSetup=true;
116+
}
117+
114118
/**
115119
* Permanently close the websocket.
116120
*/
@@ -124,7 +128,6 @@ export class WorkspaceMonitor implements vscode.Disposable {
124128
}
125129

126130
privateupdate(workspace:Workspace){
127-
this.updateReadyState(workspace);
128131
this.updateContext(workspace);
129132
this.updateStatusBar(workspace);
130133
}
@@ -133,7 +136,7 @@ export class WorkspaceMonitor implements vscode.Disposable {
133136
this.maybeNotifyOutdated(workspace);
134137
this.maybeNotifyAutostop(workspace);
135138
this.maybeNotifyDeletion(workspace);
136-
if(this.isReady){
139+
if(this.completedInitialSetup){
137140
// This instance might be created before the workspace is running
138141
this.maybeNotifyNotRunning(workspace);
139142
}
@@ -249,12 +252,6 @@ export class WorkspaceMonitor implements vscode.Disposable {
249252
this.logger.error(message);
250253
}
251254

252-
privateupdateReadyState(workspace:Workspace):void{
253-
if(workspace.latest_build.status==="running"){
254-
this.isReady=true;
255-
}
256-
}
257-
258255
privateupdateContext(workspace:Workspace){
259256
this.contextManager.set("coder.workspace.updatable",workspace.outdated);
260257
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp