Organizations, invitation page, member management and live updates #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/organizations"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Every user now belongs to an organization, todos belong to one, and changes by others show up live.
Commits
/login?redirect=returns to the requested page (app paths only, no open redirect)..tanstackignored./onboardingcreates one; with a pending invitation → joins it; a single organization is picked without a click.requireOrganization); not a member (anymore) → 403NO_ACTIVE_ORGANIZATION, the client moves on to another organization or/onboarding./accept-invitation/$id: new users sign up right there (the mailed link proves the address).live_notify()Postgres trigger (member, invitation, organization, todo) → oneLISTENper server instance →live.subscribe(oRPC event iterator / SSE) → the client refetches per topic (apps/client/src/lib/live.ts). Signals only, never data.live.connected/live.disconnectedlogs and a shortlive.dispatchspan per change instead. Graceful shutdown ends open streams first.live/live.contract.ts+ handler inlib/live.ts(see README / CLAUDE.md).Migrations
20261123210737_organizations,20261123221623_live(custom: trigger function). Runbun run db:migrate.Testing
bun run check: typecheck, lint, format, 32 server tests (incl.live/live.test.ts)bun run e2e: 9 tests (invitation flows, member management, rename/leave/delete, live across users and tabs)Changes by others show up without a reload: roles and permissions, members, invitations, organizations and todos. A removed member is moved on right away. - DB: a generic live_notify(topic, org column [, user column]) trigger on member, invitation, organization and todo; delivered on commit. - Server (live/): one LISTEN connection per instance, fanned out to the open streams of the affected users (their organizations + their own memberships). Signals only ({ topic, organizationId }), never data. - Transport: live.subscribe, an oRPC event iterator (SSE). One stream per browser: one tab holds it (Web Locks) and forwards events (BroadcastChannel). - Client (lib/live.ts): what to refetch per topic; reconnect + resync after gaps. Replaces the polling on the organization page. - Observability: streams get no request span / wide event; instead live.connected / live.disconnected logs and a short live.dispatch span per change. Graceful shutdown ends open streams first.