feat: Notion-style implicit toggle body + debounced saves - #2
Merged
Merged
Conversation
- toggle body is now implicit: everything under a title down to the next toggle (or EOF) collapses; ledger maintains only title lines (shift / re-anchor / dedupe), removing the boundary bug class - title-touching edits re-anchor instead of dropping the toggle - saves coalesced to 1/sec (was full-canvas write per keystroke), flushed synchronously on quit/Clear/terminate
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d50547b. Configure here.
|
|
||
| func textDidChange(_ notification: Notification) { | ||
| saveContent() | ||
| scheduleSave() |
There was a problem hiding this comment.
Toggles persist ahead of notes
High Severity
textDidChange still writes toggles.json on every edit while notes.txt is deferred by up to one second via scheduleSave. If the process exits before a flush (crash, force quit, kill), disk toggles match the live buffer but the canvas file does not, so reload pairs stale text with shifted title-line metadata.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d50547b. Configure here.
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.


Verified: 8 new-model ledger replica cases + full headless suite. Root-cause trail in docs/FAILURE_LOG.md (2026-07-21).
Note
Medium Risk
Toggle fold/containment logic is substantially reworked (data loss risk if debounced save isn’t flushed before a hard kill); debounced saves are mitigated by flush on normal quit/terminate.
Overview
Toggle lists now match Notion’s container model:
bodyEndLineis removed fromToggleEntry, and collapse covers everything under a title until the next toggle’s title or EOF viabodyEnd(forToggleAt:). Create/remove/flip, fold rendering, caret containment, and context menu all use that implicit range; nested toggles split at a new title instead of flattening overlaps.The edit ledger only tracks title lines—shift when edits are at/above the title, re-anchor when the title line is edited (instead of dropping the toggle), dedupe duplicate title lines. Legacy
toggles.jsonwithbodyEndLinestill decodes.Canvas persistence no longer writes on every keystroke:
scheduleSave()debounces to once per second;flushSave()runs on Clear, Quit, andapplicationWillTerminate.docs/FAILURE_LOG.mddocuments the implicit-body model, re-anchoring, and performance fix.Reviewed by Cursor Bugbot for commit d50547b. Bugbot is set up for automated code reviews on this repo. Configure here.