The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore(approvals): remove deprecated approval card components
Steven Enamakel8d4f209e1b42
diff --git a/app/src/components/approvals/ApprovalDecisionCard.test.tsx b/app/src/components/approvals/ApprovalDecisionCard.test.tsxdeleted file mode 100644index 07438c1e83..0000000000--- a/app/src/components/approvals/ApprovalDecisionCard.test.tsx+++ /dev/null@@ -1,135 +0,0 @@-import { fireEvent, render, screen, within } from '@testing-library/react';-import { describe, expect, it, vi } from 'vitest';--import ApprovalDecisionCard, { type ApprovalDecisionAction } from './ApprovalDecisionCard';--const actions: ApprovalDecisionAction[] = [- { id: 'approve', label: 'Approve once', busyLabel: 'Approving…', variant: 'primary' },- {- id: 'always',- label: 'Approve always',- busyLabel: 'Saving…',- variant: 'secondary',- title: 'Allow this flow in future',- },- { id: 'deny', label: 'Deny', busyLabel: 'Denying…', variant: 'secondary', tone: 'danger' },-];--describe('ApprovalDecisionCard', () => {- it('composes an alert dialog from its summary and optional metadata', () => {- render(- <ApprovalDecisionCard- ariaLabel="Workflow approval"- summary={<span>Run the shell command</span>}- metadata={<span>Tool: shell</span>}- actions={actions}- onAction={vi.fn()}- testId="approval-card"- className="text-sm"- />- );-- const card = screen.getByRole('alertdialog', { name: 'Workflow approval' });- expect(card).toHaveAttribute('data-testid', 'approval-card');- expect(card).toHaveClass('text-sm');- expect(within(card).getByText('Run the shell command')).toBeInTheDocument();- expect(within(card).getByText('Tool: shell')).toBeInTheDocument();- });-- it('renders actions in descriptor order and passes the selected action id', () => {- const onAction = vi.fn();- render(- <ApprovalDecisionCard- ariaLabel="Workflow approval"- summary="Run the shell command"- actions={actions}- onAction={onAction}- />- );-- expect(screen.getAllByRole('button').map(button => button.textContent)).toEqual([- 'Approve once',- 'Approve always',- 'Deny',- ]);-- fireEvent.click(screen.getByRole('button', { name: 'Approve always' }));- expect(onAction).toHaveBeenCalledWith('always');- });-- it('shows the busy label only for the active action and disables every action', () => {- render(- <ApprovalDecisionCard- ariaLabel="Workflow approval"- summary="Run the shell command"- actions={actions}- busyActionId="always"- onAction={vi.fn()}- />- );-- expect(screen.getByRole('button', { name: 'Approve once' })).toBeDisabled();- expect(screen.getByRole('button', { name: 'Saving…' })).toBeDisabled();- expect(screen.getByRole('button', { name: 'Deny' })).toBeDisabled();- expect(screen.queryByText('Approving…')).not.toBeInTheDocument();- expect(screen.queryByText('Denying…')).not.toBeInTheDocument();- });-- it('forwards variant, tone, title, and action ids to the rendered buttons', () => {- render(- <ApprovalDecisionCard- ariaLabel="Workflow approval"- summary="Run the shell command"- actions={actions}- onAction={vi.fn()}- />- );-- const approve = screen.getByRole('button', { name: 'Approve once' });- const always = screen.getByRole('button', { name: 'Approve always' });- const deny = screen.getByRole('button', { name: 'Deny' });-- expect(approve).toHaveAttribute('data-testid', 'approve');- expect(approve).toHaveClass('bg-primary-500');- expect(always).toHaveAttribute('data-testid', 'always');- expect(always).toHaveClass('border-line-strong');- expect(always).toHaveAttribute('title', 'Allow this flow in future');- expect(deny).toHaveAttribute('data-testid', 'deny');- expect(deny).toHaveClass('text-coral-600');- expect(deny).toHaveClass('border-coral-300/50');- });-- it('supports compact presentation without changing the default density', () => {- const { rerender } = render(- <ApprovalDecisionCard- ariaLabel="Compact approval"- summary="Run the shell command"- actions={actions}- density="compact"- onAction={vi.fn()}- />- );-- const compactLock = screen.getByText('🔒');- const compactActions = screen.getByRole('button', { name: 'Approve once' }).parentElement;- expect(compactLock).toHaveClass('text-sm');- expect(compactLock).not.toHaveClass('text-amber-700');- expect(compactActions).toHaveClass('mt-2', 'gap-1.5');- expect(screen.getByRole('button', { name: 'Approve once' })).toHaveClass('h-6');-- rerender(- <ApprovalDecisionCard- ariaLabel="Default approval"- summary="Run the shell command"- actions={actions}- onAction={vi.fn()}- />- );-- const defaultLock = screen.getByText('🔒');- const defaultActions = screen.getByRole('button', { name: 'Approve once' }).parentElement;- expect(defaultLock).toHaveClass('text-base', 'text-amber-700');- expect(defaultActions).toHaveClass('mt-3', 'gap-2');- expect(screen.getByRole('button', { name: 'Approve once' })).toHaveClass('h-[30px]');- });-});diff --git a/app/src/components/approvals/ApprovalDecisionCard.tsx b/app/src/components/approvals/ApprovalDecisionCard.tsxdeleted file mode 100644index 121acbd42c..0000000000--- a/app/src/components/approvals/ApprovalDecisionCard.tsx+++ /dev/null@@ -1,92 +0,0 @@-import type { ReactNode } from 'react';--import { cn } from '../../lib/cn';-import { Button } from '../ui';--export interface ApprovalDecisionAction {- id: string;- label: ReactNode;- busyLabel?: ReactNode;- variant: 'primary' | 'secondary';- tone?: 'default' | 'danger';- title?: string;-}--export interface ApprovalDecisionCardProps {- ariaLabel: string;- summary: ReactNode;- metadata?: ReactNode;- actions: ApprovalDecisionAction[];- busyActionId?: string | null;- onAction: (actionId: string) => void;- testId?: string;- className?: string;- density?: 'default' | 'compact';-}--export function ApprovalDecisionCard({- ariaLabel,- summary,- metadata,- actions,- busyActionId = null,- onAction,- testId,- className,- density = 'default',-}: ApprovalDecisionCardProps) {- const compact = density === 'compact';-- return (- <div- role="alertdialog"- aria-label={ariaLabel}- data-testid={testId}- className={cn(- 'rounded-xl border border-amber-300 bg-amber-50 p-3 shadow-xs',- 'dark:border-amber-700 dark:bg-amber-950',- className- )}>- <div className="flex items-start gap-2">- <span- aria-hidden- className={- compact- ? 'text-sm leading-none'- : 'text-base leading-none text-amber-700 dark:text-amber-200'- }>- 🔒- </span>- <div className="min-w-0 flex-1">- {summary}- {metadata}-- <div- className={- compact- ? 'mt-2 flex flex-wrap items-center gap-1.5'- : 'mt-3 flex flex-wrap items-center gap-2'- }>- {actions.map(action => (- <Button- key={action.id}- variant={action.variant}- tone={action.tone}- size={compact ? 'xs' : 'sm'}- title={action.title}- data-testid={action.id}- disabled={busyActionId !== null}- onClick={() => onAction(action.id)}>- {busyActionId === action.id && action.busyLabel !== undefined- ? action.busyLabel- : action.label}- </Button>- ))}- </div>- </div>- </div>- </div>- );-}--export default ApprovalDecisionCard;diff --git a/app/src/components/chat/FlowApprovalRequestCard.tsx b/app/src/components/chat/FlowApprovalRequestCard.tsxdeleted file mode 100644index ff79098296..0000000000--- a/app/src/components/chat/FlowApprovalRequestCard.tsx+++ /dev/null@@ -1,126 +0,0 @@-/**- * FlowApprovalRequestCard (flow-approval surface — chat)- * ---------------------------------------------------------- *- * Chat-surfaced banner for a single `flow_approval_request` socket event- * (see {@link useFlowApprovalRequests}) — a paused `tinyflows` run's gate,- * shown to the user while they're chatting rather than inspecting the run- * directly. Styling mirrors `ApprovalRequestCard` (the thread-scoped chat- * tool-approval card) so both read as the same affordance family; unlike- * that card, this one isn't keyed to the active thread — the payload has no- * `thread_id` — so it renders independent of which thread is selected.- *- * All three decisions route through the shared `openhuman.approval_decide`- * RPC via {@link decideApproval}. On success (or once the request no longer- * needs surfacing) the parent removes it from its list via `onResolved`.- */-import debug from 'debug';-import React, { useState } from 'react';--import type { FlowApprovalRequest } from '../../hooks/useFlowApprovalRequests';-import { useT } from '../../lib/i18n/I18nContext';-import { type ApprovalDecision, decideApproval } from '../../services/api/approvalApi';-import ApprovalDecisionCard, {- type ApprovalDecisionAction,-} from '../approvals/ApprovalDecisionCard';--const log = debug('openhuman:chat:flow-approval-card');--interface Props {- request: FlowApprovalRequest;- onResolved: (requestId: string) => void;-}--export const FlowApprovalRequestCard: React.FC<Props> = ({ request, onResolved }) => {- const { t } = useT();- const [deciding, setDeciding] = useState<ApprovalDecision | null>(null);- const [errorMsg, setErrorMsg] = useState<string | null>(null);-- const actionDecisions: Record<string, ApprovalDecision> = {- 'flow-approval-request-approve': 'approve_once',- 'flow-approval-request-always': 'approve_always_for_flow',- 'flow-approval-request-deny': 'deny',- };- const actions: ApprovalDecisionAction[] = [- {- id: 'flow-approval-request-approve',- label: t('chat.flowApproval.approve'),- busyLabel: t('chat.flowApproval.deciding'),- variant: 'primary',- },- {- id: 'flow-approval-request-always',- label: t('chat.flowApproval.approveAlways'),- busyLabel: t('chat.flowApproval.deciding'),- variant: 'secondary',- title: t('chat.flowApproval.approveAlwaysHint'),- },- {- id: 'flow-approval-request-deny',- label: t('chat.flowApproval.deny'),- busyLabel: t('chat.flowApproval.deciding'),- variant: 'secondary',- },- ];-- const decide = async (decision: ApprovalDecision) => {- if (deciding) return;- setDeciding(decision);- setErrorMsg(null);- try {- await decideApproval(request.request_id, decision);- log('decide: ok request=%s decision=%s', request.request_id, decision);- onResolved(request.request_id);- } catch (err) {- log('decide: failed request=%s err=%o', request.request_id, err);- setErrorMsg(t('chat.flowApproval.error'));- setDeciding(null);- }- };-- const busyActionId = deciding- ? actions.find(action => actionDecisions[action.id] === deciding)?.id- : null;-- return (- <ApprovalDecisionCard- ariaLabel={t('chat.flowApproval.title')}- testId="flow-approval-request-card"- className="text-sm"- summary={- <>- <p className="font-semibold text-amber-900 dark:text-amber-100">- {t('chat.flowApproval.title')}- </p>- <p className="mt-1 wrap-break-word text-amber-800/90 dark:text-amber-200/90">- {request.summary || t('chat.flowApproval.fallback')}- </p>- </>- }- metadata={- <>- <p className="mt-1 text-xs text-amber-800/80 dark:text-amber-200/80">- {t('chat.flowApproval.tool')}{' '}- <span className="font-mono text-amber-950 dark:text-amber-100">- {request.tool_name}- </span>- </p>- <p className="mt-0.5 text-xs text-amber-800/80 dark:text-amber-200/80">- {t('chat.flowApproval.flow')}{' '}- <span className="font-mono text-amber-950 dark:text-amber-100">{request.flow_id}</span>- </p>-- {errorMsg && (- <p className="mt-2 text-xs text-coral-600 dark:text-coral-400">⚠ {errorMsg}</p>- )}- </>- }- actions={actions}- busyActionId={busyActionId}- onAction={actionId => {- const decision = actionDecisions[actionId];- if (decision) void decide(decision);- }}- />- );-};diff --git a/app/src/components/chat/UnroutedApprovalCard.tsx b/app/src/components/chat/UnroutedApprovalCard.tsxdeleted file mode 100644index 123e5ce4c9..0000000000--- a/app/src/components/chat/UnroutedApprovalCard.tsx+++ /dev/null@@ -1,109 +0,0 @@-/**- * UnroutedApprovalCard — the banner for an approval no other surface claims.- *- * A park raised by a background trigger has no chat thread and no flow run, so- * neither `ApprovalRequestCard` nor `FlowApprovalRequestCard` will ever show- * it (openhuman#6406, general form openhuman#5746). {@link useUnroutedApprovals}- * finds those rows in the durable `approval_list_pending` queue; this renders- * one.- *- * Chrome is `ApprovalDecisionCard`, the same component the other two approval- * surfaces use, so all three read as one affordance family rather than three- * visually unrelated prompts for the same kind of decision.- *- * Only two decisions are offered. `approve_always_for_tool` is deliberately- * absent: this prompt exists precisely because the request arrived from- * attacker-influenceable content with no interactive session behind it, and a- * session-wide standing allowlist is the wrong thing to grant from a banner- * the user did not go looking for. Once is once.- */-import debug from 'debug';-import { type FC, useState } from 'react';--import type { ApprovalDecision, PendingApproval } from '../../services/api/approvalApi';-import ApprovalDecisionCard, {- type ApprovalDecisionAction,-} from '../approvals/ApprovalDecisionCard';--const log = debug('openhuman:chat:unrouted-approval-card');--const ACTION_DECISIONS: Record<string, ApprovalDecision> = {- 'unrouted-approval-approve': 'approve_once',- 'unrouted-approval-deny': 'deny',-};--const ACTIONS: ApprovalDecisionAction[] = [- {- id: 'unrouted-approval-approve',- label: 'Approve once',- busyLabel: 'Approving…',- variant: 'primary',- },- {- id: 'unrouted-approval-deny',- label: 'Deny',- busyLabel: 'Denying…',- variant: 'secondary',- tone: 'danger',- },-];--/** `2026-09-23T04:12:00Z` -> `4:12 am`, or `''` when unparseable. */-function formatRaisedAt(iso: string): string {- const at = new Date(iso);- if (Number.isNaN(at.getTime())) return '';- return at.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' });-}--interface Props {- approval: PendingApproval;- busy: boolean;- onDecide: (requestId: string, decision: ApprovalDecision) => Promise<void>;-}--export const UnroutedApprovalCard: FC<Props> = ({ approval, busy, onDecide }) => {- const [busyActionId, setBusyActionId] = useState<string | null>(null);-- const handleAction = (actionId: string) => {- const decision = ACTION_DECISIONS[actionId];- if (!decision || busy) return;- setBusyActionId(actionId);- log('deciding request_id=%s decision=%s', approval.request_id, decision);- void onDecide(approval.request_id, decision)- .catch(() => {- // The hook owns the error message and renders it above this card; the- // card only needs to stop looking busy so the decision can be retried.- })- .finally(() => setBusyActionId(null));- };-- const raisedAt = formatRaisedAt(approval.created_at);-- return (- <ApprovalDecisionCard- ariaLabel={`Background approval required: ${approval.tool_name}`}- testId="unrouted-approval-card"- summary={- <>- <span className="font-medium">Background task needs approval</span>- {' — '}- {approval.action_summary || approval.tool_name}- </>- }- metadata={- <>- <span data-testid="unrouted-approval-tool">{approval.tool_name}</span>- {raisedAt && <span> · raised {raisedAt}</span>}- {/* No thread to open: this ran with nobody watching, which is why it- is here rather than in a transcript. */}- <span> · no conversation</span>- </>- }- actions={ACTIONS}- busyActionId={busyActionId}- onAction={handleAction}- />- );-};--export default UnroutedApprovalCard;diff --git a/app/src/components/chat/__tests__/FlowApprovalRequestCard.test.tsx b/app/src/components/chat/__tests__/FlowApprovalRequestCard.test.tsxdeleted file mode 100644index 0af38ff538..0000000000--- a/app/src/components/chat/__tests__/FlowApprovalRequestCard.test.tsx+++ /dev/null@@ -1,111 +0,0 @@-/**- * FlowApprovalRequestCard (flow-approval surface — chat) — rendering +- * decision contract. Mirrors `ApprovalRequestCard.test.tsx`'s approach: mocks- * `decideApproval` directly rather than the underlying RPC client.- */-import { fireEvent, render, screen, waitFor } from '@testing-library/react';-import { beforeEach, describe, expect, it, vi } from 'vitest';--import type { FlowApprovalRequest } from '../../../hooks/useFlowApprovalRequests';-import { decideApproval } from '../../../services/api/approvalApi';-import { FlowApprovalRequestCard } from '../FlowApprovalRequestCard';--vi.mock('../../../services/api/approvalApi', () => ({ decideApproval: vi.fn() }));--const REQUEST: FlowApprovalRequest = {- request_id: 'req-1',- flow_id: 'flow-1',- run_id: 'run-1',- tool_name: 'shell',- summary: 'Run `shell` — rm -rf /tmp/scratch',-};--describe('FlowApprovalRequestCard', () => {- beforeEach(() => {- vi.clearAllMocks();- });-- it('renders the summary, tool name, and flow id', () => {- render(<FlowApprovalRequestCard request={REQUEST} onResolved={vi.fn()} />);- expect(screen.getByRole('alertdialog', { name: 'Workflow needs approval' })).toHaveAttribute(- 'data-testid',- 'flow-approval-request-card'- );- expect(screen.getByText('Run `shell` — rm -rf /tmp/scratch')).toBeInTheDocument();- expect(screen.getByText('shell')).toBeInTheDocument();- expect(screen.getByText('flow-1')).toBeInTheDocument();- expect(screen.getByTestId('flow-approval-request-approve')).toHaveTextContent('Approve once');- expect(screen.getByTestId('flow-approval-request-always')).toHaveTextContent('Approve always');- expect(screen.getByTestId('flow-approval-request-deny')).toHaveTextContent('Deny');- expect(screen.getByTestId('flow-approval-request-deny')).toHaveClass('border-line-strong');- expect(screen.getByTestId('flow-approval-request-deny').className).not.toMatch(/coral/);- });-- it('falls back to the generic prompt when summary is empty', () => {- render(<FlowApprovalRequestCard request={{ ...REQUEST, summary: '' }} onResolved={vi.fn()} />);- expect(- screen.getByText('A workflow run wants to perform an action that needs your approval.')- ).toBeInTheDocument();- });-- it('Approve once routes approve_once to approval_decide and resolves', async () => {- vi.mocked(decideApproval).mockResolvedValueOnce(undefined);- const onResolved = vi.fn();- render(<FlowApprovalRequestCard request={REQUEST} onResolved={onResolved} />);-- fireEvent.click(screen.getByText('Approve once'));-- expect(decideApproval).toHaveBeenCalledWith('req-1', 'approve_once');- await waitFor(() => expect(onResolved).toHaveBeenCalledWith('req-1'));- });-- it('Approve always routes approve_always_for_flow to approval_decide', async () => {- vi.mocked(decideApproval).mockResolvedValueOnce(undefined);- const onResolved = vi.fn();- render(<FlowApprovalRequestCard request={REQUEST} onResolved={onResolved} />);-- fireEvent.click(screen.getByText('Approve always'));-- expect(decideApproval).toHaveBeenCalledWith('req-1', 'approve_always_for_flow');- await waitFor(() => expect(onResolved).toHaveBeenCalledWith('req-1'));- });-- it('Deny routes deny to approval_decide', async () => {- vi.mocked(decideApproval).mockResolvedValueOnce(undefined);- const onResolved = vi.fn();- render(<FlowApprovalRequestCard request={REQUEST} onResolved={onResolved} />);-- fireEvent.click(screen.getByText('Deny'));-- expect(decideApproval).toHaveBeenCalledWith('req-1', 'deny');- await waitFor(() => expect(onResolved).toHaveBeenCalledWith('req-1'));- });-- it('shows only the active busy label and disables all actions while deciding', () => {- vi.mocked(decideApproval).mockReturnValueOnce(new Promise<void>(() => undefined));- render(<FlowApprovalRequestCard request={REQUEST} onResolved={vi.fn()} />);-- fireEvent.click(screen.getByTestId('flow-approval-request-always'));-- expect(screen.getByTestId('flow-approval-request-approve')).toBeDisabled();- expect(screen.getByTestId('flow-approval-request-always')).toBeDisabled();- expect(screen.getByTestId('flow-approval-request-deny')).toBeDisabled();- expect(screen.getByTestId('flow-approval-request-approve')).toHaveTextContent('Approve once');- expect(screen.getByTestId('flow-approval-request-always')).toHaveTextContent('Working…');- expect(screen.getByTestId('flow-approval-request-deny')).toHaveTextContent('Deny');- });-- it('keeps the prompt and shows an error when the decide RPC fails', async () => {- vi.mocked(decideApproval).mockRejectedValueOnce(new Error('gate not installed'));- const onResolved = vi.fn();- render(<FlowApprovalRequestCard request={REQUEST} onResolved={onResolved} />);-- fireEvent.click(screen.getByText('Approve once'));-- await waitFor(() => {- expect(screen.getByText(/Could not record your decision/)).toBeInTheDocument();- });- expect(onResolved).not.toHaveBeenCalled();- expect(screen.getByText('Approve once')).toBeInTheDocument();- });-});