mirror of
https://github.com/andrepimenta/claude-code-chat.git
synced 2025-12-08 17:09:44 +00:00
Yolo mode
This commit is contained in:
@@ -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<void> {
|
||||
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<void> {
|
||||
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');
|
||||
|
||||
@@ -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;
|
||||
|
||||
52
src/ui.ts
52
src/ui.ts
@@ -339,7 +339,7 @@ const html = `<!DOCTYPE html>
|
||||
</button>
|
||||
<div class="yolo-mode-section">
|
||||
<input type="checkbox" id="yolo-mode" onchange="updateSettings(); updateYoloWarning();">
|
||||
<label for="yolo-mode">Enable Yolo Mode (Skip All Permissions)</label>
|
||||
<label for="yolo-mode">Enable Yolo Mode (Auto-allow all permissions)</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2786,6 +2786,18 @@ const html = `<!DOCTYPE html>
|
||||
<div class="permission-header">
|
||||
<span class="icon">🔐</span>
|
||||
<span>Permission Required</span>
|
||||
<div class="permission-menu">
|
||||
<button class="permission-menu-btn" onclick="togglePermissionMenu('\${data.id}')" title="More options">⋮</button>
|
||||
<div class="permission-menu-dropdown" id="permissionMenu-\${data.id}" style="display: none;">
|
||||
<button class="permission-menu-item" onclick="enableYoloMode('\${data.id}')">
|
||||
<span class="menu-icon">⚡</span>
|
||||
<div class="menu-content">
|
||||
<span class="menu-title">Enable YOLO Mode</span>
|
||||
<span class="menu-subtitle">Auto-allow all permissions</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="permission-content">
|
||||
<p>Allow <strong>\${toolName}</strong> to execute the tool call above?</p>
|
||||
@@ -2837,6 +2849,44 @@ const html = `<!DOCTYPE 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({
|
||||
|
||||
Reference in New Issue
Block a user