Skip to content

feat(collections): bulk edit and undo (issue #86) - #110

Merged
ssalentin merged 9 commits into
mainfrom
feat/is-86-bulk-undo
Nov 15, 2026
Merged

ssalentin merged 9 commits into
mainfrom
feat/is-86-bulk-undo

Conversation

@ssalentin

Copy link
Copy Markdown
Owner

Closes #86.

What

Multi-select bulk edit and undo for collection rows, end to end: store, REST, MCP and the UI.
A bulk change sets one or more properties to the same values across up to 500 named rows and is
one undoable batch. An undo is itself a batch whose revisions carry undo_of, so history stays
append-only and every change remains reversible exactly once.

  • Migration v3 adds revision.batch_id and revision.undo_of plus an index on
    (collection_id, batch_id). The runner now accepts strictly-increasing versions instead of
    contiguous ones, so a branch that skips a step another branch owns still boots; the list is
    contiguous again at [1, 2, 3].
  • Store (bulkUpdate, undoBatch, batches): one transaction, every check before any
    write. An unknown row, a stale base_updated_at, a bad value or an empty patch fails and
    changes nothing. Conflicts answer 409 with {row_id, title, current} flat in the body.
    dry_run validates through a rollback sentinel and reports would_update / would_undo.
    Undo re-checks that every row still holds what the batch wrote; a moved or deleted row is
    named in the same 409. A batch can only be undone once (batch_undone).
  • REST: POST /api/v1/databases/:id/rows/bulk and
    POST /api/v1/databases/:id/rows/bulk/:batchId/undo. 256 KB body cap, 500-row cap.
  • MCP: bulk_update_collection_rows, undo_collection_batch, and a batch_id filter on
    collection_history. The tool list grows from 29 to 31.
  • UI: tick column in table and card view, a bulk panel that also works without JavaScript
    (?bulk=1), a Saved notice with Undo bulk change, and a Recent bulk changes list with
    one Undo button per batch. Titles stay out of the picker. Gated by COLLECTIONS_UI_WRITE=1
    like single-row editing; the actor is web-ui.

Evidence

Acceptance walk against a copy of the live instance (SOURCE_SPACE / SOURCE_DB, marker
rows only, deleted again): dry run writes nothing, the batch lands as one, the undo restores
every cell byte-identical to the pre-batch snapshot, a second undo is refused, and a stale base
aborts with a 409 that names the row. Ends WALK COMPLETE.

collections-bulk-walk.sh against a copy of the live instance

The feature in the running app (built server, COLLECTIONS_UI_WRITE=1, scratch instance):

Bulk edit panel with three rows selected
Saved notice with the undo offer and the recent batches
After the undo: both batches listed, each row back to its own earlier value
Card view under 640px with the same selection and panel
Grouped view: three rows ticked across two groups, footer sum kept in its column

The grouped shot is post-rebase: it shows the tick column and the footer aggregate row of #85
working together with the selection of this branch.

Tests

28 new cases: 21 store, 4 REST, 2 MCP, and one migration case for the gap-tolerant runner (it
replaces the old non-contiguous-refusal test). All write under mkdtemp fixtures, never the live
database. Suite: 531 passed | 1 skipped. npm run check 0 errors / 0 warnings, npm run build
succeeds.

Notes for the reviewer

  • validate() in src/lib/server/migrations.ts relaxed from contiguous to strictly-increasing
    versions. Documented in docs/collections.md; a test pins the behaviour.
  • docs/release-1.0.md: workstream C is complete with this merge. The exit text now names the
    collections this instance actually has (Dienste, Fixkosten, Wunschliste).

Revision rows gain batch_id and undo_of for bulk edit and undo (issue #86).
The runner now requires strictly increasing versions instead of contiguity,
so parallel branches can carry their pre-assigned numbers with a temporary
gap. Fresh databases land at user_version 3.
A bulk change validates every row and every base_updated_at before writing,
aborts with a 409 that names the row, and records one revision per row under a
shared batch_id. undoBatch reverses a batch as a new batch carrying undo_of,
after checking that no row moved since; batches summarizes recent batches.
Dry runs report would_update / would_undo and write nothing.
POST /api/v1/databases/:id/rows/bulk applies one patch to many rows as one
batch; POST .../rows/bulk/:batchId/undo reverses it as a new batch. Both take
dry_run, both answer the batch id, and a conflict on any row aborts with a 409
that names the row.
Agents get the same bulk edit and undo as REST, plus a dry_run on both.
collection_history gained a batch_id filter and now returns batch_id and
undo_of, so an agent can find a batch and check whether it was undone.
Tick rows in table and card views, open the bulk panel (?bulk=1, JS-upgraded),
set one property for all ticked rows and land on ?saved=1&batch=ID, which
offers to undo the batch. A Recent bulk changes list under the rows undoes
any batch again. Row checkboxes join the panel form through form=bulk-form,
so the panel works without hydration; titles stay out of the property picker.
21 store cases (atomicity, dry runs, caps, named-row conflicts, undo chains,
deleted properties), 4 REST cases (bodies, aliases, the 409 payload) and 2 MCP
cases (tool results, history batch_id filter, error envelopes).
Boots the built server against a copy of a live instance (SOURCE_SPACE and
SOURCE_DB are required) and proves over REST: dry run writes nothing, bulk
edits three marker rows as one batch with one revision each, undo restores
byte-identical cells, a batch undoes only once, and a stale base_updated_at
aborts with a 409 that names the row. Only the walk's own marker rows are
ever written, and they are deleted again.
collections.md gets the API lines, the batch_id/undo_of revision columns, schema
version 3 and a Bulk edit and undo section with desktop, saved, undo and mobile
captures plus the new acceptance walk. tools.md lists the two new MCP tools and
collection_history's batch_id filter. release-1.0.md marks workstream C's bulk
bullet done.
… exit text

collections.md references the bulk-walk terminal capture in Verification and shows
that the tick column rides grouped views. release-1.0.md ticks the mobile card
bullet and names the live collections (Dienste, Fixkosten, Wunschliste) in
workstream C's exit text instead of databases this instance never had.
@ssalentin
ssalentin merged commit 0817dac into main Nov 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bulk edit and undo for collection rows

1 participant