@@ -37,97 +37,108 @@ export const TopBar = ({
3737 onCloseSettings,
3838 onOpenCommandPalette,
3939 t
40- } : TopBarProps ) => (
41- < header className = { `topbar ${ isSettingsRoute ? "topbar-settings" : "" } ` } >
42- < div className = "topbar-tabs-wrap" >
43- { isSettingsRoute ? (
44- < div className = "route-topbar" data-testid = "settings-topbar" >
45- < button className = "route-topbar-back" type = "button" onClick = { onCloseSettings } >
46- < HeaderBackIcon />
47- < span > { t ( "backToApp" ) } </ span >
48- </ button >
49- < div className = "route-topbar-title" > { t ( "settings" ) } </ div >
50- </ div >
51- ) : (
52- < div className = "topbar-session-strip topbar-workspace-strip" data-testid = "workspace-topbar" >
53- < button
54- type = "button"
55- className = { `session-top-history ${ historyOpen ? "active" : "" } ` }
56- onClick = { onToggleHistory }
57- title = { t ( "history" ) }
58- aria-label = { t ( "history" ) }
59- data-testid = "history-toggle"
60- >
61- < HeaderHistoryIcon />
62- </ button >
63- { workspaceTabs . map ( ( item ) => (
64- < div
65- key = { item . id }
66- role = "button"
67- tabIndex = { 0 }
68- className = { `session-top-tab workspace-top-tab ${ item . active ? "active" : "" } ${ item . hasRunning ? "running-glow" : "" } ` }
69- onClick = { ( ) => onSwitchWorkspace ( item . id ) }
70- onKeyDown = { ( event ) => {
71- if ( event . key === "Enter" || event . key === " " ) {
72- event . preventDefault ( ) ;
73- onSwitchWorkspace ( item . id ) ;
74- }
75- } }
76- title = { item . label }
40+ } : TopBarProps ) => {
41+ const hasWorkspaceTabs = workspaceTabs . length > 0 ;
42+
43+ return (
44+ < header className = { `topbar ${ isSettingsRoute ? "topbar-settings" : "" } ` } >
45+ < div className = "topbar-tabs-wrap" >
46+ { isSettingsRoute ? (
47+ < div className = "route-topbar" data-testid = "settings-topbar" >
48+ < button className = "route-topbar-back" type = "button" onClick = { onCloseSettings } >
49+ < HeaderBackIcon />
50+ < span > { t ( "backToApp" ) } </ span >
51+ </ button >
52+ < div className = "route-topbar-title" > { t ( "settings" ) } </ div >
53+ </ div >
54+ ) : (
55+ < div className = "topbar-session-strip topbar-workspace-strip" data-testid = "workspace-topbar" >
56+ < button
57+ type = "button"
58+ className = { `session-top-history ${ historyOpen ? "active" : "" } ` }
59+ onClick = { onToggleHistory }
60+ title = { t ( "history" ) }
61+ aria-label = { t ( "history" ) }
62+ data-testid = "history-toggle"
63+ >
64+ < HeaderHistoryIcon />
65+ </ button >
66+ { hasWorkspaceTabs ? (
67+ workspaceTabs . map ( ( item ) => (
68+ < div
69+ key = { item . id }
70+ role = "button"
71+ tabIndex = { 0 }
72+ className = { `session-top-tab workspace-top-tab ${ item . active ? "active" : "" } ${ item . hasRunning ? "running-glow" : "" } ` }
73+ onClick = { ( ) => onSwitchWorkspace ( item . id ) }
74+ onKeyDown = { ( event ) => {
75+ if ( event . key === "Enter" || event . key === " " ) {
76+ event . preventDefault ( ) ;
77+ onSwitchWorkspace ( item . id ) ;
78+ }
79+ } }
80+ title = { item . label }
81+ >
82+ < span className = { `session-top-dot ${ item . hasRunning ? "active pulse" : "idle" } ` } />
83+ < span className = "session-top-label" > { item . label } </ span >
84+ { ! item . active && item . unread > 0 && (
85+ < span className = "session-top-unread" title = { `${ item . unread } ` } aria-label = { `${ item . unread } ` } >
86+ { item . unread > 9 ? "9+" : item . unread }
87+ </ span >
88+ ) }
89+ < button
90+ type = "button"
91+ className = "session-top-close"
92+ title = { t ( "close" ) }
93+ aria-label = { t ( "close" ) }
94+ onClick = { ( event ) => {
95+ event . stopPropagation ( ) ;
96+ onRemoveTab ( item . id ) ;
97+ } }
98+ >
99+ < HeaderCloseIcon />
100+ </ button >
101+ </ div >
102+ ) )
103+ ) : (
104+ < div className = "workspace-topbar-empty" aria-live = "polite" >
105+ < span className = "workspace-topbar-empty-kicker" > { t ( "workspaceWelcomeKicker" ) } </ span >
106+ < span className = "workspace-topbar-empty-label" > { t ( "noWorkspace" ) } </ span >
107+ </ div >
108+ ) }
109+ < button
110+ type = "button"
111+ className = "session-top-add"
112+ onClick = { onAddTab }
113+ title = { locale === "zh" ? "新建工作区" : "Add workspace" }
114+ aria-label = { locale === "zh" ? "新建工作区" : "Add workspace" }
77115 >
78- < span className = { `session-top-dot ${ item . hasRunning ? "active pulse" : "idle" } ` } />
79- < span className = "session-top-label" > { item . label } </ span >
80- { ! item . active && item . unread > 0 && (
81- < span className = "session-top-unread" title = { `${ item . unread } ` } aria-label = { `${ item . unread } ` } >
82- { item . unread > 9 ? "9+" : item . unread }
83- </ span >
84- ) }
85- < button
86- type = "button"
87- className = "session-top-close"
88- title = { t ( "close" ) }
89- aria-label = { t ( "close" ) }
90- onClick = { ( event ) => {
91- event . stopPropagation ( ) ;
92- onRemoveTab ( item . id ) ;
93- } }
94- >
95- < HeaderCloseIcon />
96- </ button >
97- </ div >
98- ) ) }
99- < button
100- type = "button"
101- className = "session-top-add"
102- onClick = { onAddTab }
103- title = { locale === "zh" ? "新建工作区" : "Add workspace" }
104- aria-label = { locale === "zh" ? "新建工作区" : "Add workspace" }
105- >
106- < HeaderAddIcon />
107- </ button >
108- </ div >
109- ) }
110- </ div >
111- < div className = "topbar-actions" >
112- { ! isSettingsRoute && (
113- < >
114- < button
115- type = "button"
116- className = "topbar-tool topbar-tool-wide"
117- onClick = { onOpenCommandPalette }
118- title = { locale === "zh" ? "快速操作(⌘/Ctrl+K)" : "Quick actions (⌘/Ctrl+K)" }
119- aria-label = { locale === "zh" ? "快速操作" : "Quick actions" }
120- >
121- < SearchIcon />
122- < span > { locale === "zh" ? "操作" : "Actions" } </ span >
123- </ button >
124- < button className = "topbar-tool" type = "button" onClick = { onOpenSettings } data-testid = "settings-open" title = { t ( "settings" ) } aria-label = { t ( "settings" ) } >
125- < HeaderSettingsIcon />
126- </ button >
127- </ >
128- ) }
129- </ div >
130- </ header >
131- ) ;
116+ < HeaderAddIcon />
117+ </ button >
118+ </ div >
119+ ) }
120+ </ div >
121+ < div className = "topbar-actions" >
122+ { ! isSettingsRoute && (
123+ < >
124+ < button
125+ type = "button"
126+ className = "topbar-tool topbar-tool-wide"
127+ onClick = { onOpenCommandPalette }
128+ title = { locale === "zh" ? "快速操作(⌘/Ctrl+K)" : "Quick actions (⌘/Ctrl+K)" }
129+ aria-label = { locale === "zh" ? "快速操作" : "Quick actions" }
130+ >
131+ < SearchIcon />
132+ < span > { locale === "zh" ? "操作" : "Actions" } </ span >
133+ </ button >
134+ < button className = "topbar-tool" type = "button" onClick = { onOpenSettings } data-testid = "settings-open" title = { t ( "settings" ) } aria-label = { t ( "settings" ) } >
135+ < HeaderSettingsIcon />
136+ </ button >
137+ </ >
138+ ) }
139+ </ div >
140+ </ header >
141+ ) ;
142+ } ;
132143
133144export default TopBar ;
0 commit comments