@@ -147,11 +147,13 @@ define(function (require, exports, module) {
147147 // Dropdown chevron button toggles shell selector
148148 $panel . find ( ".terminal-flyout-dropdown-btn" ) . on ( "click" , _onDropdownButtonClick ) ;
149149
150- // When the terminal is focused, prevent Phoenix keybindings from
151- // stealing keys that should go to the shell (e.g. Ctrl+L for clear).
152- // The EDITOR_SHORTCUTS list in TerminalInstance.js already defines which
153- // Ctrl combos should pass through to Phoenix; everything else should
154- // reach xterm/the PTY.
150+ // When the terminal is focused, route all keyboard events to the
151+ // terminal instead of letting Phoenix keybindings intercept them.
152+ // Only a few essential shortcuts are passed back to Phoenix.
153+ const PHOENIX_SHORTCUTS = [
154+ { ctrlKey : true , key : "p" } , // Command Palette
155+ { key : "f4" } // Switch terminals
156+ ] ;
155157 KeyBindingManager . addGlobalKeydownHook ( function ( event ) {
156158 if ( event . type !== "keydown" ) {
157159 return false ;
@@ -161,22 +163,33 @@ define(function (require, exports, module) {
161163 if ( ! el || ! $contentArea [ 0 ] . contains ( el ) ) {
162164 return false ;
163165 }
164- // Let the terminal handle Ctrl/Cmd key combos that aren't
165- // reserved for the editor (those are handled by TerminalInstance's
166- // _customKeyHandler which returns false for them).
166+
167167 const ctrlOrMeta = event . ctrlKey || event . metaKey ;
168168 const key = event . key . toLowerCase ( ) ;
169- if ( ctrlOrMeta && ! event . shiftKey && key === "l" ) {
170- _showClearBufferHintToast ( ) ;
171- return true ; // Block Phoenix, let xterm handle Ctrl+L
172- }
169+
173170 // Ctrl+K (Cmd+K on mac): clear terminal scrollback
174171 if ( ctrlOrMeta && ! event . shiftKey && key === "k" ) {
175172 event . preventDefault ( ) ;
176173 _clearActiveTerminal ( ) ;
177174 return true ;
178175 }
179- return false ;
176+
177+ // Show clear buffer hint on Ctrl+L
178+ if ( ctrlOrMeta && ! event . shiftKey && key === "l" ) {
179+ _showClearBufferHintToast ( ) ;
180+ }
181+
182+ // Let Phoenix handle these specific shortcuts
183+ for ( const shortcut of PHOENIX_SHORTCUTS ) {
184+ const ctrlMatch = shortcut . ctrlKey ? ctrlOrMeta : ! ctrlOrMeta ;
185+ const shiftMatch = shortcut . shiftKey ? event . shiftKey : ! event . shiftKey ;
186+ if ( ctrlMatch && shiftMatch && key === shortcut . key . toLowerCase ( ) ) {
187+ return false ; // Let Phoenix handle it
188+ }
189+ }
190+
191+ // Block Phoenix from handling everything else — let xterm get it
192+ return true ;
180193 } ) ;
181194
182195 // Refresh process info when the tab bar gains focus or mouse enters
0 commit comments