In a single-user kanban board web app, what should enter the undo history, where should it live, and how does undo meet changes the server already saved?
answer
- intents, not every state change
- field, panel or board scope
- history held by the shell, per board
- undo is a new write
- a reversal can fail too
basics
~20 sRecord intents that change the board, such as moving, creating or editing a card, never selection or filters. Keep one board-scoped history in shell-held memory, leave typing to the field's own undo, and reverse saved changes with a new write.
solid answer
~50 sUndo history should hold **intents that change the board**: a card moved from column A to column B, a card created or deleted, a title edit committed. Selection, filters and an opened side panel are view state and stay out. Scope is layered: while the user types in a card's description, undo belongs to that field; once the edit is committed it becomes one board-level entry. The board history lives in **shell-held memory, keyed by board**, so it survives opening and closing the side panel but not a reload, and that loss is stated as product behaviour. Because every change was already saved, undo is a **new write** that reverses it, not a rewind of local state; it can fail if the card changed elsewhere, and then the entry is dropped and the user told. Undoing a delete needs a recoverable delete on the server.
go deeper
Recall that undo should reverse the user's actions, such as moving a card, not things like selecting a card or opening a panel.
Explain the layered scopes: a text field's own undo while typing, then one board-level entry per committed change, held by the shell and keyed by board.
Show that undo of a saved change is a new compensating write that states what it expects, can fail, and needs a recoverable delete on the server to restore a card.
Weigh persisting history across reloads against re-validating every stale entry, and agree with the back end which operations are reversible at all.
## What counts as an undoable action In a **single-user kanban board** a user moves cards between columns, creates and deletes cards, and edits a card's title and description in a side panel. Undo history is a list of things the user can reverse, newest first. The first design decision is what goes in it. Put in **intents that change the board's data**: - moving a card (from column and position, to column and position); - creating or deleting a card; - committing an edit to a card's title, description or due date; - bulk actions, such as archiving a whole column, as **one** entry. Keep out **view state**: - selecting a card, opening or closing the side panel; - filtering by assignee, collapsing a column, scrolling. If view state enters history, the undo shortcut starts closing panels and clearing filters, and the user's real last action sits several presses away. ## Scope: field, panel or board | Scope | Covers | Lives | Hands over when | |---|---|---|---| | **Text field** | keystrokes inside one input | the browser's own editing undo for that field | the edit is committed | | **Side panel** | uncommitted changes to one card's fields | the panel's local state | the panel saves or is cancelled | | **Board** | committed intents on this board | an app-level history held by the shell, keyed by board id | reload, sign-out, or a cap on its length | The rule users expect is **innermost focus wins**: while the cursor is in the description field, the shortcut reverses typing; after the edit is committed it is one board entry, "edit description of card 12". Mixing them, so that the shortcut inside a text field moves a card back, is the most visible undo bug. ## Where the history lives - **Shell-held, not route-keyed.** Opening and closing the side panel, or switching between board and list views of the same board, must not wipe it. - **Keyed by board.** Switching to another board shows that board's history, or none; undo never reverses a move on a board the user is not looking at. - **Not in the address.** History is not a place to link to, and it can be long. - **Usually not persisted.** Surviving a reload would mean persisting intents and re-validating every one against server state that may have moved on. Most products accept losing history on reload and say so. A capped length bounds memory. How each entry captures enough to reverse itself, as an operation or as a snapshot, is the job of the command and memento patterns; the design decision here is the scope and the home. ## Undo after the server saved Every move was saved when it happened. Undo therefore cannot just restore old local state; the server would put the move back on the next fetch. The steps: 1. Read the newest entry and build its **reverse intent**: move card 12 back to column A, position 3. 2. Apply it locally at once, like any other change, and send it as a **new write**. 3. On success, move the entry to the redo list. 4. On failure, revert the local reversal, drop the entry, and tell the user why. Reversals fail for real reasons even with one user: the same board edited from another device or tab, a column deleted meanwhile, a card moved since. The reverse write should state what it expects ("card 12 is currently in column B") so the server can refuse rather than overwrite a newer change. **Deletion** needs a server design: if delete is final, undo can only create a new card with a new id, breaking links and comments. A recoverable delete, kept for a short window, lets undo restore the same card. That is a contract decision made with the back end before the feature ships. ## Mistakes to avoid - Recording every state change, including selection and filters. - One global history across boards, so undo silently changes a board off screen. - Undo as a local rewind that the next refetch reverses. - Assuming a reversal cannot fail. - A final delete with an undo button that cannot really restore. Multi-user boards change the problem entirely: undo then reverses only the user's own operations amid others' edits, which is a collaborative-editing design.
- The user drags a card, then quickly drags it again before the first save returns. What enters history?Two entries, one per drag, in order; undo reverses the second first. The reverse write for the second must expect the card where the second drag put it. If the first save then fails, the board reverts that move and drops its entry, and the second entry's reverse must be checked against the corrected position before it is offered.
- Should redo survive a new action?Common practice clears the redo list when the user performs a new action after undoing, because the redo entries describe a future that no longer follows from the current board. Keeping them would let redo apply a move against state it was never computed for.
An accountant never erases a posted ledger entry; a mistake is reversed by posting a new correcting entry, and the correction can itself be refused if the account has changed since.
- Puts selection, filters and panel opening into the undo history
- Implements undo of a saved move by restoring the previous local board snapshot only
- Keeps one undo history across every board in the app
- Assumes reversing a saved change cannot fail
- Offers undo for a delete the server has already made final