77 SetupSection ,
88 SetupData as TSetupData
99} from './webview/contract'
10- import { collectSectionCollapsed } from './collect'
10+ import { collectRemoteList , collectSectionCollapsed } from './collect'
1111import { WebviewMessages } from './webview/messages'
1212import { validateTokenInput } from './inputBox'
1313import { findPythonBinForInstall } from './autoInstall'
@@ -47,7 +47,8 @@ import {
4747 Flag ,
4848 ConfigKey as DvcConfigKey ,
4949 DOT_DVC ,
50- Args
50+ Args ,
51+ SubCommand
5152} from '../cli/dvc/constants'
5253import { GLOBAL_WEBVIEW_DVCROOT } from '../webview/factory'
5354import {
@@ -229,7 +230,7 @@ export class Setup
229230 ) {
230231 this . cliCompatible = compatible
231232 this . cliVersion = version
232- void this . updateIsStudioConnected ( )
233+ void this . updateStudioAndSend ( )
233234 const incompatible = compatible === undefined ? undefined : ! compatible
234235 void setContextValue ( ContextKey . CLI_INCOMPATIBLE , incompatible )
235236 }
@@ -339,7 +340,7 @@ export class Setup
339340 }
340341
341342 await this . accessConfig ( cwd , Flag . GLOBAL , DvcConfigKey . STUDIO_TOKEN , token )
342- return this . updateIsStudioConnected ( )
343+ return this . updateStudioAndSend ( )
343344 }
344345
345346 public getStudioLiveShareToken ( ) {
@@ -375,14 +376,28 @@ export class Setup
375376 }
376377 }
377378
379+ private async getRemoteList ( ) {
380+ await this . config . isReady ( )
381+
382+ if ( ! this . hasRoots ( ) ) {
383+ return undefined
384+ }
385+
386+ return collectRemoteList ( this . dvcRoots , ( cwd : string ) =>
387+ this . accessRemote ( cwd , SubCommand . LIST )
388+ )
389+ }
390+
378391 private async sendDataToWebview ( ) {
379392 const projectInitialized = this . hasRoots ( )
380393 const hasData = this . getHasData ( )
381394
382- const [ isPythonExtensionUsed , dvcCliDetails ] = await Promise . all ( [
383- this . isPythonExtensionUsed ( ) ,
384- this . getDvcCliDetails ( )
385- ] )
395+ const [ isPythonExtensionUsed , dvcCliDetails , remoteList ] =
396+ await Promise . all ( [
397+ this . isPythonExtensionUsed ( ) ,
398+ this . getDvcCliDetails ( ) ,
399+ this . getRemoteList ( )
400+ ] )
386401
387402 const needsGitInitialized =
388403 ! projectInitialized && ! ! ( await this . needsGitInit ( ) )
@@ -405,6 +420,7 @@ export class Setup
405420 needsGitInitialized,
406421 projectInitialized,
407422 pythonBinPath : getBinDisplayText ( pythonBinPath ) ,
423+ remoteList,
408424 sectionCollapsed : collectSectionCollapsed ( this . focusedSection ) ,
409425 shareLiveToStudio : getConfigValue (
410426 ExtensionConfigKey . STUDIO_SHARE_EXPERIMENTS_LIVE
@@ -644,16 +660,16 @@ export class Setup
644660 }
645661 }
646662
663+ private async updateStudioAndSend ( ) {
664+ await this . updateIsStudioConnected ( )
665+ return this . sendDataToWebview ( )
666+ }
667+
647668 private async updateIsStudioConnected ( ) {
648669 await this . setStudioAccessToken ( )
649670 const storedToken = this . getStudioAccessToken ( )
650671 const isConnected = isStudioAccessToken ( storedToken )
651- return this . setStudioIsConnected ( isConnected )
652- }
653-
654- private setStudioIsConnected ( isConnected : boolean ) {
655672 this . studioIsConnected = isConnected
656- void this . sendDataToWebview ( )
657673 return setContextValue ( ContextKey . STUDIO_CONNECTED , isConnected )
658674 }
659675
@@ -667,7 +683,7 @@ export class Setup
667683 path . endsWith ( join ( 'dvc' , 'config' ) ) ||
668684 path . endsWith ( join ( 'dvc' , 'config.local' ) )
669685 ) {
670- void this . updateIsStudioConnected ( )
686+ void this . updateStudioAndSend ( )
671687 }
672688 }
673689 )
@@ -705,13 +721,23 @@ export class Setup
705721 )
706722 }
707723
708- private async accessConfig ( cwd : string , ...args : Args ) {
724+ private accessConfig ( cwd : string , ...args : Args ) {
725+ return this . accessDvc ( AvailableCommands . CONFIG , cwd , ...args )
726+ }
727+
728+ private accessRemote ( cwd : string , ...args : Args ) {
729+ return this . accessDvc ( AvailableCommands . REMOTE , cwd , ...args )
730+ }
731+
732+ private async accessDvc (
733+ commandId :
734+ | typeof AvailableCommands . CONFIG
735+ | typeof AvailableCommands . REMOTE ,
736+ cwd : string ,
737+ ...args : Args
738+ ) {
709739 try {
710- return await this . internalCommands . executeCommand (
711- AvailableCommands . CONFIG ,
712- cwd ,
713- ...args
714- )
740+ return await this . internalCommands . executeCommand ( commandId , cwd , ...args )
715741 } catch { }
716742 }
717743}
0 commit comments