Skip to content

fix: convert-page-to-tag autocomplete entry does nothing - #13392

Merged
tiensonqin merged 4 commits into
masterfrom
devin/1790161960-fix-convert-page-to-tag
Sep 24, 2026
Merged

tiensonqin merged 4 commits into
masterfrom
devin/1790161960-fix-convert-page-to-tag

Conversation

@tiensonqin

@tiensonqin tiensonqin commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

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 from fe65e36f13 (remove ui db):

  1. :convert-page-to-tag? lives only on the raw autocomplete entry (set in components/editor.cljs), but <chosen-result replaces it with a fetched entity snapshot before the flag is checked — so convert-page-to-tag! never ran.
  2. Even where the flag survived, (entity/class? chosen-result) read the pre-conversion snapshot, so class? was false and insert-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 so class? sees the post-conversion :block/tags (:logseq.class/Tag). This mirrors the pre-refactor flow, which re-read the entity after convert-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): choosing Convert "beforepage" to tag inserted literal #beforepage text, added no tag, and left beforepage a plain page — it also spawned a separate same-named # beforepage tag entity (two beforepage entries in Recent).

After: choosing Convert "afterpage" to tag removed the typed text, tagged the block with # afterpage, and converted the page itself into the # afterpage tag.

Before 🔴 After 🟢
before: literal #beforepage text, page unconverted after: # afterpage tag pill on block
before recording after recording
Page-level proof (unconverted Page vs converted Tag)

beforepage still a plain page
afterpage converted to # afterpage 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


Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed in 02f6c3f. The handler now re-resolves the entity after convert-page-to-tag! anyway (needed for the stale-snapshot fix), so it detects the rejected-conversion case — the entity still being a Page — and skips both insert-command! and tag-on-chosen-handler, leaving the typed #... text untouched alongside the error notification. Added hashtag-convert-page-to-tag-rejected-keeps-editor-text-test covering this path.

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed in b8e35ba — applied the suggested restructure: the accepted path returns the p/do! chain (focus moved inside it) so insertion/tagging rejections still propagate, and the rejected branch just refocuses the input.

@tiensonqin
tiensonqin force-pushed the devin/1790161960-fix-convert-page-to-tag branch from 3117d0d to 43a59cb Compare September 23, 2026 13:13
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1790161960-fix-convert-page-to-tag branch from 43a59cb to e3307cd Compare September 23, 2026 13:16
@tiensonqin
tiensonqin force-pushed the devin/1790161960-fix-convert-page-to-tag branch from e3307cd to 7b184dc Compare September 23, 2026 14:38
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1790161960-fix-convert-page-to-tag branch from 7b184dc to db7f92a Compare September 23, 2026 17:57
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Re-verified on the rebased branch (dev app, DB graph): typing #convtestpage offers the convert entry, selecting it removes the typed text, tags the block, and the page itself becomes a tag listing the tagged block.

Autocomplete entry After selection Converted tag page
convert entry shown block tagged with #convtestpage # convtestpage tag page

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.
@tiensonqin
tiensonqin force-pushed the devin/1790161960-fix-convert-page-to-tag branch from db7f92a to 28fa87e Compare September 24, 2026 17:42
@tiensonqin
tiensonqin merged commit 0b91290 into master Sep 24, 2026
4 of 10 checks passed
@tiensonqin
tiensonqin deleted the devin/1790161960-fix-convert-page-to-tag branch September 24, 2026 17:42
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 1, 2026
* 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.
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
* 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.
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
* 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.
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.

bug: tagging via autocomplete "convert page to tag" inserts #[[<class-uuid>]] instead of a tag (regression from fe65e36f13)

1 participant