fix(issue-33): account restore on restart + sync rules store folder paths not Graph IDs#34
Merged
Merged
Conversation
… restore - GivenAnAccountOnboardingServiceIntegration: two tests asserting RemotePath is slash-prefixed folder name (e.g. /Documents), not a Graph item ID - GivenAWorkspaceViewModel: three tests asserting LoadPersistedAccountsAsync populates Accounts from repository, auto-selects first account, and leaves collection empty when repository returns no rows Supporting stubs (not yet implemented): - SelectedFolder readonly record struct added to Domain - OneDriveAccount.SelectedFolders property alongside SelectedFolderIds - WorkspaceViewModel(IServiceProvider, IAccountRepository) constructor overload - WorkspaceViewModel.LoadPersistedAccountsAsync stub (throws NotImplementedException) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bug 1 — accounts not restored on app restart:
- WorkspaceViewModel now has a two-arg constructor
(IServiceProvider, IAccountRepository) that starts with an empty
Accounts collection (no design-time data on the runtime path)
- LoadPersistedAccountsAsync loads all AccountEntity rows from
IAccountRepository, maps them to AccountViewModel, adds to Accounts,
and auto-selects the first account
- App.axaml.cs resolves the WorkspaceViewModel (DI now injects
IAccountRepository) and fires LoadPersistedAccountsAsync after
the main window is created
- Design-time / single-IServiceProvider constructor retains
BuildAccounts() fake data unchanged
Bug 2 — sync rules storing Graph item IDs not folder paths:
- OneDriveAccount.SelectedFolderIds removed; replaced by
SelectedFolders: IReadOnlyList<SelectedFolder>
- SelectedFolder is a new readonly record struct(string Id, string Name)
carrying both the Graph drive item ID and the display name
- AddAccountWizardViewModel.ExecuteAddAccountAsync now builds
SelectedFolder instances from WizardFolderItem.FolderId + Name
- AccountOnboardingService.UpsertSyncRulesAsync now writes
RemotePath = "/\{folder.Name}" (e.g. "/Documents") instead of the
raw Graph item ID
- WorkspaceViewModel.OnWizardCompleted uses SelectedFolders.Count
All existing tests updated to use SelectedFolders. 197 tests green.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Closes #33
Summary
Two bugs introduced by #26 (persistence layer). Both relate to unimplemented acceptance criteria.
Bug 1 — Accounts not visible in UI after app restart
Root cause
WorkspaceViewModel.Accountswas always populated from the staticBuildAccounts()method (hard-coded design-time data). No code ever readIAccountRepositoryat startup —App.axaml.csonly ran migrations.Fix
WorkspaceViewModelgains a new runtime constructor(IServiceProvider, IAccountRepository)that starts with an emptyAccountscollection (no design-time data on the DI path).LoadPersistedAccountsAsync(CancellationToken)method loads all rows fromIAccountRepository, maps them toAccountViewModel, adds toAccounts, and auto-selects the first account.App.axaml.csresolvesWorkspaceViewModelfrom DI (which now auto-injectsIAccountRepository) and firesLoadPersistedAccountsAsyncafter the main window is created.BuildAccounts()fake data for design-time and test use — all existing tests unaffected.Bug 2 — Sync rules stored Graph item IDs not folder paths
Root cause
AddAccountWizardViewModel.ExecuteAddAccountAsyncput raw Graph drive item IDs (e.g.01ABCDEF…) intoOneDriveAccount.SelectedFolderIds.AccountOnboardingServicethen wrote those IDs asSyncRuleEntity.RemotePath. The sync rule evaluator and pipeline expect slash-prefixed path strings (e.g./Documents), not Graph IDs.Fix
SelectedFolder(string Id, string Name)—readonly record structin theDomainlayer carrying both the Graph item ID and the display name.OneDriveAccount.SelectedFolderIdsremoved; replaced bySelectedFolders: IReadOnlyList<SelectedFolder>.AddAccountWizardViewModelnow buildsSelectedFolderinstances fromWizardFolderItem.FolderId + Name.AccountOnboardingService.UpsertSyncRulesAsyncwritesRemotePath = $"/{folder.Name}"(e.g./Documents).Tests
New tests:
when_load_persisted_accounts_is_called_then_stored_account_appears_in_accountswhen_load_persisted_accounts_is_called_with_no_accounts_then_accounts_collection_is_emptywhen_load_persisted_accounts_is_called_then_first_account_is_auto_selectedwhen_complete_onboarding_is_called_then_sync_rule_remote_path_is_slash_prefixed_folder_namewhen_complete_onboarding_is_called_then_sync_rule_remote_path_does_not_contain_graph_item_iddotnet build— 0 errors, 0 warningsdotnet test— 197 pass, 0 fail🤖 Generated with Claude Code