33// it" answer the request; once answered it shrinks to one line.
44
55import { Ban , Check , Hand , TimerOff } from "lucide-react" ;
6- import { useContext , useId } from "react" ;
6+ import { useContext } from "react" ;
77import { useT } from "../../i18n" ;
88import type { ApprovalItem , Bot } from "../../lib/protocol.gen" ;
99import { Button } from "../../ui/Button" ;
10+ import { NoteInput , RequestCard , SettledLine } from "../../ui/ChatCard" ;
1011import { useAnswer } from "../chat/useAnswer" ;
1112import { ShowBrowser } from "./showBrowser" ;
1213
@@ -28,30 +29,15 @@ function read(approval: ApprovalItem): { task: string; site: string | null } {
2829
2930function Answered ( { approval, task } : { approval : ApprovalItem ; task : string } ) {
3031 const words = useT ( ) . browser . help ;
31- const line = "flex min-w-0 items-center gap-2 rounded-lg px-1.5 py-1 text-sm" ;
3232 switch ( approval . status ) {
3333 case "allowed" :
34- return (
35- < p className = { line } >
36- < Check aria-hidden size = { 14 } className = "shrink-0 text-ok" />
37- < span className = "truncate font-medium" > { words . doneLine ( task ) } </ span >
38- </ p >
39- ) ;
34+ return < SettledLine icon = { Check } tone = "ok" text = { words . doneLine ( task ) } /> ;
4035 case "denied" :
4136 return (
42- < p className = { line } >
43- < Ban aria-hidden size = { 14 } className = "shrink-0 text-danger" />
44- < span className = "truncate font-medium" > { words . wontLine ( task ) } </ span >
45- { approval . note && < span className = "truncate text-muted text-xs" > “{ approval . note } ”</ span > }
46- </ p >
37+ < SettledLine icon = { Ban } tone = "danger" text = { words . wontLine ( task ) } note = { approval . note } />
4738 ) ;
4839 default :
49- return (
50- < p className = { line } >
51- < TimerOff aria-hidden size = { 14 } className = "shrink-0 text-quiet" />
52- < span className = "truncate font-medium" > { words . expired ( task ) } </ span >
53- </ p >
54- ) ;
40+ return < SettledLine icon = { TimerOff } tone = "quiet" text = { words . expired ( task ) } /> ;
5541 }
5642}
5743
@@ -63,23 +49,18 @@ export function HelpCard({ approval, bot }: { approval: ApprovalItem; bot: Bot }
6349 allow : t . chat . approval . allowFailed ,
6450 deny : t . chat . approval . denyFailed ,
6551 } ) ;
66- const noteId = useId ( ) ;
6752 const { task, site } = read ( approval ) ;
6853 if ( approval . status !== "pending" ) {
6954 return < Answered approval = { approval } task = { task } /> ;
7055 }
7156
7257 return (
73- < section
74- aria-label = { words . asks ( bot . name , task ) }
75- className = "my-1 max-w-2xl rounded-2xl border border-accent/40 bg-panel px-4 py-3.5 shadow-sm animate-attention"
58+ < RequestCard
59+ label = { words . asks ( bot . name , task ) }
60+ icon = { Hand }
61+ tone = "accent"
62+ title = { words . needs ( bot . name ) }
7663 >
77- < p className = "flex items-center gap-2.5 font-semibold text-sm" >
78- < span className = "grid h-7 w-7 shrink-0 place-items-center rounded-full bg-accent/12 text-accent" >
79- < Hand aria-hidden size = { 15 } />
80- </ span >
81- { words . needs ( bot . name ) }
82- </ p >
8364 < p className = "mt-2 break-words text-sm" data-selectable >
8465 { task }
8566 </ p >
@@ -89,15 +70,11 @@ export function HelpCard({ approval, bot }: { approval: ApprovalItem; bot: Bot }
8970 </ p >
9071 ) }
9172 < p className = "mt-1.5 text-muted text-xs" > { words . why } </ p >
92- < label htmlFor = { noteId } className = "sr-only" >
93- { t . chat . approval . noteLabel ( bot . name ) }
94- </ label >
95- < input
96- id = { noteId }
73+ < NoteInput
74+ label = { t . chat . approval . noteLabel ( bot . name ) }
9775 value = { note }
98- onChange = { ( event ) => setNote ( event . target . value ) }
76+ onChange = { setNote }
9977 placeholder = { t . chat . approval . notePlaceholder }
100- className = "mt-3 h-9 w-full rounded-xl border border-line-strong bg-canvas px-3 text-sm outline-none placeholder:text-muted focus:border-muted"
10178 />
10279 < div className = "mt-2.5 flex flex-wrap gap-2" >
10380 { showBrowser && (
@@ -117,6 +94,6 @@ export function HelpCard({ approval, bot }: { approval: ApprovalItem; bot: Bot }
11794 { words . wontDo }
11895 </ Button >
11996 </ div >
120- </ section >
97+ </ RequestCard >
12198 ) ;
12299}
0 commit comments