snapV2Settings is a global singleton, unpersisted and outside the provider tree #61

Open
opened 2026-09-05 15:12:19 +00:00 by ImBenji · 0 comments
Owner

final snapV2Settings = SnapV2Settings(); (lib/models/functions/snap_engine_v2.dart:150) is a bare top-level global. It extends ChangeNotifier but is never registered in main.dart's MultiProvider, so widgets reach around the provider architecture to read and mutate it.

Two consequences:

It is never persisted. Nothing in session_recovery_store.dart touches it and there is no Hive or prefs read for it anywhere, so every snap toggle - snapEnabled, sideSnap, angleConstraint, cellLengthSnap, endSnap, sideSnapFromEdge - resets to its default on every launch. Somebody who works with angle constraint off has to turn it off again every single time. Note the theme settings DO persist, through RecoveryStore, so this is specifically the snap group rather than settings in general.

It contradicts the documented architecture. CLAUDE.md lists seven providers as the state layer; this is an eighth one hiding in the model layer. Anything holding it cannot be swapped in a test without mutating global state, which is why the snap tests drive it directly.

Fix is to persist it through RecoveryStore alongside the theme keys, and ideally to move it into the provider tree so it stops being special. The persistence half is the part users would feel.

STRATEGY.md notes "snap settings still not persisted" in its open list. Found during the roadmap audit on 2026-09-05.

`final snapV2Settings = SnapV2Settings();` (`lib/models/functions/snap_engine_v2.dart:150`) is a bare top-level global. It extends `ChangeNotifier` but is never registered in `main.dart`'s `MultiProvider`, so widgets reach around the provider architecture to read and mutate it. Two consequences: **It is never persisted.** Nothing in `session_recovery_store.dart` touches it and there is no Hive or prefs read for it anywhere, so every snap toggle - `snapEnabled`, `sideSnap`, `angleConstraint`, `cellLengthSnap`, `endSnap`, `sideSnapFromEdge` - resets to its default on every launch. Somebody who works with angle constraint off has to turn it off again every single time. Note the theme settings DO persist, through `RecoveryStore`, so this is specifically the snap group rather than settings in general. **It contradicts the documented architecture.** CLAUDE.md lists seven providers as the state layer; this is an eighth one hiding in the model layer. Anything holding it cannot be swapped in a test without mutating global state, which is why the snap tests drive it directly. Fix is to persist it through `RecoveryStore` alongside the theme keys, and ideally to move it into the provider tree so it stops being special. The persistence half is the part users would feel. STRATEGY.md notes "snap settings still not persisted" in its open list. Found during the roadmap audit on 2026-09-05.
ImBenji added this to the Arcs & Angles project 2026-09-05 15:12:19 +00:00
ImBenji added the enhancement label 2026-09-05 15:13:50 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: IMBENJI.NET/Metro-Map-Maker#61