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

Commite4bd57f

Browse files
committed
Review comments
1 parent9bf0cd7 commite4bd57f

File tree

1 file changed

+22
-85
lines changed

1 file changed

+22
-85
lines changed

‎src/remote/remote.ts‎

Lines changed: 22 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -545,21 +545,9 @@ export class Remote {
545545
constupdatedAgent=awaitthis.waitForAgentWithProgress(
546546
monitor,
547547
agent,
548-
{
549-
progressTitle:"Waiting for the agent to connect...",
550-
timeoutMs:3*60*1000,
551-
errorDialogTitle:`Failed to wait for${agent.name} connection`,
552-
},
553-
(foundAgent)=>{
554-
if(foundAgent.status!=="connecting"){
555-
returnfoundAgent;
556-
}
557-
returnundefined;
558-
},
548+
`Waiting for agent${agent.name} to connect...`,
549+
(foundAgent)=>foundAgent.status!=="connecting",
559550
);
560-
if(!updatedAgent){
561-
return;
562-
}
563551
agent=updatedAgent;
564552
this.logger.info(`Agent${agent.name} status is now`,agent.status);
565553
}
@@ -606,28 +594,15 @@ export class Remote {
606594
constagentStatePromise=this.waitForAgentWithProgress(
607595
monitor,
608596
agent,
609-
{
610-
progressTitle:"Waiting for agent startup scripts...",
611-
timeoutMs:5*60*1000,
612-
errorDialogTitle:`Failed to wait for${agent.name} startup`,
613-
},
614-
(foundAgent)=>{
615-
if(foundAgent.lifecycle_state!=="starting"){
616-
returnfoundAgent;
617-
}
618-
returnundefined;
619-
},
597+
`Waiting for agent${agent.name} startup scripts...`,
598+
(foundAgent)=>foundAgent.lifecycle_state!=="starting",
620599
);
621600

622-
// Race between logs completion(which fails on socket error)and agent state change
601+
// Race between logs completion and agent state change
623602
constupdatedAgent=awaitPromise.race([
624603
agentStatePromise,
625604
logsCompletion.then(()=>agentStatePromise),
626605
]);
627-
628-
if(!updatedAgent){
629-
return;
630-
}
631606
agent=updatedAgent;
632607
this.logger.info(
633608
`Agent${agent.name} lifecycle state is now`,
@@ -766,70 +741,34 @@ export class Remote {
766741
}
767742

768743
/**
769-
* Waits for an agent condition with progress notification and error handling.
770-
* Returns the updated agent or undefined if the user chooses to close remote.
744+
* Waits for an agent condition with progress notification.
771745
*/
772746
privateasyncwaitForAgentWithProgress(
773747
monitor:WorkspaceMonitor,
774748
agent:WorkspaceAgent,
775-
options:{
776-
progressTitle:string;
777-
timeoutMs:number;
778-
errorDialogTitle:string;
779-
},
780-
checker:(agent:WorkspaceAgent)=>WorkspaceAgent|undefined,
781-
):Promise<WorkspaceAgent|undefined>{
782-
try{
783-
constfoundAgent=awaitvscode.window.withProgress(
784-
{
785-
title:options.progressTitle,
786-
location:vscode.ProgressLocation.Notification,
787-
},
788-
async()=>
789-
this.waitForAgentCondition(
790-
monitor,
791-
agent,
792-
checker,
793-
options.timeoutMs,
794-
`Timeout:${options.errorDialogTitle}`,
795-
),
796-
);
797-
returnfoundAgent;
798-
}catch(error){
799-
this.logger.error(options.errorDialogTitle,error);
800-
constresult=awaitthis.vscodeProposed.window.showErrorMessage(
801-
options.errorDialogTitle,
802-
{
803-
useCustom:true,
804-
modal:true,
805-
detail:errorinstanceofError ?error.message :String(error),
806-
},
807-
"Close Remote",
808-
);
809-
if(result==="Close Remote"){
810-
awaitthis.closeRemote();
811-
}
812-
returnundefined;
813-
}
749+
progressTitle:string,
750+
checker:(agent:WorkspaceAgent)=>boolean,
751+
):Promise<WorkspaceAgent>{
752+
constfoundAgent=awaitvscode.window.withProgress(
753+
{
754+
title:progressTitle,
755+
location:vscode.ProgressLocation.Notification,
756+
},
757+
async()=>this.waitForAgentCondition(monitor,agent,checker),
758+
);
759+
returnfoundAgent;
814760
}
815761

816762
/**
817763
* Waits for an agent condition to be met by monitoring workspace changes.
818764
* Returns the result when the condition is met or throws an error on timeout.
819765
*/
820-
privateasyncwaitForAgentCondition<T>(
766+
privateasyncwaitForAgentCondition(
821767
monitor:WorkspaceMonitor,
822768
agent:WorkspaceAgent,
823-
checker:(agent:WorkspaceAgent)=>T|undefined,
824-
timeoutMs:number,
825-
timeoutMessage:string,
826-
):Promise<T>{
827-
returnnewPromise<T>((resolve,reject)=>{
828-
consttimeout=setTimeout(()=>{
829-
updateEvent.dispose();
830-
reject(newError(timeoutMessage));
831-
},timeoutMs);
832-
769+
checker:(agent:WorkspaceAgent)=>boolean,
770+
):Promise<WorkspaceAgent>{
771+
returnnewPromise<WorkspaceAgent>((resolve,reject)=>{
833772
constupdateEvent=monitor.onChange.event((workspace)=>{
834773
try{
835774
constagents=extractAgents(workspace.latest_build.resources);
@@ -841,12 +780,10 @@ export class Remote {
841780
}
842781
constresult=checker(foundAgent);
843782
if(result!==undefined){
844-
clearTimeout(timeout);
845783
updateEvent.dispose();
846-
resolve(result);
784+
resolve(foundAgent);
847785
}
848786
}catch(error){
849-
clearTimeout(timeout);
850787
updateEvent.dispose();
851788
reject(error);
852789
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp