Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions docs/HANDOFF.md
Original file line number Diff line number Diff line change
Expand Up @@ -4587,3 +4587,48 @@ rows", transactions 2 "show more" in steps of 20, plus a view-only list.

### Open problems
- Not checked visually in a browser in this session.

## HO-122: Confirm before deleting or disconnecting; fix links on a filtered new transaction

- **Date:** 2026-10-11 (UTC)
- **Author:** Muhammad Tahub Khatri with Claude Code
- **Branch / PR:** `fix/ui-confirmations` / PR linked from the branch

### What changed
- **Broken links:** adding a transaction from a filtered list
(`/transactions/new?account=…`) built "Review transfers" as
`…/transactions?account=…/transfers` and left the Bills link pointing
at Transactions. `transactionsPath()` in `transaction-form.tsx` drops
the query for those links; Cancel keeps the filter.
- **Confirmations:** new shared `Confirm` (`src/components/ui/confirm.tsx`),
a `<details>` that names the action, says what happens, and holds a
"Confirm …" button, like Recurring's "Remove tracking". Used for:
- Import: Discard (deletes the preview and its saved CSV)
- Budgets: Remove budget
- Bills: Unlink payment
- Settings: Disconnect (phone)
- **Day panel ×:** the first press turns it into "Remove?" on the same
button (focus stays), the second removes; moving away resets it.
- Not changed: Bills "Stop tracking bill" and "Dismiss pattern" and
Recurring "Not recurring" have a Restore, so they stay one click.
- **Dates:** Transfers showed raw ISO dates ("2026-07-14") and Recurring
the raw next date; both now read "Jul 14, 2026".
- **Live regions:** Bills and Budgets form results keep an empty
`role="status"` mounted (`.live-region`, no space while empty), so the
first message is announced.
- Tests: `transaction-form.test.ts` (Vitest) for `transactionsPath`;
e2e updated for every confirmed action (`pdf-import`, `bills`,
`budgets`, `agent-link`, `calendar`) and `transactions.spec.ts` checks
the hint links on a filtered new transaction.

### Verified
- `pnpm lint`, `typecheck`, `format:check`, `docs:check` and `build`
pass. `pnpm test:unit`: everything passes except the Neon storage tests,
which need `storage-tests` credentials this container does not have.
- Playwright was not run (Muhammad runs it).

### What's next
- One shared button style for every feature (still per feature).

### Open problems
- None.
11 changes: 11 additions & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ select {
color: inherit;
}

/* A status message that stays in the page so screen readers announce its
first message; while empty it takes no space. */
.live-region:empty {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}

:focus-visible {
outline: 2px solid var(--ink);
outline-offset: 2px;
Expand Down
32 changes: 32 additions & 0 deletions src/components/ui/confirm.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* Uses the tokens in src/app/globals.css (ADR-046). */

.confirm {
display: grid;
justify-items: start;
gap: 0.5rem;
}

.confirm > summary {
padding: 0.5rem 1rem;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--surface);
color: var(--ink);
cursor: pointer;
list-style: none;
}

.confirm > summary::-webkit-details-marker {
display: none;
}

.confirm > summary:hover,
.confirm[open] > summary {
background: var(--tint);
}

.consequence {
max-width: 40rem;
color: var(--ink-soft);
font-size: 0.875rem;
}
26 changes: 26 additions & 0 deletions src/components/ui/confirm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { ReactNode } from "react";
import styles from "./confirm.module.css";

type Props = {
/** What the action does, e.g. "Remove budget". Opens the confirmation. */
label: string;
/** One sentence on what happens and what can't be undone. */
consequence: string;
/** The button that does it, labelled "Confirm …". */
children: ReactNode;
};

