Make note / move block: address blocks by a stable anchor, not a line number #80

Closed
opened 2026-10-13 21:41:21 +00:00 by kayg · 1 comment
Owner

notes.make-note and notes.move-block take {line, to_line}. The web app (PR #79 and its follow-up) waits until the server has every change typed on this device, then sends the block's line numbers.

The gap: another device (or an outside edit to the file) can change the note between that wait and the server running the job. Lines above the block shift, and the job takes the wrong block: the wrong text is made into a note or moved to another note. Undo can take it back, but the person may not notice.

Wanted:

  • Address the block by a stable anchor: a Yjs relative position from the client's document, or the block's ^id.
  • Also send the text the client saw (or its hash).
  • The server resolves the anchor in the current document and refuses (a clear error, nothing changed) if the anchor's text no longer matches. The app then says "The note changed. Try again." and changes nothing.
  • A test: two clients, one inserts lines above the block while the other runs make-note; the right block moves, or the request is refused.

Until then the line numbers are only as fresh as the last sync.

🤖 Generated with Claude Code

https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T

`notes.make-note` and `notes.move-block` take `{line, to_line}`. The web app (PR #79 and its follow-up) waits until the server has every change typed on this device, then sends the block's line numbers. **The gap:** another device (or an outside edit to the file) can change the note between that wait and the server running the job. Lines above the block shift, and the job takes the wrong block: the wrong text is made into a note or moved to another note. Undo can take it back, but the person may not notice. **Wanted:** - Address the block by a stable anchor: a Yjs relative position from the client's document, or the block's `^id`. - Also send the text the client saw (or its hash). - The server resolves the anchor in the current document and **refuses** (a clear error, nothing changed) if the anchor's text no longer matches. The app then says "The note changed. Try again." and changes nothing. - A test: two clients, one inserts lines above the block while the other runs make-note; the right block moves, or the request is refused. Until then the line numbers are only as fresh as the last sync. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Author
Owner

PR #84 is green on both jobs.

  • Anchors: make-note and move-block point at a block by at (Yjs relative position) or block (^id), plus hash, and are refused with block_changed if the line moved under them. line still works for one release.
  • History: notes.history is added for the Info sheet.

The API is in the PR body.

PR #84 is green on both jobs. - **Anchors:** make-note and move-block point at a block by `at` (Yjs relative position) or `block` (`^id`), plus `hash`, and are refused with `block_changed` if the line moved under them. `line` still works for one release. - **History:** `notes.history` is added for the Info sheet. The API is in the PR body.
kayg closed this issue 2026-10-13 22:03:11 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal#80
No description provided.