diff --git a/src/extension.ts b/src/extension.ts index 2445832..b894ae0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -305,6 +305,9 @@ class ClaudeChatProvider { case 'deleteCustomSnippet': this._deleteCustomSnippet(message.snippetId); return; + case 'enableYoloMode': + this._enableYoloMode(); + return; } } @@ -2038,15 +2041,39 @@ class ClaudeChatProvider { }); } + private async _enableYoloMode(): Promise { + try { + // Update VS Code configuration to enable YOLO mode + const config = vscode.workspace.getConfiguration('claudeCodeChat'); + + // Clear any global setting and set workspace setting + await config.update('permissions.yoloMode', true, vscode.ConfigurationTarget.Workspace); + + console.log('YOLO Mode enabled - all future permissions will be skipped'); + + // Send updated settings to UI + this._sendCurrentSettings(); + + } catch (error) { + console.error('Error enabling YOLO mode:', error); + } + } + private async _updateSettings(settings: { [key: string]: any }): Promise { const config = vscode.workspace.getConfiguration('claudeCodeChat'); try { for (const [key, value] of Object.entries(settings)) { - await config.update(key, value, vscode.ConfigurationTarget.Global); + if (key === 'permissions.yoloMode') { + // YOLO mode is workspace-specific + await config.update(key, value, vscode.ConfigurationTarget.Workspace); + } else { + // Other settings are global (user-wide) + await config.update(key, value, vscode.ConfigurationTarget.Global); + } } - vscode.window.showInformationMessage('Settings updated successfully'); + console.log('Settings updated:', settings); } catch (error) { console.error('Failed to update settings:', error); vscode.window.showErrorMessage('Failed to update settings'); diff --git a/src/ui-styles.ts b/src/ui-styles.ts index 7012630..9d1ce91 100644 --- a/src/ui-styles.ts +++ b/src/ui-styles.ts @@ -107,6 +107,86 @@ const styles = ` font-size: 16px; } + .permission-menu { + position: relative; + margin-left: auto; + } + + .permission-menu-btn { + background: none; + border: none; + color: var(--vscode-descriptionForeground); + cursor: pointer; + padding: 4px 8px; + border-radius: 4px; + font-size: 16px; + font-weight: bold; + transition: all 0.2s ease; + line-height: 1; + } + + .permission-menu-btn:hover { + background-color: var(--vscode-list-hoverBackground); + color: var(--vscode-foreground); + } + + .permission-menu-dropdown { + position: absolute; + top: 100%; + right: 0; + background-color: var(--vscode-menu-background); + border: 1px solid var(--vscode-menu-border); + border-radius: 6px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + z-index: 1000; + min-width: 220px; + padding: 4px 0; + margin-top: 4px; + } + + .permission-menu-item { + display: flex; + align-items: flex-start; + gap: 10px; + padding: 12px 16px; + background: none; + border: none; + width: 100%; + text-align: left; + cursor: pointer; + color: var(--vscode-foreground); + transition: background-color 0.2s ease; + } + + .permission-menu-item:hover { + background-color: var(--vscode-list-hoverBackground); + } + + .permission-menu-item .menu-icon { + font-size: 16px; + margin-top: 1px; + flex-shrink: 0; + } + + .permission-menu-item .menu-content { + display: flex; + flex-direction: column; + gap: 2px; + } + + .permission-menu-item .menu-title { + font-weight: 500; + font-size: 13px; + line-height: 1.2; + } + + .permission-menu-item .menu-subtitle { + font-size: 11px; + color: var(--vscode-descriptionForeground); + opacity: 0.8; + line-height: 1.2; + } + .permission-content { font-size: 13px; line-height: 1.4; diff --git a/src/ui.ts b/src/ui.ts index 269162a..fd72be0 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -339,7 +339,7 @@ const html = `
- +
@@ -2786,6 +2786,18 @@ const html = `
🔐 Permission Required +
+ + +

Allow \${toolName} to execute the tool call above?

@@ -2837,6 +2849,44 @@ const html = ` } } + function togglePermissionMenu(permissionId) { + const menu = document.getElementById(\`permissionMenu-\${permissionId}\`); + const isVisible = menu.style.display !== 'none'; + + // Close all other permission menus + document.querySelectorAll('.permission-menu-dropdown').forEach(dropdown => { + dropdown.style.display = 'none'; + }); + + // Toggle this menu + menu.style.display = isVisible ? 'none' : 'block'; + } + + function enableYoloMode(permissionId) { + // Hide the menu + document.getElementById(\`permissionMenu-\${permissionId}\`).style.display = 'none'; + + // Send message to enable YOLO mode + vscode.postMessage({ + type: 'enableYoloMode' + }); + + // Auto-approve this permission + respondToPermission(permissionId, true); + + // Show notification + addMessage('⚡ YOLO Mode enabled! All future permissions will be automatically allowed.', 'system'); + } + + // Close permission menus when clicking outside + document.addEventListener('click', function(event) { + if (!event.target.closest('.permission-menu')) { + document.querySelectorAll('.permission-menu-dropdown').forEach(dropdown => { + dropdown.style.display = 'none'; + }); + } + }); + // Session management functions function newSession() { vscode.postMessage({