mirror of
https://github.com/andrepimenta/claude-code-chat.git
synced 2025-12-13 21:59:42 +00:00
Let user chose yolo mode when there is an error with permissions
This commit is contained in:
@@ -430,8 +430,6 @@ class ClaudeChatProvider {
|
|||||||
args.push('--mcp-config', mcpConfigPath);
|
args.push('--mcp-config', mcpConfigPath);
|
||||||
args.push('--allowedTools', 'mcp__permissions__approval_prompt');
|
args.push('--allowedTools', 'mcp__permissions__approval_prompt');
|
||||||
args.push('--permission-prompt-tool', 'mcp__permissions__approval_prompt');
|
args.push('--permission-prompt-tool', 'mcp__permissions__approval_prompt');
|
||||||
} else {
|
|
||||||
args.push('--dangerously-skip-permissions');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1366,6 +1366,41 @@ const styles = `
|
|||||||
animation: slideDown 0.3s ease;
|
animation: slideDown 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.yolo-suggestion {
|
||||||
|
margin-top: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
background-color: rgba(0, 122, 204, 0.1);
|
||||||
|
border: 1px solid rgba(0, 122, 204, 0.3);
|
||||||
|
border-radius: 6px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yolo-suggestion-text {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--vscode-foreground);
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yolo-suggestion-btn {
|
||||||
|
background-color: var(--vscode-button-background);
|
||||||
|
color: var(--vscode-button-foreground);
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 6px 12px;
|
||||||
|
font-size: 11px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.2s ease;
|
||||||
|
font-weight: 500;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yolo-suggestion-btn:hover {
|
||||||
|
background-color: var(--vscode-button-hoverBackground);
|
||||||
|
}
|
||||||
|
|
||||||
.file-picker-modal {
|
.file-picker-modal {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|||||||
64
src/ui.ts
64
src/ui.ts
@@ -639,6 +639,20 @@ const html = `<!DOCTYPE html>
|
|||||||
}
|
}
|
||||||
|
|
||||||
messageDiv.appendChild(contentDiv);
|
messageDiv.appendChild(contentDiv);
|
||||||
|
|
||||||
|
// Check if this is a permission-related error and add yolo mode button
|
||||||
|
if (type === 'error' && isPermissionError(content)) {
|
||||||
|
const yoloSuggestion = document.createElement('div');
|
||||||
|
yoloSuggestion.className = 'yolo-suggestion';
|
||||||
|
yoloSuggestion.innerHTML = \`
|
||||||
|
<div class="yolo-suggestion-text">
|
||||||
|
<span>💡 This looks like a permission issue. You can enable Yolo Mode to skip all permission checks.</span>
|
||||||
|
</div>
|
||||||
|
<button class="yolo-suggestion-btn" onclick="enableYoloMode()">Enable Yolo Mode</button>
|
||||||
|
\`;
|
||||||
|
messageDiv.appendChild(yoloSuggestion);
|
||||||
|
}
|
||||||
|
|
||||||
messagesDiv.appendChild(messageDiv);
|
messagesDiv.appendChild(messageDiv);
|
||||||
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
||||||
}
|
}
|
||||||
@@ -823,6 +837,20 @@ const html = `<!DOCTYPE html>
|
|||||||
}
|
}
|
||||||
|
|
||||||
messageDiv.appendChild(contentDiv);
|
messageDiv.appendChild(contentDiv);
|
||||||
|
|
||||||
|
// Check if this is a permission-related error and add yolo mode button
|
||||||
|
if (data.isError && isPermissionError(content)) {
|
||||||
|
const yoloSuggestion = document.createElement('div');
|
||||||
|
yoloSuggestion.className = 'yolo-suggestion';
|
||||||
|
yoloSuggestion.innerHTML = \`
|
||||||
|
<div class="yolo-suggestion-text">
|
||||||
|
<span>💡 This looks like a permission issue. You can enable Yolo Mode to skip all permission checks.</span>
|
||||||
|
</div>
|
||||||
|
<button class="yolo-suggestion-btn" onclick="enableYoloMode()">Enable Yolo Mode</button>
|
||||||
|
\`;
|
||||||
|
messageDiv.appendChild(yoloSuggestion);
|
||||||
|
}
|
||||||
|
|
||||||
messagesDiv.appendChild(messageDiv);
|
messagesDiv.appendChild(messageDiv);
|
||||||
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
||||||
}
|
}
|
||||||
@@ -1481,6 +1509,42 @@ const html = `<!DOCTYPE html>
|
|||||||
const yoloMode = yoloModeCheckbox.checked;
|
const yoloMode = yoloModeCheckbox.checked;
|
||||||
warning.style.display = yoloMode ? 'block' : 'none';
|
warning.style.display = yoloMode ? 'block' : 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isPermissionError(content) {
|
||||||
|
const permissionErrorPatterns = [
|
||||||
|
'Error: MCP config file not found',
|
||||||
|
'Error: MCP tool',
|
||||||
|
'Claude requested permissions to use',
|
||||||
|
'permission denied',
|
||||||
|
'Permission denied',
|
||||||
|
'permission request',
|
||||||
|
'Permission request',
|
||||||
|
'EACCES',
|
||||||
|
'permission error',
|
||||||
|
'Permission error'
|
||||||
|
];
|
||||||
|
|
||||||
|
return permissionErrorPatterns.some(pattern =>
|
||||||
|
content.toLowerCase().includes(pattern.toLowerCase())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableYoloMode() {
|
||||||
|
// Update the checkbox
|
||||||
|
const yoloModeCheckbox = document.getElementById('yolo-mode');
|
||||||
|
if (yoloModeCheckbox) {
|
||||||
|
yoloModeCheckbox.checked = true;
|
||||||
|
|
||||||
|
// Trigger the settings update
|
||||||
|
updateSettings();
|
||||||
|
|
||||||
|
// Show confirmation message
|
||||||
|
addMessage('✅ Yolo Mode enabled! All permission checks will be bypassed for future commands.', 'system');
|
||||||
|
|
||||||
|
// Update the warning banner
|
||||||
|
updateYoloWarning();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function hideToolsModal() {
|
function hideToolsModal() {
|
||||||
document.getElementById('toolsModal').style.display = 'none';
|
document.getElementById('toolsModal').style.display = 'none';
|
||||||
|
|||||||
Reference in New Issue
Block a user