Skip to content

fix: keep note order working after many drops into one place [20261121-renumber-note-positions-when-repeated] - #105

Merged
ttncode merged 2 commits into
mainfrom
fix/20261121-renumber-note-positions-when-repeated
Nov 21, 2026
Merged

ttncode merged 2 commits into
mainfrom
fix/20261121-renumber-note-positions-when-repeated

Conversation

@ttncode

@ttncode ttncode commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Topic: 20261121-renumber-note-positions-when-repeated

Change summary

  • Each drop or Alt+Up/Down step takes the midpoint of its neighbours' position. Positions start as millisecond timestamps (~1.7e12), so about 23 drops into one 1000 gap used up float precision: drop 24 landed in the wrong place. Notes that already shared a position could not be dropped between at all.
  • extension/model.js: placeNote checks the midpoint is strictly between its neighbours; if not, spacedOut re-spaces the section in its new order, 1000 apart, hanging down from the section's top note (so it stays on the timestamp scale), and returns renumbered: [{ id, position }].
  • extension/app.js: applyPlacement applies renumbered and saves those notes with the moved one in one persist call; their updatedAt is left alone.
  • tests/model.test.js: 4 tests — 40 drops under the top note, a drop between tied notes, renumbering stays in the pinned section, and an unpinned renumbered note lands by age.

Verify

step command result
unit node --test "tests/*.test.js" exit 0 · 218/218 pass · Node 22.17.1
regression renumber disabled 3 tests fail; restored → pass
review fix renumber spaced from 1000·n instead of the top note unpin test fails; fixed → pass

Verified: green, and the run describes the tree as it is now.

Note: npm test on main is still the old form until #103 merges.

Ship decision: GO

No open Critical or Important finding. 8 readers; 1 fix-now finding fixed (renumbering to 1000·n put a section on another scale, so unpin/pin/recover misplaced notes).

Things I didn't touch

  • No renumber test uses placement: "before" (code correct by reading).
  • applyPlacement in app.js is untested; app.js can't be imported in Node.
  • The duplicate Sprints note on import (audit item 4).

Release

20261121-renumber-note-positions-when-repeated — note order keeps working after many drops

Change

  • Fixed: dragging notes, or moving them with Alt+Up / Alt+Down, always lands them where aimed, even after many moves into the same place or between notes that share a place.

Before release

  • The change carries no migration and reads no new configuration value. (checked)
  • kiln verify ran the full unit suite: exit 0, 218 of 218 pass on Node 22.17.1. (checked)
  • The new tests fail with the renumber disabled (3 fail) and the scale fix undone (1 fails), and pass with both. (checked)
  • In the desktop app, dropping a note right under the top note 30 times keeps it second each time. (confirm)

Release steps

  1. Merge the pull request once CI is green.
  2. Ship it in the next release as usual.

After release

  • After updating, the notes list keeps its manual order, and pinning or unpinning a note still places it by age. (confirm)

Rollback

  • Trigger: notes reorder on their own, or a drop lands in the wrong place more often than before.
  • Steps: git revert the merge commit, then open and merge that pull request, then release.
  • Time: one revert pull request and one release. Positions already rewritten stay valid numbers, so the old code reads them.

Each drop takes the midpoint of its neighbours. Positions start as
millisecond timestamps, so about 23 drops into a 1000 gap used up its
precision and later drops landed in the wrong place; notes that already
shared a position could not be dropped between at all.

When the midpoint is not strictly between its neighbours, space the
section out again from its top note, so positions stay on the timestamp
scale that pinning, recovery and new notes rely on, and save the moved
notes together without touching their edit time.
This was referenced Nov 21, 2026
@ttncode
ttncode merged commit 45af8f8 into main Nov 21, 2026
1 check passed
@ttncode
ttncode deleted the fix/20261121-renumber-note-positions-when-repeated branch November 21, 2026 07:21
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.

1 participant