/** * @license * Copyright 2025 Qwen Team * SPDX-License-Identifier: Apache-2.0 */ import type React from 'react'; import { useEffect } from 'react'; import { PermissionRequest, type PermissionOption, type ToolCall, } from './PermissionRequest.js'; import './PermissionDrawer.css'; interface PermissionDrawerProps { isOpen: boolean; options: PermissionOption[]; toolCall: ToolCall; onResponse: (optionId: string) => void; onClose?: () => void; } /** * Permission drawer component - displays permission requests in a bottom sheet * @param isOpen - Whether the drawer is open * @param options - Permission options to display * @param toolCall - Tool call information * @param onResponse - Callback when user responds * @param onClose - Optional callback when drawer closes */ export const PermissionDrawer: React.FC = ({ isOpen, options, toolCall, onResponse, onClose, }) => { // Close drawer on Escape key useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (!isOpen) { return; } // Close on Escape if (e.key === 'Escape' && onClose) { onClose(); return; } // Quick select with number keys (1-9) const numMatch = e.key.match(/^[1-9]$/); if (numMatch) { const index = parseInt(e.key, 10) - 1; if (index < options.length) { e.preventDefault(); onResponse(options[index].optionId); } } }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [isOpen, onClose, options, onResponse]); if (!isOpen) { return null; } return ( <> {/* Backdrop */}
{/* Drawer */}

Permission Required

{onClose && ( )}
); };