Skip to content

Give each screen its own view models so the profile editor loads - #75

Merged
hameno merged 1 commit into
masterfrom
feature/fix_profile_editor_loading
Oct 10, 2026
Merged

hameno merged 1 commit into
masterfrom
feature/fix_profile_editor_loading

Conversation

@hameno

@hameno hameno commented Oct 10, 2026

Copy link
Copy Markdown
Member

The profile editor could get stuck on its loading spinner forever (seen on a device with the 3.0 builds, beta 3.0.0-200 included).

Cause: NavigationState.toEntries only used the saveable-state decorator, so view models were scoped to the activity and shared by key. A second profile editor reused the first one's WidgetProfileEditorViewModel and the profile id it was created with; the widget editor had the same flaw. Once a new profile had been discarded, every later profile editor kept observing that missing profile.

Fix:

  • rememberViewModelStoreNavEntryDecorator (lifecycle-viewmodel-navigation3 2.11.0): each back stack entry gets its own view models, cleared when it is popped
  • An untouched new profile is discarded in onCleared (editor really closed), no longer on composition dispose, which also fired on a tab switch and deleted the profile under the open editor
  • An editor whose profile no longer exists goes back instead of loading forever

Tests: navigation view model scoping (separate per entry, survives a tab switch), new-profile discard on close but not on hide, missing profile. Verified on an emulator: a new profile survives a tab switch, is discarded on back, and opening another profile afterwards loads.

🤖 Generated with Claude Code

Navigation had no view model store per back stack entry, so view models were
shared through the activity: a second profile (or widget) editor reused the
first one's view model and the id it was opened with. After a new profile had
been discarded, every profile editor kept waiting for that missing profile.

Entries now get their own view models (lifecycle-viewmodel-navigation3),
cleared when they leave the back stack. An untouched new profile is discarded
then, not when the editor is merely hidden by a tab switch, and an editor
whose profile no longer exists goes back instead of loading forever.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Test Results

132 tests  +5   132 ✅ +5   33s ⏱️ +12s
 36 suites +1     0 💤 ±0 
 36 files   +1     0 ❌ ±0 

Results for commit 9374686. ± Comparison against base commit d19e84a.

@hameno
hameno merged commit fbe996b into master Oct 10, 2026
2 checks passed
@hameno
hameno deleted the feature/fix_profile_editor_loading branch October 10, 2026 20:46
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