55 * and close button. Includes an "add" button to open the connect form.
66 */
77
8+ import type { WorkspaceFolder } from '../bridge/types' ;
89import type { Protocol } from '../bridge/utils' ;
910import type { SessionStatus } from './RemoteSession' ;
1011
@@ -19,6 +20,8 @@ export interface ConnectionEntry {
1920 protocol ?: Protocol ;
2021 status : SessionStatus | 'idle' ;
2122 error ?: string ;
23+ /** Workspace folders reported by the server once the session is connected. */
24+ workspaceFolders ?: ( WorkspaceFolder | string ) [ ] ;
2225}
2326
2427interface ConnectionBarProps {
@@ -49,15 +52,26 @@ export function ConnectionBar({
4952 < div className = "conn-bar-tabs" >
5053 { entries . map ( ( entry ) => {
5154 const isActive = entry . id === activeId ;
55+ const ws = getWorkspaceLabel ( entry . workspaceFolders ) ;
56+ const tooltip = ws
57+ ? `${ ws . fullPath } \n${ entry . host } `
58+ : entry . host ;
5259 return (
5360 < button
5461 key = { entry . id }
5562 className = { `conn-tab ${ isActive ? 'active' : '' } ` }
5663 onClick = { ( ) => onSwitch ( entry . id ) }
57- title = { entry . host }
64+ title = { tooltip }
5865 >
5966 < span className = { `conn-dot ${ dotClass ( isActive ? entry . status : 'idle' ) } ` } />
60- < span className = "conn-label" > { formatHost ( entry . host ) } </ span >
67+ { ws ? (
68+ < span className = "conn-label conn-label-rich" >
69+ < span className = "conn-label-primary" > { ws . name } </ span >
70+ < span className = "conn-label-secondary" > { formatHost ( entry . host ) } </ span >
71+ </ span >
72+ ) : (
73+ < span className = "conn-label" > { formatHost ( entry . host ) } </ span >
74+ ) }
6175 < span
6276 className = "conn-close"
6377 role = "button"
@@ -86,6 +100,27 @@ export function ConnectionBar({
86100// Helpers
87101// ---------------------------------------------------------------------------
88102
103+ /**
104+ * Extract a human-friendly workspace label from the first workspace folder.
105+ * Returns `null` when no workspace data is available yet (e.g. still connecting).
106+ */
107+ function getWorkspaceLabel (
108+ folders ?: ( WorkspaceFolder | string ) [ ] ,
109+ ) : { name : string ; fullPath : string } | null {
110+ if ( ! folders || folders . length === 0 ) return null ;
111+ const folder = folders [ 0 ] ;
112+ const fullPath =
113+ typeof folder === 'string'
114+ ? folder
115+ : folder . uri ?. replace ( / ^ f i l e : \/ \/ / , '' ) ?? folder . name ?? '' ;
116+ if ( ! fullPath ) return null ;
117+ const name =
118+ ( typeof folder === 'string' ? null : folder . name ) ||
119+ fullPath . split ( '/' ) . filter ( Boolean ) . pop ( ) ||
120+ fullPath ;
121+ return { name, fullPath } ;
122+ }
123+
89124/** Truncate a host string to fit in the tab bar. */
90125function formatHost ( host : string ) : string {
91126 const clean = host . replace ( / ^ h t t p s ? : \/ \/ / , '' ) ;
0 commit comments