Repository navigation
fix: convert-page-to-tag autocomplete entry does nothing - #13392
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Fixed in 02f6c3f. The handler now re-resolves the entity after |
|
Fixed in b8e35ba — applied the suggested restructure: the accepted path returns the |
3117d0d to
43a59cb
Compare
43a59cb to
e3307cd
Compare
e3307cd to
7b184dc
Compare
7b184dc to
db7f92a
Compare
The convert-page-to-tag? flag lives on the raw autocomplete entry, but <chosen-result replaces it with a fetched entity snapshot before the conversion check, so the flag was always nil and the conversion never ran. Even when the flag survived, entity/class? read the pre-conversion snapshot so the block was never tagged. Bind the flag before resolving, run the conversion, then re-resolve the entity so class? reflects the post-conversion state. Fixes logseq/db-test#1270
convert-page-to-tag! resolves without converting for duplicate tags, namespaced pages, and built-ins. After such a rejection the handler still rewrote the typed hashtag (e.g. #Projects/Alpha -> #Alpha) while the notification said the conversion failed. Gate the insert/tagging continuation on the re-resolved entity actually being a class.
Focus the rejected-conversion branch instead of running the p/do! chain last so accepted conversions still propagate insertion/tagging rejection.
Extract the stub setup into install-convert-page-to-tag-stubs! (delegating to install-hashtag-on-chosen-stubs!) so each test stays under the large-vars line limit.
db7f92a to
28fa87e
Compare
* fix: convert-page-to-tag autocomplete entry does nothing The convert-page-to-tag? flag lives on the raw autocomplete entry, but <chosen-result replaces it with a fetched entity snapshot before the conversion check, so the flag was always nil and the conversion never ran. Even when the flag survived, entity/class? read the pre-conversion snapshot so the block was never tagged. Bind the flag before resolving, run the conversion, then re-resolve the entity so class? reflects the post-conversion state. Fixes logseq/db-test#1270 * fix: don't rewrite editor text when page-to-tag conversion is rejected convert-page-to-tag! resolves without converting for duplicate tags, namespaced pages, and built-ins. After such a rejection the handler still rewrote the typed hashtag (e.g. #Projects/Alpha -> #Alpha) while the notification said the conversion failed. Gate the insert/tagging continuation on the re-resolved entity actually being a class. * fix: keep insert/tag promise as the selection result Focus the rejected-conversion branch instead of running the p/do! chain last so accepted conversions still propagate insertion/tagging rejection. * test: share hashtag selection stub helpers for convert-page-to-tag tests Extract the stub setup into install-convert-page-to-tag-stubs! (delegating to install-hashtag-on-chosen-stubs!) so each test stays under the large-vars line limit.
* fix: convert-page-to-tag autocomplete entry does nothing The convert-page-to-tag? flag lives on the raw autocomplete entry, but <chosen-result replaces it with a fetched entity snapshot before the conversion check, so the flag was always nil and the conversion never ran. Even when the flag survived, entity/class? read the pre-conversion snapshot so the block was never tagged. Bind the flag before resolving, run the conversion, then re-resolve the entity so class? reflects the post-conversion state. Fixes logseq/db-test#1270 * fix: don't rewrite editor text when page-to-tag conversion is rejected convert-page-to-tag! resolves without converting for duplicate tags, namespaced pages, and built-ins. After such a rejection the handler still rewrote the typed hashtag (e.g. #Projects/Alpha -> #Alpha) while the notification said the conversion failed. Gate the insert/tagging continuation on the re-resolved entity actually being a class. * fix: keep insert/tag promise as the selection result Focus the rejected-conversion branch instead of running the p/do! chain last so accepted conversions still propagate insertion/tagging rejection. * test: share hashtag selection stub helpers for convert-page-to-tag tests Extract the stub setup into install-convert-page-to-tag-stubs! (delegating to install-hashtag-on-chosen-stubs!) so each test stays under the large-vars line limit.
* fix: convert-page-to-tag autocomplete entry does nothing The convert-page-to-tag? flag lives on the raw autocomplete entry, but <chosen-result replaces it with a fetched entity snapshot before the conversion check, so the flag was always nil and the conversion never ran. Even when the flag survived, entity/class? read the pre-conversion snapshot so the block was never tagged. Bind the flag before resolving, run the conversion, then re-resolve the entity so class? reflects the post-conversion state. Fixes logseq/db-test#1270 * fix: don't rewrite editor text when page-to-tag conversion is rejected convert-page-to-tag! resolves without converting for duplicate tags, namespaced pages, and built-ins. After such a rejection the handler still rewrote the typed hashtag (e.g. #Projects/Alpha -> #Alpha) while the notification said the conversion failed. Gate the insert/tagging continuation on the re-resolved entity actually being a class. * fix: keep insert/tag promise as the selection result Focus the rejected-conversion branch instead of running the p/do! chain last so accepted conversions still propagate insertion/tagging rejection. * test: share hashtag selection stub helpers for convert-page-to-tag tests Extract the stub setup into install-convert-page-to-tag-stubs! (delegating to install-hashtag-on-chosen-stubs!) so each test stays under the large-vars line limit.
Summary
Fixes logseq/db-test#1270 — choosing the autocomplete's "Convert
<page>to tag" entry did nothing at HEAD: the page was not converted and#<name>was inserted as plain text.Two related defects in
tag-on-chosen-handler(src/main/frontend/handler/page.cljs), both fromfe65e36f13(remove ui db)::convert-page-to-tag?lives only on the raw autocomplete entry (set incomponents/editor.cljs), but<chosen-resultreplaces it with a fetched entity snapshot before the flag is checked — soconvert-page-to-tag!never ran.(entity/class? chosen-result)read the pre-conversion snapshot, soclass?wasfalseandinsert-command!wrote#<name>/#[[uuid]]text instead of tagging the block.Fix: bind
convert-page-to-tag?before resolving, run the conversion, then re-resolve the entity soclass?sees the post-conversion:block/tags(:logseq.class/Tag). This mirrors the pre-refactor flow, which re-read the entity afterconvert-page-to-tag!.Rejected conversions (duplicate tag, namespaced page, built-in) are detected via the re-resolved entity still being a
Page— the handler then skips rewriting the typed text and tagging, leaving the editor untouched alongside the error notification.Adds regression tests covering both the accepted path (
hashtag-convert-page-to-tag-uses-post-conversion-snapshot-test) and the rejected path (hashtag-convert-page-to-tag-rejected-keeps-editor-text-test).Evidence (dev app, DB graph)
Before (pre-fix
page.cljs): choosingConvert "beforepage" to taginserted literal#beforepagetext, added no tag, and leftbeforepagea plain page — it also spawned a separate same-named# beforepagetag entity (twobeforepageentries in Recent).After: choosing
Convert "afterpage" to tagremoved the typed text, tagged the block with# afterpage, and converted the page itself into the# afterpagetag.Page-level proof (unconverted Page vs converted Tag)
Link to Devin session: https://app.devin.ai/sessions/04521b24a0ff48e183db4e1e675d8ddc
Open in Devin Desktop: https://app.devin.ai/desktop/session/04521b24a0ff48e183db4e1e675d8ddc?variant=devin
Requested by: @tiensonqin