33
44import { computeConnColorNum } from "@/app/block/blockutil" ;
55import { TypeAheadModal } from "@/app/modals/typeaheadmodal" ;
6- import {
7- atoms ,
8- createBlock ,
9- getApi ,
10- getConnStatusAtom ,
11- getHostName ,
12- getUserName ,
13- globalStore ,
14- WOS ,
15- } from "@/app/store/global" ;
6+ import { ConnectionsModel } from "@/app/store/connections-model" ;
7+ import { atoms , createBlock , getConnStatusAtom , getHostName , getUserName , globalStore , WOS } from "@/app/store/global" ;
168import { globalRefocusWithTimeout } from "@/app/store/keymodel" ;
179import { RpcApi } from "@/app/store/wshclientapi" ;
1810import { TabRpcClient } from "@/app/store/wshrpcutil" ;
@@ -107,7 +99,7 @@ function createFilteredLocalSuggestionItem(
10799 iconColor : "var(--grey-text-color)" ,
108100 value : "" ,
109101 label : localName ,
110- current : connection == null ,
102+ current : util . isBlank ( connection ) ,
111103 } ;
112104 return [ localSuggestion ] ;
113105 }
@@ -172,12 +164,26 @@ function getLocalSuggestions(
172164 connSelected : string ,
173165 connStatusMap : Map < string , ConnStatus > ,
174166 fullConfig : FullConfigType ,
175- filterOutNowsh : boolean
167+ filterOutNowsh : boolean ,
168+ hasGitBash : boolean
176169) : SuggestionConnectionScope | null {
177170 const wslFiltered = filterConnections ( connList , connSelected , fullConfig , filterOutNowsh ) ;
178171 const wslSuggestionItems = createWslSuggestionItems ( wslFiltered , connection , connStatusMap ) ;
179172 const localSuggestionItem = createFilteredLocalSuggestionItem ( localName , connection , connSelected ) ;
180- const combinedSuggestionItems = [ ...localSuggestionItem , ...wslSuggestionItems ] ;
173+
174+ const gitBashItems : Array < SuggestionConnectionItem > = [ ] ;
175+ if ( hasGitBash && "Git Bash" . toLowerCase ( ) . includes ( connSelected . toLowerCase ( ) ) ) {
176+ gitBashItems . push ( {
177+ status : "connected" ,
178+ icon : "laptop" ,
179+ iconColor : "var(--grey-text-color)" ,
180+ value : "local:gitbash" ,
181+ label : "Git Bash" ,
182+ current : connection === "local:gitbash" ,
183+ } ) ;
184+ }
185+
186+ const combinedSuggestionItems = [ ...localSuggestionItem , ...gitBashItems , ...wslSuggestionItems ] ;
181187 const sortedSuggestionItems = sortConnSuggestionItems ( combinedSuggestionItems , fullConfig ) ;
182188 if ( sortedSuggestionItems . length == 0 ) {
183189 return null ;
@@ -235,7 +241,7 @@ function getDisconnectItem(
235241 connection : string ,
236242 connStatusMap : Map < string , ConnStatus >
237243) : SuggestionConnectionItem | null {
238- if ( ! connection ) {
244+ if ( util . isLocalConnName ( connection ) ) {
239245 return null ;
240246 }
241247 const connStatus = connStatusMap . get ( connection ) ;
@@ -346,6 +352,7 @@ const ChangeConnectionBlockModal = React.memo(
346352 const fullConfig = jotai . useAtomValue ( atoms . fullConfigAtom ) ;
347353 let filterOutNowsh = util . useAtomValueSafe ( viewModel . filterOutNowsh ) ?? true ;
348354 const showS3 = util . useAtomValueSafe ( viewModel . showS3 ) ?? false ;
355+ const hasGitBash = jotai . useAtomValue ( ConnectionsModel . getInstance ( ) . hasGitBashAtom ) ;
349356
350357 let maxActiveConnNum = 1 ;
351358 for ( const conn of allConnStatus ) {
@@ -402,7 +409,7 @@ const ChangeConnectionBlockModal = React.memo(
402409 oref : WOS . makeORef ( "block" , blockId ) ,
403410 meta : { connection : connName , file : newFile , "cmd:cwd" : null } ,
404411 } ) ;
405-
412+
406413 try {
407414 await RpcApi . ConnEnsureCommand (
408415 TabRpcClient ,
@@ -425,7 +432,8 @@ const ChangeConnectionBlockModal = React.memo(
425432 connSelected ,
426433 connStatusMap ,
427434 fullConfig ,
428- filterOutNowsh
435+ filterOutNowsh ,
436+ hasGitBash
429437 ) ;
430438 const remoteSuggestions = getRemoteSuggestions (
431439 connList ,
0 commit comments