Repository navigation
fix(app): dispose the workspace on navigate-home - #284
Merged
Merged
Conversation
IncidentWorkspaceViewModel was never IDisposable, so navigating home only ever disposed its child tab view models inside BuildChildren (on a rebuild) -- never on final teardown. The last generation of children, and the workspace's own ticker subscriptions carried by Scba/Tasks/ Reminder, outlived the navigation: an abandoned workspace kept ticking once a second and could still append to its journal or play alarms for an incident nobody could see anymore. A joined client additionally leaked its four RemoteIncidentSession lifecycle subscriptions (Changed, Disconnected, Reconnected, Ended) with no matching unsubscribe. Make IncidentWorkspaceViewModel : IDisposable. Dispose() is now the single, idempotent teardown point: it unsubscribes the four remote events and disposes every current child via a DisposeChildren() helper shared with BuildChildren, so a workspace rebuilt several times still only disposes its current children once. MainWindowViewModel disposes the outgoing workspace via a OnCurrentViewChanged(object?, object?) hook on CurrentView, so it fires uniformly for every navigate-away path (GoHome, GoHomeRequested, and beyond) without duplicating a Dispose() call at each call site. GoHome now awaits the outgoing workspace's LeaveAsync() (tearing down a joined client's remote session) before switching CurrentView, matching ShowWorkspace's existing GoHomeRequested lambda. Ownership of a freshly constructed IncidentWorkspaceViewModel transfers from HomeViewModel to whoever handles WorkspaceOpened, which is now what disposes it -- suppress the two resulting CA2000 findings with a justification. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PXhXSh2pae9WnaACYUUe3V Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
DeepDiver1975
force-pushed
the
fix/review-workspace-dispose
branch
from
September 11, 2026 09:20
4ab8d7e to
1a5923e
Compare
16 of 19 tasks
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.
Problem
IncidentWorkspaceViewModelwas notIDisposable. Its child tab view-models were only disposed whenBuildChildrenreplaced them; navigating home from a workspace (both theGoHomeRequestedpath and theGoHomecommand) simply dropped the workspace. TheScba,TasksandReminderchildren keepITickersubscriptions andsession.Changedhandlers, andDispatcherTimerTickerholds strong references, so every abandoned workspace kept ticking once per second forever.ScbaViewModel.OnTickcould still append journal entries and play alarms for an incident the user had already left. The fourRemoteIncidentSessionevent subscriptions were never removed either.Fix
IncidentWorkspaceViewModelimplementsIDisposable: one idempotent teardown that disposes every child and unsubscribes the remote-session events.MainWindowViewModeldisposes the outgoing workspace on both navigation paths, after the existingLeaveAsync(remote session teardown).session.Changedno longer reaches the old workspace's children.Found during a code review of
main; part of a series of review follow-up PRs.Test plan
dotnet test LageBuch.Desktop.slnfgreen🤖 Generated with Claude Code
https://claude.ai/code/session_01PXhXSh2pae9WnaACYUUe3V