Files
pad/web
xarmian c29519f72b fix(web): Manage Billing reaches the Stripe portal, and only for a billing account (BUG-3897, BUG-3898) (#2224)
* fix(web): Manage Billing is a full navigation to the Stripe portal (BUG-3897)

The Pro "Manage Billing" link points at /billing/portal, a pad-cloud
sidecar path with no SPA route. It lacked data-sveltekit-reload, so
SvelteKit's client router took the click and rendered the catch-all
("no dashboard available"): the request never reached nginx's /billing/
route, and the portal's origin check needs the Referer a full navigation
sends. Every other link into a sidecar path already carries the
attribute (the /auth/github and /auth/google links); the export download
is exempt through its download attribute.

The page test mounts the real billing page as a Pro user and requires
the attribute; on main it fails on exactly that assertion.

Claude-Session: https://claude.ai/code/session_016Msqj8nRQUNbgdsXxhBBVR

* fix(web): Manage Billing needs a Stripe customer; a portal refusal shows a message (BUG-3898)

A Pro plan granted by an admin has no Stripe customer, so the portal can
only refuse it, and the user saw pad-cloud's raw JSON. The billing page
now reads stripe_customer_id from GET /auth/me (the session payload does
not carry it) and gives a Pro account without one a one-line note in
place of the button. A customer with no live subscription still gets
the portal, for its invoices (R2). Until /auth/me answers, or if it
fails, the button stays.

pad-cloud's portal now answers a refusal by sending the browser back to
/console/billing?portal_error=<code>. The page shows that code's message
(a generic one for any unknown code, never the code itself), clears the
parameter, and drops it unread in the apps, like a checkout return. The
codes are pinned in $lib/billing/portalError.ts and match pad-cloud's
stripe.go: not_configured, unauthenticated, origin, no_billing_account,
stripe_error.

Claude-Session: https://claude.ai/code/session_016Msqj8nRQUNbgdsXxhBBVR

* fix(web): the billing-account read follows a plan that becomes Pro during the visit (BUG-3898 r1)

Review round r1: the stripe_customer_id read ran only if the account was
already Pro at mount, so a checkout return confirmed by polling skipped
the gate. It now runs from an effect, once per visit, as soon as the
account is Pro.

Tests: the page tests now apply history.replaceState instead of only
recording it, so they assert the real URL. A new row covers portal_error
alongside a checkout return (both read, both cleared) and a plan that
becomes Pro mid-visit. The BUG-3897 test mocks /auth/me as a customer
explicitly instead of passing through a swallowed TypeError.

Claude-Session: https://claude.ai/code/session_016Msqj8nRQUNbgdsXxhBBVR
2026-10-17 22:45:56 -04:00
..
2026-03-26 01:52:36 +00:00
2026-03-26 01:52:36 +00:00

Pad Web UI

SvelteKit 2 + Svelte 5 frontend for Pad, compiled to static files and embedded into the Go binary.

Development

npm install
npm run dev          # Dev server at localhost:5173 (proxies API to localhost:7777)
npm run build        # Production build to build/
npm run check        # Type checking with svelte-check

When developing, run the Go backend separately with make dev from the project root.

Building for Production

Do not build in isolation. Always use make build from the project root — this builds the web frontend, then compiles the Go binary with the build output embedded via //go:embed.

Stack

  • Svelte 5 with runes ($state, $derived, $effect)
  • SvelteKit 2 with adapter-static (SPA mode)
  • Tiptap block editor with markdown round-trip
  • svelte-dnd-action for drag-and-drop in board/list views
  • SSE for real-time updates
  • TypeScript throughout

Structure

src/
  routes/                    SvelteKit pages
    +layout.svelte           App shell (sidebar + main)
    +page.svelte             Landing/redirect
    [workspace]/
      +page.svelte           Dashboard (collections, phases, activity)
      +layout.svelte         SSE connection per workspace
      [collection]/
        +page.svelte         Collection view (board/list)
      [collection]/[item]/
        +page.svelte         Item detail + editor
      conventions/            Purpose-built conventions page
      playbooks/              Purpose-built playbooks page
      settings/               Workspace settings
  lib/
    api/client.ts            HTTP API client
    components/
      layout/                Sidebar, navigation
      editor/                Tiptap editor, raw markdown editor
      fields/                FieldEditor, relation picker
      items/                 ItemCard, ItemDetail
      collections/           BoardView, ListView
      common/                StatusBadge, badges, modals
      search/                CommandPalette
    stores/                  Svelte 5 reactive stores
      workspace.svelte.ts    Workspace state
      collections.svelte.ts  Collection + item state
      ui.svelte.ts           Sidebar, mobile state
    types/index.ts           TypeScript types and constants
  app.css                    Global styles and design tokens