Skip to content

Commit fc26efa

Browse files
Quang Tran Minhclaude
andcommitted
hotfix: hide launch options when connecting to existing Claude terminal
- Fix primary logic in extension.ts to only show launch options when no terminal exists - Add hideLaunchOptions() method for explicit control - Fix race condition in webview initialization to prevent brief appearance of launch options - Ensure consistent state between extension and provider - Improve logging for debugging terminal connection scenarios 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6345d7d commit fc26efa

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

src/extension.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,15 @@ export async function activate(context: vscode.ExtensionContext) {
178178
claudeTerminalInputProvider.updateTerminal(terminal, isExistingTerminal);
179179
}
180180

181-
// If auto-start is disabled and no Claude terminal or not running, show launch options
182-
if (!autoStart && (!terminal || !isClaudeAlreadyRunning)) {
183-
console.log('Auto-start disabled and no active Claude terminal - will show launch options');
181+
// Show/hide launch options based on terminal availability and auto-start setting
182+
if (!autoStart && !terminal) {
183+
// Only show launch options if no terminal exists at all
184+
console.log('Auto-start disabled and no terminal exists - will show launch options');
184185
claudeTerminalInputProvider.showLaunchOptions();
186+
} else if (terminal) {
187+
// Always hide launch options when any terminal exists (new or existing)
188+
console.log('Terminal is available - explicitly hiding launch options');
189+
claudeTerminalInputProvider.hideLaunchOptions();
185190
}
186191

187192
// Store a reference to ensure it's not undefined later

src/ui/claudeTerminalInputProvider.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ export class ClaudeTerminalInputProvider implements vscode.WebviewViewProvider {
9696
}
9797
}
9898

99+
public hideLaunchOptions() {
100+
// Hide launch options UI
101+
this._shouldShowLaunchOptions = false;
102+
if (this._view) {
103+
console.log('Explicitly hiding launch options');
104+
this._view.webview.postMessage({
105+
command: "hideLaunchOptions"
106+
});
107+
}
108+
}
109+
99110
/**
100111
* Sends a command to the Claude terminal asynchronously
101112
* @param text The text to send to the terminal
@@ -133,11 +144,18 @@ export class ClaudeTerminalInputProvider implements vscode.WebviewViewProvider {
133144
terminalName: this._terminal?.name || 'No Terminal'
134145
});
135146

136-
// Show launch options if needed
137-
if (this._shouldShowLaunchOptions) {
147+
// Show launch options only if no terminal exists AND should show (prevents race condition)
148+
if (this._shouldShowLaunchOptions && !this._terminal) {
149+
console.log('Showing launch options during webview initialization');
138150
webviewView.webview.postMessage({
139151
command: "showLaunchOptions"
140152
});
153+
} else if (this._terminal) {
154+
// Explicitly hide launch options if terminal exists
155+
console.log('Terminal exists during webview initialization - hiding launch options');
156+
webviewView.webview.postMessage({
157+
command: "hideLaunchOptions"
158+
});
141159
}
142160

143161
// Handle message from webview

0 commit comments

Comments
 (0)