Problem
Every RPC handler and service method that modifies state follows the same two-step pattern: mutate appState property, then call store.mutate { ... } with a near-identical mutation. This is duplicated 20+ times in AppDelegate's RPC handlers and throughout SessionService. It's easy to update one and forget the other, leading to state/persistence divergence.
Proposed Improvement
Create mutation methods on a thin service layer (or extend SessionService) that atomically update both AppState and JSONStore. For example: func updateSession(id: UUID, mutate: (inout Session) -> Void) that applies the change to both stores in one call.
Effort
Medium (2–3 hours). Define the helper methods, replace dual-mutation call sites.
Files Affected
Sources/Crow/App/AppDelegate.swift (20+ dual-mutation sites in RPC handlers)
Sources/Crow/App/SessionService.swift
- Potentially new:
Sources/Crow/App/StateMutator.swift
Priority: 8/10
Problem
Every RPC handler and service method that modifies state follows the same two-step pattern: mutate
appStateproperty, then callstore.mutate { ... }with a near-identical mutation. This is duplicated 20+ times in AppDelegate's RPC handlers and throughout SessionService. It's easy to update one and forget the other, leading to state/persistence divergence.Proposed Improvement
Create mutation methods on a thin service layer (or extend SessionService) that atomically update both AppState and JSONStore. For example:
func updateSession(id: UUID, mutate: (inout Session) -> Void)that applies the change to both stores in one call.Effort
Medium (2–3 hours). Define the helper methods, replace dual-mutation call sites.
Files Affected
Sources/Crow/App/AppDelegate.swift(20+ dual-mutation sites in RPC handlers)Sources/Crow/App/SessionService.swiftSources/Crow/App/StateMutator.swiftPriority: 8/10