Sign in with a code, made-up data without Plaid, and easier everyday use

- Sign in with a code from your email (the link still works); setup item for the code email
- Use made-up data: a pretend bank with three months of spending, no Plaid account needed
- Is this your pay? when regular money in is filed as something else, with a one-press fix
- They look right: keep every bank-given category in one press
- Your week on Home, Plan in the main menu, history start per bank on Accounts
- A new version of broke is ready, in the sidebar and Settings
- Start skips the rebuild when nothing changed; country screen says it was guessed
- Fix: skipping banks no longer sends you back to setup

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
minimus7andClaude Opus 5.5 committed 2026-11-09 10:54:31 -06:00
1 parent 37a97fe20a
commit 73208b79df
30 files changed
+496 -39

No files matched your search

+40 -2
View File
@@ -130,6 +130,40 @@ export function CategoryCheck({ initial, cats: catsIn, onEmpty, title, closed =
ask(`Help me sort these categories. Suggest rules for what you're confident about, and ask me about anything you're not sure of.\n\nThese need checking: ${lines.join("; ")}.`);
}
// One press for the backlog: every row that has a category is kept as it is, so only rows with no category are left for
// the user. Money coming in stays where the bank put it (usually a refund); pay is the "Is this your pay?" question on Home.
// Shows what it will do before it does it.
const [plan, setPlan] = useState<{ keep: string[]; left: number } | null>(null);
async function planAll() {
const id = await uid();
if (!id) return;
const all = ((await fetchChecks(db(), id, undefined, 1000)) as Checks).rows;
const keep = all.filter((t) => t.category && t.category.key !== "OTHER");
setPlan({ keep: keep.flatMap((t) => t.same), left: all.length - keep.length });
}
async function doAll() {
if (!plan) return;
const now = new Date().toISOString();
for (let i = 0; i < plan.keep.length; i += 200) await db().from("transactions").update({ checked_at: now }).in("id", plan.keep.slice(i, i + 200));
toast(plan.left ? `Done. ${plural(plan.left, "transaction")} with no category still need you.` : "Done. Every category is checked.");
setPlan(null);
const id = await uid();
setChecks(id ? ((await fetchChecks(db(), id, undefined, limit)) as Checks) : { rows: [], total: 0 });
router.refresh();
}
const fixAll = plan ? (
<div className="w-full flex flex-wrap items-center gap-2 text-sm">
<span className="text-muted">
{plan.keep.length ? `Keep ${plural(plan.keep.length, "transaction")} in the category your bank gave them.` : "Nothing to keep: these have no category yet."}
{plan.left ? ` ${plural(plan.left, "transaction")} with no category will still need you.` : ""}
</span>
{!!plan.keep.length && <button type="button" className="btn-primary" onClick={doAll}>Do it</button>}
<button type="button" className="text-muted hover:text-ink" onClick={() => setPlan(null)}>Cancel</button>
</div>
) : (
<button type="button" onClick={planAll} className="btn">They look right</button>
);
// More of the same list, biggest first. Anything already answered is gone from it.
async function showMore() {
const id = await uid();
@@ -158,14 +192,18 @@ export function CategoryCheck({ initial, cats: catsIn, onEmpty, title, closed =
<div id="check-title" className="card-title">{head}</div>
<p className="text-sm text-muted">Is this right? Tips are only as good as your categories.</p>
</div>
<button type="button" onClick={() => setOpen(true)} className="btn">Check them</button>
{!plan && <button type="button" onClick={() => setOpen(true)} className="btn">Check them</button>}
{fixAll}
</section>
);
return (
<section className="card px-5 md:px-6 pt-5 pb-1" aria-labelledby="check-title">
<div id="check-title" className="card-title">{head}</div>
<p className="text-sm text-muted mt-1">Is this right? Tips are only as good as your categories.</p>
<button type="button" onClick={sortWithAI} className="btn inline-flex items-center gap-1.5 mt-3"><Sparkles size={15} /> Ask AI to sort these</button>
<div className="flex flex-wrap items-center gap-2 mt-3">
{fixAll}
{!plan && <button type="button" onClick={sortWithAI} className="btn inline-flex items-center gap-1.5"><Sparkles size={15} /> Ask AI to sort these</button>}
</div>
<ul className="mt-2">{checks.rows.map((t) => <CheckItem key={t.id} t={t} cats={cats} onAnswer={onAnswer} />)}</ul>
{checks.rows.length < checks.total && (
<div className="flex flex-wrap items-center justify-between gap-3 py-4 border-t border-line">
+3
View File
@@ -38,10 +38,12 @@ async function saveCountry(profile: Profile, country: string, currency: string)
export function Welcome({ profile, onDone }: { profile: Profile; onDone?: (p: Profile) => void }) {
const router = useRouter();
const [c, setC] = useState({ country: "", currency: "" });
const [guessed, setGuessed] = useState("");
const [busy, setBusy] = useState(false);
const [err, setErr] = useState("");
useEffect(() => {
const country = guessCountry(navigator.languages ?? [navigator.language], Intl.DateTimeFormat().resolvedOptions().timeZone);
setGuessed(country);
setC((x) => (x.country ? x : { country, currency: countryOf(country).currency }));
}, []);
@@ -64,6 +66,7 @@ export function Welcome({ profile, onDone }: { profile: Profile; onDone?: (p: Pr
<p className="text-sm text-muted mt-1">broke uses it for your currency, which banks you can link and which tax tips apply. You can change it later.</p>
</div>
<CountryField country={c.country} currency={c.currency} onChange={(country, currency) => setC({ country, currency })} />
{c.country && c.country === guessed && <p className="text-sm text-muted">Guessed from your computer&apos;s time zone and language. Change it if that&apos;s wrong.</p>}
<button onClick={go} disabled={busy || !c.country || !c.currency} className="btn-primary w-full">{busy ? "Saving..." : "Continue"}</button>
{err && <p className="text-sm text-bad">{err}</p>}
</div>
+27
View File
@@ -0,0 +1,27 @@
"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
// "Use made-up data": adds the demo bank (api/demo-bank) when there's no Plaid account to link a test bank with.
export function DemoBankButton({ onDone, primary = false }: { onDone?: () => void; primary?: boolean }) {
const router = useRouter();
const [busy, setBusy] = useState(false);
const [err, setErr] = useState("");
async function add() {
setBusy(true);
setErr("");
const res = await fetch("/api/demo-bank", { method: "POST" }).catch(() => null);
setBusy(false);
if (!res?.ok && res?.status !== 409) return setErr(((await res?.json().catch(() => null)) as { error?: string } | null)?.error ?? "Couldn't add the made-up bank. Try again.");
onDone?.();
router.refresh();
}
return (
<>
<button onClick={add} disabled={busy} className={primary ? "btn-primary" : "btn"}>{busy ? "Adding made-up data..." : "Use made-up data"}</button>
<p className="text-xs text-muted">A pretend bank with three months of everyday spending. No Plaid account needed. Clear it any time in Settings, Database.</p>
{err && <p className="text-sm text-bad">{err}</p>}
</>
);
}
+2
View File
@@ -1,4 +1,5 @@
import Link from "next/link";
import { DemoBankButton } from "@/components/DemoBank";
import { FeedConnect } from "@/components/FeedConnect";
import { ImportStatement } from "@/components/ImportStatement";
import { AkahuButton, LinkBankButton, TestModeNote } from "@/components/PlaidButtons";
@@ -27,6 +28,7 @@ export async function EmptyBank({ title = "Link an account to get started", body
{choices.bank === "plaid" && <LinkBankButton label={investOnly ? "Link a bank or card" : "Link a bank"} primary />}
{choices.sandbox && <LinkBankButton sandbox label="Use a test bank (sandbox)" />}
{choices.sandbox && <TestModeNote />}
{choices.demo && <DemoBankButton primary={!choices.bank && !choices.feeds.length} />}
<ImportStatement accounts={[]} locale={country.locale} currency={country.currency} />
{children ?? (investOnly && <Link href="/transactions" className="text-sm underline underline-offset-2">Add a transaction by hand</Link>)}
<Link href="/accounts/add" className="text-sm text-muted underline underline-offset-2 hover:text-ink">More ways to add an account</Link>
+1 -1
View File
@@ -183,7 +183,7 @@ export function MoneyPlan({ initial, today, name }: { initial: PlanState; today:
{state.error && <p className="text-sm text-bad" role="alert">{state.error}</p>}
{state.stale && !state.running && <p className="text-sm text-bad">{state.stale} Redo it to use your current accounts.</p>}
{!state.ready && <p className="text-sm text-muted">The money plan needs a database update. Open Setup to apply it.</p>}
{p?.note && !state.running && <p className="text-sm text-muted">{p.note} Steps built on those numbers aren&apos;t counted.</p>}
{p?.note && !state.running && <p className="text-sm text-muted">{p.note} Steps built on those numbers aren&apos;t counted. <a href="/accounts" className="underline underline-offset-2">See how far back each bank goes</a>.</p>}
</div>
{p && live.length > 0 && (
+5 -4
View File
@@ -1,6 +1,6 @@
"use client";
import { ArrowLeftRight, ChartPie, Ellipsis, House, Landmark, MessageCircle, Monitor, Moon, Sun } from "lucide-react";
import { ArrowLeftRight, ChartPie, ClipboardList, Ellipsis, House, Landmark, MessageCircle, Monitor, Moon, Sun } from "lucide-react";
import Link from "next/link";
import type { ComponentType } from "react";
import { usePathname, useRouter } from "next/navigation";
@@ -9,12 +9,13 @@ import { useAssistant } from "@/components/Assistant";
import { BookmarkButton, SavedList } from "@/components/Bookmarks";
import { DonateLink, DonatePrompt } from "@/components/Donate";
// Home is the three steps. Spending holds Budgets and Recurring as tabs, More holds the rest; every page keeps its own URL.
// Spending holds Budgets and Recurring as tabs, Plan holds Optimize, Bonuses and Cards, More holds the rest. Every page keeps its own URL.
type Icon = ComponentType<{ size?: number; strokeWidth?: number }>;
const LINKS: { href: string; label: string; icon: Icon }[] = [
{ href: "/", label: "Home", icon: House },
{ href: "/spending", label: "Spending", icon: ChartPie },
{ href: "/transactions", label: "Activity", icon: ArrowLeftRight },
{ href: "/plan", label: "Plan", icon: ClipboardList },
{ href: "/accounts", label: "Accounts", icon: Landmark },
{ href: "/more", label: "More", icon: Ellipsis },
];
@@ -22,7 +23,7 @@ const SPENDING = [{ href: "/spending", label: "Overview" }, { href: "/budgets",
const PLAN = [{ href: "/plan", label: "Money plan" }, { href: "/optimize", label: "Optimize" }, { href: "/bonuses", label: "Bonuses" }, { href: "/cards", label: "Cards" }];
const under = (path: string, href: string) => (href === "/" ? path === "/" : path === href || path.startsWith(href + "/"));
const tabsOf = (path: string) => [SPENDING, PLAN].find((g) => g.some((t) => under(path, t.href)));
const sectionOf = (path: string) => (SPENDING.some((t) => under(path, t.href)) ? "/spending" : LINKS.find((l) => under(path, l.href))?.href ?? (tabsOf(path) || under(path, "/connect-ai") || under(path, "/debt") ? "/more" : undefined));
const sectionOf = (path: string) => (SPENDING.some((t) => under(path, t.href)) ? "/spending" : PLAN.some((t) => under(path, t.href)) ? "/plan" : LINKS.find((l) => under(path, l.href))?.href ?? (under(path, "/connect-ai") || under(path, "/debt") ? "/more" : undefined));
const TITLES: Record<string, string> = {
"/": "Home", "/transactions": "Activity", "/spending": "Spending", "/budgets": "Budgets", "/recurring": "Recurring", "/plan": "Money plan",
@@ -89,7 +90,7 @@ function PhoneBar({ section }: { section?: string }) {
const assistant = useAssistant();
const cell = "flex flex-col items-center gap-0.5 text-[11px] py-1.5 rounded-xl";
return (
<nav aria-label="Main" className="fixed bottom-0 inset-x-0 z-30 md:hidden bg-surface border-t border-line grid grid-cols-6 px-1 pt-1 pb-[max(6px,env(safe-area-inset-bottom))]">
<nav aria-label="Main" className="fixed bottom-0 inset-x-0 z-30 md:hidden bg-surface border-t border-line grid grid-cols-7 px-1 pt-1 pb-[max(6px,env(safe-area-inset-bottom))]">
{LINKS.map(({ href, label, icon: Icon }) => (
<Link key={href} href={href} prefetch aria-current={href === section ? "page" : undefined} className={`${cell} ${href === section ? "text-ink font-medium" : "text-muted"}`}>
<Icon size={21} strokeWidth={href === section ? 2 : 1.6} />
+2
View File
@@ -6,6 +6,7 @@ import { useRouter } from "next/navigation";
import { useEffect, useRef, useState } from "react";
import { Welcome } from "@/components/CountryPicker";
import { GoalPicker, type DraftPlan } from "@/components/GoalPicker";
import { DemoBankButton } from "@/components/DemoBank";
import { FeedConnect } from "@/components/FeedConnect";
import { Logo } from "@/components/Logo";
import { linkedText, useAkahu, useLinkBank } from "@/components/PlaidButtons";
@@ -83,6 +84,7 @@ function BankStep({ choices, country, info, next, reload }: { choices: AddChoice
{choices.bank === "plaid" && <button onClick={() => link.start()} className={linked ? "btn" : "btn-primary"}>{linked ? "Link another bank" : "Link a bank or card"}</button>}
{choices.bank === "akahu" && <button onClick={akahu.start} className={linked ? "btn" : "btn-primary"}>Link your NZ banks</button>}
{choices.sandbox && <button onClick={() => link.start(true)} className="btn">Use a test bank</button>}
{choices.demo && !linked && <DemoBankButton primary={!choices.bank} onDone={reload} />}
{linked > 0 && <button onClick={next} className="btn-primary">Continue</button>}
</div>
{(link.error || akahu.error) && <p className="text-sm text-bad">{link.error || akahu.error}</p>}
+44
View File
@@ -0,0 +1,44 @@
"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { useMoney } from "@/components/Money";
import { emptyRule, saveRule } from "@/components/RuleForm";
import type { PayGuess } from "@/lib/pay";
import { createClient, updateMeta } from "@/utils/supabase/client";
// "Is this your pay?": regular money coming in that the bank filed as something else. Yes saves a rule that files it
// (and every past one) as Income, so the plan, budgets and leftover money count it. No never asks about that name again.
export function PayFound({ pay, filedAs, incomeId, notPay }: { pay: PayGuess; filedAs: string; incomeId: string; notPay: string[] }) {
const router = useRouter();
const { money0 } = useMoney();
const [state, setState] = useState<"idle" | "busy" | "gone">("idle");
const [err, setErr] = useState("");
if (state === "gone") return null;
async function yes() {
setState("busy");
const r = await saveRule(emptyRule({ match: pay.name, direction: "in", category_id: incomeId }), true);
if (r.error) return setErr(r.error), setState("idle");
setState("gone");
router.refresh();
}
async function no() {
setState("busy");
const sb = createClient();
await updateMeta(sb, { data: { not_pay: [...notPay, pay.name] } });
setState("gone");
}
return (
<section className="card p-5 space-y-3">
<div className="space-y-1">
<p className="font-medium">Is {money0(pay.typical)} every {pay.every} from {pay.name} your pay?</p>
<p className="text-sm text-muted">Your bank filed it as {filedAs}, so broke can&apos;t count it as money coming in. That changes your plan, budgets and what&apos;s left over.</p>
</div>
<div className="flex flex-wrap gap-2">
<button className="btn-primary" disabled={state === "busy"} onClick={yes}>Yes, it&apos;s my pay</button>
<button className="btn" disabled={state === "busy"} onClick={no}>No</button>
</div>
{err && <p className="text-sm text-bad">{err}</p>}
</section>
);
}
+31
View File
@@ -0,0 +1,31 @@
"use client";
import { useEffect, useState } from "react";
import { AskButton } from "@/components/Assistant";
import { useMoney } from "@/components/Money";
import { changeLines, trackLines, type CheckinFacts } from "@/lib/checkins";
type Checkin = { id: string; created_at: string; facts: CheckinFacts; summary: string | null };
// "Your week" on Home: the weekly review, written once a week (POST /api/checkins makes a new one when the last is 7+
// days old, else returns it). Your AI's words when one is connected, else the plain facts. A few lines, no more.
export function WeekCard() {
const { money0, dateLabel } = useMoney();
const [c, setC] = useState<Checkin | null>(null);
useEffect(() => {
fetch("/api/checkins", { method: "POST", headers: { "content-type": "application/json" }, body: "{}" })
.then((r) => (r.ok ? r.json() : null)).then((x: Checkin | null) => x?.facts && setC(x)).catch(() => {});
}, []);
if (!c) return null;
const lines = (c.summary ? c.summary.split("\n").map((l) => l.replace(/^- /, "").trim()) : [...changeLines(c.facts, { $: money0 }), ...trackLines(c.facts, money0)]).filter(Boolean).slice(0, 4);
if (!lines.length) return null;
return (
<section className="card p-5 space-y-2.5">
<div className="flex items-baseline justify-between gap-3">
<span className="text-sm text-muted">Your week · {dateLabel(c.created_at.slice(0, 10), { month: "short", day: "numeric" })}</span>
<AskButton q="Talk me through my week: what changed, and what should I do about it?" className="text-sm text-muted hover:text-ink">Ask about this</AskButton>
</div>
<ul className="space-y-1.5 text-sm list-disc pl-5">{lines.map((l) => <li key={l}>{l}</li>)}</ul>
</section>
);
}