Skip to content

fix(plugin): remember last unpacked plugin directory#12697

Open
VictorVow wants to merge 1 commit into
logseq:masterfrom
VictorVow:fix/plugin-default-path
Open

fix(plugin): remember last unpacked plugin directory#12697
VictorVow wants to merge 1 commit into
logseq:masterfrom
VictorVow:fix/plugin-default-path

Conversation

@VictorVow

Copy link
Copy Markdown
Contributor

Summary

The "Load unpacked plugin" dialog previously called showOpenDialog with no defaultPath, so the OS native picker (xdg-desktop-portal / GTK on Linux, equivalents on macOS/Windows) fell back to whatever location it had cached for the "open directory" purpose — often unrelated to the user's plugin folder and never updated by Logseq itself.

This change persists the last picked path in local storage as :lsp-last-unpacked-plugin-path, and passes its parent directory as defaultPath on subsequent opens, so the picker lands right next to the previously loaded plugin's sibling folders.

  • src/electron/electron/handler.cljsopen-dir-dialog now takes an optional default-path; uses path.dirname so the picker opens at the parent of the last selection. :openDialog IPC handler forwards the optional argument.
  • src/main/frontend/handler/plugin.cljsload-unpacked-plugin reads the persisted path, passes it to the IPC, and stores the new pick.

Test plan

  • Open Plugins → Load unpacked plugin, pick a folder; close and reopen the dialog — it should open at the parent of the last pick.
  • First-ever use (no stored path) still works and falls back to OS default behavior.
  • Cancelling the dialog does not overwrite the stored path with an empty value.

The "Load unpacked plugin" dialog previously opened with no defaultPath,
so the OS picker fell back to whatever location it remembered for that
dialog purpose — often unrelated to the user's plugin folder.

Persist the last picked path in local storage and pass its parent as
defaultPath on subsequent opens, so the picker lands next to sibling
plugin folders.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the UX of “Load unpacked plugin” on Electron by remembering the last selected unpacked plugin directory and using it to seed the next native directory picker location.

Changes:

  • Persist the last selected unpacked plugin path in frontend local storage (:lsp-last-unpacked-plugin-path) and reuse it on subsequent dialog opens.
  • Extend the Electron main-process open-dir-dialog helper to accept an optional default-path and set showOpenDialog’s defaultPath to the parent directory via path.dirname.
  • Update the :openDialog IPC handler to forward the optional default-path argument.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/main/frontend/handler/plugin.cljs Reads/writes the last unpacked plugin path in local storage and passes it into the openDialog IPC call.
src/electron/electron/handler.cljs Adds optional default-path support to open-dir-dialog and forwards it from the :openDialog IPC handler to Electron’s showOpenDialog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants