fix: restrict auto-accept to plan mode only, block AskUserQuestion prompts

The auto-accept feature was too aggressive - it would press Enter for any
silence without a completion message, including AskUserQuestion prompts.
Now uses the elicitation_dialog notification hook to detect when Claude is
asking a question, and blocks auto-accept in that case. Only plan mode
approvals (silence with no completion message AND no elicitation signal)
trigger auto-accept.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-24 03:10:02 +01:00
co-authored by Claude Opus 4.5
parent b4aea57d9c
commit 10222075cb
9 changed files with 136 additions and 31 deletions
+10 -1
View File
@@ -1460,13 +1460,22 @@ export class WebServer extends EventEmitter {
this.app.post('/api/hook-event', async (req) => {
const { event, sessionId } = req.body as HookEventRequest;
const validEvents = ['idle_prompt', 'permission_prompt', 'stop'] as const;
const validEvents = ['idle_prompt', 'permission_prompt', 'elicitation_dialog', 'stop'] as const;
if (!event || !validEvents.includes(event as typeof validEvents[number])) {
return createErrorResponse(ApiErrorCode.INVALID_INPUT, 'Invalid event type');
}
if (!sessionId || !this.sessions.has(sessionId)) {
return createErrorResponse(ApiErrorCode.NOT_FOUND, 'Session not found');
}
// Signal the respawn controller to block auto-accept for question prompts
if (event === 'elicitation_dialog') {
const controller = this.respawnControllers.get(sessionId);
if (controller) {
controller.signalElicitation();
}
}
this.broadcast(`hook:${event}`, { sessionId, timestamp: Date.now() });
return { success: true };
});