fix(ui): stop the initial sync from stealing the user's sidebar selection - #235
Merged
Merged
Conversation
…tion The cache now survives a restart, so projects are navigable before the first sync completes. But `trigger_initial_sync` left `is_initial_sync` set for the whole sync, so its completion took the initial branch a second time and `InitialDataLoaded` re-applied `default_project`, dropping the user wherever the config pointed. Clear the flag as soon as the user picks a view. Without navigation it stays set, so a fresh install still resolves `default_project` once the sync brings the projects in.
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.
The bug
Navigate to a project before the initial sync finishes and you get yanked to
default_projectthe moment it lands. That defeats the point of keeping the cache across restarts: the projects are navigable early, but the sync takes the view back.Cause
trigger_initial_sync(app_component/mod.rs:114-127) setsis_initial_sync = true, loads the cached snapshot, and starts the sync. The cached load firesInitialDataLoaded, which appliesdefault_projectand is exactly right at that point. But nothing clears the flag, so when the sync completesupdate_data_from_synctakes the initial branch again and re-appliesdefault_projectover whatever the user picked.Debug mode dodges it because it flips the flag back immediately (
:117-119).The flag predates the persistent cache. It was added in b91e951 to stop a manual refresh bouncing you to the default project, back when the DB was wiped at every launch and the first sync really was the moment the app first had data to select from.
Fix
Clear
is_initial_syncinAction::NavigateToSidebar. Once the user has picked a view, the sync no longer owns the selection.Without navigation the flag stays set, so a fresh install with an empty cache still resolves
default_projectafter the sync brings the projects in. Inbox is an ordinary project row (is_inbox_project), not a built-in view like Today, so it can't be resolved before the first fetch and that second pass still earns its keep.Not in scope
SidebarSelection::Project(usize)is positional, so a project deleted from another client slides your selection onto a neighbour instead of redirecting. Wants a uuid-keyed selection, which wants stable local UUIDs first (PR feat(sync): persist the local cache and sync in the background #209 item 1).Testing
cargo clippy --all-targetsclean,cargo testpasses. No unit test: asserting this needs anAppComponentplus a faked sync round-trip, a lot of fixture for one boolean.