/**
* An action that deletes or disconnects something, behind one more click:
* the first names it, the panel says what happens, the button inside does
* it. The same shape as Recurring's "Remove tracking".
*/
export function Confirm({ label, consequence, children }: Props) {
return (
<details className={styles.confirm}>
<summary>{label}</summary>
<p className={styles.consequence}>{consequence}</p>
{children}
</details>
);
}
24 changes: 15 additions & 9 deletions src/features/bills/ui/bills-page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Link from "next/link";
import { Confirm } from "@/components/ui/confirm";
import { shiftDays } from "@/features/recurring/client";
import { cents, formatCents, toDecimalString } from "@/lib/money";
import { isSettled, type CycleStatus, type CycleView } from "../domain/cycles";
Expand Down Expand Up @@ -215,16 +216,21 @@ function BillDetail({ data }: { data: BillsView }) {
</p>
) : null}
{editable ? (
<BillOperation
<Confirm
label="Unlink payment"
action={unlinkPaymentAction.bind(
null,
...args,
cycle.scheduledOn,
cycle.revision,
link.id,
)}
/>
consequence="This invoice will no longer count this transaction as its payment. The transaction itself stays."
>
<BillOperation
label="Confirm unlink payment"
action={unlinkPaymentAction.bind(
null,
...args,
cycle.scheduledOn,
cycle.revision,
link.id,
)}
/>
</Confirm>
) : null}
</li>
))}
Expand Down
5 changes: 4 additions & 1 deletion src/features/bills/ui/forms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ function Feedback({ state }: { state: FormState }) {
return (
<>
{state.errors.form ? <p role="alert">{state.errors.form}</p> : null}
{state.message ? <p role="status">{state.message}</p> : null}
{/* Always there, so the first message is announced too. */}
<p role="status" className="live-region">
{state.message}
</p>
</>
);
}
Expand Down
22 changes: 14 additions & 8 deletions src/features/budgets/ui/budgets-page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Link from "next/link";
import { Confirm } from "@/components/ui/confirm";
import { absolute, formatCents } from "@/lib/money";
import {
copyBudgetsAction,
Expand Down Expand Up @@ -191,15 +192,20 @@ export function BudgetsPage({ data }: { data: BudgetsView }) {
)}
/>
{row.allocation !== null ? (
<BudgetOperation
action={removeBudgetAction.bind(
null,
workspaceId,
month,
row.id,
)}
<Confirm
label="Remove budget"
/>
consequence="This clears the plan for this category this month. Spending stays as it is; you can set a new budget any time."
>
<BudgetOperation
action={removeBudgetAction.bind(
null,
workspaceId,
month,
row.id,
)}
label="Confirm remove budget"
/>
</Confirm>
) : null}
</div>
) : null}
Expand Down
10 changes: 8 additions & 2 deletions src/features/budgets/ui/forms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export function BudgetForm({
</p>
) : null}
{state.errors.form ? <p role="alert">{state.errors.form}</p> : null}
{state.message ? <p role="status">{state.message}</p> : null}
{/* Always there, so the first message is announced too. */}
<p role="status" className="live-region">
{state.message}
</p>
</form>
);
}
Expand All @@ -72,7 +75,10 @@ export function BudgetOperation({
{pending ? "Saving…" : label}
</button>
{state.errors.form ? <p role="alert">{state.errors.form}</p> : null}
{state.message ? <p role="status">{state.message}</p> : null}
{/* Always there, so the first message is announced too. */}
<p role="status" className="live-region">
{state.message}
</p>
</form>
);
}
53 changes: 37 additions & 16 deletions src/features/cashflow/ui/day-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,35 @@ function AddForm({
);
}

/**
* × asks once more before it removes: the first press turns it into
* "Remove?", the second removes. It stays the same button, so focus stays
* on it; moving away puts the × back.
*/
function RemoveButton({
name,
disabled,
onRemove,
}: {
name: string;
disabled: boolean;
onRemove: () => void;
}) {
const [armed, setArmed] = useState(false);
return (
<button
type="button"
className={armed ? "item-confirm" : "item-remove"}
aria-label={armed ? `Confirm remove ${name}` : `Remove ${name}`}
disabled={disabled}
onClick={() => (armed ? onRemove() : setArmed(true))}
onBlur={() => setArmed(false)}
>
{armed ? "Remove?" : <span aria-hidden="true">×</span>}
</button>
);
}

