1111
1212import { useCallback } from 'react' ;
1313import type { WebBridge } from '../bridge/transport' ;
14- import type { ChatEntry } from '../bridge/types' ;
14+ import type { ChatEntry , WorkspaceFolder } from '../bridge/types' ;
1515import './ChatSidebar.css' ;
1616
1717// ---------------------------------------------------------------------------
@@ -22,6 +22,8 @@ interface ChatSidebarProps {
2222 bridge : WebBridge | null ;
2323 chats : ChatEntry [ ] ;
2424 selectedId : string | null ;
25+ /** Workspace folders from the current server session (may be plain path strings). */
26+ workspaceFolders ?: ( WorkspaceFolder | string ) [ ] ;
2527 /** Whether the mobile drawer is open (controlled by parent). */
2628 mobileOpen : boolean ;
2729 /** Called when the mobile drawer should close (backdrop tap, item select). */
@@ -49,7 +51,7 @@ export function ChatSidebarToggle({ onClick }: { onClick: () => void }) {
4951// Main sidebar component
5052// ---------------------------------------------------------------------------
5153
52- export function ChatSidebar ( { bridge, chats = [ ] , selectedId, mobileOpen, onMobileClose } : ChatSidebarProps ) {
54+ export function ChatSidebar ( { bridge, chats = [ ] , selectedId, workspaceFolders = [ ] , mobileOpen, onMobileClose } : ChatSidebarProps ) {
5355 const handleSelect = useCallback (
5456 ( chatId : string ) => {
5557 bridge ?. selectChat ( chatId ) ;
@@ -81,6 +83,19 @@ export function ChatSidebar({ bridge, chats = [], selectedId, mobileOpen, onMobi
8183
8284 { /* Sidebar panel */ }
8385 < div className = { `chat-sidebar ${ mobileOpen ? 'open' : '' } ` } >
86+ { workspaceFolders . length > 0 && ( ( ) => {
87+ const folder = workspaceFolders [ 0 ] ;
88+ // Server sends workspace folders as plain path strings OR {name, uri} objects
89+ const fullPath = typeof folder === 'string' ? folder : ( folder . uri ?. replace ( / ^ f i l e : \/ \/ / , '' ) ?? folder . name ?? '' ) ;
90+ const displayName = ( typeof folder === 'string' ? null : folder . name ) || fullPath . split ( '/' ) . filter ( Boolean ) . pop ( ) || fullPath ;
91+ return (
92+ < div className = "chat-sidebar-workspace" title = { fullPath } >
93+ < i className = "codicon codicon-folder" />
94+ < span className = "chat-sidebar-workspace-name" > { displayName } </ span >
95+ </ div >
96+ ) ;
97+ } ) ( ) }
98+
8499 < div className = "chat-sidebar-header" >
85100 < span className = "chat-sidebar-title" > Chats</ span >
86101 < button
0 commit comments