Skip to content

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

Closed
logseq/logseq
#13392

Description

@e-zz

Search first

  • I searched and no similar issues were found

What Happened?

When you type #existing-page in a block, the autocomplete offers a "convert <page> to tag" entry. Choosing it does convert the page to a tag, but the text inserted into the block is the class uuid wrapped in page-ref brackets (#[[6ab39306-6831-432a-b488-641794461240]]) instead of a tag reference. The resulting text does not render as a tag, and the block is not tagged.

Expected: the page becomes a tag and the block is tagged with it, showing #@test rendered as a normal tag.

This looks like a regression from fe65e36f13 ("refactor: remove ui db", 2026-07-08), which removed the post-conversion entity re-read — see "Root cause" below.

Reproduce the Bug

  1. Create a page titled test.
  2. In some block, type # and let the page autocomplete appear; pick the entry "convert test to tag".
  3. Observe the inserted text.

Result: the block contains the literal text

#[[6ab39306-6831-432a-b488-641794461240]]

which does not render as a tag, and the block has no :block/tags pointing at the new class.

Expected Behavior

The inserted text should be #test (i.e. a tag reference), rendered as a tag, and the block should be tagged with the newly created tag class. Today the inserted text is an unreadable page-ref to a class uuid.

Root cause (read from source; regression identified via git history)

src/main/frontend/handler/page.cljs, tag-on-chosen-handler:

(p/let [repo (state/get-current-repo)
        chosen-result (<chosen-result repo chosen-result)          ; snapshot map, fetched BEFORE convert
        _ (when (and (:convert-page-to-tag? chosen-result)
                     (entity/page? chosen-result)
                     (not (entity/class? chosen-result)))
            (db-page-handler/convert-page-to-tag! chosen-result))  ; conversion runs here
        target (when (and (:db/id chosen-result) (not (entity/class? chosen-result)))
                 (db-async/<get-alias-source-page repo (:db/id chosen-result)))
        chosen-result (if (and target (not (entity/class? chosen-result)) (entity/class? target)) target chosen-result)
        chosen (:block/title chosen-result)
        class? (or (string/includes? chosen (str (t :editor/new-tag) " "))
                   (entity/class? chosen-result))                   ; reads the STALE pre-conversion snapshot
        ...
        (editor-handler/insert-command! id
                                        (if (and class? (not inline-tag?)) "" (str "#" wrapped-tag))
                                        ...)

<chosen-result (same file) resolves the selection to a plain map via :thread-api/pull, i.e. a snapshot. Because the conversion happens after that snapshot is taken and the map is never refreshed, (entity/class? chosen-result) still observes the pre-conversion tags (#{:logseq.class/Page}, no :logseq.class/Tag). class? therefore evaluates to false, so insert-command! inserts "#" + wrapped-tag instead of "", and the subsequent tag-on-chosen-handler (which is what would attach the timestamped tag) receives class? = false as well.

The previous implementation re-read the entity after converting, which the refactor removed:

;; before fe65e36f13:
(p/let [_ (when (:convert-page-to-tag? chosen-result)
            (let [entity (db/entity (:db/id chosen-result))]
              (when (and (ldb/page? entity) (not (ldb/class? entity)))
                (db-page-handler/convert-page-to-tag! entity))))
        chosen-result (if (:block/uuid chosen-result)
                        (db/entity [:block/uuid (:block/uuid chosen-result)])   ;; <-- re-read after convert
                        chosen-result)
        target (first (:block/_alias chosen-result))
        ...)

The fix is presumably to re-resolve chosen-result after convert-page-to-tag! resolves (e.g. re-pull by :block/uuid), so class? reflects the post-conversion state.

Note the conversion itself does succeed — convert-page-to-tag-tx (src/main/frontend/worker/handler/property.cljs) retracts :logseq.class/Page and adds :logseq.class/Tag on the same entity (same :block/uuid); only the editor-side text insertion is wrong.

Measured environment

  • Logseq 2.0.1 desktop, DB graph, Windows (merge-all-fixes tree, HEAD bb70c73d29; fe65e36f13 is an ancestor, so the regression is present at HEAD).
  • The inserted uuid resolves to a class entity (extends :logseq.class/Root, auto :db/ident), distinct from the pre-existing page entity. The inserted #[[<class-uuid>]] text is the defect reported here.

Files

No response

Browser, Desktop or Mobile Platform Information

Windows 11, Logseq desktop 2.0.1 (DB version), DB graph.

Additional Context

No response

Are you willing to submit a PR? If you know how to fix the bug.

  • I'm willing to submit a PR (Thank you!)

Activity

  1. e-zz commented on Sep 23, 2026

    @e-zz
    Author

    Adding two same-subject references, both verified. Neither is claimed to be a duplicate of this bug.

    #1212 (false look-alike, useful as a boundary) — establishes that #[[<uuid>]] is the normal stored form of an inline tag in block text, and that displaying the raw UUID instead of the tag name is a name-resolution problem. That issue's fix (logseq/logseq#13307, merged, touching only deps/db/src/logseq/db/sqlite/build.cljs) addressed the import path: tag pages were named from the tag's :db/ident (which carries a random suffix) instead of :block/title.

    That is a different path from the bug reported here. This report is about the editor-insertion path: after conversion, insert-command! writes the UUID-form text into the visible block and the block is never tagged. So the two share a surface symptom (raw UUID visible in a block) but not a cause. Worth keeping distinct, since a fix to the import path would not address this one.

    #598 (closed, cited for the rule, not as a duplicate) — a maintainer states the intended semantics:

    [[]] are used to reference a node in a block whereas # is used to tag a block which will add a tag's properties to that block.

    That is the basis for the Expected Behavior above. An operation presented as "convert <page> to tag" should therefore end with the block tagged (a # attachment, so the tag's properties apply), not with a [[]] reference to the class entity.

    Why the autocomplete path matters here

    The conversion itself succeeds, and the resulting class is usable — tagging a block with it via the tag editor works correctly. Only the text the autocomplete flow inserts into the block is wrong, which is why the symptom is easy to read as "the conversion failed" when it did not.

  2. added a commit that references this issue on Sep 23, 2026
    99b88f2
  3. added a commit that references this issue on Sep 23, 2026
    8a2c716
  4. added a commit that references this issue on Sep 23, 2026
    534f97f
  5. added a commit that references this issue on Sep 23, 2026
    e0dae65
  6. added a commit that references this issue on Sep 24, 2026
    044cefa
  7. added a commit that references this issue on Sep 24, 2026
    0b91290
  8. added a commit that references this issue on Oct 1, 2026
    b4fa8d4
  9. added 2 commits that reference this issue on Oct 8, 2026
    9d5d85f
    22298f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions