-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
bugSomething isn't workingSomething isn't workingui/uxUser interface and experienceUser interface and experience
Description
Summary
When save_tree=True, toggling tree_mode OFF→ON should restore the saved tree state (collapsed groups, expanded folders, group_by). However, the restoration is inconsistent.
Current Behavior
- ✅ Works: Make changes → toggle OFF → toggle ON → state restored
- ❌ Doesn't work: Toggle OFF → toggle ON (no changes) → state lost
Root Cause Analysis
Two design issues identified in update_tree_mode() and load_state():
1. Timing dependency
load_state() validates saved groups against tree_state.groups (line 96 in tree.py):
existing_groups = set(self.groups)
if v and v in existing_groups: # validation fails if groups is emptyBut groups is only populated by update_tree(). The order matters:
- ❌
load_state()→update_tree()(groups empty during validation) - ✅
update_tree()→load_state()(groups populated)
2. group_by restoration side effects
When load_state() restores a different group_by, it triggers update_group_by() which:
- Clears
collapsed_groupsandexpanded_folders - Calls
tree.update()
The collapsed_groups restoration happens AFTER this in load_state(), so it should work. But the interplay is fragile.
Partial Fix Applied
Commit ac15bcd improves some cases by:
- Calling
update_tree()beforeload_state() - Saving state when
tree_modeis turned OFF
Suggested Full Fix
Consider refactoring to separate concerns:
- Tree building: Always done by
update_tree(), populates structure - State restoration: Done after tree is built, only affects collapse/expand state
- Persistence: Save on any state change, not just on toggle OFF
This may require changes to:
prefs/tree.py:TreeState,load(),save()preferences.py:update_tree_mode(),update_group_by()
Related Files
preferences.py:update_tree_mode()(line ~531)prefs/tree.py:TreeState.load(),TreeState.save()
Labels
- bug
- tree-view
- low-priority
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingui/uxUser interface and experienceUser interface and experience