feat: add ignore option for permission requests (UI-only dismissal)
This commit is contained in:
@@ -348,6 +348,31 @@ export async function handleHooksApprovalRespondPlan(req: Request): Promise<Resp
|
||||
}
|
||||
}
|
||||
|
||||
// ── Ignore (remove from UI state only, don't respond to Claude Code) ──
|
||||
|
||||
export async function handleHooksApprovalIgnore(req: Request): Promise<Response | null> {
|
||||
if (req.method !== 'POST') return null
|
||||
|
||||
try {
|
||||
const body = await req.json() as { requestId: string }
|
||||
|
||||
if (!body.requestId) {
|
||||
return errorResponse('Missing requestId', 400)
|
||||
}
|
||||
|
||||
console.log(`[HooksApproval] Ignoring ${body.requestId} (removing from UI state only)`)
|
||||
|
||||
// Remove from session state → broadcasts patch to all clients
|
||||
// The long-poll promise stays alive and will timeout naturally (120s),
|
||||
// at which point Claude Code gets {} and handles it with default behavior.
|
||||
notifyResolveApproval(body.requestId, 'ignore')
|
||||
|
||||
return jsonResponse({ success: true, requestId: body.requestId })
|
||||
} catch (e) {
|
||||
return errorResponse('Invalid JSON body', 400)
|
||||
}
|
||||
}
|
||||
|
||||
// ── List pending (for state recovery) ──
|
||||
|
||||
export async function handleHooksApprovalList(req: Request): Promise<Response | null> {
|
||||
|
||||
@@ -26,7 +26,7 @@ import { handleTranscriptDebugSessions, handleTranscriptDebugRaw, handleTranscri
|
||||
import {
|
||||
handleHooksApprovalPermission, handleHooksApprovalPlan,
|
||||
handleHooksApprovalRespond, handleHooksApprovalRespondPlan,
|
||||
handleHooksApprovalList
|
||||
handleHooksApprovalIgnore, handleHooksApprovalList
|
||||
} from './hooks-approval'
|
||||
|
||||
export async function handleRequest(req: Request): Promise<Response> {
|
||||
@@ -371,6 +371,11 @@ export async function handleRequest(req: Request): Promise<Response> {
|
||||
if (res) return res
|
||||
}
|
||||
|
||||
if (path === '/api/hooks-approval/ignore' && req.method === 'POST') {
|
||||
const res = await handleHooksApprovalIgnore(req)
|
||||
if (res) return res
|
||||
}
|
||||
|
||||
// Agents
|
||||
if (path === '/api/agents' && req.method === 'GET') {
|
||||
return handleAgents(req)
|
||||
|
||||
Reference in New Issue
Block a user