Skip to content

Self-improving AI Employees for everyone

fix(chat): the approval card announces outcomes, not countdowns

trohitgd26efd0f7c13
diff --git a/client/src/features/chat/__tests__/approvals.test.tsx b/client/src/features/chat/__tests__/approvals.test.tsx
index f7754c3b..77b4542e 100644
--- a/client/src/features/chat/__tests__/approvals.test.tsx
+++ b/client/src/features/chat/__tests__/approvals.test.tsx
@@ -215,6 +215,22 @@ describe('a draft in the chat', () => {
expect(within(own).getByText('Yes, Saturday at 10 works.')).toBeInTheDocument();
});
+ it('announces a discarded draft once, not its Restore countdown', async () => {
+ const restore = new Date(Date.now() + 60_000).toISOString();
+ server.approvals = [summary({ approval_id: 'g1', kind: 'gate', run_id: null, tool_call_id: null, status: 'discarded', restore_until: restore })];
+ renderPane();
+ const own = await screen.findByRole('region', { name: 'Drafts waiting for you' });
+ expect(within(own).getByRole('status')).toHaveTextContent('Discarded. Maya won’t send this.');
+ expect(within(own).getByRole('button', { name: /^Restore/ })).toHaveAttribute('aria-live', 'off');
+ });
+
+ it('announces a send that did not go', async () => {
+ server.approvals = [summary({ status: 'failed', outcome: { certainty: 'not_sent' } })];
+ renderPane();
+ const card = (await screen.findByText('I drafted a WhatsApp to Ana.')).closest('[data-turn="assistant"]') as HTMLElement;
+ expect(await within(card).findByText('It didn’t go out.')).toHaveAttribute('role', 'status');
+ });
+
it('asks before turning Ask first off', async () => {
renderPane();
const chip = await screen.findByRole('button', { name: 'Ask first' });
diff --git a/client/src/features/chat/approval/ApprovalCard.tsx b/client/src/features/chat/approval/ApprovalCard.tsx
index 2f0ceefe..572d8758 100644
--- a/client/src/features/chat/approval/ApprovalCard.tsx
+++ b/client/src/features/chat/approval/ApprovalCard.tsx
@@ -340,9 +340,19 @@ function Footer({
if (footer.kind === 'discarded') {
return (
<div className={cn(bar, 'bg-bg-app')}>
- <span className="min-w-0 flex-1 text-xs text-fg-muted">{footer.text}</span>
+ <span className="min-w-0 flex-1 text-xs text-fg-muted" role="status">
+ {footer.text}
+ </span>
{footer.canRestore && (
- <Button variant="outline" size="sm" disabled={busy} onClick={() => decide({ approval, decision: 'restore' })} className="gap-1.5 font-semibold tabular-nums">
+ // Its countdown ticks every second: never announced.
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={busy}
+ onClick={() => decide({ approval, decision: 'restore' })}
+ className="gap-1.5 font-semibold tabular-nums"
+ aria-live="off"
+ >
<RotateCcw aria-hidden className="size-3.25" />
{footer.restoreSeconds !== null ? `Restore · ${footer.restoreSeconds}s` : 'Restore'}
</Button>
@@ -379,7 +389,9 @@ function FailedFooter({
if (confirming) {
return (
<div className={cn(className, 'bg-action-stop-soft')}>
- <span className="min-w-0 flex-1 text-xs text-fg-default">It may already have gone out. Send it again anyway?</span>
+ <span className="min-w-0 flex-1 text-xs text-fg-default" role="status">
+ It may already have gone out. Send it again anyway?
+ </span>
<Button variant="quiet" size="sm" onClick={() => setConfirming(false)} className="font-semibold">
Keep it
</Button>
@@ -398,7 +410,9 @@ function FailedFooter({
}
return (
<div className={cn(className, 'bg-action-stop-soft')}>
- <span className="min-w-0 flex-1 text-xs text-fg-default">{text}</span>
+ <span className="min-w-0 flex-1 text-xs text-fg-default" role="status">
+ {text}
+ </span>
<Button
variant="outline"
size="sm"