Public: anyone can read this; the crew can change it.

Boards belong to a person: a guest's board lives in their browser and is kept by signing in #35

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The server-side ownership work (schema, createBoard/claimBoard, / listing, POST /b/:id/claim) was already on this branch from an earlier pass. This pass filled in the remaining gaps: static/boards.

Notes

shipped production is serving it deploy fc047f8

opened this

The server-side ownership work (schema, createBoard/claimBoard, / listing, POST /b/:id/claim) was already on this branch from an earlier pass. This pass filled in the remaining gaps:

  • static/boards.<hash>.js (new): records every board a guest opens into localStorage and renders that list on / for a guest, with a note that it lives in this browser only and a Sign in link. No inline script, per the CSP. Malformed storage is handled without blanking the page.
  • src/pages/board.ts: landing page now has a #guest-boards container and includes boards.js; the board page includes it too so a visit gets recorded.
  • src/db.ts: added listBoardsForOwner, used by the terminal to show a person's own boards plus unowned ones (removed the now-unused listBoards, which leaked everyone's boards).
  • src/tty.ts: the board picker and board creation now respect FORGE_APP_USER the way the web page respects a signed-in visitor — no more listing every board.
  • Tests added in src/db.test.ts, src/boards.test.ts (new, drives the script with a real happy-dom DOM/localStorage), and src/server.test.ts (a board's link still edits it for someone who isn't its owner).
  • README updated to describe the guest board list and the terminal's ownership parity.

Left out: signing in does not auto-claim a guest's stored boards — claiming still happens per-board via the existing "Keep this board" button, since the issue only asks that signing in let you claim them, not do it automatically. bun test passes (52 tests); I smoke-tested the guest flow and the tty owner filter manually.

Closes #11

Changes requested — before the latest push

Read every line against the direction, drove static/boards.3900872342.js against the live preview in a headless DOM, and checked the preview's responses. Requesting changes on the terminal half — the web half is good.

Good, and verified: a guest's visit is recorded and / renders it; a board named Review board <img src=x> comes back as text, not markup (textContent, and encodeURIComponent on the href); malformed storage yields an empty list instead of a blank page; nothing about that list ever reaches the server; no inline script, so the CSP is untouched; the floor is intact on every response I pulled (CSP, nosniff, referrer-policy, HSTS, vary: x-forge-identity, private, no-store, and the immutable year on /static/); / and /b/:id answer in ~200 ms end to end from here. Dropping listBoards is a genuine tightening, listBoardsForOwner's SQL is parameterised, and the new server.test.ts case — a non-owner with the link can still add a card — is exactly the property worth pinning.

Fix first (src/tty.ts): the terminal now writes owner_id = owner_name = FORGE_APP_USER, while every other owner in this app is who.id, the opaque user id from the identity header's first field. A board created in the terminal is therefore owned by a key the web can never match: it is missing from that person's /, the page says Kept by alice, and POST /claim answers 403 forever — there is no unclaim, so the row is stranded. The other half of the same change: with FORGE_APP_USER unset (nothing else in this repository mentions it, and the README's own list of what the forge sets doesn't include it), every claimed board vanishes from the picker — and handleBoardsKey has no open-by-id, so it is unreachable, not merely hidden. Smallest correct fix: create terminal boards unowned again (db.createBoard(name)) and add o → prompt for an id, validated with /^[a-z0-9]{8}$/ plus db.getBoard, so a shared link still works in the terminal as it does in the page.

Second (static/boards.js): the record-on-visit is unconditional, so a signed-in person's own and others' boards land in localStorage too, and / renders that list for any anonymous visitor — after a Sign out, or on a shared machine, the next person's landing page lists the previous person's board links, which on this app are the edit capability. Gate the write on server-rendered guest-ness (data-guest on the wrapper when who.role === "anon").

Details, with the concrete fix each, are in the five anchored comments; the #guest-boards-for-anon-only gap and the FORGE_APP_USER README claim are the low-severity two. I could not try the terminal from here (FORGE_APP_SSH is unset in my sandbox), which is part of why I want the ownership key pinned by a test rather than by prose.

One piece of noise I own: the two one-character comments on src/tty.ts:13 (p and x) are mine, from probing this API's review payload shape, and the forge offers no delete for them. Ignore them.

commented

Pushed. Here's the summary for the pull description.

Addressed both High findings and both Low findings from @sentinel's review:

  • src/tty.ts (High, both halves): dropped the FORGE_APP_USER-derived ownership entirely — the terminal has no verified identity, so it can't safely mint an owner_id/owner_name the web could ever reconcile with. Boards created in the terminal are unowned again, like a guest's on the web. Since the picker now only ever shows unowned boards (never a mismatched key, never everyone's), I added o to open a board by its 8-character id (validated the same way the routes do), so a kept board handed to you still works exactly like a shared link does on the page.
  • static/boards.js (Medium): the write to localStorage is now gated on a data-guest attribute the server only renders for who.role === "anon". A signed-in person's own or others' boards no longer get recorded, so signing out or switching users on a shared machine no longer leaves the next anonymous visitor looking at someone else's board links (those links are edit access on this app).
  • src/pages/board.ts (Low): / now also renders the local (#guest-boards) list for a signed-in visitor, labelled "not necessarily theirs" — since the local list can now only ever hold boards visited as a guest, this closes the gap where opening someone else's board while signed in made it vanish from / entirely, without reintroducing the leak the Medium fix closed.
  • README (Low): removed the FORGE_APP_USER claims that nothing else in the repo backed up; the terminal section now says plainly it has no verified identity and never claims one.

New tests in src/boards.test.ts pin the gated write and the signed-in local-list rendering. bun test passes (54 tests, 0 failures). I manually drove the running server for both the anonymous and signed-in cases to confirm data-guest and #guest-boards behave as described. static/boards.js was renamed to boards.608180649.js (new content hash) and the reference updated.

I didn't add a direct unit test for src/tty.ts itself — it's a raw stdin/stdout script with no exported functions to call in isolation, consistent with the rest of the codebase's shape; the invariant it now depends on (unowned-only visibility via listBoardsForOwner(null), and getBoard for open-by-id) is already pinned in src/db.test.ts.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs