feat(sidebar): persist user-pinned custom project paths in localStorage - #543
Closed
3bluebytes wants to merge 1 commit into
Closed
feat(sidebar): persist user-pinned custom project paths in localStorage#5433bluebytes wants to merge 1 commit into
3bluebytes wants to merge 1 commit into
Conversation
The directory picker's "Custom path" branch validates a path server-side but only stored the choice in component state, so the path disappeared on reload and was absent from the project selector. Sidebar sessions had to be started before a project ever showed up, forcing users to re-pick the same directory on every visit. This change pins successfully-validated custom paths in `window.localStorage["pi-web:custom-project-paths"]` and merges them into `getRecentProjects`. Session-derived projects still win on overlap because they are canonicalised against the server's filesystem view. - New `lib/custom-projects.ts` with load/save/remove helpers that fall back gracefully when storage is unavailable (privacy mode, SSR). - `getRecentProjects` now accepts an optional custom-projects list and exposes `isCustomOnlyProject` so the sidebar can show a remove button only for entries that are not backed by any session. - The sidebar calls `saveCustomProject` after a successful `/api/cwd/validate` and reloads the list. A small × button removes a pinned entry on hover. - Tests cover the new helpers and the merge logic; the full suite (597 tests) and lint stay green. i18n strings: en + zh-CN.
Owner
|
I don’t think this is necessary. The project list should only include directories with existing sessions; custom paths can remain temporary until a session is created. |
Owner
|
A simpler alternative would be to remember the last successfully selected cwd and prefill the custom picker with it. This avoids adding directories without sessions to the project list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The directory picker's "Custom path" branch validates a path server-side but only stores the choice in component state. The path vanishes on reload and is absent from the project selector, so users have to re-pick the same directory every time they open Pi Web.
Project list (
getRecentProjects) is computed purely from session files on disk, so any path the user has only ever browsed (no session started) never appears in the selector.Fix
Pin successfully-validated custom paths in
window.localStorage["pi-web:custom-project-paths"]and merge them intogetRecentProjects. Session-derived projects still win on overlap because they are canonicalised against the server's filesystem view.lib/custom-projects.tswithloadCustomProjects/saveCustomProject/removeCustomProjecthelpers. Falls back gracefully when storage is unavailable (privacy mode, SSR, denied access).getRecentProjectsnow accepts an optionalcustomProjectslist and exposesisCustomOnlyProjectso the sidebar can show a remove button only for entries not backed by any session.saveCustomProjectafter a successful/api/cwd/validateand refreshes state from storage. A small × button removes a pinned entry on hover.sidebar.removeCustomProjectkey in en + zh-CN.Tests
lib/custom-projects.test.mjscovers round-trip, dedup-by-key, malformed entries, removal, and storage-unavailable / SSR fallback.lib/project-groups.test.mjscover the merge logic andisCustomOnlyProject.npm test): 597/597 pass.npm run lint: clean.npm run build: clean (no new warnings).Screenshots
Will attach after first reply.