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

Boards: saved boards as files in forge/boards — a grid of panels with a time range and auto-refresh; make, rename, duplicate, reorder, resize, delete #1785

opened this

Merged 50d 22h ago, live in production

This pull adds the missing API half of #1575: boards can now be listed, read, written and deleted over /api/v1/boards.

Notes

opened this

This pull adds the missing API half of #1575: boards can now be listed, read, written and deleted over /api/v1/boards. Most of the rest was already on main from #1767: the JSON files in forge/boards, /boards and /boards/:slug, and the make, rename, duplicate, reorder, resize and delete forms with their board.saved / board.deleted events. They also include the live-region auto-refresh and the three-panel save-and-reload test. The board tests pass. bun x tsc --noEmit couldn't run here because the bun type definitions aren't installed, so the type check is left to the forge's check.

What changed

  • API routes: GET /api/v1/boards, GET /api/v1/boards/:slug, PUT /api/v1/boards/:slug (makes the board if new, replaces it if present) and DELETE /api/v1/boards/:slug.
  • Access: an agent gets 403, a signed-in non-admin gets 404, and a signed-out caller gets 401. A read-only token cannot write.
  • Validation and commits: a write goes through the same save as the forms, so a panel whose query can't run is refused with 422 before any commit. Each write is one commit and emits a board.saved event, or board.deleted for a delete. A new action, writeBoard in src/actions/boards.ts, backs this.
  • Reserved slugs: sources and query can no longer be board slugs, joining data, so /api/v1/boards/sources and /api/v1/boards/query keep working. A title that slugs to one of these gets -board appended.
  • Tests: new cases in test/boards-store.test.ts cover write, list, read, update and delete over the API. A query that fails parseQuery is refused on write. A hand-pushed file with a bad query is drawn as an error panel on read and the board still loads. The access doors and the reserved slugs are tested too.
  • README: the Boards paragraph now mentions the API.

Left out

  • Web agent status: the web pages still answer an agent with 404, as #1767 does. Only the API says 403. I didn't change #1767's behaviour.
  • No new dependency.

Try it

  • Run bun test test/boards.
  • Or, as an admin who is a person, PUT /api/v1/boards/my-board with a JSON board body, then open /boards/my-board.

🤖 Generated with Claude Code

Closes #1575

commented

Both fixes are pushed. The board tests (57) and the type check pass. I didn't run the rest of the suite; the forge's check does that.

  • PUT crash and query fan-out: save() in src/actions/boards.ts now runs parseBoard first and returns { refused } when it fails. runQuery then runs only over the parsed panels. A body like {"panels":{}}, [null], 25 panels, or a bare array now gets a 422 and no commit, and the 24-panel cap is enforced before any query runs. This also covers the forms, rename, duplicate and pin, since they all go through save(). The new test in test/boards-store.test.ts PUTs those bodies and checks the 422, that no board file exists afterwards, and that the board count is unchanged. I did not run the test against the old code to confirm it fails there.
  • One door: I removed boardsDoor. All /api/v1/boards routes now use boardsAdmin, so a non-admin or an agent gets 403 and a stranger gets 401. Writes and deletes also go through requireAccount(adminToken), as /query already does. I chose 403 because sources and query already had tests expecting it, so those didn't change. The board-route tests that expected 404 for a non-admin now expect 403.
  • Not in this pull: there is no MCP boards tool and no src/tui boards screen. The direction asks for both, but each is a separate surface to build, so I left them out. I couldn't open issues from this run; they still need to be filed.
commented

The full gate on land was red and named no test; the pull is open again.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs