@@ -202,6 +202,10 @@ export class ClaudeTerminalInputProvider implements vscode.WebviewViewProvider {
202202 case "launchClaudeHistory" :
203203 this . _handleLaunchClaudeHistory ( ) ;
204204 return ;
205+
206+ case "toggleMode" :
207+ this . _handleModeToggle ( ) ;
208+ return ;
205209 }
206210 } ,
207211 undefined ,
@@ -1023,6 +1027,41 @@ export class ClaudeTerminalInputProvider implements vscode.WebviewViewProvider {
10231027 }
10241028 }
10251029
1030+ /**
1031+ * Public method to toggle Claude Code mode (exposed for command palette access)
1032+ */
1033+ public async toggleMode ( ) : Promise < void > {
1034+ await this . _handleModeToggle ( ) ;
1035+ }
1036+
1037+ /**
1038+ * Handles mode toggle by sending Shift+Tab to Claude Code terminal
1039+ */
1040+ private async _handleModeToggle ( ) {
1041+ try {
1042+ console . log ( 'Toggling Claude Code mode (Shift+Tab)' ) ;
1043+
1044+ // Check if terminal is available
1045+ if ( this . _isTerminalClosed || ! this . _terminal ) {
1046+ vscode . window . showWarningMessage ( 'Claude Code terminal is not active. Please start Claude Code first.' ) ;
1047+ return ;
1048+ }
1049+
1050+ // Show the terminal in the background (preserves focus)
1051+ this . _terminal ?. show ( true ) ;
1052+
1053+ // Send Shift+Tab key sequence to toggle mode
1054+ // \x1b[Z is the escape sequence for Shift+Tab
1055+ this . _terminal ?. sendText ( '\x1b[Z' , false ) ;
1056+
1057+ console . log ( 'Mode toggle command sent to Claude Code terminal' ) ;
1058+
1059+ } catch ( error ) {
1060+ console . error ( 'Error toggling Claude mode:' , error ) ;
1061+ vscode . window . showErrorMessage ( `Failed to toggle Claude mode: ${ error } ` ) ;
1062+ }
1063+ }
1064+
10261065 private _getHtmlForWebview ( webview : vscode . Webview ) {
10271066 // Generate nonce for script security
10281067 const nonce = getNonce ( ) ;
@@ -1043,6 +1082,9 @@ export class ClaudeTerminalInputProvider implements vscode.WebviewViewProvider {
10431082 const imageIconPath = webview . asWebviewUri (
10441083 vscode . Uri . joinPath ( this . _extensionUri , "resources" , "image-svgrepo-com.svg" )
10451084 ) ;
1085+ const modeToggleIconPath = webview . asWebviewUri (
1086+ vscode . Uri . joinPath ( this . _extensionUri , "resources" , "mode-toggle.svg" )
1087+ ) ;
10461088 const codiconsCss = webview . asWebviewUri (
10471089 vscode . Uri . joinPath ( this . _extensionUri , "media" , "codicon.css" )
10481090 ) ;
@@ -1156,6 +1198,9 @@ export class ClaudeTerminalInputProvider implements vscode.WebviewViewProvider {
11561198 <button id="imageButton" title="Attach image" class="image-button">
11571199 <img src="${ imageIconPath } " width="20" height="20" alt="Attach Image" />
11581200 </button>
1201+ <button id="modeToggleButton" title="Toggle Claude Mode (Shift+Tab)" class="mode-toggle-button">
1202+ <img src="${ modeToggleIconPath } " width="16" height="16" alt="Toggle Mode" />
1203+ </button>
11591204 </div>
11601205 <div id="contextMenuContainer" class="context-menu-container" style="display: none;"></div>
11611206 <div id="imagePreviewContainer" class="image-preview-container"></div>
0 commit comments