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

Undo on a new board deletes the columns it came with: a board's setup is not an undoable change #107

open not picked up yet opened this
opened this

Stop a fresh board's own setup from sitting in the undo log: pressing Undo on a board nobody has changed should do nothing, not delete the columns it came with.

What it is like today. Measured on main at b74399a, locally, against a booted copy:

POST /boards            -> board with ["To do", "Doing", "Done"]
POST /b/<id>/undo       -> ["To do", "Doing"]        # "Done" is gone
POST /b/<id>/undo x2    -> []                        # an empty board
POST /b/<id>/undo       -> {"ok": false}             # now there is nothing to undo

The cause is one line of reuse: createBoard builds its three defaults by calling createColumn (src/db.ts:158), and createColumn logs { deleteColumnIds: [id] } for undo (src/db.ts:245). So every new board starts with three undo entries that no person made, and on a board people share the first press of Undo silently destroys a column and every card anyone had put in it (the column delete cascades; those cards are not in that action row, so a second Undo does not bring them back).

Done looks like

  • [ ] A board created with its default columns has an empty undo log: undo(board.id) on an untouched board returns false and the board still has its three columns.
  • [ ] The defaults are still created by the same code path — no duplicated INSERT — with logging suppressed for setup (an internal argument to createColumn, or a small private helper both paths use). Whatever the seam, it is not reachable from a route.
  • [ ] The first real change is the first thing Undo takes back: add one card to a new board, press Undo once, the card is gone and all three columns are still there.
  • [ ] Tests in src/db.test.ts that fail without the change: (a) fresh board → undo is false and listColumns still has three; (b) fresh board + one card → one undo removes the card and leaves the columns.
  • [ ] Nothing else moves: bumpRevision(BOARDS_SCOPE) on create, the column.added event on a real column add, and the Undo button's behaviour on a board with history are all unchanged.
  • [ ] If any existing test only passes because of the three phantom entries (the MAX_UNDO_DEPTH trim test is the one to re-read), fix the test and say in the pull that it was asserting a bug.

Files I expect to change

src/db.ts (createBoard, createColumn), src/db.test.ts. The README's undo paragraph only if it counts entries.

Risks

  • #43 is in flight and rewrites every logAction call site to carry a human label. This change deletes one of those call sites; whichever lands first, the other is a one-line merge — no need to wait, just rebase and say so.
  • Suppressing the log too widely would make a real "Add column" un-undoable. The test for a logged column add already exists; keep it green.

Suggested: scout.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs