Skip to content

fix(sidebar): remember collapsed folders per vault - #124

Merged
FabioHAraujo merged 2 commits into
mainfrom
feat/remember-folder-state
Nov 13, 2026
Merged

FabioHAraujo merged 2 commits into
mainfrom
feat/remember-folder-state

Conversation

@FabioHAraujo

Copy link
Copy Markdown
Contributor

Problem and resulting behavior

The sidebar kept the collapsed folders only in the component, so every start opened all folders expanded and the layout the user left was lost.

Now each vault in settings.json keeps the folders shown collapsed:

  • VaultConfig.collapsed_folders (serde default, so existing settings behave as before: any folder not listed opens expanded).
  • save_collapsed_folders(vault_id, folders) runs through on_worker, since each settings save reads the credential store. vault::collapsed_folders keeps only valid vault-relative paths (safe_join) that are still folders, once each, capped at 10,000; renamed and deleted folders drop out. While the vault folder is unavailable (unplugged drive) every valid path is kept.
  • The sidebar derives the collapsed set from the vault and the last toggle, and saves one call at a time with only the latest state per vault. Renaming a folder from the sidebar keeps it (and its subfolders) collapsed.

Validation

  • bun run version:check, bun run check, bun run check:e2e, bun test (121 pass), Python script tests: OK.
  • cargo fmt --check, cargo clippy --lib --tests -- -D warnings, cargo test --locked --lib (200 pass): OK. New test vault::tests::collapsed_folders_keep_existing_folders_once.
  • bun run build and bun run test:e2e (47 pass), including the new tests/e2e/folder-tree.pw.ts (opens a remembered folder collapsed, saves each toggle).
  • Unit tests for the rename mapping and the save queue in tests/note-tree.test.ts.

Additional context

The settings file is local; nothing changes in the sync protocol. Older versions ignore the new field and drop it on their next save.

Every start opened all sidebar folders expanded: the collapsed state lived
only in the component. Each vault in settings.json now keeps the folders
shown collapsed (`collapsed_folders`); any other folder still opens
expanded, so existing settings behave as before.

The new `save_collapsed_folders` command runs on the worker, since each
settings save reads the credential store. It keeps only valid
vault-relative paths that are still folders, so renamed and deleted ones
drop out (all valid paths are kept while the vault folder is unavailable).
The sidebar saves one call at a time, latest state per vault, and a renamed
folder stays collapsed.
On non-Windows targets the junction check is compiled out, leaving an
`if` that returns `true` followed by `false`; Rust 1.100's clippy flags it
and CI's lint job failed. The reparse-point flag is now a value that is
`false` off Windows, with the same result on every platform.
@FabioHAraujo
FabioHAraujo merged commit 6fbdb7c into main Nov 13, 2026
6 checks passed
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.

1 participant