feat: 3-button file permission UX (Allow Once / Allow This Conversation / Deny)

This commit is contained in:
2026-03-10 12:45:12 +09:00
parent c9b4fd4722
commit 14d2acf6c4
3 changed files with 51 additions and 16 deletions

View File

@@ -496,6 +496,17 @@ function startObserverHttpBridge() {
auto_detected: true,
source: 'dom_observer',
};
// File permission: inject multi-choice buttons
const cmdLower = (data.command || '').toLowerCase();
if (cmdLower.includes('allow') && !pending.buttons) {
pending.buttons = [
{ text: 'Allow Once', index: 0 },
{ text: 'Allow This Conversation', index: 1 },
{ text: 'Deny', index: 2 },
];
pending.step_type = 'file_permission';
pending.command = `파일 접근 권한: ${data.description || data.command}`;
}
fs.writeFileSync(path.join(pendingDir, `${rid}.json`), JSON.stringify(pending, null, 2));
logToFile(`[HTTP] pending created: ${rid} cmd="${data.command}" btns=${(data.buttons || []).length} ctx="${(data.description || '').substring(0, 50)}"`);
res.writeHead(200, { 'Content-Type': 'application/json' });
@@ -1989,16 +2000,22 @@ async function processResponseFile(filePath) {
pendingStepIndex = pending.step_index ?? lastPendingStepIndex;
if (!pendingStepType && pending.command) {
const cmd = (pending.command || '').toLowerCase();
if (cmd.includes('allow this conversation')) {
pendingStepType = 'file_permission_conversation';
}
else if (cmd.includes('allow once')) {
pendingStepType = 'file_permission_once';
}
else if (cmd.includes('allow')) {
pendingStepType = 'file_permission_once'; // default to once
if (cmd.includes('allow') || cmd.includes('파일 접근') || pending.step_type === 'file_permission') {
// Map button_index → scope: 0=Once, 1=Conversation, 2=Deny
const btnIdx = resp.button_index ?? -1;
if (btnIdx === 1) {
pendingStepType = 'file_permission_conversation';
}
else {
pendingStepType = 'file_permission_once';
}
}
}
// Also handle when step_type was explicitly set
if (pendingStepType === 'file_permission') {
const btnIdx = resp.button_index ?? -1;
pendingStepType = btnIdx === 1 ? 'file_permission_conversation' : 'file_permission_once';
}
}
catch { }
}

File diff suppressed because one or more lines are too long