Repository navigation
feat(collections): bulk edit and undo (issue #86) - #110
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 staysappend-only and every change remains reversible exactly once.
revision.batch_idandrevision.undo_ofplus an index on(collection_id, batch_id). The runner now accepts strictly-increasing versions instead ofcontiguous ones, so a branch that skips a step another branch owns still boots; the list is
contiguous again at
[1, 2, 3].bulkUpdate,undoBatch,batches): one transaction, every check before anywrite. An unknown row, a stale
base_updated_at, a bad value or an empty patch fails andchanges nothing. Conflicts answer
409with{row_id, title, current}flat in the body.dry_runvalidates through a rollback sentinel and reportswould_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).POST /api/v1/databases/:id/rows/bulkandPOST /api/v1/databases/:id/rows/bulk/:batchId/undo. 256 KB body cap, 500-row cap.bulk_update_collection_rows,undo_collection_batch, and abatch_idfilter oncollection_history. The tool list grows from 29 to 31.(
?bulk=1), a Saved notice with Undo bulk change, and a Recent bulk changes list withone Undo button per batch. Titles stay out of the picker. Gated by
COLLECTIONS_UI_WRITE=1like single-row editing; the actor is
web-ui.Evidence
Acceptance walk against a copy of the live instance (
SOURCE_SPACE/SOURCE_DB, markerrows 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.The feature in the running app (built server,
COLLECTIONS_UI_WRITE=1, scratch instance):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
mkdtempfixtures, never the livedatabase. Suite: 531 passed | 1 skipped.
npm run check0 errors / 0 warnings,npm run buildsucceeds.
Notes for the reviewer
validate()insrc/lib/server/migrations.tsrelaxed from contiguous to strictly-increasingversions. 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 thecollections this instance actually has (Dienste, Fixkosten, Wunschliste).