1- import React from 'react'
1+ import React , { useState , useRef , useEffect } from 'react'
2+
3+ type Mode = 'fast' | 'planner' | 'colab' | 'teach'
24
35interface TitleBarProps {
4- mode : 'fast' | 'planner' | 'colab'
5- onModeChange : ( mode : 'fast' | 'planner' | 'colab' ) => void
6+ mode : Mode
7+ onModeChange : ( mode : Mode ) => void
68 onSettingsClick : ( ) => void
79 onMcpClick : ( ) => void
810 onBrowserClick : ( ) => void
@@ -13,29 +15,78 @@ interface TitleBarProps {
1315 onTogglePanel : ( ) => void
1416}
1517
16- const TitleBar : React . FC < TitleBarProps > = ( { mode, onModeChange, onSettingsClick, onMcpClick, onBrowserClick, showBrowser, onTerminalClick, showTerminal, showPanel, onTogglePanel } ) => {
18+ const MODES : { id : Mode ; label : string ; icon : string ; desc : string ; color : string } [ ] = [
19+ { id : 'fast' , label : 'Fast Mode' , icon : '⚡' , desc : 'Direct execution, high speed' , color : 'text-cyan-400' } ,
20+ { id : 'planner' , label : 'Planner' , icon : '📋' , desc : 'Strategy first, safe edits' , color : 'text-amber-400' } ,
21+ { id : 'colab' , label : 'Collaborative' , icon : '👥' , desc : 'Multi-agent architectural design' , color : 'text-indigo-400' } ,
22+ { id : 'teach' , label : 'Teach & Code' , icon : '🎓' , desc : 'Step-by-step technical mentoring' , color : 'text-emerald-400' } ,
23+ ]
24+
25+ const TitleBar : React . FC < TitleBarProps > = ( {
26+ mode, onModeChange, onSettingsClick, onMcpClick,
27+ onBrowserClick, showBrowser, onTerminalClick, showTerminal,
28+ showPanel, onTogglePanel
29+ } ) => {
30+ const [ showDropdown , setShowDropdown ] = useState ( false )
31+ const dropdownRef = useRef < HTMLDivElement > ( null )
32+ const activeMode = MODES . find ( m => m . id === mode ) || MODES [ 0 ]
33+
34+ useEffect ( ( ) => {
35+ const handleClickOutside = ( event : MouseEvent ) => {
36+ if ( dropdownRef . current && ! dropdownRef . current . contains ( event . target as Node ) ) {
37+ setShowDropdown ( false )
38+ }
39+ }
40+ document . addEventListener ( 'mousedown' , handleClickOutside )
41+ return ( ) => document . removeEventListener ( 'mousedown' , handleClickOutside )
42+ } , [ ] )
43+
1744 return (
18- < div className = "h-10 bg-slate-900 border-b border-white/5 flex items-center justify-between px-3 select-none titlebar-drag" >
19- < div className = "flex items-center gap-2 no-drag h-full" >
20- < div className = "flex bg-slate-900/60 rounded-md p-0.5 border border-white/5 shadow-inner" >
21- < button
22- onClick = { ( ) => onModeChange ( 'fast' ) }
23- className = { `w-14 h-5 flex items-center justify-center rounded text-[8px] font-black uppercase tracking-widest transition-all duration-200 no-drag ${ mode === 'fast' ? 'bg-cyan-600/90 text-white scale-105' : 'text-slate-500 hover:text-slate-300 hover:bg-white/5' } ` }
24- >
25- Fast
26- </ button >
27- < button
28- onClick = { ( ) => onModeChange ( 'planner' ) }
29- className = { `w-16 h-5 flex items-center justify-center rounded text-[8px] font-black uppercase tracking-widest transition-all duration-200 no-drag ${ mode === 'planner' ? 'bg-amber-600/90 text-white scale-105' : 'text-slate-500 hover:text-slate-300 hover:bg-white/5' } ` }
30- >
31- Planner
32- </ button >
33- < button
34- onClick = { ( ) => onModeChange ( 'colab' ) }
35- className = { `w-14 h-5 flex items-center justify-center rounded text-[8px] font-black uppercase tracking-widest transition-all duration-200 no-drag ${ mode === 'colab' ? 'bg-indigo-600/90 text-white scale-105' : 'text-slate-500 hover:text-slate-300 hover:bg-white/5' } ` }
45+ < div className = "h-10 bg-slate-900 border-b border-white/5 flex items-center justify-between px-3 select-none titlebar-drag shrink-0 z-[1000]" >
46+ < div className = "flex items-center gap-1 no-drag h-full" >
47+ { /* Mode Selector Dropdown */ }
48+ < div className = "relative h-full flex items-center" ref = { dropdownRef } >
49+ < button
50+ onClick = { ( ) => setShowDropdown ( ! showDropdown ) }
51+ className = "flex items-center gap-2 px-3 py-1 bg-white/5 hover:bg-white/10 rounded-md border border-white/5 transition-all no-drag group"
3652 >
37- Colab
53+ < span className = "text-xs" > { activeMode . icon } </ span >
54+ < span className = { `text-[10px] font-black uppercase tracking-widest ${ activeMode . color } ` } > { activeMode . label } </ span >
55+ < svg
56+ width = "10" height = "10" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "3"
57+ className = { `text-slate-500 transition-transform duration-200 ${ showDropdown ? 'rotate-180' : '' } ` }
58+ >
59+ < path d = "M6 9l6 6 6-6" />
60+ </ svg >
3861 </ button >
62+
63+ { showDropdown && (
64+ < div className = "absolute top-full left-0 mt-1 w-64 bg-[#0d1117] border border-white/10 rounded-lg shadow-2xl overflow-hidden animate-in fade-in slide-in-from-top-1 duration-200 z-[1100]" >
65+ < div className = "p-1" >
66+ { MODES . map ( ( m ) => (
67+ < button
68+ key = { m . id }
69+ onClick = { ( ) => {
70+ onModeChange ( m . id )
71+ setShowDropdown ( false )
72+ } }
73+ className = { `w-full flex flex-col gap-0.5 px-3 py-2 rounded-md transition-all text-left group ${ mode === m . id ? 'bg-white/5' : 'hover:bg-white/5' } ` }
74+ >
75+ < div className = "flex items-center justify-between" >
76+ < div className = "flex items-center gap-2" >
77+ < span className = "text-xs" > { m . icon } </ span >
78+ < span className = { `text-[10px] font-black uppercase tracking-widest ${ mode === m . id ? m . color : 'text-slate-400 group-hover:text-slate-200' } ` } >
79+ { m . label }
80+ </ span >
81+ </ div >
82+ { mode === m . id && < div className = { `w-1 h-1 rounded-full ${ m . color . replace ( 'text-' , 'bg-' ) } ` } /> }
83+ </ div >
84+ < span className = "text-[9px] text-slate-500 ml-5 group-hover:text-slate-400 transition-colors uppercase font-medium" > { m . desc } </ span >
85+ </ button >
86+ ) ) }
87+ </ div >
88+ </ div >
89+ ) }
3990 </ div >
4091
4192 < button
@@ -89,7 +140,6 @@ const TitleBar: React.FC<TitleBarProps> = ({ mode, onModeChange, onSettingsClick
89140 title = { showPanel ? 'Hide context panel' : 'Show context panel' }
90141 className = { `w-11 h-10 flex items-center justify-center transition-colors no-drag ${ showPanel ? 'text-cyan-400 bg-cyan-900/20' : 'text-slate-400 hover:bg-white/10 hover:text-white' } ` }
91142 >
92- { /* Files/tree icon */ }
93143 < svg width = "14" height = "14" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "1.8" strokeLinecap = "round" strokeLinejoin = "round" >
94144 < path d = "M3 6h18M3 12h12M3 18h8" />
95145 </ svg >
@@ -121,4 +171,3 @@ const TitleBar: React.FC<TitleBarProps> = ({ mode, onModeChange, onSettingsClick
121171}
122172
123173export default TitleBar
124-
0 commit comments