feat: escalate chat approvals through inbox

This commit is contained in:
thanhnv
2026-07-08 23:09:43 +09:00
parent a029a51e72
commit 780fe86273
15 changed files with 316 additions and 26 deletions
@@ -23,6 +23,7 @@ export function Approvals() {
const [sensitive, setSensitive] = useState(true);
const [reason, setReason] = useState('review requested from Control Panel');
const [decisionReason, setDecisionReason] = useState('reviewed in approval inbox');
const [approvalJwt, setApprovalJwt] = useState('');
const [message, setMessage] = useState<string | null>(null);
const inbox = useQuery({
@@ -49,7 +50,7 @@ export function Approvals() {
const decide = useMutation({
mutationFn: ({ id, decision }: { id: string; decision: 'approve' | 'reject' }) =>
api.decideApproval(actor, { id, decision, reason: decisionReason }),
api.decideApproval(actor, { id, decision, reason: decisionReason, approvalJwt: approvalJwt || undefined }),
onSuccess: (res) => {
setMessage(`${res.proposal.status} ${res.proposal.id}${res.applied ? ` applied v${res.applied.version}` : ''}`);
void queryClient.invalidateQueries({ queryKey: ['approvals'] });
@@ -129,6 +130,10 @@ export function Approvals() {
<span className="text-gray-500">Decision reason</span>
<input className="w-full rounded border border-gray-300 px-3 py-2" value={decisionReason} onChange={(e) => setDecisionReason(e.target.value)} />
</label>
<label className="block space-y-1 text-sm">
<span className="text-gray-500">Approval JWT</span>
<input className="w-full rounded border border-gray-300 px-3 py-2 font-mono text-xs" value={approvalJwt} onChange={(e) => setApprovalJwt(e.target.value)} />
</label>
{inbox.data.proposals.map((p) => (
<div key={p.id} className="rounded border border-gray-200 p-4">
<div className="flex flex-wrap items-center justify-between gap-3">