export function DayPanel({
workspaceId,
day,
Expand Down Expand Up @@ -309,26 +338,18 @@ export function DayPanel({
>
It happened
</button>
<button
type="button"
className="item-remove"
aria-label={`Remove ${item.name}`}
<RemoveButton
name={item.name}
disabled={removing}
onClick={() => remove(item)}
>
<span aria-hidden="true">×</span>
</button>
onRemove={() => remove(item)}
/>
</span>
) : canEdit && item.removable ? (
<button
type="button"
className="item-remove"
aria-label={`Remove ${item.name}`}
<RemoveButton
name={item.name}
disabled={removing}
onClick={() => remove(item)}
>
<span aria-hidden="true">×</span>
</button>
onRemove={() => remove(item)}
/>
) : item.isPlan ? (
<span className="item-remove" />
) : (
Expand Down
14 changes: 10 additions & 4 deletions src/features/imports/ui/preview-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useActionState, useId } from "react";
import { useFormStatus } from "react-dom";
import { Confirm } from "@/components/ui/confirm";
import { formatCents, formatSigned } from "@/lib/money";
import { type Check, formatStatementDate } from "../domain/checks";
import type { StatementRow } from "../domain/statement";
Expand Down Expand Up @@ -29,7 +30,7 @@ function DiscardButton() {
const { pending } = useFormStatus();
return (
<button type="submit" className={styles.secondary} disabled={pending}>
{pending ? "Discarding…" : "Discard"}
{pending ? "Discarding…" : "Confirm discard"}
</button>
);
}
Expand Down Expand Up @@ -143,9 +144,14 @@ export function PreviewPanel({
</button>
</div>
</form>
<form action={discard} className={styles.actions}>
<DiscardButton />
</form>
<Confirm
label="Discard"
consequence="This deletes the checked statement and its saved copy. Nothing from it is imported; to import it later, upload it again."
>
<form action={discard} className={styles.actions}>
<DiscardButton />
</form>
</Confirm>
</>
)}
</section>
Expand Down
20 changes: 13 additions & 7 deletions src/features/messaging/ui/phone-link-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useRouter } from "next/navigation";
import { useEffect, useOptimistic, useState, useTransition } from "react";
import { Confirm } from "@/components/ui/confirm";
import { APP_NAME } from "@/config/app";
import { formatLinkCode } from "../domain/link-code";
import {
Expand Down Expand Up @@ -234,14 +235,19 @@ export function PhoneLinkCard({ workspaceId, state, agentPhone }: Props) {
iPhone’s Notifications settings.
</p>
<div className={styles.actions}>
<button
type="button"
className={styles.secondary}
onClick={disconnect}
disabled={busy}
<Confirm
label="Disconnect"
consequence="Your phone stops getting texts and can't log spending. To link it again you'll need a new code."
>
Disconnect
</button>
<button
type="button"
className={styles.secondary}
onClick={disconnect}
disabled={busy}
>
Confirm disconnect
</button>
</Confirm>
<span className={styles.meta}>or text STOP</span>
</div>
</>
Expand Down
7 changes: 6 additions & 1 deletion src/features/recurring/ui/recurring-page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Link from "next/link";
import { NavRefresh } from "@/components/ui/nav-refresh";
import { formatCents } from "@/lib/money";
import { longDate } from "../domain/evidence";
import type { FormAction } from "../domain/forms";
import type { Payment, summarizePayments } from "../domain/payments";
import { ChargeEvidence } from "./charge-evidence";
Expand Down Expand Up @@ -103,7 +104,11 @@ function PaymentCard({
? "Expected next payday"
: "Expected next charge"}
</dt>
<dd>{payment.nextOn ?? "Unknown — add a date to resume tracking"}</dd>
<dd>
{payment.nextOn
? longDate(payment.nextOn)
: "Unknown — add a date to resume tracking"}
</dd>
</div>
</dl>
{payment.sampleCount ? (
Expand Down
Loading
Loading