Run /compact command in chat instead of spawning terminal

The /compact command now executes through the chat interface using
the existing Claude process, providing a seamless user experience
instead of opening a separate terminal window.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
andrepimenta
2025-12-02 18:12:46 +00:00
parent a156881a08
commit 14ac46018f
2 changed files with 16 additions and 6 deletions

View File

@@ -2637,6 +2637,12 @@ class ClaudeChatProvider {
} }
private _executeSlashCommand(command: string): void { private _executeSlashCommand(command: string): void {
// Handle /compact in chat instead of spawning a terminal
if (command === 'compact') {
this._sendMessageToClaude(`/${command}`);
return;
}
const config = vscode.workspace.getConfiguration('claudeCodeChat'); const config = vscode.workspace.getConfiguration('claudeCodeChat');
const wslEnabled = config.get<boolean>('wsl.enabled', false); const wslEnabled = config.get<boolean>('wsl.enabled', false);
const wslDistro = config.get<string>('wsl.distro', 'Ubuntu'); const wslDistro = config.get<string>('wsl.distro', 'Ubuntu');

View File

@@ -1679,18 +1679,22 @@ const getScript = (isTelemetryEnabled: boolean) => `<script>
function executeSlashCommand(command) { function executeSlashCommand(command) {
// Hide the modal // Hide the modal
hideSlashCommandsModal(); hideSlashCommandsModal();
// Clear the input since user selected a command // Clear the input since user selected a command
messageInput.value = ''; messageInput.value = '';
// Send command to VS Code to execute in terminal // Send command to VS Code to execute
vscode.postMessage({ vscode.postMessage({
type: 'executeSlashCommand', type: 'executeSlashCommand',
command: command command: command
}); });
// Show user feedback // Show user feedback - /compact runs in chat, others in terminal
addMessage('user', \`Executing /\${command} command in terminal. Check the terminal output and return when ready.\`, 'assistant'); if (command === 'compact') {
// No message needed - compact runs in chat and shows its own status
} else {
addMessage('user', \`Executing /\${command} command in terminal. Check the terminal output and return when ready.\`, 'assistant');
}
} }
function handleCustomCommandKeydown(event) { function handleCustomCommandKeydown(event) {