Repository navigation
feat(local): keep which source folders are open across launches - #2441
officialasishkumar wants to merge 1 commit into
Conversation
The sources tree forgot every open folder on a reload, a relaunch or a switch back to a workspace, so someone working inside a nested folder had to open the same chain again each time. The file-agent proposal (01-sources-and-folders) already designs this as `expanded-folders.ts`, "expansion kept per workspace", and documents.md listed it as a Known gap. - `tree/expanded-folders.ts` stores each workspace's open folder ids in localStorage under `surfsense:expanded-folders:v1`, shaped like the remembered ticks beside it. Unreadable or unavailable storage falls back to every folder closed, and a workspace with nothing open drops its entry. - `tree/use-expanded-folders.ts` owns the open set for the panel: it reads the workspace's set, writes every change back, and forgets a folder once the folder listing no longer has it. Folders have no AUTOINCREMENT, so a deleted folder's id can go to the next folder made, which would otherwise open by itself. Until the listing arrives the index has no root folder, and nothing is pruned. - `SourcesPanel` takes an optional `workspaceId`; the dashboard passes it. Without one the open folders last only while the panel is mounted, as before. Opening a folder after a move or a new folder, the keyboard's arrows and the row toggle all go through the same setter, so each is kept. Docs: documents.md describes the behaviour and drops the Known gap; the Sources user page says open folders stay open.
|
@officialasishkumar is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
What
The sources tree now remembers which folders are open, per workspace, across a reload, a relaunch and a switch back to the workspace.
features/sources/tree/expanded-folders.tsstores each workspace's open folder ids inlocalStorageundersurfsense:expanded-folders:v1, shaped likeremembered-ticks.tsbeside it. Unreadable or unavailable storage falls back to every folder closed; a workspace with nothing open drops its entry.features/sources/tree/use-expanded-folders.tsowns the open set for the panel: it reads the workspace's set, writes every change back, and forgets a folder onceGET /foldersno longer lists it. Folders have noAUTOINCREMENT, so a deleted folder's id can go to the next folder made, which would otherwise open by itself. Until the listing arrives the index has no root folder, so nothing is pruned while folders are still loading.SourcesPaneltakes an optionalworkspaceId, which the dashboard passes. Without one the open folders last only while the panel is mounted, as before, so the panel's other callers and tests are unchanged.The row toggle, the arrow keys, and the automatic open after a move or a new folder all go through the same setter, so all of them are remembered.
Docs:
docs/architecture/documents.mddescribes the behaviour under The sources tree and drops the Known gap "Which folders are open is not kept across a reload." The Sources user page (www/content/docs/v2/sources.mdx) says open folders stay open.Why
Someone working inside a nested folder had to open the same chain again after every relaunch and every switch back to the workspace. 01-sources-and-folders already designs this as
expanded-folders.ts, "expansion kept per workspace", anddocuments.mdlists it under Known gaps. It is separate from the Trash work claimed in #2375.No linked issue.
How to test
Automated, in
surfsense_local/frontend:tree/use-expanded-folders.test.tscovers: closed by default, kept on reopen, kept per workspace, forgetting a folder the listing dropped (so a reused id starts closed), not pruning while folders load, nothing stored without a workspace, and unreadable storage.dashboard-page.test.tsxadds "keeps a workspace's open folders when the app opens again": it opens Research, unmounts and mounts the dashboard again, and checks that Research's source still shows.workspaceIdpassed from the dashboard.python scripts/check_docs.pyandnode scripts/check_translations.mjspass. There are no new strings.By hand, with
cd surfsense_local/electron && pnpm dev:Summary by CodeRabbit