forked from bots-garden/ori
| ✨ Introduce new feature(s): ACP web client — Go backend (agent, bridge, httpserver, mockagent) + React SPA (Zed-like agent panel), tests, quality gate PASS | 1 | /** |
| 2 | * PermissionPrompt asks the user to approve or reject a sensitive agent | |
| 3 | * action, offering exactly the options the agent proposed (allow once, | |
| 4 | * always, reject, ...), like Zed's permission bar. | |
| 5 | * | |
| 6 | * @example | |
| 7 | * <PermissionPrompt | |
| 8 | * request={{ requestId: "perm-1", title: "Run `make test`", options: [ | |
| 9 | * { optionId: "allow", name: "Allow", kind: "allow_once" }] }} | |
| 10 | * onRespond={(requestId, optionId) => console.log(requestId, optionId)} | |
| 11 | * /> | |
| 12 | */ | |
| 13 | ||
| 14 | import type { PermissionRequestState } from "../reducer"; | |
| 15 | ||
| 16 | interface PermissionPromptProps { | |
| 17 | request: PermissionRequestState; | |
| 18 | onRespond: (requestId: string, optionId: string) => void; | |
| 19 | } | |
| 20 | ||
| 21 | export function PermissionPrompt({ | |
| 22 | request, | |
| 23 | onRespond, | |
| 24 | }: PermissionPromptProps) { | |
| 25 | return ( | |
| 26 | <div | |
| 27 | className="permission" | |
| 28 | role="alertdialog" | |
| 29 | aria-label="permission request" | |
| 30 | > | |
| 31 | <p className="permission-title">🔐 {request.title}</p> | |
| 32 | <div className="permission-options"> | |
| 33 | {request.options.map((option) => ( | |
| 34 | <button | |
| 35 | key={option.optionId} | |
| 36 | type="button" | |
| 37 | className={`permission-option permission-${option.kind}`} | |
| 38 | onClick={() => onRespond(request.requestId, option.optionId)} | |
| 39 | > | |
| 40 | {option.name} | |
| 41 | </button> | |
| 42 | ))} | |
| 43 | </div> | |
| 44 | </div> | |
| 45 | ); | |
| 46 | } |