@@ -27,6 +27,7 @@ function App() {
2727 const [ currentSession , setCurrentSession ] = useState ( null )
2828 const [ searchQuery , setSearchQuery ] = useState ( '' )
2929 const [ debouncedQuery , setDebouncedQuery ] = useState ( '' )
30+ const [ forceExpand , setForceExpand ] = useState ( false )
3031 const currentPort = useRef ( null )
3132 const searchInputRef = useRef ( null )
3233
@@ -134,19 +135,12 @@ function App() {
134135 return ( ) => clearTimeout ( id )
135136 } , [ searchQuery ] )
136137
137- // Keyboard shortcuts: Ctrl/Cmd+F and '/' to focus search
138+ // Keyboard shortcuts: Ctrl/Cmd+F and '/' to focus search (不改釘選狀態)
138139 useEffect ( ( ) => {
139140 const focusSearch = ( ) => {
140- if ( collapsed ) {
141- setCollapsed ( false )
142- setUserConfig ( { independentPanelCollapsed : false } )
143- setTimeout ( ( ) => {
144- if ( searchInputRef . current ) {
145- searchInputRef . current . focus ( )
146- searchInputRef . current . select ( )
147- }
148- } , 0 )
149- } else if ( searchInputRef . current ) {
141+ if ( searchInputRef . current ) {
142+ // Ensure the sidebar temporarily expands when using shortcuts
143+ setForceExpand ( true )
150144 searchInputRef . current . focus ( )
151145 searchInputRef . current . select ( )
152146 }
@@ -157,7 +151,7 @@ function App() {
157151 target &&
158152 ( target . tagName === 'INPUT' || target . tagName === 'TEXTAREA' || target . isContentEditable )
159153
160- // Always override browser find to route to panel search
154+ // Always override browser find to route to panel search(不自動釘選)
161155 if ( ( e . ctrlKey || e . metaKey ) && ! e . altKey && ! e . shiftKey && e . key . toLowerCase ( ) === 'f' ) {
162156 e . preventDefault ( )
163157 focusSearch ( )
@@ -171,7 +165,7 @@ function App() {
171165 }
172166 window . addEventListener ( 'keydown' , onKeyDown )
173167 return ( ) => window . removeEventListener ( 'keydown' , onKeyDown )
174- } , [ collapsed ] )
168+ } , [ ] )
175169
176170 // Utility function to safely convert any value to a string
177171 const toSafeString = ( value ) =>
@@ -218,7 +212,7 @@ function App() {
218212 return (
219213 < div className = "IndependentPanel" >
220214 < div className = "chat-container" >
221- < div className = { `chat-sidebar ${ collapsed ? 'collapsed' : '' } ` } >
215+ < div className = { `chat-sidebar ${ collapsed && ! forceExpand ? 'collapsed' : '' } ` } >
222216 < div className = "chat-sidebar-button-group" >
223217 < button
224218 type = "button"
@@ -242,6 +236,8 @@ function App() {
242236 placeholder = { t ( 'Search conversations...' ) }
243237 value = { searchQuery }
244238 onChange = { handleSearchChange }
239+ onFocus = { ( ) => setForceExpand ( true ) }
240+ onBlur = { ( ) => setForceExpand ( false ) }
245241 className = "search-input"
246242 aria-label = { t ( 'Search' ) }
247243 aria-controls = "chat-list"
0 commit comments