Cmd+Shift+K "Search only: current page" returns blocks from the whole graph

Open Beginner friendly
#1,506 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
clojure
Domain
search

Research direction

Start in src/main/frontend/components/cmdk/core.cljs at load-results :current-page, then check how src/main/frontend/components/cmdk/state.cljs maps page-uuid and how src/main/frontend/worker/search.cljs reads the page restriction. Reproduce with a word found on another page but not the current one. Done means “Search only: current page” returns no blocks from other pages.

Written by the indexing model from the issue text.

Description

Search first
  • I searched and no similar issues were found
What Happened?

With the "Search only: current page" filter (Cmd+Shift+K), results include blocks from other pages. The filter label is shown, but the search is not restricted to the current page.

Reproduce the Bug
  1. Open any page, e.g. page A.
  2. Press Cmd+Shift+K. The dialog shows "Search only: current page".
  3. Type a word that appears on other pages but not on page A.
  4. Blocks from other pages are listed as current-page results.
Expected Behavior

Only blocks of the current page are listed (no result in step 3).

Screenshots

No response

Files

No response

Browser, Desktop or Mobile Platform Information

macOS, Logseq desktop 2.0.2, DB graph

Additional Context

Likely cause (same code in 2.0.2 and master):

In load-results :current-page (src/main/frontend/components/cmdk/core.cljs), the page uuid is added to the options as :page-uuid:

opts (assoc opts :page-uuid current-page-uuid)

but search-blocks in src/main/frontend/worker/search.cljs only reads :page. The restriction is dropped and the whole graph is searched, then every result is rendered with :current-page? true.

cmdk-block-search-options (src/main/frontend/components/cmdk/state.cljs) already maps page-uuid to :page, but it is called before the uuid is resolved, so without it. Possible fix: (assoc opts :page (str current-page-uuid)), or resolve the uuid first and pass it to cmdk-block-search-options.

Are you willing to submit a PR? If you know how to fix the bug.
  • I'm willing to submit a PR (Thank you!)
Dominant language
No language data
Stars
29
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from logseq/db-test

All issues in logseq/db-test

Similar issues

More Search issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.