From e3f44964513a29fc42fadd3a4d8ef0a02244f772 Mon Sep 17 00:00:00 2001 From: Musa Kaleem <131704022+Musa-Kal@users.noreply.github.com> Date: Sat, 21 Nov 2026 02:34:45 -0500 Subject: [PATCH 1/6] First steps on Home, clearer next actions, more help tips, UI fixes - Home shows a "Set the table" first steps card until a group has more than one member. - Group header leads with Settle up when you owe. - New expense, Settle up and New plan offer Create a group when you have no groups, instead of a dead end. - A real not-found page. - Eight new help topics, each linked to an existing guide heading. - Colour roles: olive for money owed to you and success, muted grey for settled amounts, saffron for the selected bottom tab. Tomato stays the primary action colour. - Fixes: duplicate empty state buttons on Plans and Friends, a clipped search placeholder on phones, scroll rows with no overflow cue, the wrong tab lit on payment and repeating pages. --- apps/web/e2e/onboarding.spec.ts | 5 + .../src/features/balances/balances-tab.tsx | 4 +- .../src/features/dashboard/balance-hero.tsx | 6 +- .../dashboard/home-dashboard.test.tsx | 41 +++++ .../src/features/dashboard/home-dashboard.tsx | 119 +++++++------ .../expenses/expense-detail-parts.tsx | 2 +- .../web/src/features/expenses/expense-row.tsx | 2 +- .../src/features/expenses/expenses-tab.tsx | 38 ++++- .../features/expenses/form/split-editor.tsx | 12 +- .../features/expenses/group-picker.test.tsx | 11 +- .../src/features/expenses/group-picker.tsx | 19 ++- .../features/export-import/import-screen.tsx | 2 +- .../features/friends/friends-page.test.tsx | 7 +- .../web/src/features/friends/friends-page.tsx | 25 ++- .../features/friends/settle-friend-sheet.tsx | 2 +- .../features/groups/create-group-sheet.tsx | 2 + .../src/features/groups/group-layout.test.tsx | 22 +++ apps/web/src/features/groups/group-layout.tsx | 38 ++++- apps/web/src/features/groups/groups-page.tsx | 1 - apps/web/src/features/help/help.tsx | 11 +- apps/web/src/features/help/topics.ts | 8 + .../src/features/insights/filter-sheet.tsx | 2 +- .../src/features/insights/search-screen.tsx | 5 +- .../src/features/insights/spending-view.tsx | 2 +- .../notifications/notifications-page.tsx | 3 +- .../src/features/onboarding/first-steps.tsx | 159 ++++++++++++++++++ .../src/features/plans/create-plan-page.tsx | 8 +- .../src/features/plans/plans-page.test.tsx | 8 +- apps/web/src/features/plans/plans-page.tsx | 15 +- apps/web/src/features/plans/rsvp-panel.tsx | 6 +- apps/web/src/features/settle/settle-flow.tsx | 4 +- .../src/features/shell/app-layout.test.tsx | 15 ++ apps/web/src/features/shell/app-layout.tsx | 6 +- apps/web/src/features/shell/landing-page.tsx | 3 +- .../src/features/shell/route-error.test.tsx | 28 ++- apps/web/src/features/shell/route-error.tsx | 29 ++++ apps/web/src/lib/overflow.ts | 29 ++++ apps/web/src/main.tsx | 4 +- apps/web/src/routes/-dev-kit/tokens-panel.tsx | 4 +- apps/web/src/styles/base.css | 13 ++ docs/design.md | 43 +++-- packages/i18n/src/de/help.ts | 12 ++ packages/i18n/src/de/plans.ts | 15 ++ packages/i18n/src/de/shell.ts | 1 + packages/i18n/src/en/help.ts | 12 ++ packages/i18n/src/en/plans.ts | 16 ++ packages/i18n/src/en/shell.ts | 1 + packages/i18n/src/es/help.ts | 12 ++ packages/i18n/src/es/plans.ts | 15 ++ packages/i18n/src/es/shell.ts | 1 + packages/i18n/src/fr/help.ts | 12 ++ packages/i18n/src/fr/plans.ts | 15 ++ packages/i18n/src/fr/shell.ts | 1 + packages/i18n/src/pt/help.ts | 12 ++ packages/i18n/src/pt/plans.ts | 15 ++ packages/i18n/src/pt/shell.ts | 1 + packages/tokens/src/color.ts | 26 +-- packages/tokens/src/index.test.ts | 1 + packages/ui/src/amount.tsx | 10 +- packages/ui/src/help.tsx | 8 +- 60 files changed, 792 insertions(+), 157 deletions(-) create mode 100644 apps/web/src/features/onboarding/first-steps.tsx create mode 100644 apps/web/src/lib/overflow.ts diff --git a/apps/web/e2e/onboarding.spec.ts b/apps/web/e2e/onboarding.spec.ts index 4b5bdc88..6e323389 100644 --- a/apps/web/e2e/onboarding.spec.ts +++ b/apps/web/e2e/onboarding.spec.ts @@ -32,4 +32,9 @@ test('landing page leads to sign up, onboarding and home', async ({ page }) => { await expect(page).toHaveURL(/\/home$/) await expect(page.getByRole('heading', { level: 1 })).toContainText(name) + + // Home picks up where onboarding left off: the first steps card leads to making a group. + const steps = page.getByRole('region', { name: t('home.firstSteps.title') }) + await steps.getByRole('link', { name: t('home.firstSteps.groupAction') }).click() + await expect(page.getByRole('dialog', { name: t('groups.create.title') })).toBeVisible() }) diff --git a/apps/web/src/features/balances/balances-tab.tsx b/apps/web/src/features/balances/balances-tab.tsx index 233fc79b..90c9d88b 100644 --- a/apps/web/src/features/balances/balances-tab.tsx +++ b/apps/web/src/features/balances/balances-tab.tsx @@ -170,7 +170,7 @@ export function BalancesTab({ groupId }: { groupId: string }) { className={cn( 'flex items-center gap-3 px-4 py-3', d.from_user === me && 'bg-tomato-soft/40', - d.to_user === me && 'bg-saffron-soft/40', + d.to_user === me && 'bg-olive-soft/50', )} > @@ -278,7 +278,7 @@ export function BalancesTab({ groupId }: { groupId: string }) { = 0 ? 'left-1/2 bg-saffron' : 'right-1/2 bg-tomato', + r.cents >= 0 ? 'left-1/2 bg-olive' : 'right-1/2 bg-tomato', )} style={{ width }} /> diff --git a/apps/web/src/features/dashboard/balance-hero.tsx b/apps/web/src/features/dashboard/balance-hero.tsx index b6a1454b..892b2659 100644 --- a/apps/web/src/features/dashboard/balance-hero.tsx +++ b/apps/web/src/features/dashboard/balance-hero.tsx @@ -2,6 +2,7 @@ import { intlLocale, formatMoney, t } from '@potluck/i18n' import { Amount } from '@potluck/ui' import { Link } from '@tanstack/react-router' import { ChevronRight } from 'lucide-react' +import { GoodToKnow } from '@/features/help/help' import type { BalanceSummary } from './summary' // Perforated bottom edge, like a bill torn off the pad. @@ -98,7 +99,10 @@ export function BalanceHero({ summary }: { summary: BalanceSummary }) { {t('home.balance.title')}, {acrossWhat(summary)} - {currency} + + {currency} + +

{headline}

{net === 0 ? ( diff --git a/apps/web/src/features/dashboard/home-dashboard.test.tsx b/apps/web/src/features/dashboard/home-dashboard.test.tsx index 8a4a51c8..3efcffc7 100644 --- a/apps/web/src/features/dashboard/home-dashboard.test.tsx +++ b/apps/web/src/features/dashboard/home-dashboard.test.tsx @@ -197,6 +197,47 @@ describe('HomeDashboard', () => { expect(screen.queryByRole('heading', { name: t('home.needsYou') })).not.toBeInTheDocument() }) + it('walks a newcomer through the first steps, one at a time', async () => { + const fake = resetDb({ + tables: { profiles: [viewerProfile], groups: [], group_balances: [], event_rsvps: [] }, + }) + fake.respond('rpc:my_timeline', { data: [] }) + const { unmount } = renderWithProviders(, { path: '/home' }) + const steps = await screen.findByRole('region', { name: t('home.firstSteps.title') }) + expect( + within(steps).getByRole('link', { name: t('home.firstSteps.groupAction') }), + ).toHaveAttribute('href', '/groups?new=true') + // Nothing can be planned without a group, so that prompt waits. + expect(screen.queryByText(t('timeline.empty.title'))).not.toBeInTheDocument() + unmount() + + // A group of one: the next step is people. + const solo = resetDb({ + tables: { + profiles: [viewerProfile], + groups: [{ ...groupRows[0]!, group_members: [{ count: 1 }] }], + group_balances: [], + event_rsvps: [], + }, + }) + solo.respond('rpc:my_timeline', { data: [] }) + renderWithProviders(, { path: '/home' }) + const next = await screen.findByRole('region', { name: t('home.firstSteps.title') }) + expect( + within(next).getByRole('link', { name: t('home.firstSteps.peopleAction') }), + ).toHaveAttribute('href', '/groups/g-hike/members') + fireEvent.click(within(next).getByRole('button', { name: t('home.firstSteps.hide') })) + expect( + screen.queryByRole('region', { name: t('home.firstSteps.title') }), + ).not.toBeInTheDocument() + }) + + it('shows no first steps once a group has company', async () => { + renderWithProviders(, { path: '/home' }) + await screen.findByText(t('home.groups')) + expect(screen.queryByText(t('home.firstSteps.title'))).not.toBeInTheDocument() + }) + it('never says nothing needs you while money is owed, in any currency', async () => { const fake = resetDb({ tables: { diff --git a/apps/web/src/features/dashboard/home-dashboard.tsx b/apps/web/src/features/dashboard/home-dashboard.tsx index 7e35a87f..4a163644 100644 --- a/apps/web/src/features/dashboard/home-dashboard.tsx +++ b/apps/web/src/features/dashboard/home-dashboard.tsx @@ -9,6 +9,7 @@ import { useEffect, useMemo, useState } from 'react' import { useSession } from '@/lib/auth' import { supabase } from '@/lib/supabase' import { RecentActivityRow } from '@/features/activity/activity-link' +import { FirstSteps } from '@/features/onboarding/first-steps' import { InboxBell } from '@/features/notifications/inbox-bell' import { NavRow } from '@/features/insights/nav-row' import { SearchIconLink } from '@/features/insights/search-link' @@ -33,6 +34,7 @@ export function HomeDashboard() { const timeline = useQuery(planQueries.timeline(supabase, range)) const groups = useQuery(planQueries.groups(supabase)) + const noGroups = groups.data?.length === 0 const items = useMemo(() => timeline.data ?? [], [timeline.data]) const needsTimes = items.filter((i) => i.status === 'polling' && !i.availability_submitted) // Asked explicitly first. @@ -145,64 +147,71 @@ export function HomeDashboard() {
- -
-

{t('timeline.title')}

- - {t('common.seeAll')} - - -
- {timeline.isPending ? ( -
- - - + {groups.data && } + {/* Nothing can be planned without a group: the first steps card leads there instead. */} + {!(noGroups && upcoming.length === 0) && ( + +
+

{t('timeline.title')}

+ + {t('common.seeAll')} + +
- ) : upcoming.length === 0 ? ( - - }> - {t('timeline.empty.action')} - - } - /> - - ) : ( - - {upcoming.map((item) => ( - dayKey(iso, viewer.timeZone)} + {timeline.isPending ? ( +
+ + + +
+ ) : upcoming.length === 0 ? ( + + }> + {t('timeline.empty.action')} + + } /> - ))} - - )} -
+ + ) : ( + + {upcoming.map((item) => ( + dayKey(iso, viewer.timeZone)} + /> + ))} + + )} + + )} - -

{t('home.groups')}

- {groups.isPending ? ( -
- - - -
- ) : ( - - )} -
+ {!noGroups && ( + +

{t('home.groups')}

+ {groups.isPending ? ( +
+ + + +
+ ) : ( + + )} +
+ )} 0 ? 'text-saffron-ink' : 'text-tomato-ink', + sign * (paid - share) > 0 ? 'text-olive-ink' : 'text-tomato-ink', )} > {owesOrGetsBack(isMe, sign * (paid - share) > 0, money(Math.abs(paid - share)))} diff --git a/apps/web/src/features/expenses/expense-row.tsx b/apps/web/src/features/expenses/expense-row.tsx index 490f4670..f5a4f224 100644 --- a/apps/web/src/features/expenses/expense-row.tsx +++ b/apps/web/src/features/expenses/expense-row.tsx @@ -131,7 +131,7 @@ export function ExpenseRow({ aria-hidden className={cn( 'text-xs font-medium', - line.kind === 'lent' ? 'text-saffron-ink' : 'text-tomato-ink', + line.kind === 'lent' ? 'text-olive-ink' : 'text-tomato-ink', )} > {line.kind === 'lent' diff --git a/apps/web/src/features/expenses/expenses-tab.tsx b/apps/web/src/features/expenses/expenses-tab.tsx index 404e0b7b..d53e9d61 100644 --- a/apps/web/src/features/expenses/expenses-tab.tsx +++ b/apps/web/src/features/expenses/expenses-tab.tsx @@ -11,10 +11,12 @@ import { Button, Card, Chip, + cn, EmptyState, IconButton, Input, Skeleton, + useMediaQuery, usePrefersReducedMotion, } from '@potluck/ui' import { Link } from '@tanstack/react-router' @@ -22,6 +24,8 @@ import { Download, Plus, Search, X } from 'lucide-react' import { motion } from 'motion/react' import { useDeferredValue, useMemo, useState } from 'react' import { useUserId } from '@/lib/auth' +import { FADE_RIGHT, useMoreToTheRight } from '@/lib/overflow' +import { GoodToKnow } from '@/features/help/help' import { ActivityIconLink } from '@/features/activity/activity-link' import { ActiveFilterChips, FilterButton, FilterSheet } from '@/features/insights/filter-sheet' import { activeFilters, withoutFilter, type MoneyFilters } from '@/features/insights/filter-state' @@ -61,6 +65,8 @@ export function ExpensesTab({ const timeZone = useTimeZone() const nameOf = useNameOf() const reduced = usePrefersReducedMotion() + const wide = useMediaQuery('(min-width: 40rem)') + const [chipsRef, moreChips] = useMoreToTheRight() const group = useMoneyGroup(groupId) const expenses = useGroupExpenses(groupId) const settlements = useGroupSettlements(groupId) @@ -224,7 +230,8 @@ export function ExpensesTab({ type="search" value={query} onChange={(e) => setQuery(e.target.value)} - placeholder={t('expenses.search')} + // The whole label does not fit beside three buttons on a phone: the short word does. + placeholder={wide ? t('expenses.search') : t('search.title')} aria-label={t('expenses.search')} leading={} className="h-11 rounded-pill" @@ -269,7 +276,11 @@ export function ExpensesTab({
toggleCategory(null)}> {t('expenses.allCategories')} @@ -340,12 +351,23 @@ export function ExpensesTab({
{sections.map((section) => (
-

- {dayLabel(section.day, timeZone)} -

+
+

+ {dayLabel(section.day, timeZone)} +

+ {section === sections[0] && ( + + )} +
    {section.items.map((item) => { diff --git a/apps/web/src/features/expenses/form/split-editor.tsx b/apps/web/src/features/expenses/form/split-editor.tsx index 941d8114..175dd3c8 100644 --- a/apps/web/src/features/expenses/form/split-editor.tsx +++ b/apps/web/src/features/expenses/form/split-editor.tsx @@ -1,3 +1,4 @@ +import { FADE_RIGHT, useMoreToTheRight } from '@/lib/overflow' import { avatarSrc } from '@/lib/queries' import type { MoneyMember, SplitTypeValue } from '@potluck/api' import { firstName, SPLIT_TYPES } from '@potluck/core' @@ -85,6 +86,7 @@ export function SplitEditor({ }: SplitEditorProps) { const order = members.map((m) => m.id) const modesRef = useRef(null) + const [modesFadeRef, moreModes] = useMoreToTheRight() useEffect(() => { // Sideways only: scrollIntoView could also move the page. const track = modesRef.current @@ -318,8 +320,14 @@ export function SplitEditor({ in view. Icons join in only where the split column is wide (one column layouts from md, before the two column lg). */}
    { + modesRef.current = node + modesFadeRef(node) + }} + className={cn( + '-mx-1 [scrollbar-width:none] overflow-x-auto px-1 pb-1 [&::-webkit-scrollbar]:hidden', + moreModes && FADE_RIGHT, + )} > import('@/test/supabase')) @@ -31,9 +32,11 @@ describe('GroupPicker', () => { expect(onPick).toHaveBeenLastCalledWith(direct) }) - it('explains when there are no groups yet', () => { + it('explains when there are no groups yet, and leads to making one', async () => { const client = seededClient((c) => c.setQueryData(moneyKeys.myGroups(), [])) - renderWithClient(, client) - expect(screen.getByText(t('expenses.pickGroup.none'))).toBeInTheDocument() + renderInRouter(, client) + expect(await screen.findByText(t('expenses.pickGroup.none'))).toBeInTheDocument() + const create = within(document.body).getByRole('link', { name: t('empty.groups.action') }) + expect(create.getAttribute('href')).toMatch(/^\/groups\?new=true$/) }) }) diff --git a/apps/web/src/features/expenses/group-picker.tsx b/apps/web/src/features/expenses/group-picker.tsx index 691b9040..9d4ed07b 100644 --- a/apps/web/src/features/expenses/group-picker.tsx +++ b/apps/web/src/features/expenses/group-picker.tsx @@ -3,9 +3,10 @@ import { firstName } from '@potluck/core' import { moneyQueries, type MoneyGroup } from '@potluck/api' import { groupTitle } from './format' import { t } from '@potluck/i18n' -import { AvatarStack, Card, EmptyState, Skeleton } from '@potluck/ui' +import { AvatarStack, Button, Card, EmptyState, Skeleton } from '@potluck/ui' import { useQuery } from '@tanstack/react-query' -import { ChevronRight } from 'lucide-react' +import { Link } from '@tanstack/react-router' +import { ChevronRight, Plus } from 'lucide-react' import { useUserId } from '@/lib/auth' import { supabase } from '@/lib/supabase' @@ -35,7 +36,19 @@ export function GroupPicker({ ))}
    ) : !data || data.length === 0 ? ( - + }> + + {t('empty.groups.action')} + + + } + /> ) : (
      {data.map((group) => ( diff --git a/apps/web/src/features/export-import/import-screen.tsx b/apps/web/src/features/export-import/import-screen.tsx index ba46a6a1..23ee2c7d 100644 --- a/apps/web/src/features/export-import/import-screen.tsx +++ b/apps/web/src/features/export-import/import-screen.tsx @@ -313,7 +313,7 @@ function BalancesAfter({ plan, group }: { plan: ImportPlan; group: MoneyGroup }) = 0 ? 'left-1/2 bg-saffron' : 'right-1/2 bg-tomato', + r.after >= 0 ? 'left-1/2 bg-olive' : 'right-1/2 bg-tomato', )} style={{ width: `${(Math.abs(r.after) / scale) * 50}%` }} /> diff --git a/apps/web/src/features/friends/friends-page.test.tsx b/apps/web/src/features/friends/friends-page.test.tsx index 910b0207..50d6ed3d 100644 --- a/apps/web/src/features/friends/friends-page.test.tsx +++ b/apps/web/src/features/friends/friends-page.test.tsx @@ -190,9 +190,10 @@ describe('FriendsPage', () => { seed({ friends: false, groups: [] }) renderPage() expect(await screen.findByText(t('friends.empty.title'))).toBeInTheDocument() - const [header, empty] = screen.getAllByRole('button', { name: t('friends.empty.action') }) - expect(header).toBeInTheDocument() - fireEvent.click(empty!) + // With nobody here the empty state carries the one button; the header's steps aside. + const buttons = screen.getAllByRole('button', { name: t('friends.empty.action') }) + expect(buttons).toHaveLength(1) + fireEvent.click(buttons[0]!) const sheet = await screen.findByRole('dialog', { name: t('friends.addTitle') }) expect(within(sheet).getByText(t('friends.noGroups'))).toBeInTheDocument() expect(within(sheet).getByRole('link', { name: t('groups.new') })).toHaveAttribute( diff --git a/apps/web/src/features/friends/friends-page.tsx b/apps/web/src/features/friends/friends-page.tsx index a8042dbb..275db317 100644 --- a/apps/web/src/features/friends/friends-page.tsx +++ b/apps/web/src/features/friends/friends-page.tsx @@ -32,6 +32,7 @@ import { GroupTile } from '@/features/groups/group-bits' import { useMyGroups, useMyGroupsRealtime } from '@/features/groups/use-groups' import { shareInvite } from '@/features/invites/share' import { useUserId } from '@/lib/auth' +import { Help } from '@/features/help/help' import { errorMessage } from '@/lib/errors' import { avatarSrc } from '@/lib/queries' import { supabase } from '@/lib/supabase' @@ -62,7 +63,7 @@ function FriendBalance({ friend, total }: { friend: Friend; total: FriendTotal | .reduce((a, b) => t('friends.and', { first: a, second: b })) const label = (owedToYou: boolean) => (owedToYou ? t('friends.owesYou', { amount: '' }) : t('friends.youOwe', { amount: '' })).trim() - const tone = (owedToYou: boolean) => (owedToYou ? 'text-saffron-ink' : 'text-tomato-ink') + const tone = (owedToYou: boolean) => (owedToYou ? 'text-olive-ink' : 'text-tomato-ink') if (directions.length === 1) { const [only] = directions @@ -288,14 +289,20 @@ export function FriendsPage() { title={t('friends.title')} subtitle={t('friends.subtitle')} actions={ - +
      + + {/* With nobody here yet the empty state carries the one button. */} + {(isPending || (friends && friends.length > 0)) && ( + + )} +
      } /> diff --git a/apps/web/src/features/friends/settle-friend-sheet.tsx b/apps/web/src/features/friends/settle-friend-sheet.tsx index be06b321..d7a5b02d 100644 --- a/apps/web/src/features/friends/settle-friend-sheet.tsx +++ b/apps/web/src/features/friends/settle-friend-sheet.tsx @@ -163,7 +163,7 @@ export function SettleFriendSheet({ 0 ? 'text-saffron-ink' : 'text-tomato-ink', + row.netCents > 0 ? 'text-olive-ink' : 'text-tomato-ink', )} > {row.netCents > 0 diff --git a/apps/web/src/features/groups/create-group-sheet.tsx b/apps/web/src/features/groups/create-group-sheet.tsx index 854c1ef1..96001d52 100644 --- a/apps/web/src/features/groups/create-group-sheet.tsx +++ b/apps/web/src/features/groups/create-group-sheet.tsx @@ -7,6 +7,7 @@ import { useQueryClient } from '@tanstack/react-query' import { useNavigate } from '@tanstack/react-router' import { useState, type FormEvent } from 'react' import { CurrencyField } from '@/features/me/profile-fields' +import { Help } from '@/features/help/help' import { errorMessage } from '@/lib/errors' import type { GroupColor } from '@/lib/group-colors' import { useMyProfile } from '@/lib/queries' @@ -207,6 +208,7 @@ export function CreateGroupSheet({ open, onOpenChange }: CreateGroupSheetProps)
    )}
+ diff --git a/apps/web/src/features/groups/group-layout.test.tsx b/apps/web/src/features/groups/group-layout.test.tsx index 5b87b1af..070d327b 100644 --- a/apps/web/src/features/groups/group-layout.test.tsx +++ b/apps/web/src/features/groups/group-layout.test.tsx @@ -90,6 +90,28 @@ describe('GroupLayout', () => { rememberGroupFilters('g-hike', {}) }) + it('leads with settling up while you owe, and not once you are square or the group is archived', async () => { + const { unmount } = renderLayout([group()]) + expect(await screen.findByRole('link', { name: t('balances.settleUp') })).toHaveAttribute( + 'href', + '/new/settle?groupId=g-hike', + ) + unmount() + // Balances has its own settle up buttons. + const balances = renderLayout([group()], '/groups/g-hike/balances') + await screen.findByRole('heading', { name: 'Hike crew' }) + expect(screen.queryByRole('link', { name: t('balances.settleUp') })).not.toBeInTheDocument() + balances.unmount() + renderLayout([ + group({ + members: [member(VIEWER, 'Ava Chen', 'owner', 0), member('u-ben', 'Ben Ortiz', 'admin', 0)], + }), + ]) + await screen.findByRole('heading', { name: 'Hike crew' }) + expect(screen.queryByRole('link', { name: t('balances.settleUp') })).not.toBeInTheDocument() + expect(screen.getByRole('button', { name: t('groups.header.invite') })).toBeInTheDocument() + }) + it('opens the invite sheet', async () => { renderLayout([group()]) fireEvent.click(await screen.findByRole('button', { name: t('groups.header.invite') })) diff --git a/apps/web/src/features/groups/group-layout.tsx b/apps/web/src/features/groups/group-layout.tsx index 558c550a..c5c193d1 100644 --- a/apps/web/src/features/groups/group-layout.tsx +++ b/apps/web/src/features/groups/group-layout.tsx @@ -3,7 +3,7 @@ import { can } from '@potluck/core' import { formatMoney, t } from '@potluck/i18n' import { Avatar, AvatarStack, Button, cn, Skeleton, usePrefersReducedMotion } from '@potluck/ui' import { Link, Outlet, useRouterState } from '@tanstack/react-router' -import { CalendarRange, ChevronLeft, History, UserPlus } from 'lucide-react' +import { ArrowRightLeft, CalendarRange, ChevronLeft, History, UserPlus } from 'lucide-react' import { motion } from 'motion/react' import { useEffect, useId, useRef, useState } from 'react' import { recallGroupFilters } from '@/features/insights/group-filters' @@ -63,8 +63,10 @@ function GroupTabs({ group }: { group: GroupDetail }) { const update = () => setMore(nav.scrollLeft + nav.clientWidth < nav.scrollWidth - 4) const current = nav.querySelector('[aria-current="page"]')?.parentElement if (current) { + // Centered, not just inside the edge: the right edge is the faded part. + const centered = current.offsetLeft - (nav.clientWidth - current.offsetWidth) / 2 const right = current.offsetLeft + current.offsetWidth - nav.clientWidth + 16 - if (right > nav.scrollLeft) nav.scrollLeft = right + if (right > nav.scrollLeft) nav.scrollLeft = Math.max(right, centered) } update() nav.addEventListener('scroll', update, { passive: true }) @@ -195,6 +197,11 @@ function SharedHeader({ group, onInvite }: { group: GroupDetail; onInvite: () => inviteRole: 'member', }) const dates = tripDatesLabel(group) + // Balances has its own settle up buttons, so there the header does not repeat them. + const onBalances = useRouterState({ + select: (s) => s.location.pathname.endsWith(`/groups/${group.id}/balances`), + }) + const owes = !group.archived_at && group.my_net_cents < 0 && !onBalances const cover = !!group.cover_path return (
@@ -248,11 +255,26 @@ function SharedHeader({ group, onInvite }: { group: GroupDetail; onInvite: () => currency={group.currency} className="text-[0.9375rem]" /> - {canInvite && ( - - )} +
+ {/* Owing is the thing to act on here, so paying it back leads and inviting steps back. */} + {owes && ( + + )} + {canInvite && ( + + )} +
{group.archived_at && (

@@ -290,7 +312,7 @@ function DirectHeader({ group }: { group: GroupDetail }) {

0 ? 'text-saffron-ink' : net < 0 ? 'text-tomato-ink' : 'text-mute', + net > 0 ? 'text-olive-ink' : net < 0 ? 'text-tomato-ink' : 'text-mute', )} > {line} diff --git a/apps/web/src/features/groups/groups-page.tsx b/apps/web/src/features/groups/groups-page.tsx index 61ed535c..014e092c 100644 --- a/apps/web/src/features/groups/groups-page.tsx +++ b/apps/web/src/features/groups/groups-page.tsx @@ -162,7 +162,6 @@ export function GroupsPage({ +

+

+ {t('home.firstSteps.progress', { done, total: 3 })} +

+
    + + + {t('home.firstSteps.groupAction')} + + + } + /> + + + {t('home.firstSteps.peopleAction')} + + + ) + } + /> + +
+
+ + + {t('help.section.gettingStarted')} + + ({t('help.newTab')}) + + + ) +} diff --git a/apps/web/src/features/plans/create-plan-page.tsx b/apps/web/src/features/plans/create-plan-page.tsx index 5ce052de..f17864e9 100644 --- a/apps/web/src/features/plans/create-plan-page.tsx +++ b/apps/web/src/features/plans/create-plan-page.tsx @@ -31,6 +31,7 @@ import { fromZonedTime } from 'date-fns-tz' import { Minus, Plus } from 'lucide-react' import { useMemo, useState, type FormEvent, type ReactNode } from 'react' import { supabase } from '@/lib/supabase' +import { Help } from '@/features/help/help' import { BackToPlans } from './back-link' import { formatDuration, formatMinuteOfDay, planErrorMessage } from './format' import { useViewer, useViewerProfile } from './viewer' @@ -107,8 +108,10 @@ export function CreatePlanPage({ groupId: initialGroup }: CreatePlanPageProps) { title={t('empty.groups.title')} description={t('events.create.noGroups')} action={ - } /> @@ -137,6 +140,7 @@ function Page({ children }: { children: ReactNode }) { leading={} title={{t('events.create.title')}} subtitle={t('events.create.subtitle')} + actions={} />
{children}
diff --git a/apps/web/src/features/plans/plans-page.test.tsx b/apps/web/src/features/plans/plans-page.test.tsx index 3a7963c6..0d1ea9a3 100644 --- a/apps/web/src/features/plans/plans-page.test.tsx +++ b/apps/web/src/features/plans/plans-page.test.tsx @@ -180,10 +180,10 @@ describe('PlansPage', () => { seed([], false) renderWithProviders(, { path: '/plans' }) expect(await screen.findByText(t('empty.plans.title'))).toBeInTheDocument() - expect(screen.getAllByRole('link', { name: t('events.new') })[0]).toHaveAttribute( - 'href', - '/new/plan', - ) + // One button, in the empty state: the header's steps aside. + const links = screen.getAllByRole('link', { name: t('events.new') }) + expect(links).toHaveLength(1) + expect(links[0]).toHaveAttribute('href', '/new/plan') }) it('says when nothing has happened yet', async () => { diff --git a/apps/web/src/features/plans/plans-page.tsx b/apps/web/src/features/plans/plans-page.tsx index 2033c90e..a228d38e 100644 --- a/apps/web/src/features/plans/plans-page.tsx +++ b/apps/web/src/features/plans/plans-page.tsx @@ -7,6 +7,7 @@ import { Link } from '@tanstack/react-router' import { Plus } from 'lucide-react' import { useMemo, useState } from 'react' import { supabase } from '@/lib/supabase' +import { Help } from '@/features/help/help' import { Appear } from '@/features/timeline/appear' import { DayTimeline } from '@/features/timeline/day-timeline' import { groupByDay } from '@/features/timeline/days' @@ -56,7 +57,17 @@ export function PlansPage() { return (
- + + + {/* With nothing planned the empty state carries the one button. */} + {!empty && planButton} +
+ } + /> {(groups.data?.length ?? 0) > 1 && (
{title} {count !== undefined && ( - + {count} )} diff --git a/apps/web/src/features/plans/rsvp-panel.tsx b/apps/web/src/features/plans/rsvp-panel.tsx index 9cf519fa..8433d23b 100644 --- a/apps/web/src/features/plans/rsvp-panel.tsx +++ b/apps/web/src/features/plans/rsvp-panel.tsx @@ -2,6 +2,7 @@ import type { PlanMember, PlanRsvp, RsvpStatus } from '@potluck/api' import { formatDate, t } from '@potluck/i18n' import { AvatarStack, Card, cn } from '@potluck/ui' import { Check, CircleHelp, X } from 'lucide-react' +import { Help } from '@/features/help/help' import { useNow } from './use-now' import { useRsvp } from './use-rsvp' @@ -60,7 +61,10 @@ export function RsvpPanel({ return (
-

{t('rsvp.title')}

+

+ {t('rsvp.title')} + +

{deadline && ( {t(deadlinePassed ? 'rsvp.deadlinePassed' : 'rsvp.deadline', { diff --git a/apps/web/src/features/settle/settle-flow.tsx b/apps/web/src/features/settle/settle-flow.tsx index c60e7412..82b8258b 100644 --- a/apps/web/src/features/settle/settle-flow.tsx +++ b/apps/web/src/features/settle/settle-flow.tsx @@ -185,9 +185,7 @@ function PersonPicker({ {m.display_name} {line && ( - + {line} )} diff --git a/apps/web/src/features/shell/app-layout.test.tsx b/apps/web/src/features/shell/app-layout.test.tsx index 7013aabb..73bc85b8 100644 --- a/apps/web/src/features/shell/app-layout.test.tsx +++ b/apps/web/src/features/shell/app-layout.test.tsx @@ -126,6 +126,21 @@ describe('AppLayout', () => { ).toHaveTextContent('9+') }) + it.each(['/payments/p-1', '/recurring/r-1', '/expenses/e-1'])( + 'keeps Groups lit on %s, which lives in a group', + async (path) => { + renderWithProviders(, { path }) + const [, tabs] = await navs() + expect(within(tabs!).getByRole('link', { name: t('nav.groups') })).toHaveAttribute( + 'aria-current', + 'page', + ) + expect(within(tabs!).getByRole('link', { name: t('nav.home') })).not.toHaveAttribute( + 'aria-current', + ) + }, + ) + it('marks plans and home as you move around', async () => { renderWithProviders(, { path: '/plans' }) const [, tabs] = await navs() diff --git a/apps/web/src/features/shell/app-layout.tsx b/apps/web/src/features/shell/app-layout.tsx index 7a8d9643..cd9286cf 100644 --- a/apps/web/src/features/shell/app-layout.tsx +++ b/apps/web/src/features/shell/app-layout.tsx @@ -36,8 +36,10 @@ type TabId = 'home' | 'search' | 'groups' | 'plans' | 'notifications' | 'me' function useActiveTab(): TabId { const path = useRouterState({ select: (s) => s.location.pathname }) - // An expense lives in a group, so its page keeps Groups lit. - if (path.startsWith('/groups') || path.startsWith('/friends') || path.startsWith('/expenses')) + // Expenses, payments and repeating expenses live in a group, so their pages keep Groups lit. + if ( + ['/groups', '/friends', '/expenses', '/payments', '/recurring'].some((p) => path.startsWith(p)) + ) return 'groups' if (path.startsWith('/plans') || path.startsWith('/new/plan')) return 'plans' if (path.startsWith('/notifications')) return 'notifications' diff --git a/apps/web/src/features/shell/landing-page.tsx b/apps/web/src/features/shell/landing-page.tsx index 9b9131b0..f3d55ebc 100644 --- a/apps/web/src/features/shell/landing-page.tsx +++ b/apps/web/src/features/shell/landing-page.tsx @@ -12,8 +12,7 @@ import { heroFrame } from './hero-frame' const HeroDemo = lazy(() => import('./hero-demo').then((m) => ({ default: m.HeroDemo }))) /** Tomato gingham: the tablecloth the demo cards sit on. */ -const gingham = - 'bg-paper [background-image:linear-gradient(90deg,color-mix(in_oklab,var(--pl-tomato)_42%,transparent)_50%,transparent_50%),linear-gradient(color-mix(in_oklab,var(--pl-tomato)_42%,transparent)_50%,transparent_50%)] [background-size:44px_44px]' +const gingham = 'gingham [--gingham-size:44px]' function Feature({ icon, diff --git a/apps/web/src/features/shell/route-error.test.tsx b/apps/web/src/features/shell/route-error.test.tsx index 73876d12..09142c94 100644 --- a/apps/web/src/features/shell/route-error.test.tsx +++ b/apps/web/src/features/shell/route-error.test.tsx @@ -9,7 +9,7 @@ import { } from '@tanstack/react-router' import { fireEvent, render, screen } from '@testing-library/react' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { RouteError } from './route-error' +import { RouteError, RouteNotFound } from './route-error' // The router restores scroll on navigation; jsdom has no layout to scroll. window.scrollTo = () => {} @@ -75,3 +75,29 @@ describe('RouteError', () => { expect(screen.queryByRole('heading', { name: t('errors.screen.title') })).toBeNull() }) }) + +describe('RouteNotFound', () => { + it('gives an unknown address a page with a way home', async () => { + const rootRoute = createRootRoute({ component: () => }) + const homeRoute = createRoute({ + getParentRoute: () => rootRoute, + path: '/home', + component: () =>

Home

, + }) + const router = createRouter({ + routeTree: rootRoute.addChildren([homeRoute]), + history: createMemoryHistory({ initialEntries: ['/nowhere'] }), + defaultNotFoundComponent: RouteNotFound, + }) + vi.spyOn(console, 'warn').mockImplementation(() => {}) + render() + expect( + await screen.findByRole('heading', { level: 1, name: t('errors.notFound') }), + ).toBeInTheDocument() + expect(screen.getByText(t('errors.notFoundBody'))).toBeInTheDocument() + expect(screen.queryByText('Not Found')).toBeNull() + fireEvent.click(screen.getByRole('link', { name: t('errors.screen.home') })) + expect(await screen.findByText('Home')).toBeInTheDocument() + vi.restoreAllMocks() + }) +}) diff --git a/apps/web/src/features/shell/route-error.tsx b/apps/web/src/features/shell/route-error.tsx index ce3f8712..b50a26fa 100644 --- a/apps/web/src/features/shell/route-error.tsx +++ b/apps/web/src/features/shell/route-error.tsx @@ -2,6 +2,7 @@ import { t } from '@potluck/i18n' import { Button, EmptyState } from '@potluck/ui' import { Link, useRouter, type ErrorComponentProps } from '@tanstack/react-router' import { House, RotateCcw } from 'lucide-react' +import { Wordmark } from './brand' /** * What a screen shows when it throws while rendering or loading, instead of the router's bare @@ -40,3 +41,31 @@ export function RouteError({ reset }: ErrorComponentProps) {
) } + +/** + * What an address that matches no screen shows, instead of the router's bare "Not Found". Set as + * the router's `defaultNotFoundComponent`. It has no app frame around it (the miss happens at the + * root), so it carries the wordmark and its own way home. + */ +export function RouteNotFound() { + return ( +
+ + + +
+ }> + {t('errors.screen.home')} + + } + /> +
+
+ ) +} diff --git a/apps/web/src/lib/overflow.ts b/apps/web/src/lib/overflow.ts new file mode 100644 index 00000000..fc8704fb --- /dev/null +++ b/apps/web/src/lib/overflow.ts @@ -0,0 +1,29 @@ +import { useEffect, useState } from 'react' + +/** + * Tells whether a sideways scroller has more to its right than it shows. Returns a ref callback + * for the scroller and the flag. Use it to fade the right edge, so a row that runs off the + * screen reads as "there is more" and not as cut off. + */ +export function useMoreToTheRight(): [(node: T | null) => void, boolean] { + const [node, setNode] = useState(null) + const [more, setMore] = useState(false) + useEffect(() => { + if (!node) return + const update = () => setMore(node.scrollLeft + node.clientWidth < node.scrollWidth - 4) + update() + node.addEventListener('scroll', update, { passive: true }) + window.addEventListener('resize', update) + const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(update) + observer?.observe(node) + return () => { + node.removeEventListener('scroll', update) + window.removeEventListener('resize', update) + observer?.disconnect() + } + }, [node]) + return [setNode, more] +} + +/** Fades the right edge of a scroller. Pair with `useMoreToTheRight`. */ +export const FADE_RIGHT = '[mask-image:linear-gradient(to_right,black_82%,transparent)]' diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx index b38e111e..4cf86914 100644 --- a/apps/web/src/main.tsx +++ b/apps/web/src/main.tsx @@ -2,7 +2,7 @@ import { QueryClientProvider } from '@tanstack/react-query' import { createRouter, RouterProvider } from '@tanstack/react-router' import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' -import { RouteError } from '@/features/shell/route-error' +import { RouteError, RouteNotFound } from '@/features/shell/route-error' import { startLanguage } from '@/lib/language' import { queryClient } from '@/lib/query-client' import { initTheme } from '@/styles/theme-preference' @@ -21,6 +21,8 @@ const router = createRouter({ // A screen that throws shows our own page, with a retry and a way home, in place of the // router's unstyled default. defaultErrorComponent: RouteError, + // An address no screen answers to gets a page with a way home, not the bare "Not Found". + defaultNotFoundComponent: RouteNotFound, }) declare module '@tanstack/react-router' { diff --git a/apps/web/src/routes/-dev-kit/tokens-panel.tsx b/apps/web/src/routes/-dev-kit/tokens-panel.tsx index ecce1b64..6ad483c3 100644 --- a/apps/web/src/routes/-dev-kit/tokens-panel.tsx +++ b/apps/web/src/routes/-dev-kit/tokens-panel.tsx @@ -7,8 +7,8 @@ const swatches: Array<{ key: keyof ThemeColors; label: string; note: string }> = { key: 'mute', label: 'Mute', note: 'Secondary text' }, { key: 'line', label: 'Line', note: 'Borders' }, { key: 'tomato', label: 'Tomato', note: 'Action, you owe' }, - { key: 'saffron', label: 'Saffron', note: 'Owed to you' }, - { key: 'olive', label: 'Olive', note: 'Settled' }, + { key: 'olive', label: 'Olive', note: 'Owed to you, done' }, + { key: 'saffron', label: 'Saffron', note: 'Plans, notices' }, { key: 'plum', label: 'Plum', note: 'Accents' }, ] diff --git a/apps/web/src/styles/base.css b/apps/web/src/styles/base.css index fd9192bd..be3bfe97 100644 --- a/apps/web/src/styles/base.css +++ b/apps/web/src/styles/base.css @@ -112,6 +112,19 @@ color: var(--pl-on-hero); } +/* Tomato gingham, the tablecloth: the landing page's table edge and the first steps card. */ +@utility gingham { + background-color: var(--pl-paper); + background-image: + linear-gradient( + 90deg, + color-mix(in oklab, var(--pl-tomato) 42%, transparent) 50%, + transparent 50% + ), + linear-gradient(color-mix(in oklab, var(--pl-tomato) 42%, transparent) 50%, transparent 50%); + background-size: var(--gingham-size, 12px) var(--gingham-size, 12px); +} + @utility pb-safe { padding-bottom: env(safe-area-inset-bottom); } diff --git a/docs/design.md b/docs/design.md index d333764f..c4f18dfa 100644 --- a/docs/design.md +++ b/docs/design.md @@ -4,17 +4,35 @@ Potluck should feel like a well-run dinner party: warm, confident, a little play ## Palette (light) -| Token | Value | Use | -| --------- | --------- | ------------------------------------------ | -| `paper` | `#fbf5ea` | app background | -| `card` | `#ffffff` | surfaces | -| `ink` | `#1d1a16` | text, primary dark surfaces (balance hero) | -| `mute` | `#7a7166` | secondary text | -| `line` | `#ebe2d3` | borders, dividers | -| `tomato` | `#e8492f` | primary action, "you owe", heat max | -| `saffron` | `#f5b53d` | highlights, "you are owed", date chips | -| `olive` | `#5f7a3a` | success, settled, group headers | -| `plum` | `#6b3d6e` | accents, avatars | +Paper and ink, a splash of tomato, and three supporting colors with one job each: green is money +coming back, yellow is a plan or a date, plum is history. + +| Token | Value | Use | +| --------- | --------- | ----------------------------------------------------------------------------- | +| `paper` | `#fbf5ea` | app background | +| `card` | `#ffffff` | surfaces | +| `ink` | `#1d1a16` | text, primary dark surfaces (balance hero), quieter strong buttons | +| `mute` | `#7a7166` | secondary text, settled and zero amounts | +| `line` | `#ebe2d3` | borders, dividers | +| `tomato` | `#e8492f` | the action color and the brand mark; also "you owe", count badges, heat max | +| `olive` | `#4a8431` | "you are owed", done and success, a switch that is on | +| `saffron` | `#f5b53d` | plans, date chips, highlights and gentle notices, the lit pill in the tab bar | +| `plum` | `#6b3d6e` | quiet accent: history, charts, avatars | + +Tomato does three jobs, told apart by weight and shape, never by a second hue: + +- **The next step** is a solid tomato pill with white text (`Button` primary, the add button, the + poll card button). One per screen where you can. +- **Money you owe** is tomato text only (`tomato-ink`, no fill, no border), always with words or a + sign beside it ("you owe", a minus), so it never reads as something to press. +- **Destructive actions** (delete, remove, leave) are the `danger` button: a soft tomato tint with a + thin border and tomato text, never the solid fill, so they cannot pass for the primary button + beside them. They always open a confirm dialog that names what will happen; only there, alone + beside Cancel, is the confirming button solid. + +A settled or zero amount is `mute`, not green. Links are ink with a tomato underline. Tomato gingham +(the `gingham` utility) is the tablecloth: the landing page's table edge and the first steps card on +Home. Do not spread it further. Dark mode is designed, not inverted: background `#14110e`, surface `#1f1b17`, ink becomes `#f6efe3`, tomato `#ff6a4d`, saffron `#ffc65c`. Check AA contrast for every text pairing. @@ -56,6 +74,9 @@ Heat scale for availability (0 to max): `#f1e9db`, `#f9dccf`, `#f4ab95`, `#ee7a5 ## Layout - Mobile first. Bottom tab bar: Home, Groups, (+ big add button), Plans, Me. +- One clear next step per screen. An empty state always carries the action that fills it, and a + header button that would repeat it steps aside. A "?" (`features/help`) sits beside anything that + needs explaining, and opens a short note or the guide heading. - At `lg` the tab bar becomes a left rail and detail views open as a second pane. - The add button opens a quick sheet: Add expense, Plan something, Settle up. - Lists people scan (the Groups page) are one compact row per item on phones (tile, name, balance, 12px padding) so five or more fit; from `sm` up they become cards. diff --git a/packages/i18n/src/de/help.ts b/packages/i18n/src/de/help.ts index 31f1239b..d622f893 100644 --- a/packages/i18n/src/de/help.ts +++ b/packages/i18n/src/de/help.ts @@ -7,6 +7,14 @@ export const help = { readMore: 'Mehr lesen', guide: 'Anleitung', topics: { + plansPage: 'So ist die Seite Pläne sortiert', + startPoll: 'So läuft eine Umfrage', + rsvp: 'So funktionieren Zusagen', + inbox: 'Über den Posteingang', + expenseList: 'Die Ausgabenliste lesen', + balancesAcross: 'So setzt sich dein Gesamtsaldo zusammen', + createGroup: 'Über das Starten einer Gruppe', + friendTotals: 'Was die Summen bedeuten', splitEqual: 'So funktioniert gleichmäßiges Teilen', splitExact: 'So funktionieren genaue Beträge', splitPercent: 'So funktioniert Teilen nach Prozent', @@ -55,6 +63,10 @@ export const help = { importExpenses: 'So funktioniert der Import', }, tips: { + balancesAcross: + 'Jede Gruppe und jeder Zweier-Tab hat einen eigenen Saldo. Diese Karte zählt sie in einer Währung zusammen. Andere Währungen stehen getrennt daneben und werden nie umgerechnet.', + expenseList: + '"{lent}": Du hast bezahlt und die anderen schulden dir ihren Anteil. "{borrowed}": Jemand anderes hat bezahlt und das ist dein Anteil.', simplifiedDebts: 'Potluck verrechnet, wer wem etwas schuldet, damit die Gruppe weniger Zahlungen braucht. Vielleicht zahlst du jemandem, mit dem du nie direkt geteilt hast, aber deine Summe bleibt gleich.', everyDebt: diff --git a/packages/i18n/src/de/plans.ts b/packages/i18n/src/de/plans.ts index 2d4361b8..28cd0afd 100644 --- a/packages/i18n/src/de/plans.ts +++ b/packages/i18n/src/de/plans.ts @@ -285,6 +285,21 @@ export const timeline = { } satisfies Translation export const home = { + firstSteps: { + title: 'Deck den Tisch', + body: 'Drei kleine Schritte, dann führt Potluck die Rechnung.', + group: 'Gruppe starten', + groupHint: 'Die WG, eine Reise, die Kochrunde.', + people: 'Hol deine Leute dazu', + peopleHint: 'Schick einen Einladungslink oder trag jemanden mit Namen ein.', + expense: 'Erste Ausgabe eintragen', + expenseHint: 'Potluck rechnet aus, wer wem was schuldet.', + groupAction: 'Gruppe erstellen', + peopleAction: 'Leute hinzufügen', + expenseAction: 'Ausgabe hinzufügen', + progress: '{done} von {total} erledigt', + hide: 'Diese Schritte ausblenden', + }, greeting: { morning: 'Morgen, {name}.', afternoon: 'Hallo, {name}.', diff --git a/packages/i18n/src/de/shell.ts b/packages/i18n/src/de/shell.ts index 3be7c290..225ef450 100644 --- a/packages/i18n/src/de/shell.ts +++ b/packages/i18n/src/de/shell.ts @@ -173,6 +173,7 @@ export const errors = { generic: 'In der Küche ist was angebrannt. Nochmal versuchen?', network: 'Du scheinst offline zu sein. Wir versuchen es erneut, sobald du zurück bist.', notFound: 'Diese Seite hat sich verlaufen.', + notFoundBody: 'Prüf den Link oder geh zur Startseite und such von dort.', forbidden: 'An diesem Tisch hast du keinen Platz.', sessionExpired: 'Deine Sitzung ist abgelaufen. Melde dich erneut an.', rateLimited: 'Immer mit der Ruhe. Versuch es gleich nochmal.', diff --git a/packages/i18n/src/en/help.ts b/packages/i18n/src/en/help.ts index 11e9f14b..5ec6c4ea 100644 --- a/packages/i18n/src/en/help.ts +++ b/packages/i18n/src/en/help.ts @@ -5,6 +5,14 @@ export const help = { readMore: 'Read more', guide: 'Guide', topics: { + plansPage: 'How the Plans page is sorted', + startPoll: 'How a poll works', + rsvp: 'How RSVPs work', + inbox: 'About the inbox', + expenseList: 'Reading the expense list', + balancesAcross: 'How your total is counted', + createGroup: 'About starting a group', + friendTotals: 'What the totals mean', splitEqual: 'How equal splits work', splitExact: 'How exact amounts work', splitPercent: 'How percent splits work', @@ -53,6 +61,10 @@ export const help = { importExpenses: 'How importing works', }, tips: { + balancesAcross: + 'Every group and friend tab keeps its own balance. This card adds them up in one currency. Other currencies are listed apart and never converted.', + expenseList: + '"{lent}": you paid, and others owe you their share. "{borrowed}": someone else paid, and this is your share.', simplifiedDebts: 'Potluck nets out who owes whom so the group needs fewer payments. You might pay someone you never split with directly, but your total stays the same.', everyDebt: diff --git a/packages/i18n/src/en/plans.ts b/packages/i18n/src/en/plans.ts index 39e7e79f..b5e544fa 100644 --- a/packages/i18n/src/en/plans.ts +++ b/packages/i18n/src/en/plans.ts @@ -392,6 +392,22 @@ export const timeline = { /** Keyed by `activity.verb`. Params: actor, plus whatever the row's `data` carries. */ export const home = { + /** The first run checklist on Home, shown until there is a group with someone else in it. */ + firstSteps: { + title: 'Set the table', + body: 'Three small steps and Potluck starts keeping the tab.', + group: 'Start a group', + groupHint: 'Roommates, a trip, the dinner crew.', + people: 'Add your people', + peopleHint: 'Send an invite link, or add someone by name.', + expense: 'Add the first expense', + expenseHint: 'Potluck works out who owes what.', + groupAction: 'Create a group', + peopleAction: 'Add people', + expenseAction: 'Add expense', + progress: '{done} of {total} done', + hide: 'Hide these steps', + }, greeting: { morning: 'Morning, {name}.', afternoon: 'Afternoon, {name}.', diff --git a/packages/i18n/src/en/shell.ts b/packages/i18n/src/en/shell.ts index 4ec1ecfa..fa3eaa7d 100644 --- a/packages/i18n/src/en/shell.ts +++ b/packages/i18n/src/en/shell.ts @@ -171,6 +171,7 @@ export const errors = { generic: 'Something burned in the kitchen. Try again?', network: 'You seem to be offline. We will retry when you are back.', notFound: 'That page wandered off.', + notFoundBody: 'Check the link, or head home and find it from there.', forbidden: 'You do not have a seat at this table.', sessionExpired: 'Your session timed out. Sign in again.', rateLimited: 'Easy there. Try again in a moment.', diff --git a/packages/i18n/src/es/help.ts b/packages/i18n/src/es/help.ts index d95b5f35..921ba8f4 100644 --- a/packages/i18n/src/es/help.ts +++ b/packages/i18n/src/es/help.ts @@ -7,6 +7,14 @@ export const help = { readMore: 'Leer más', guide: 'Guía', topics: { + plansPage: 'Cómo se ordena la página Planes', + startPoll: 'Cómo funciona una encuesta', + rsvp: 'Cómo funcionan las confirmaciones', + inbox: 'Sobre la bandeja de entrada', + expenseList: 'Cómo leer la lista de gastos', + balancesAcross: 'Cómo se suma tu total', + createGroup: 'Sobre crear un grupo', + friendTotals: 'Qué significan los totales', splitEqual: 'Cómo funciona dividir a partes iguales', splitExact: 'Cómo funcionan los importes exactos', splitPercent: 'Cómo funciona dividir por porcentaje', @@ -55,6 +63,10 @@ export const help = { importExpenses: 'Cómo funciona importar', }, tips: { + balancesAcross: + 'Cada grupo y cada cuenta con un amigo lleva su propio saldo. Esta tarjeta los suma en una moneda. Las demás monedas aparecen aparte y nunca se convierten.', + expenseList: + '"{lent}": pagaste tú y los demás te deben su parte. "{borrowed}": pagó otra persona y esta es tu parte.', simplifiedDebts: 'Potluck compensa quién debe a quién para que el grupo necesite menos pagos. Quizá le pagues a alguien con quien nunca dividiste nada directamente, pero tu total sigue igual.', everyDebt: diff --git a/packages/i18n/src/es/plans.ts b/packages/i18n/src/es/plans.ts index fd734ffa..90886a4b 100644 --- a/packages/i18n/src/es/plans.ts +++ b/packages/i18n/src/es/plans.ts @@ -283,6 +283,21 @@ export const timeline = { } satisfies Translation export const home = { + firstSteps: { + title: 'Pon la mesa', + body: 'Tres pasos cortos y Potluck empieza a llevar la cuenta.', + group: 'Crea un grupo', + groupHint: 'El piso compartido, un viaje, las cenas de los jueves.', + people: 'Suma a tu gente', + peopleHint: 'Envía un enlace de invitación o añade a alguien por su nombre.', + expense: 'Añade el primer gasto', + expenseHint: 'Potluck calcula quién debe qué.', + groupAction: 'Crear un grupo', + peopleAction: 'Añadir personas', + expenseAction: 'Añadir gasto', + progress: '{done} de {total} hechos', + hide: 'Ocultar estos pasos', + }, greeting: { morning: 'Buenos días, {name}.', afternoon: 'Buenas tardes, {name}.', diff --git a/packages/i18n/src/es/shell.ts b/packages/i18n/src/es/shell.ts index 6f6b8bf7..df70b34a 100644 --- a/packages/i18n/src/es/shell.ts +++ b/packages/i18n/src/es/shell.ts @@ -173,6 +173,7 @@ export const errors = { generic: 'Algo se quemó en la cocina. ¿Lo intentas de nuevo?', network: 'Parece que no tienes conexión. Lo reintentaremos cuando vuelvas.', notFound: 'Esa página se fue de paseo.', + notFoundBody: 'Revisa el enlace o vuelve al inicio y búscala desde allí.', forbidden: 'No tienes sitio en esta mesa.', sessionExpired: 'Tu sesión caducó. Vuelve a iniciar sesión.', rateLimited: 'Con calma. Inténtalo de nuevo en un momento.', diff --git a/packages/i18n/src/fr/help.ts b/packages/i18n/src/fr/help.ts index e21236a7..b8b7626d 100644 --- a/packages/i18n/src/fr/help.ts +++ b/packages/i18n/src/fr/help.ts @@ -7,6 +7,14 @@ export const help = { readMore: 'En savoir plus', guide: 'Guide', topics: { + plansPage: 'Comment la page Sorties est organisée', + startPoll: 'Comment marche un sondage', + rsvp: 'Comment marchent les réponses', + inbox: 'À propos de la boîte de réception', + expenseList: 'Lire la liste des dépenses', + balancesAcross: 'Comment ton total est calculé', + createGroup: 'À propos de la création de groupe', + friendTotals: 'Ce que veulent dire les totaux', splitEqual: 'Comment marche le partage à parts égales', splitExact: 'Comment marchent les montants exacts', splitPercent: 'Comment marche le partage en pourcentage', @@ -55,6 +63,10 @@ export const help = { importExpenses: 'Comment marche l’import', }, tips: { + balancesAcross: + 'Chaque groupe et chaque compte entre amis garde son propre solde. Cette carte les additionne dans une seule devise. Les autres devises sont listées à part et jamais converties.', + expenseList: + '"{lent}" : tu as payé et les autres te doivent leur part. "{borrowed}" : quelqu\'un d\'autre a payé et voici ta part.', simplifiedDebts: "Potluck compense qui doit quoi à qui pour que le groupe ait besoin de moins de paiements. Tu paieras peut-être quelqu'un avec qui tu n'as jamais partagé directement, mais ton total reste le même.", everyDebt: diff --git a/packages/i18n/src/fr/plans.ts b/packages/i18n/src/fr/plans.ts index 4486729b..1517ca6a 100644 --- a/packages/i18n/src/fr/plans.ts +++ b/packages/i18n/src/fr/plans.ts @@ -284,6 +284,21 @@ export const timeline = { } satisfies Translation export const home = { + firstSteps: { + title: 'Mets la table', + body: 'Trois petites étapes et Potluck commence à tenir les comptes.', + group: 'Crée un groupe', + groupHint: 'La coloc, un voyage, les dîners du jeudi.', + people: 'Ajoute tes proches', + peopleHint: "Envoie un lien d'invitation ou ajoute quelqu'un par son nom.", + expense: 'Ajoute la première dépense', + expenseHint: 'Potluck calcule qui doit quoi.', + groupAction: 'Créer un groupe', + peopleAction: 'Ajouter des personnes', + expenseAction: 'Ajouter une dépense', + progress: '{done} sur {total} terminées', + hide: 'Masquer ces étapes', + }, greeting: { morning: 'Bonjour, {name}.', afternoon: 'Bon après-midi, {name}.', diff --git a/packages/i18n/src/fr/shell.ts b/packages/i18n/src/fr/shell.ts index 1b95547e..0a6ee691 100644 --- a/packages/i18n/src/fr/shell.ts +++ b/packages/i18n/src/fr/shell.ts @@ -173,6 +173,7 @@ export const errors = { generic: 'Ça a brûlé en cuisine. On réessaie ?', network: 'Tu sembles hors ligne. On réessaiera dès ton retour.', notFound: "Cette page s'est fait la malle.", + notFoundBody: "Vérifie le lien, ou reviens à l'accueil et cherche à partir de là.", forbidden: "Tu n'as pas de place à cette table.", sessionExpired: 'Ta session a expiré. Reconnecte-toi.', rateLimited: 'Doucement. Réessaie dans un instant.', diff --git a/packages/i18n/src/pt/help.ts b/packages/i18n/src/pt/help.ts index 9773f59d..1163887d 100644 --- a/packages/i18n/src/pt/help.ts +++ b/packages/i18n/src/pt/help.ts @@ -7,6 +7,14 @@ export const help = { readMore: 'Saiba mais', guide: 'Guia', topics: { + plansPage: 'Como a página Planos é organizada', + startPoll: 'Como funciona uma enquete', + rsvp: 'Como funcionam as confirmações', + inbox: 'Sobre a caixa de entrada', + expenseList: 'Como ler a lista de despesas', + balancesAcross: 'Como seu total é somado', + createGroup: 'Sobre criar um grupo', + friendTotals: 'O que os totais significam', splitEqual: 'Como funciona a divisão em partes iguais', splitExact: 'Como funcionam os valores exatos', splitPercent: 'Como funciona a divisão por porcentagem', @@ -55,6 +63,10 @@ export const help = { importExpenses: 'Como funciona a importação', }, tips: { + balancesAcross: + 'Cada grupo e cada conta com um amigo tem seu próprio saldo. Este cartão soma tudo em uma moeda. As outras moedas aparecem à parte e nunca são convertidas.', + expenseList: + '"{lent}": você pagou e os outros devem a parte deles. "{borrowed}": outra pessoa pagou e esta é a sua parte.', simplifiedDebts: 'O Potluck compensa quem deve a quem para o grupo precisar de menos pagamentos. Talvez você pague alguém com quem nunca dividiu nada diretamente, mas o seu total continua o mesmo.', everyDebt: diff --git a/packages/i18n/src/pt/plans.ts b/packages/i18n/src/pt/plans.ts index 0b7c2b82..b26a18ee 100644 --- a/packages/i18n/src/pt/plans.ts +++ b/packages/i18n/src/pt/plans.ts @@ -284,6 +284,21 @@ export const timeline = { } satisfies Translation export const home = { + firstSteps: { + title: 'Ponha a mesa', + body: 'Três passos curtos e o Potluck começa a cuidar da conta.', + group: 'Crie um grupo', + groupHint: 'A república, uma viagem, os jantares de quinta.', + people: 'Chame sua turma', + peopleHint: 'Envie um link de convite ou adicione alguém pelo nome.', + expense: 'Adicione a primeira despesa', + expenseHint: 'O Potluck calcula quem deve o quê.', + groupAction: 'Criar um grupo', + peopleAction: 'Adicionar pessoas', + expenseAction: 'Adicionar despesa', + progress: '{done} de {total} concluídos', + hide: 'Ocultar estes passos', + }, greeting: { morning: 'Bom dia, {name}.', afternoon: 'Boa tarde, {name}.', diff --git a/packages/i18n/src/pt/shell.ts b/packages/i18n/src/pt/shell.ts index 67296828..6c57e958 100644 --- a/packages/i18n/src/pt/shell.ts +++ b/packages/i18n/src/pt/shell.ts @@ -173,6 +173,7 @@ export const errors = { generic: 'Algo queimou na cozinha. Tentar de novo?', network: 'Parece que você está sem conexão. Tentaremos de novo quando você voltar.', notFound: 'Essa página saiu para passear.', + notFoundBody: 'Confira o link ou volte ao início e procure a partir de lá.', forbidden: 'Você não tem lugar nesta mesa.', sessionExpired: 'Sua sessão expirou. Entre de novo.', rateLimited: 'Calma aí. Tente de novo daqui a pouco.', diff --git a/packages/tokens/src/color.ts b/packages/tokens/src/color.ts index de5aa134..2fce465e 100644 --- a/packages/tokens/src/color.ts +++ b/packages/tokens/src/color.ts @@ -1,6 +1,10 @@ /** * Color tokens. "Paper and ink, a splash of tomato and saffron." * + * Tomato is the brand and the thing to press next: a solid fill is an action, tomato + * text is money you owe. Olive is money coming back to you and anything done, saffron + * is plans and dates, plum stays a quiet accent for history and charts. + * * Each theme exposes the same semantic keys so components never branch on * the theme. `*Ink` variants are the text-safe versions of a hue (AA on * paper and card), `*Soft` variants are tinted backgrounds, `on*` is the @@ -16,7 +20,7 @@ export const palette = { line: '#ebe2d3', tomato: '#e8492f', saffron: '#f5b53d', - olive: '#5f7a3a', + olive: '#4a8431', plum: '#6b3d6e', } as const @@ -37,7 +41,7 @@ export interface ThemeColors { lineStrong: string tomato: string - /** Solid fill for primary buttons, AA with `onTomato`. */ + /** Solid fill for primary buttons and count badges, AA with `onTomato`. */ tomatoStrong: string tomatoInk: string tomatoSoft: string @@ -97,9 +101,9 @@ export const lightColors: ThemeColors = { saffronSoft: '#fdf0d4', onSaffron: '#1d1a16', - olive: '#5f7a3a', - oliveInk: '#4f6a2c', - oliveSoft: '#e9eedd', + olive: '#4a8431', + oliveInk: '#3a6f24', + oliveSoft: '#e4f0d9', onOlive: '#ffffff', plum: '#6b3d6e', @@ -112,7 +116,7 @@ export const lightColors: ThemeColors = { heroMute: '#b9ad9c', heroTomato: '#ff7a5c', heroSaffron: '#f5b53d', - heroOlive: '#a6c47c', + heroOlive: '#a8d587', avatarInk: '#1d1a16', @@ -140,9 +144,9 @@ export const darkColors: ThemeColors = { saffronSoft: '#382c15', onSaffron: '#14110e', - olive: '#8fb062', - oliveInk: '#a6c47c', - oliveSoft: '#222a18', + olive: '#8fc46a', + oliveInk: '#a8d587', + oliveSoft: '#1f2b17', onOlive: '#14110e', plum: '#c79bd0', @@ -156,7 +160,7 @@ export const darkColors: ThemeColors = { heroMute: '#6c6152', heroTomato: '#b23a22', heroSaffron: '#8a5800', - heroOlive: '#4f6a2c', + heroOlive: '#3a6f24', avatarInk: '#4a4038', @@ -221,7 +225,7 @@ export function avatarColor(seed: string): (typeof avatarPalette)[number] { export const celebration = [ '#e8492f', '#f5b53d', - '#5f7a3a', + '#4a8431', '#6b3d6e', '#fbf5ea', '#ff8a70', diff --git a/packages/tokens/src/index.test.ts b/packages/tokens/src/index.test.ts index e2d1c800..9babbc19 100644 --- a/packages/tokens/src/index.test.ts +++ b/packages/tokens/src/index.test.ts @@ -56,6 +56,7 @@ describe.each(Object.values(themes))('$name theme contrast', (theme) => { ['oliveInk on paper', c.oliveInk, c.paper], ['oliveInk on card', c.oliveInk, c.card], ['plumInk on card', c.plumInk, c.card], + ['oliveInk on sunken', c.oliveInk, c.sunken], ['onTomato on tomatoStrong', c.onTomato, c.tomatoStrong], ['onSaffron on saffron', c.onSaffron, c.saffron], ['onOlive on olive', c.onOlive, c.olive], diff --git a/packages/ui/src/amount.tsx b/packages/ui/src/amount.tsx index cf98a967..49754fcb 100644 --- a/packages/ui/src/amount.tsx +++ b/packages/ui/src/amount.tsx @@ -44,14 +44,14 @@ export function formatMoney( const toneClass: Record> = { default: { owe: 'text-tomato-ink', - owed: 'text-saffron-ink', - settled: 'text-olive-ink', + owed: 'text-olive-ink', + settled: 'text-mute', neutral: 'text-ink', }, hero: { owe: 'text-hero-tomato', - owed: 'text-hero-saffron', - settled: 'text-hero-olive', + owed: 'text-hero-olive', + settled: 'text-hero-mute', neutral: 'text-on-hero', }, } @@ -63,7 +63,7 @@ export interface AmountProps { locale?: string /** How to show the sign. `auto` shows minus only. */ sign?: AmountSign - /** `auto` colors by sign: negative = owe (tomato), positive = owed (saffron). */ + /** `auto` colors by sign: negative = owe (tomato), positive = owed (olive). */ tone?: AmountTone /** Use on the balance hero so colors stay legible on its surface. */ surface?: AmountSurface diff --git a/packages/ui/src/help.tsx b/packages/ui/src/help.tsx index 58cd3bf2..fccd03c2 100644 --- a/packages/ui/src/help.tsx +++ b/packages/ui/src/help.tsx @@ -97,6 +97,8 @@ export interface HelpTipProps { newTabHint?: string /** Which edge of the button the popover lines up with. */ align?: 'start' | 'end' + /** Set on the balance hero, where the "?" takes the hero's own foreground colors. */ + onHero?: boolean className?: string } @@ -113,6 +115,7 @@ export function HelpTip({ readMoreLabel, newTabHint, align = 'end', + onHero = false, className, }: HelpTipProps) { const id = useId() @@ -177,7 +180,10 @@ export function HelpTip({ aria-expanded={open} aria-controls={panelId} popoverTarget={panelId} - className={triggerClass} + className={cn( + triggerClass, + onHero && 'text-hero-mute hover:text-on-hero aria-expanded:text-on-hero', + )} > From 66f393b4d8dcf1950e1074b623228c6a2642922f Mon Sep 17 00:00:00 2001 From: Musa Kaleem <131704022+Musa-Kal@users.noreply.github.com> Date: Sat, 21 Nov 2026 02:42:45 -0500 Subject: [PATCH 2/6] review: Fix not-found nesting, newcomer check, review nits --- .../dashboard/home-dashboard.test.tsx | 67 +++++++++++++++++-- .../src/features/dashboard/home-dashboard.tsx | 18 +++-- .../features/expenses/form/split-editor.tsx | 14 ++-- .../src/features/groups/group-layout.test.tsx | 5 ++ .../src/features/onboarding/first-steps.tsx | 45 +++---------- .../onboarding/use-first-steps-hidden.ts | 25 +++++++ .../src/features/shell/route-error.test.tsx | 34 ++++++++++ apps/web/src/main.tsx | 4 +- packages/i18n/src/de/plans.ts | 1 - packages/i18n/src/en/plans.ts | 1 - packages/i18n/src/es/plans.ts | 1 - packages/i18n/src/fr/plans.ts | 1 - packages/i18n/src/pt/plans.ts | 1 - 13 files changed, 164 insertions(+), 53 deletions(-) create mode 100644 apps/web/src/features/onboarding/use-first-steps-hidden.ts diff --git a/apps/web/src/features/dashboard/home-dashboard.test.tsx b/apps/web/src/features/dashboard/home-dashboard.test.tsx index 3efcffc7..102f0c50 100644 --- a/apps/web/src/features/dashboard/home-dashboard.test.tsx +++ b/apps/web/src/features/dashboard/home-dashboard.test.tsx @@ -1,4 +1,5 @@ import type * as AuthModule from '@/lib/auth' +import { groupKeys } from '@potluck/api' import { t } from '@potluck/i18n' import { fireEvent, screen, waitFor, within } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' @@ -99,6 +100,29 @@ const groupRows = [ }, ] +// The fake returns rows whole, so one row answers both the member count and the member list. +const membersOf = (...ids: string[]) => + ids.map((id) => ({ + count: ids.length, + role: 'member', + joined_at: '2026-08-17T12:00:00Z', + profiles: { id, display_name: id }, + })) + +/** Home for someone whose only groups are `groups`, once every group list has answered. */ +async function renderHomeWith(groups: Record[]) { + const fake = resetDb({ + tables: { profiles: [viewerProfile], groups, group_balances: [], event_rsvps: [] }, + }) + fake.respond('rpc:my_timeline', { data: [] }) + const view = renderWithProviders(, { path: '/home' }) + await screen.findByText(t('home.balance.settledHint')) + await waitFor(() => + expect(view.queryClient.getQueryState(groupKeys.list(VIEWER))?.status).toBe('success'), + ) + return view +} + function seed({ items = timeline as object[], balances = true } = {}) { const fake = resetDb({ tables: { @@ -120,7 +144,10 @@ function seed({ items = timeline as object[], balances = true } = {}) { } describe('HomeDashboard', () => { - beforeEach(() => seed()) + beforeEach(() => { + window.localStorage.clear() + seed() + }) it('greets you and adds up what you owe across groups', async () => { renderWithProviders(, { path: '/home' }) @@ -209,13 +236,14 @@ describe('HomeDashboard', () => { ).toHaveAttribute('href', '/groups?new=true') // Nothing can be planned without a group, so that prompt waits. expect(screen.queryByText(t('timeline.empty.title'))).not.toBeInTheDocument() + expect(screen.queryByRole('link', { name: t('home.newGroup') })).not.toBeInTheDocument() unmount() // A group of one: the next step is people. const solo = resetDb({ tables: { profiles: [viewerProfile], - groups: [{ ...groupRows[0]!, group_members: [{ count: 1 }] }], + groups: [{ ...groupRows[0]!, group_members: membersOf(VIEWER) }], group_balances: [], event_rsvps: [], }, @@ -233,9 +261,40 @@ describe('HomeDashboard', () => { }) it('shows no first steps once a group has company', async () => { - renderWithProviders(, { path: '/home' }) - await screen.findByText(t('home.groups')) + await renderHomeWith([{ ...groupRows[0]!, group_members: membersOf(VIEWER, 'u-ben') }]) expect(screen.queryByText(t('home.firstSteps.title'))).not.toBeInTheDocument() + expect(screen.getByRole('link', { name: /Hike crew/ })).toBeInTheDocument() + }) + + it('keeps a way to start a group on Home after a newcomer hides the first steps', async () => { + await renderHomeWith([]) + const steps = await screen.findByRole('region', { name: t('home.firstSteps.title') }) + fireEvent.click(within(steps).getByRole('button', { name: t('home.firstSteps.hide') })) + expect( + screen.queryByRole('region', { name: t('home.firstSteps.title') }), + ).not.toBeInTheDocument() + expect(screen.getByRole('link', { name: t('home.newGroup') })).toHaveAttribute( + 'href', + '/groups', + ) + expect(screen.getByText(t('timeline.empty.title'))).toBeInTheDocument() + }) + + it.each([ + [ + 'an archived group', + { ...groupRows[0]!, archived_at: '2026-10-01T00:00:00Z', group_members: membersOf(VIEWER) }, + ], + ['a friend tab', { ...groupRows[4]!, group_members: membersOf(VIEWER, 'u-jules') }], + ])('does not treat someone with only %s as new', async (_what, row) => { + await renderHomeWith([row]) + expect(screen.queryByText(t('home.firstSteps.title'))).not.toBeInTheDocument() + // Home is whole, as for anyone else: the plan prompt and the way to a new group. + expect(screen.getByText(t('timeline.empty.title'))).toBeInTheDocument() + expect(screen.getByRole('link', { name: t('home.newGroup') })).toHaveAttribute( + 'href', + '/groups', + ) }) it('never says nothing needs you while money is owed, in any currency', async () => { diff --git a/apps/web/src/features/dashboard/home-dashboard.tsx b/apps/web/src/features/dashboard/home-dashboard.tsx index 4a163644..5a124731 100644 --- a/apps/web/src/features/dashboard/home-dashboard.tsx +++ b/apps/web/src/features/dashboard/home-dashboard.tsx @@ -9,7 +9,9 @@ import { useEffect, useMemo, useState } from 'react' import { useSession } from '@/lib/auth' import { supabase } from '@/lib/supabase' import { RecentActivityRow } from '@/features/activity/activity-link' +import { useMyGroups } from '@/features/groups/use-groups' import { FirstSteps } from '@/features/onboarding/first-steps' +import { useFirstStepsHidden } from '@/features/onboarding/use-first-steps-hidden' import { InboxBell } from '@/features/notifications/inbox-bell' import { NavRow } from '@/features/insights/nav-row' import { SearchIconLink } from '@/features/insights/search-link' @@ -34,7 +36,15 @@ export function HomeDashboard() { const timeline = useQuery(planQueries.timeline(supabase, range)) const groups = useQuery(planQueries.groups(supabase)) - const noGroups = groups.data?.length === 0 + // Every group, archived ones and friend tabs included: any of those, or a group with someone + // else in it, means this is not a first visit. Until the list is in, nobody counts as new. + const mine = useMyGroups().data + const [stepsHidden, hideSteps] = useFirstStepsHidden(viewer.userId) + const newcomer = + mine !== undefined && !mine.some((g) => g.is_direct || g.archived_at || g.members.length > 1) + const firstSteps = newcomer && !stepsHidden + // With no group at all the card leads; what cannot be used without a group waits behind it. + const stepsLead = firstSteps && mine?.length === 0 const items = useMemo(() => timeline.data ?? [], [timeline.data]) const needsTimes = items.filter((i) => i.status === 'polling' && !i.availability_submitted) // Asked explicitly first. @@ -147,9 +157,9 @@ export function HomeDashboard() {
- {groups.data && } + {firstSteps && } {/* Nothing can be planned without a group: the first steps card leads there instead. */} - {!(noGroups && upcoming.length === 0) && ( + {!(stepsLead && upcoming.length === 0) && (

{t('timeline.title')}

@@ -198,7 +208,7 @@ export function HomeDashboard() { )} - {!noGroups && ( + {!stepsLead && (

{t('home.groups')}

{groups.isPending ? ( diff --git a/apps/web/src/features/expenses/form/split-editor.tsx b/apps/web/src/features/expenses/form/split-editor.tsx index 175dd3c8..0b7a0f58 100644 --- a/apps/web/src/features/expenses/form/split-editor.tsx +++ b/apps/web/src/features/expenses/form/split-editor.tsx @@ -16,7 +16,7 @@ import { Plus, ReceiptText, } from 'lucide-react' -import { useEffect, useRef, type ReactNode } from 'react' +import { useCallback, useEffect, useRef, type ReactNode } from 'react' import { Help } from '@/features/help/help' import { SPLIT_HELP } from '@/features/help/topics' import { joinNames } from '@/features/plans/format' @@ -87,6 +87,13 @@ export function SplitEditor({ const order = members.map((m) => m.id) const modesRef = useRef(null) const [modesFadeRef, moreModes] = useMoreToTheRight() + const modesTrackRef = useCallback( + (node: HTMLDivElement | null) => { + modesRef.current = node + modesFadeRef(node) + }, + [modesFadeRef], + ) useEffect(() => { // Sideways only: scrollIntoView could also move the page. const track = modesRef.current @@ -320,10 +327,7 @@ export function SplitEditor({ in view. Icons join in only where the split column is wide (one column layouts from md, before the two column lg). */}
{ - modesRef.current = node - modesFadeRef(node) - }} + ref={modesTrackRef} className={cn( '-mx-1 [scrollbar-width:none] overflow-x-auto px-1 pb-1 [&::-webkit-scrollbar]:hidden', moreModes && FADE_RIGHT, diff --git a/apps/web/src/features/groups/group-layout.test.tsx b/apps/web/src/features/groups/group-layout.test.tsx index 070d327b..29dae0b4 100644 --- a/apps/web/src/features/groups/group-layout.test.tsx +++ b/apps/web/src/features/groups/group-layout.test.tsx @@ -102,6 +102,11 @@ describe('GroupLayout', () => { await screen.findByRole('heading', { name: 'Hike crew' }) expect(screen.queryByRole('link', { name: t('balances.settleUp') })).not.toBeInTheDocument() balances.unmount() + // Still owing, but nothing can be paid in an archived group. + const archived = renderLayout([group({ archived_at: '2026-10-01T00:00:00Z' })]) + await screen.findByText(t('groups.header.youOwe', { amount: '$60.51' })) + expect(screen.queryByRole('link', { name: t('balances.settleUp') })).not.toBeInTheDocument() + archived.unmount() renderLayout([ group({ members: [member(VIEWER, 'Ava Chen', 'owner', 0), member('u-ben', 'Ben Ortiz', 'admin', 0)], diff --git a/apps/web/src/features/onboarding/first-steps.tsx b/apps/web/src/features/onboarding/first-steps.tsx index 9f7641fb..17e0a588 100644 --- a/apps/web/src/features/onboarding/first-steps.tsx +++ b/apps/web/src/features/onboarding/first-steps.tsx @@ -1,22 +1,11 @@ -import type { PlanGroup } from '@potluck/api' import { t } from '@potluck/i18n' import { Button, cn } from '@potluck/ui' import { Link } from '@tanstack/react-router' import { Check, X } from 'lucide-react' -import { useState, type ReactNode } from 'react' +import type { ReactNode } from 'react' import { HELP_PAGES } from '@/features/help/topics' import { docsUrl } from '@/lib/docs' -const hiddenKey = (userId: string) => `potluck:first-steps-hidden:${userId}` - -function readHidden(userId: string): boolean { - try { - return window.localStorage.getItem(hiddenKey(userId)) === '1' - } catch { - return false - } -} - function Step({ number, state, @@ -60,24 +49,12 @@ function Step({ /** * The first run checklist on Home: start a group, add people, add an expense. It shows the one - * thing to do next and goes away by itself once a group has someone else in it (from there the - * group's own screens lead on), or when it is hidden. + * thing to do next. Home decides who sees it: only someone new, until a group has someone else + * in it (from there the group's own screens lead on) or the card is hidden. `groupId` is the + * group they started, once there is one. */ -export function FirstSteps({ groups, userId }: { groups: PlanGroup[]; userId: string }) { - const [hidden, setHidden] = useState(() => readHidden(userId)) - const first = groups[0] - const hasCompany = groups.some((g) => g.memberCount > 1) - if (hidden || hasCompany) return null - - const done = first ? 1 : 0 - const hide = () => { - setHidden(true) - try { - window.localStorage.setItem(hiddenKey(userId), '1') - } catch { - // Private mode: it stays hidden for this visit only. - } - } +export function FirstSteps({ groupId, onHide }: { groupId?: string; onHide: () => void }) { + const done = groupId ? 1 : 0 return (
diff --git a/apps/web/src/features/onboarding/use-first-steps-hidden.ts b/apps/web/src/features/onboarding/use-first-steps-hidden.ts new file mode 100644 index 00000000..2ef37306 --- /dev/null +++ b/apps/web/src/features/onboarding/use-first-steps-hidden.ts @@ -0,0 +1,25 @@ +import { useState } from 'react' + +const hiddenKey = (userId: string) => `potluck:first-steps-hidden:${userId}` + +function readHidden(userId: string): boolean { + try { + return window.localStorage.getItem(hiddenKey(userId)) === '1' + } catch { + return false + } +} + +/** Whether this person hid the first steps card in this browser, and the way to hide it. */ +export function useFirstStepsHidden(userId: string): [boolean, () => void] { + const [hidden, setHidden] = useState(() => readHidden(userId)) + const hide = () => { + setHidden(true) + try { + window.localStorage.setItem(hiddenKey(userId), '1') + } catch { + // Private mode: it stays hidden for this visit only. + } + } + return [hidden, hide] +} diff --git a/apps/web/src/features/shell/route-error.test.tsx b/apps/web/src/features/shell/route-error.test.tsx index 09142c94..fb8a16ec 100644 --- a/apps/web/src/features/shell/route-error.test.tsx +++ b/apps/web/src/features/shell/route-error.test.tsx @@ -100,4 +100,38 @@ describe('RouteNotFound', () => { expect(await screen.findByText('Home')).toBeInTheDocument() vi.restoreAllMocks() }) + + it('takes the whole page for a miss under a layout, as the app sets the router up', async () => { + const rootRoute = createRootRoute({ component: () => }) + const groupRoute = createRoute({ + getParentRoute: () => rootRoute, + path: '/groups/$groupId', + component: () => ( +
+ + +
+ ), + }) + const expensesRoute = createRoute({ + getParentRoute: () => groupRoute, + path: '/', + component: () =>

Expenses

, + }) + const router = createRouter({ + routeTree: rootRoute.addChildren([groupRoute.addChildren([expensesRoute])]), + history: createMemoryHistory({ initialEntries: ['/groups/g-hike/bogus'] }), + defaultNotFoundComponent: RouteNotFound, + notFoundMode: 'root', + }) + vi.spyOn(console, 'warn').mockImplementation(() => {}) + render() + expect( + await screen.findByRole('heading', { level: 1, name: t('errors.notFound') }), + ).toBeInTheDocument() + // One main landmark, and none of the group's frame around the page. + expect(screen.getAllByRole('main')).toHaveLength(1) + expect(screen.queryByRole('navigation', { name: 'Group' })).toBeNull() + vi.restoreAllMocks() + }) }) diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx index 4cf86914..37a9e38a 100644 --- a/apps/web/src/main.tsx +++ b/apps/web/src/main.tsx @@ -21,8 +21,10 @@ const router = createRouter({ // A screen that throws shows our own page, with a retry and a way home, in place of the // router's unstyled default. defaultErrorComponent: RouteError, - // An address no screen answers to gets a page with a way home, not the bare "Not Found". + // An address no screen answers to gets a page with a way home, not the bare "Not Found". It + // is a whole page, so a miss under a layout (a group, the app frame) shows it at the root too. defaultNotFoundComponent: RouteNotFound, + notFoundMode: 'root', }) declare module '@tanstack/react-router' { diff --git a/packages/i18n/src/de/plans.ts b/packages/i18n/src/de/plans.ts index 28cd0afd..c2b9cc84 100644 --- a/packages/i18n/src/de/plans.ts +++ b/packages/i18n/src/de/plans.ts @@ -296,7 +296,6 @@ export const home = { expenseHint: 'Potluck rechnet aus, wer wem was schuldet.', groupAction: 'Gruppe erstellen', peopleAction: 'Leute hinzufügen', - expenseAction: 'Ausgabe hinzufügen', progress: '{done} von {total} erledigt', hide: 'Diese Schritte ausblenden', }, diff --git a/packages/i18n/src/en/plans.ts b/packages/i18n/src/en/plans.ts index b5e544fa..8b0c8da1 100644 --- a/packages/i18n/src/en/plans.ts +++ b/packages/i18n/src/en/plans.ts @@ -404,7 +404,6 @@ export const home = { expenseHint: 'Potluck works out who owes what.', groupAction: 'Create a group', peopleAction: 'Add people', - expenseAction: 'Add expense', progress: '{done} of {total} done', hide: 'Hide these steps', }, diff --git a/packages/i18n/src/es/plans.ts b/packages/i18n/src/es/plans.ts index 90886a4b..936478c0 100644 --- a/packages/i18n/src/es/plans.ts +++ b/packages/i18n/src/es/plans.ts @@ -294,7 +294,6 @@ export const home = { expenseHint: 'Potluck calcula quién debe qué.', groupAction: 'Crear un grupo', peopleAction: 'Añadir personas', - expenseAction: 'Añadir gasto', progress: '{done} de {total} hechos', hide: 'Ocultar estos pasos', }, diff --git a/packages/i18n/src/fr/plans.ts b/packages/i18n/src/fr/plans.ts index 1517ca6a..26f427f3 100644 --- a/packages/i18n/src/fr/plans.ts +++ b/packages/i18n/src/fr/plans.ts @@ -295,7 +295,6 @@ export const home = { expenseHint: 'Potluck calcule qui doit quoi.', groupAction: 'Créer un groupe', peopleAction: 'Ajouter des personnes', - expenseAction: 'Ajouter une dépense', progress: '{done} sur {total} terminées', hide: 'Masquer ces étapes', }, diff --git a/packages/i18n/src/pt/plans.ts b/packages/i18n/src/pt/plans.ts index b26a18ee..a5573d55 100644 --- a/packages/i18n/src/pt/plans.ts +++ b/packages/i18n/src/pt/plans.ts @@ -295,7 +295,6 @@ export const home = { expenseHint: 'O Potluck calcula quem deve o quê.', groupAction: 'Criar um grupo', peopleAction: 'Adicionar pessoas', - expenseAction: 'Adicionar despesa', progress: '{done} de {total} concluídos', hide: 'Ocultar estes passos', }, From 22e0aa93c49bd8fb6c9c733f0d559a3dd5f6461e Mon Sep 17 00:00:00 2001 From: Musa Kaleem <131704022+Musa-Kal@users.noreply.github.com> Date: Sat, 21 Nov 2026 02:46:18 -0500 Subject: [PATCH 3/6] review: Hold Home for group list, share router fallbacks --- .../web/src/features/dashboard/home-dashboard.tsx | 15 +++++++++------ apps/web/src/features/shell/route-error.test.tsx | 10 +++++----- apps/web/src/features/shell/router-options.ts | 12 ++++++++++++ apps/web/src/lib/prefetch.test.ts | 1 + apps/web/src/lib/prefetch.ts | 1 + apps/web/src/main.tsx | 10 ++-------- 6 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 apps/web/src/features/shell/router-options.ts diff --git a/apps/web/src/features/dashboard/home-dashboard.tsx b/apps/web/src/features/dashboard/home-dashboard.tsx index 5a124731..cee57d3f 100644 --- a/apps/web/src/features/dashboard/home-dashboard.tsx +++ b/apps/web/src/features/dashboard/home-dashboard.tsx @@ -38,7 +38,8 @@ export function HomeDashboard() { // Every group, archived ones and friend tabs included: any of those, or a group with someone // else in it, means this is not a first visit. Until the list is in, nobody counts as new. - const mine = useMyGroups().data + const myGroups = useMyGroups() + const mine = myGroups.data const [stepsHidden, hideSteps] = useFirstStepsHidden(viewer.userId) const newcomer = mine !== undefined && !mine.some((g) => g.is_direct || g.archived_at || g.members.length > 1) @@ -80,16 +81,18 @@ export function HomeDashboard() { ? summarizeBalances(balances.data, viewer.profile?.defaultCurrency) : null const todayKey = dayKey(now, viewer.timeZone) - // On phones everything stacks, so "Needs you" (known once the timeline is in) and the real - // balance card (taller than its skeleton) would push down whatever was already on screen. - // What sits below them waits, invisible but laid out, until both have answered (with data or - // an error) or a moment has passed, whichever comes first. + // On phones everything stacks, so "Needs you" (known once the timeline is in), the first steps + // card (known once every group is in) and the real balance card (taller than its skeleton) + // would push down whatever was already on screen. What sits below them waits, invisible but + // laid out, until all three have answered (with data or an error) or a moment has passed, + // whichever comes first. const [heldLongEnough, setHeldLongEnough] = useState(false) useEffect(() => { const timer = setTimeout(() => setHeldLongEnough(true), HOLD_MS) return () => clearTimeout(timer) }, []) - const settled = heldLongEnough || (!timeline.isPending && !balances.isPending) + const settled = + heldLongEnough || (!timeline.isPending && !balances.isPending && !myGroups.isPending) const holdBelow = settled ? undefined : 'max-lg:invisible' return ( diff --git a/apps/web/src/features/shell/route-error.test.tsx b/apps/web/src/features/shell/route-error.test.tsx index fb8a16ec..416efdd0 100644 --- a/apps/web/src/features/shell/route-error.test.tsx +++ b/apps/web/src/features/shell/route-error.test.tsx @@ -9,7 +9,8 @@ import { } from '@tanstack/react-router' import { fireEvent, render, screen } from '@testing-library/react' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { RouteError, RouteNotFound } from './route-error' +import { RouteError } from './route-error' +import { routerFallbacks } from './router-options' // The router restores scroll on navigation; jsdom has no layout to scroll. window.scrollTo = () => {} @@ -37,7 +38,7 @@ function renderBrokenScreen() { const router = createRouter({ routeTree: rootRoute.addChildren([screenRoute]), history: createMemoryHistory({ initialEntries: ['/search'] }), - defaultErrorComponent: RouteError, + ...routerFallbacks, }) return render() } @@ -87,7 +88,7 @@ describe('RouteNotFound', () => { const router = createRouter({ routeTree: rootRoute.addChildren([homeRoute]), history: createMemoryHistory({ initialEntries: ['/nowhere'] }), - defaultNotFoundComponent: RouteNotFound, + ...routerFallbacks, }) vi.spyOn(console, 'warn').mockImplementation(() => {}) render() @@ -121,8 +122,7 @@ describe('RouteNotFound', () => { const router = createRouter({ routeTree: rootRoute.addChildren([groupRoute.addChildren([expensesRoute])]), history: createMemoryHistory({ initialEntries: ['/groups/g-hike/bogus'] }), - defaultNotFoundComponent: RouteNotFound, - notFoundMode: 'root', + ...routerFallbacks, }) vi.spyOn(console, 'warn').mockImplementation(() => {}) render() diff --git a/apps/web/src/features/shell/router-options.ts b/apps/web/src/features/shell/router-options.ts new file mode 100644 index 00000000..c5391482 --- /dev/null +++ b/apps/web/src/features/shell/router-options.ts @@ -0,0 +1,12 @@ +import { RouteError, RouteNotFound } from './route-error' + +/** What the app's router shows when a screen throws or an address matches no screen. */ +export const routerFallbacks = { + // A screen that throws shows our own page, with a retry and a way home, in place of the + // router's unstyled default. + defaultErrorComponent: RouteError, + // An address no screen answers to gets a page with a way home, not the bare "Not Found". It + // is a whole page, so a miss under a layout (a group, the app frame) shows it at the root too. + defaultNotFoundComponent: RouteNotFound, + notFoundMode: 'root', +} as const diff --git a/apps/web/src/lib/prefetch.test.ts b/apps/web/src/lib/prefetch.test.ts index 6b9048d8..2e1a1408 100644 --- a/apps/web/src/lib/prefetch.test.ts +++ b/apps/web/src/lib/prefetch.test.ts @@ -50,6 +50,7 @@ describe('route prefetch', () => { planQueries.timeline(supabase, range).queryKey, planQueries.past(supabase, range.from).queryKey, planQueries.groups(supabase).queryKey, + myGroupsQueryOptions(supabase, ME).queryKey, ) }) diff --git a/apps/web/src/lib/prefetch.ts b/apps/web/src/lib/prefetch.ts index 4984a2e2..7dbf5e10 100644 --- a/apps/web/src/lib/prefetch.ts +++ b/apps/web/src/lib/prefetch.ts @@ -38,6 +38,7 @@ export const prefetch = { void queryClient.prefetchQuery(planQueries.homeBalances(client, userId)) void queryClient.prefetchQuery(planQueries.timeline(client, timelineRange())) void queryClient.prefetchQuery(planQueries.groups(client)) + void queryClient.prefetchQuery(myGroupsQueryOptions(client, userId)) }) }, diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx index 37a9e38a..51219f9b 100644 --- a/apps/web/src/main.tsx +++ b/apps/web/src/main.tsx @@ -2,7 +2,7 @@ import { QueryClientProvider } from '@tanstack/react-query' import { createRouter, RouterProvider } from '@tanstack/react-router' import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' -import { RouteError, RouteNotFound } from '@/features/shell/route-error' +import { routerFallbacks } from '@/features/shell/router-options' import { startLanguage } from '@/lib/language' import { queryClient } from '@/lib/query-client' import { initTheme } from '@/styles/theme-preference' @@ -18,13 +18,7 @@ const router = createRouter({ routeTree, context: { queryClient }, defaultPreload: 'intent', - // A screen that throws shows our own page, with a retry and a way home, in place of the - // router's unstyled default. - defaultErrorComponent: RouteError, - // An address no screen answers to gets a page with a way home, not the bare "Not Found". It - // is a whole page, so a miss under a layout (a group, the app frame) shows it at the root too. - defaultNotFoundComponent: RouteNotFound, - notFoundMode: 'root', + ...routerFallbacks, }) declare module '@tanstack/react-router' { From 8c4eebe7c412ddd0d8752023d2eb406b4d1d5bbf Mon Sep 17 00:00:00 2001 From: Musa Kaleem <131704022+Musa-Kal@users.noreply.github.com> Date: Sat, 21 Nov 2026 02:55:21 -0500 Subject: [PATCH 4/6] test: Mute zero owe and owed amounts on the balance card --- .../dashboard/home-dashboard.test.tsx | 24 +++++++++++++++++++ packages/ui/src/amount.test.tsx | 13 ++++++++++ packages/ui/src/amount.tsx | 10 ++++++-- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/apps/web/src/features/dashboard/home-dashboard.test.tsx b/apps/web/src/features/dashboard/home-dashboard.test.tsx index 102f0c50..1e5fb588 100644 --- a/apps/web/src/features/dashboard/home-dashboard.test.tsx +++ b/apps/web/src/features/dashboard/home-dashboard.test.tsx @@ -224,6 +224,30 @@ describe('HomeDashboard', () => { expect(screen.queryByRole('heading', { name: t('home.needsYou') })).not.toBeInTheDocument() }) + it('mutes the zero figures on the balance card and keeps the all square headline olive', async () => { + seed({ items: [], balances: false }) + renderWithProviders(, { path: '/home' }) + const hero = await screen.findByRole('region', { name: t('home.balance.title') }) + await within(hero).findByText(t('home.balance.settledHint')) + // You owe and Owed to you: zero is muted grey, never tomato or olive (docs/design.md). + const zeros = within(hero).getAllByText('$0.00') + expect(zeros).toHaveLength(2) + for (const zero of zeros) expect(zero.parentElement).toHaveAttribute('data-tone', 'settled') + expect(within(hero).getByText(t('home.balance.settled'))).toHaveClass('text-hero-olive') + }) + + it('keeps what you owe tomato and what you are owed olive on the balance card', async () => { + renderWithProviders(, { path: '/home' }) + const hero = await screen.findByRole('region', { name: t('home.balance.title') }) + const figure = (label: string) => + within(within(hero).getByText(label).parentElement!).getByText(/\d/, { + selector: '.sr-only', + }).parentElement + await within(hero).findByText('You owe $32.51') + expect(figure(t('home.balance.youOwe'))).toHaveAttribute('data-tone', 'owe') + expect(figure(t('home.balance.owedToYou'))).toHaveAttribute('data-tone', 'owed') + }) + it('walks a newcomer through the first steps, one at a time', async () => { const fake = resetDb({ tables: { profiles: [viewerProfile], groups: [], group_balances: [], event_rsvps: [] }, diff --git a/packages/ui/src/amount.test.tsx b/packages/ui/src/amount.test.tsx index bdded897..e0f67f7c 100644 --- a/packages/ui/src/amount.test.tsx +++ b/packages/ui/src/amount.test.tsx @@ -57,6 +57,19 @@ describe('Amount', () => { expect(container.firstElementChild).toHaveAttribute('data-tone', 'neutral') }) + it('mutes a zero amount even when the caller names it owed or owing', () => { + // Design rule (docs/design.md): settled or zero amounts are muted grey, on either surface. + for (const tone of ['owe', 'owed'] as const) { + const { container, unmount } = render( + , + ) + expect(container.firstElementChild).toHaveAttribute('data-tone', 'settled') + unmount() + } + const { container } = render() + expect(container.firstElementChild).toHaveAttribute('data-tone', 'owe') + }) + it('lets callers override the spoken label', () => { render() expect(screen.getByText('You are owed $8.00')).toBeInTheDocument() diff --git a/packages/ui/src/amount.tsx b/packages/ui/src/amount.tsx index 49754fcb..4301f44c 100644 --- a/packages/ui/src/amount.tsx +++ b/packages/ui/src/amount.tsx @@ -63,7 +63,10 @@ export interface AmountProps { locale?: string /** How to show the sign. `auto` shows minus only. */ sign?: AmountSign - /** `auto` colors by sign: negative = owe (tomato), positive = owed (olive). */ + /** + * `auto` colors by sign: negative = owe (tomato), positive = owed (olive). A zero amount asked + * for as `owe` or `owed` is muted like `settled`. + */ tone?: AmountTone /** Use on the balance hero so colors stay legible on its surface. */ surface?: AmountSurface @@ -127,7 +130,10 @@ export function Amount({ : 'neutral' : tone === 'inherit' ? null - : tone + : // Nothing owed either way is settled, whatever the caller calls the column. + (tone === 'owe' || tone === 'owed') && !cents + ? 'settled' + : tone const label = srLabel ?? formatMoney(cents, currency, { locale, sign }) return ( From 0e51327b96a199f72a3841f8c49eb232630807e3 Mon Sep 17 00:00:00 2001 From: Musa Kaleem <131704022+Musa-Kal@users.noreply.github.com> Date: Sat, 21 Nov 2026 03:01:05 -0500 Subject: [PATCH 5/6] test: Hold Home group sections until my groups answers --- .../dashboard/home-dashboard.test.tsx | 64 ++++++++++++++++++- .../src/features/dashboard/home-dashboard.tsx | 8 ++- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/apps/web/src/features/dashboard/home-dashboard.test.tsx b/apps/web/src/features/dashboard/home-dashboard.test.tsx index 1e5fb588..f48c91f5 100644 --- a/apps/web/src/features/dashboard/home-dashboard.test.tsx +++ b/apps/web/src/features/dashboard/home-dashboard.test.tsx @@ -1,12 +1,13 @@ import type * as AuthModule from '@/lib/auth' -import { groupKeys } from '@potluck/api' +import type * as ApiModule from '@potluck/api' +import { groupKeys, planQueries } from '@potluck/api' import { t } from '@potluck/i18n' import { fireEvent, screen, waitFor, within } from '@testing-library/react' import { beforeEach, describe, expect, it, vi } from 'vitest' import { VIEWER } from '@/test/fixtures' import { viewerProfile } from '@/test/plan-fixtures' import { renderWithProviders } from '@/test/render' -import { resetDb, rowsOf } from '@/test/supabase' +import { resetDb, rowsOf, supabase } from '@/test/supabase' import { HomeDashboard } from './home-dashboard' vi.mock('@/lib/supabase', () => import('@/test/supabase')) @@ -15,6 +16,20 @@ vi.mock('@/lib/auth', async (importOriginal) => ({ useUserId: () => VIEWER, })) +// The list of every group can be made to answer late: set `myGroupsGate` and resolve it later. +let myGroupsGate: Promise | null = null +vi.mock('@potluck/api', async (importOriginal) => { + const actual = await importOriginal() + const myGroupsQueryOptions: typeof actual.myGroupsQueryOptions = (client, viewerId) => ({ + ...actual.myGroupsQueryOptions(client, viewerId), + queryFn: async () => { + await myGroupsGate + return actual.fetchMyGroups(client, viewerId) + }, + }) + return { ...actual, myGroupsQueryOptions } +}) + const DAY = 86_400_000 const at = (days: number) => new Date(Date.now() + days * DAY).toISOString() @@ -146,6 +161,7 @@ function seed({ items = timeline as object[], balances = true } = {}) { describe('HomeDashboard', () => { beforeEach(() => { window.localStorage.clear() + myGroupsGate = null seed() }) @@ -284,6 +300,50 @@ describe('HomeDashboard', () => { ).not.toBeInTheDocument() }) + /** Newcomer Home with the timeline, balances and plan groups in, the list of every group not. */ + async function renderNewcomerWaitingOnGroups() { + let release = () => {} + myGroupsGate = new Promise((resolve) => { + release = resolve + }) + const fake = resetDb({ + tables: { profiles: [viewerProfile], groups: [], group_balances: [], event_rsvps: [] }, + }) + fake.respond('rpc:my_timeline', { data: [] }) + const view = renderWithProviders(, { path: '/home' }) + await screen.findByText(t('home.balance.settledHint')) + await screen.findByText(t('home.summary.none')) + const groupsKey = planQueries.groups(supabase).queryKey + await waitFor(() => expect(view.queryClient.getQueryState(groupsKey)?.status).toBe('success')) + return { ...view, release } + } + + it('never shows a newcomer the plan prompt or Groups before the first steps card', async () => { + const { release } = await renderNewcomerWaitingOnGroups() + // Everything else has answered; whether this is a first visit is still unknown. + expect(screen.queryByRole('heading', { name: t('home.groups') })).not.toBeInTheDocument() + expect(screen.queryByRole('heading', { name: t('timeline.title') })).not.toBeInTheDocument() + expect(screen.queryByText(t('timeline.empty.title'))).not.toBeInTheDocument() + // What does not depend on having a group is there meanwhile. + expect(screen.getByRole('link', { name: new RegExp(t('insights.open')) })).toBeInTheDocument() + + release() + expect( + await screen.findByRole('region', { name: t('home.firstSteps.title') }), + ).toBeInTheDocument() + expect(screen.queryByRole('heading', { name: t('home.groups') })).not.toBeInTheDocument() + expect(screen.queryByText(t('timeline.empty.title'))).not.toBeInTheDocument() + }) + + it('stops waiting on a slow group list after a moment and shows Home whole', async () => { + await renderNewcomerWaitingOnGroups() + expect(screen.queryByRole('heading', { name: t('home.groups') })).not.toBeInTheDocument() + expect( + await screen.findByRole('heading', { name: t('home.groups') }, { timeout: 4000 }), + ).toBeInTheDocument() + expect(screen.getByText(t('timeline.empty.title'))).toBeInTheDocument() + }) + it('shows no first steps once a group has company', async () => { await renderHomeWith([{ ...groupRows[0]!, group_members: membersOf(VIEWER, 'u-ben') }]) expect(screen.queryByText(t('home.firstSteps.title'))).not.toBeInTheDocument() diff --git a/apps/web/src/features/dashboard/home-dashboard.tsx b/apps/web/src/features/dashboard/home-dashboard.tsx index cee57d3f..197dac20 100644 --- a/apps/web/src/features/dashboard/home-dashboard.tsx +++ b/apps/web/src/features/dashboard/home-dashboard.tsx @@ -94,6 +94,10 @@ export function HomeDashboard() { const settled = heldLongEnough || (!timeline.isPending && !balances.isPending && !myGroups.isPending) const holdBelow = settled ? undefined : 'max-lg:invisible' + // On every width: the empty Coming up prompt and Groups give way to the first steps card for + // someone with no group, so neither is drawn until the group list says which it is (or the + // same moment has passed). Showing them first and taking them away again is a flash. + const groupsKnown = heldLongEnough || !myGroups.isPending return (
@@ -162,7 +166,7 @@ export function HomeDashboard() {
{firstSteps && } {/* Nothing can be planned without a group: the first steps card leads there instead. */} - {!(stepsLead && upcoming.length === 0) && ( + {(upcoming.length > 0 || (groupsKnown && !stepsLead)) && (

{t('timeline.title')}

@@ -211,7 +215,7 @@ export function HomeDashboard() { )} - {!stepsLead && ( + {groupsKnown && !stepsLead && (

{t('home.groups')}

{groups.isPending ? ( From 8bf6895881d51f90579f4b9a6fb065816174aa67 Mon Sep 17 00:00:00 2001 From: Musa Kaleem <131704022+Musa-Kal@users.noreply.github.com> Date: Sat, 21 Nov 2026 03:07:24 -0500 Subject: [PATCH 6/6] document: Document not-found page and first steps e2e coverage --- docs/development.md | 2 +- docs/testing.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/development.md b/docs/development.md index b9e22d69..93b383ef 100644 --- a/docs/development.md +++ b/docs/development.md @@ -300,7 +300,7 @@ Notes for changing particular screens in `apps/web`. The general rules are in `a - Categories: pick with `CategoryPicker` (`features/expenses/form/category-picker.tsx`, top level chips plus a row of subcategories) and label with `categoryLabel()`. A new expense's category follows core `suggestCategory` (group history from `categoryHistoryQueryOptions`) until someone taps one. Subcategories are stored as their own ids; totals and charts roll them up with core `parentCategory()`. - Groups ([ADR 20](adr/0020-group-types-restorable-deletes-and-shared-notes.md)): a deleted group is gone from every query for 30 days; "Recently deleted" (`features/groups/recently-deleted.tsx`) reads `my_deleted_groups`, and its old address shows the deleted page with Restore (`MissingGroup`). Covers render through `GroupCover` / `coverSrc()` (public URL, works signed out). The Notes tab (`notes-page.tsx`) saves with a base version and subscribes to `group_whiteboards`, refetching through `useRealtime`'s `onSubscribed` once the channel joins (an edit saved while it was joining sends no change event, and every channel asks Realtime to hold `SUBSCRIBED` until Postgres changes flow with `postgres_changes_options.wait`; the plan page's `useEventRealtime` does the same for paints and guest answers); keep that pattern for any other shared text. Long names with no spaces use `wrap-anywhere`, not `break-words`, so they cannot widen a grid column or the phone page. -- Errors and offline: a screen that throws renders `RouteError` (`features/shell/route-error.tsx`, the router's `defaultErrorComponent` and the root's `errorComponent`) with Try again and Go home. `OfflineBanner` (root layout) shows while `useOnline()` (`src/lib/online.ts`, `navigator.onLine` plus its events) is false. A form in `MoneyPageShell` disables its save offline, shows `OfflineSaveNote` and calls `useWarnBeforeUnload` while its entry would be lost; do the same for any new save button there. A save that fails because Potluck could not be reached (`isNetworkError` in `src/lib/errors.ts`, classified once in the mutation's `onError`) gets no toast: the form stays as typed and read only (a `fieldset disabled` around its fields, also while the save is out) so a retry repeats exactly what was sent, `OfflineSaveNote` (`failed`) says so, the save button itself reads Try again (one action, never a second button beside it), and the group's money queries are invalidated so a save that did arrive shows up once back online. Saves are never retried by themselves. A new expense or payment carries one request id per form (`newRequestId` in `src/lib/request-id.ts`, kept in `useState`), sent with every try, so a retry after a lost reply returns the first save instead of a second (ADR 8, Request keys), and the success message describes the returned row, not the form; a new create form that can be retried does the same. A held payment form keeps showing the debt it was sent against (the same snapshot the settled screen uses), since the refetched debts may already count it. +- Errors and offline: a screen that throws renders `RouteError` (`features/shell/route-error.tsx`, the router's `defaultErrorComponent` and the root's `errorComponent`) with Try again and Go home. An address no screen answers to renders `RouteNotFound` (same file) as a whole page at the root, even for a miss under a layout (`notFoundMode: 'root'`); both fallbacks are set in `features/shell/router-options.ts`, which `main.tsx` spreads into the router. `OfflineBanner` (root layout) shows while `useOnline()` (`src/lib/online.ts`, `navigator.onLine` plus its events) is false. A form in `MoneyPageShell` disables its save offline, shows `OfflineSaveNote` and calls `useWarnBeforeUnload` while its entry would be lost; do the same for any new save button there. A save that fails because Potluck could not be reached (`isNetworkError` in `src/lib/errors.ts`, classified once in the mutation's `onError`) gets no toast: the form stays as typed and read only (a `fieldset disabled` around its fields, also while the save is out) so a retry repeats exactly what was sent, `OfflineSaveNote` (`failed`) says so, the save button itself reads Try again (one action, never a second button beside it), and the group's money queries are invalidated so a save that did arrive shows up once back online. Saves are never retried by themselves. A new expense or payment carries one request id per form (`newRequestId` in `src/lib/request-id.ts`, kept in `useState`), sent with every try, so a retry after a lost reply returns the first save instead of a second (ADR 8, Request keys), and the success message describes the returned row, not the form; a new create form that can be retried does the same. A held payment form keeps showing the debt it was sent against (the same snapshot the settled screen uses), since the refetched debts may already count it. - Undo inside a sheet: a sheet makes everything behind it inert, so a toast's Undo cannot be tapped or reached by keyboard while it is open. Put Undo in the sheet where the thing was (the invite panel shows one `RevokedNote` per revoked link, in that link's slot, and each takes focus when its link goes) and raise the toasts, one per link still undoable, only once the sheet closes (`inSheet`; the members page's inline panel keeps the notes alone). Each note lasts as long as the toast would (8 s), and a reply that lands after the panel is gone raises the toast directly. - Blocks in forms: the expense form tells whoever placed a block, by name and before saving, when the person they blocked is in the split or among the payers (`blockedOnExpense`, from `my_blocks`, the same rule as `private.blocked_pair`); everyone else only hears the server's neutral `blocked_person`. Payment controls in a 1:1 tab follow `useBlockedInTab` (`features/friends/split-note.ts`): the blocked side sees Edit, Delete and Restore only on payments they recorded, and `paymentErrorMessage` words any remaining refusal for a payment. Who may edit a payment is `mayEditPayment` (`features/settle/payment-rules.ts`), used by the Edit button on the payment's page, the payment menu in the expenses list (hidden in an archived group) and `/payments/$paymentId/edit`, which sends anyone else back to the payment's page. Never show who blocked whom to the blocked side. - Sessions ended elsewhere: `endEndedSession` leaves a flag (`sessionEndedHere`, cleared by the sign-in page) so sign in says why once. `confirmSession` leaves it itself as soon as `getUser` answers that the session is gone, before any sign out, because auth-js has already dropped the stored session inside `getUser` by then (and fired `SIGNED_OUT`, which may open sign in first); the sign-in page also listens (`onSessionEnded`) for a flag left after it opened. `useSessionCheck` checks on open and on focus or visibility (those two throttled to one check per 30 seconds), and its timer starts again after every check, so no two checks while on screen are more than 30 seconds apart. diff --git a/docs/testing.md b/docs/testing.md index 0a8b4599..d28d045e 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -157,7 +157,7 @@ Every test creates its own users and groups with unique names, so tests run in p | Spec | Covers | | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `onboarding.spec.ts` | landing page, sign up, onboarding (name, time zone, currency), skipping the first group step, home greets you by name | +| `onboarding.spec.ts` | landing page, sign up, onboarding (name, time zone, currency), skipping the first group step, home greets you by name, the first steps card on Home opens the create group sheet | | `groups-invites.spec.ts` | create a group, create an invite link, a signed out friend opens `/join/`, signs in and joins, the owner sees them, then revokes the link in the invite sheet and gets it back with one tap on Undo there | | `expenses.spec.ts` | equal, exact, percent (typed values kept as typed), shares and itemized splits with each person's share on the detail page, editing the amount, delete with Undo, a EUR expense in a USD group showing the converted amount | | `expense-entry.spec.ts` | two payers agree across row, detail, balances and CSV; payers that do not add up are refused; adjustment split and edit history; a refund; the two-person shortcut; by item reopening its items; default split and last currency; offline save held with the entry kept |