pgadmin-org / pgadmin-org/pgadmin4

Remember the last used folder per file dialog purpose, rather than one folder globally

Open
#10,381 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

electron Feature
Dominant language
Python
Stars
3.8k
Forks
891
Avg merge
4d 7h
Merged PRs (30d)
8

Description

Describe the solution you'd like

PR #10327 makes the desktop runtime remember the last directory a native file dialog visited, so that dialogs stop reopening in Downloads after the Electron 38 change removed the implicit behaviour. It keeps a single lastVisitedDirectory key in the runtime config store, written by both the open and the save handlers, which means Backup, Restore, ERD saves, the storage manager and everything else share one remembered folder: save an ERD somewhere and the next backup starts in the same place.

It would be nicer to remember a folder per purpose, so that backups keep returning to wherever backups go whilst ERD saves keep returning to wherever diagrams go, rather than each dialog inheriting whatever the previous one happened to touch.

Describe alternatives you've considered

Leaving it as one global folder, which is what #10327 does and what most people may well want, since it already fixes the reported problem and needs no per-caller changes.

Additional context

Suggested by @razzeee in https://github.com/pgadmin-org/pgadmin4/pull/10327#issuecomment-5495082075.

The extension looks straightforward rather than a rework, because every native dialog funnels through FileManagerModule.showNative() in web/pgadmin/misc/file_manager/static/js/FileManagerModule.jsx: a context key could be passed through window.electronUI.showSaveDialog/showOpenDialog and the preload shims in runtime/src/js/pgadmin_preload.js, and the store keyed per context, falling back to the current global value whenever a context has nothing saved yet.

The part that needs the work is the callers. params currently carries only dialog_type, which is one of create_file, open_file, select_file or select_folder, and that describes the shape of the dialog rather than what it is for, so each call site would have to start passing a purpose of its own before there is anything to key on.

Contributor guide

Open the contributing guide

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.

Research direction

Start with FileManagerModule.showNative() in web/pgadmin/misc/file_manager/static/js/FileManagerModule.jsx, then trace window.electronUI.showSaveDialog/showOpenDialog and the preload shims in runtime/src/js/pgadmin_preload.js. Review the callers that currently pass only dialog_type and define purpose keys for them. Done means each purpose remembers its own folder while contexts without a saved folder fall back to the current global value.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, javascript
Domain
desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.