From 73208b79df15676ef96aacdf1467a0127c04fdd0 Mon Sep 17 00:00:00 2001 From: minimus7 Date: Mon, 9 Nov 2026 10:54:31 -0600 Subject: [PATCH] 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 --- next.config.ts | 10 ++++ scripts/start.mjs | 11 ++++- src/app/(app)/accounts/page.tsx | 8 +++- src/app/(app)/layout.tsx | 3 ++ src/app/(app)/more/page.tsx | 14 ++---- src/app/(app)/page.tsx | 22 +++++++++ src/app/(app)/settings/Settings.tsx | 5 +- src/app/(app)/settings/page.tsx | 2 + src/app/api/demo-bank/route.ts | 52 +++++++++++++++++++++ src/app/login/page.tsx | 60 ++++++++++++++++++++---- src/app/setup/SetupChecklist.tsx | 4 +- src/components/CategoryCheck.tsx | 42 ++++++++++++++++- src/components/CountryPicker.tsx | 3 ++ src/components/DemoBank.tsx | 27 +++++++++++ src/components/EmptyBank.tsx | 2 + src/components/MoneyPlan.tsx | 2 +- src/components/Nav.tsx | 9 ++-- src/components/Onboarding.tsx | 2 + src/components/PayFound.tsx | 44 ++++++++++++++++++ src/components/WeekCard.tsx | 31 +++++++++++++ src/lib/demo.test.ts | 17 +++++++ src/lib/demo.ts | 71 +++++++++++++++++++++++++++++ src/lib/pay.test.ts | 15 ++++++ src/lib/pay.ts | 28 ++++++++++++ src/lib/plaid.ts | 3 +- src/lib/providers/index.ts | 2 + src/lib/setup.ts | 18 ++++++++ src/lib/sync.ts | 4 +- src/lib/updates.ts | 22 +++++++++ src/utils/supabase/middleware.ts | 2 - 30 files changed, 496 insertions(+), 39 deletions(-) create mode 100644 src/app/api/demo-bank/route.ts create mode 100644 src/components/DemoBank.tsx create mode 100644 src/components/PayFound.tsx create mode 100644 src/components/WeekCard.tsx create mode 100644 src/lib/demo.test.ts create mode 100644 src/lib/demo.ts create mode 100644 src/lib/pay.test.ts create mode 100644 src/lib/pay.ts create mode 100644 src/lib/updates.ts diff --git a/next.config.ts b/next.config.ts index ae1d9e0..b24ead9 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,9 +1,19 @@ +import { execSync } from "node:child_process"; import type { NextConfig } from "next"; +// When the code this copy runs was last changed (its newest commit), for "A new version of broke is ready". +let builtFrom = ""; +try { + builtFrom = execSync("git log -1 --format=%cI", { stdio: ["ignore", "pipe", "ignore"] }).toString().trim(); +} catch { + /* no git (a download without history): the update check stays quiet */ +} + const nextConfig: NextConfig = { devIndicators: false, distDir: process.env.NEXT_DIST_DIR || ".next", // a production build can sit beside the running dev server serverExternalPackages: ["pg"], + env: { BROKE_BUILT_FROM: builtFrom }, // Keep pages you visited for 3 min, so going back or switching tabs is instant. Every edit calls router.refresh(), // which drops the cache, so changes still show at once. experimental: { staleTimes: { dynamic: 180 } }, diff --git a/scripts/start.mjs b/scripts/start.mjs index 121b217..8575710 100755 --- a/scripts/start.mjs +++ b/scripts/start.mjs @@ -2,7 +2,7 @@ // Starts broke on this computer and opens it. Before the keys are in, it runs in development mode: the setup page saves // keys and the server picks them up without a restart. After that it runs the faster production build. import { spawn, spawnSync } from "node:child_process"; -import { existsSync, readFileSync } from "node:fs"; +import { existsSync, readdirSync, readFileSync, statSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; @@ -34,7 +34,14 @@ if (await fetch(url, { redirect: "manual" }).then(() => true, () => false)) { openIt(); process.exit(0); } -if (ready && !npm("run", "build")) process.exit(1); +// The last build is reused when nothing it was built from has changed since: code, packages, settings or keys. +const newest = (p) => !existsSync(p) ? 0 : statSync(p).isDirectory() + ? Math.max(0, ...readdirSync(p, { recursive: true }).map((f) => statSync(join(p, String(f))).mtimeMs)) + : statSync(p).mtimeMs; +const built = existsSync(".next/BUILD_ID") ? statSync(".next/BUILD_ID").mtimeMs : 0; +const stale = Math.max(...["src", "public", "package-lock.json", "next.config.ts", ".env", ".env.local"].map(newest)) > built; +if (ready && !stale) console.log("Nothing changed since the last build: starting it."); +if (ready && stale && !npm("run", "build")) process.exit(1); const next = join("node_modules", ".bin", win ? "next.cmd" : "next"); // Listens on this computer only, which is what makes saving keys from the page safe (writeGate checks the rest). const args = ready ? ["start", "-H", "127.0.0.1", "-p", port] : ["dev", "--turbopack", "-H", "127.0.0.1", "-p", port]; diff --git a/src/app/(app)/accounts/page.tsx b/src/app/(app)/accounts/page.tsx index 72be2ca..dac943c 100644 --- a/src/app/(app)/accounts/page.tsx +++ b/src/app/(app)/accounts/page.tsx @@ -60,6 +60,12 @@ export default async function Accounts() { supabase.from("accounts").select("id, name, custom_name, mask, type, subtype, current_balance:balance, currency, home:home_balance, included").eq("manual", true).eq("user_id", user!.id), ]); const items = (data ?? []) as unknown as Item[]; + // How far back each bank's transactions go, so a short history doesn't read as a strange month. + const since = new Map(await Promise.all(items.map(async (i) => { + const ids = i.accounts.map((a) => a.id); + const { data: first } = ids.length ? await supabase.from("transactions").select("date").in("account_id", ids).order("date").limit(1) : { data: [] }; + return [i.id, (first?.[0]?.date as string | undefined) ?? null] as const; + }))); const manualItem = { id: "manual", institution_name: "Added by you", institution_logo: null, institution_color: null, last_synced_at: null, accounts: [] }; const all = [ ...items.flatMap((i) => i.accounts.map((a) => ({ ...a, item: i }))), @@ -164,7 +170,7 @@ export default async function Accounts() {
{item.status && item.status !== "ok" ? item.status === "ITEM_LOGIN_REQUIRED" ? "Sign in to your bank again to keep syncing." : (item.error ?? "This connection stopped syncing.") - : `${holds(item.accounts) ? `${holds(item.accounts)} · ` : ""}${plural(item.accounts.length, "account")} · synced ${item.last_synced_at ? ago(item.last_synced_at) : "never"}`} + : `${holds(item.accounts) ? `${holds(item.accounts)} · ` : ""}${plural(item.accounts.length, "account")}${since.get(item.id) ? ` · history from ${new Date(`${since.get(item.id)}T12:00:00Z`).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric", timeZone: "UTC" })}` : ""} · synced ${item.last_synced_at ? ago(item.last_synced_at) : "never"}`}
diff --git a/src/app/(app)/layout.tsx b/src/app/(app)/layout.tsx index 6eddb9f..08fe4e8 100644 --- a/src/app/(app)/layout.tsx +++ b/src/app/(app)/layout.tsx @@ -11,12 +11,14 @@ import { countryOf } from "@/lib/countries"; import { getUser, userTz } from "@/lib/data"; import { fmtFor, todayIn } from "@/lib/format"; import { modeOf } from "@/lib/privacy"; +import { updateReady } from "@/lib/updates"; import { createClient } from "@/utils/supabase/server"; // Accounts made before country support are treated as US (countryOf default) and get a dashboard nudge instead. const FIRST_RUN_SINCE = "2026-10-22"; export default async function AppLayout({ children }: { children: React.ReactNode }) { + const update = await updateReady(); const [{ user }, tz] = await Promise.all([getUser(), userTz()]); const profile = user?.user_metadata?.profile; // created_at isn't in the token, so only users with no country pay for the full user record. @@ -47,6 +49,7 @@ export default async function AppLayout({ children }: { children: React.ReactNod