Repository navigation
Conversation
The editor's "+ Create" autocomplete called state::create_page, which moved CURRENT_PAGE to the new empty page; nothing moved it back, so the editor closed on the wrong page and the draft, including the link being inserted, was lost. Split create_page into add_page (adds the page, returns its id, no navigation) and create_page (add_page + open it). The autocomplete uses add_page, so CURRENT_PAGE and EDITING never change and the seeding effect leaves the edited buffer alone. The new id comes from add_page rather than next_page_id - 1, which was wrong when nothing was added. Also make the keyboard Enter/Tab path index into the same candidate list the dropdown renders. It rebuilt the list without excluding the current page, so the highlighted row and the inserted link could differ. Closes #68 Claude-Session: https://claude.ai/code/session_01GKBuAzByqMPegsXcUYJb7h
- Replace the u64::MAX "create" sentinel with a LinkTarget enum, and route both the mouse and keyboard picks through insert_link_target so the tests exercise the real dispatch. The keyboard row -> target mapping is now a pure, unit-tested selected_link_target. - Check for an open [[query before creating anything, so a stale cursor cannot leave an orphan page; refuse a span containing ]] or a newline, matching update_autocomplete, so a stale cursor cannot overwrite a finished link. - Test: the draft survives the delegate's signed copy of the new page landing in SITES, plus the usual positive control. - Point AGENTS.md's page-order invariant and allocation comments at add_page, which now owns id and order allocation. Claude-Session: https://claude.ai/code/session_01GKBuAzByqMPegsXcUYJb7h
Also tighten selected_link_target's doc to say the Create row is only reachable when rendered, and rewrap add_page's doc comment. Claude-Session: https://claude.ai/code/session_01GKBuAzByqMPegsXcUYJb7h
selected_link_target now takes the shown Create row's title (or None) and only maps the index just past the page rows to it, so a stale ac_selected cannot create a duplicate from a hidden row. The #68 test no longer edits the title, so content survival is pinned on its own. Claude-Session: https://claude.ai/code/session_01GKBuAzByqMPegsXcUYJb7h
sanity
added a commit
that referenced
this pull request
Oct 15, 2026
Published from main at 240565c (includes #101 and #103). Claude-Session: https://claude.ai/code/session_01GKBuAzByqMPegsXcUYJb7h
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.
Problem
In the editor, picking "+ Create ..." from the
[[autocomplete calledstate::create_page, which setsCURRENT_PAGEto the new page. The handler then setEDITING = false("switch back to the page we were editing") but never restoredCURRENT_PAGE, so the user landed on the new empty page and the draft, including the link just inserted, was thrown away (#68).Approach
state::create_pageis split intoadd_page(adds the page and returnsSome(id), does not navigate, and changes nothing when it returnsNone) andcreate_page(add_pageand then open it in the editor). The sidebar's "+ New Page" still usescreate_page. For non-owners,create_pageis now a no-op. Before, it pointedCURRENT_PAGEat a page that didn't exist, but the button is owner-only anyway.insert_link_target(LinkTarget, pos), which replaces theu64::MAXsentinel. ForNewit usesadd_page, soCURRENT_PAGEandEDITINGnever change. The seeding effect from fix(ui): stop the editor re-seeding over an in-progress edit #64 sees the same page identity and a buffer that no longer matches what it seeded, so it leaves the draft alone.add_page's return value. The oldnext_page_id - 1was wrong when no page was added.[[querybefore the cursor is checked before creating anything, so a stale cursor can't leave an orphan page. The query span is rejected if it contains]]or a newline, the same ruleupdate_autocompleteuses.selected_link_target.AGENTS.md's page-order invariant and the allocation comments now nameadd_page, which owns id and order allocation.Testing
VirtualDomtests ineditor.rs(reseed_tests) mount the realEditor:creating_a_page_from_autocomplete_keeps_the_draft_and_the_linkchecks that the editor stays on page 1 and stays open, and that the buffer isintro [[<new id>]] and the restwith the retitle kept. The draft also survives ahandle_signed_page-shaped replacement of the new page in SITES. There is a positive control showing the seeding effect is live. Mutation-checked: making the create branch moveCURRENT_PAGEagain makes the test fail...._on_a_site_we_do_not_own_changes_nothingchecks that no page is added, no link is inserted, andCURRENT_PAGEis unchanged.create_page_still_opens_the_new_page_in_the_editorguards the sidebar path.selected_link_target: maps a row index to a page or to the Create row.splice_link: covers a stale or mid-multibyte cursor, a closed link, and a newline.selected_link_target, using the sameVecthe dropdown iterates.cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo test(delta-ui: 248 passed), and thewasm32check.Review
Light tier with two lenses (skeptical, code-first). The first pass found nothing blocking. Its should-fix findings were the untested dispatch and keyboard path, the untested delegate-response path, the orphan page on a stale cursor, and the stale
AGENTS.mdand comments. All are addressed in be9bfd9, and that head has been re-reviewed.This is a UI-only change, so the contract and delegate WASM are untouched. It needs a Delta UI republish to reach users.
Closes #68
[AI-assisted - Claude]
https://claude.ai/code/session_01GKBuAzByqMPegsXcUYJb7h