Skip to content

fix(ui): stop the initial sync from stealing the user's sidebar selection - #235

Merged
romaintb merged 1 commit into
mainfrom
fix/keep-selection-across-initial-sync
Sep 5, 2026
Merged

romaintb merged 1 commit into
mainfrom
fix/keep-selection-across-initial-sync

Conversation

@romaintb

@romaintb romaintb commented Sep 5, 2026

Copy link
Copy Markdown
Owner

The bug

Navigate to a project before the initial sync finishes and you get yanked to default_project the 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) sets is_initial_sync = true, loads the cached snapshot, and starts the sync. The cached load fires InitialDataLoaded, which applies default_project and is exactly right at that point. But nothing clears the flag, so when the sync completes update_data_from_sync takes the initial branch again and re-applies default_project over 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_sync in Action::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_project after 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

Testing

cargo clippy --all-targets clean, cargo test passes. No unit test: asserting this needs an AppComponent plus a faked sync round-trip, a lot of fixture for one boolean.

…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.
@romaintb romaintb added the ui label Sep 5, 2026
@romaintb romaintb self-assigned this Sep 5, 2026
@romaintb
romaintb merged commit b15fcaf into main Sep 5, 2026
9 checks passed
@romaintb
romaintb deleted the fix/keep-selection-across-initial-sync branch September 5, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant