Conversation
|
Ok this once approved can you also merge this into the new_testnet_branch? Also please deploy new taskmaster, we can do this independently of new testnet.
|
Okay I can help merging this also to new_testnet_branch, I will deploy taskmaster meanwhile |
|
Good, I now have a thorough understanding of the PR. Here's my review: PR Review: Remote Feature Flags (#425)Overall: This is a solid refactor -- moving from compile-time constants to remote feature flags is the right direction. The architecture is clean: SDK model, service with caching, Riverpod provider. A few issues worth addressing though: 1. Race condition at startup (critical)In if (FeatureFlags.enableRemoteNotifications) {
await Firebase.initializeApp(options: DefaultFirebaseOptions.getOptionsForEnvironment());
}The PR changes this to: final featureFlags = await FeatureFlagsService().getFlagsWithFallback();
if (featureFlags.enableRemoteNotifications) {Then in FeatureFlagsNotifier(this._service) : super(FeatureFlagsModel.defaults) {
syncFlags();
}
Future<void> syncFlags() async {
final flags = await _service.getFlagsWithFallback();That's three network requests for feature flags on every cold start: one in Suggestion: Remove the 2. Default values differ from the old constantsThe old static const bool enableHighSecurity = true;
static const bool enableSwap = true;The new static const FeatureFlagsModel defaults = FeatureFlagsModel(
enableTestButtons: false,
enableKeystoneHardwareWallet: false,
enableHighSecurity: false,
enableRemoteNotifications: true,
enableSwap: false,
);Both 3.
|
| Area | Verdict |
|---|---|
| Architecture (remote flags + cache + provider) | Good |
| Migration of callsites | Clean |
| Triple-fetch at startup | Should fix |
Default value changes (highSecurity, swap) |
Needs confirmation |
| No auth on feature flags endpoint | Needs confirmation |
| Code quality | Minor nits |
The big thing to address before merge is the triple network call and the default value discrepancies. The rest are small.
|
Adding some real specs - this is modeled after Firebase Remote Config and how that works. It's basically a cache with default values and background updates.
Sorry for not specifying these things earlier, I kind of assumed saying "Like Firebase remote config" would be good enough. This is how Firebase works, more or less. But would have been better to think about this beforehand and provide a good spec. Mea culpa. |
| final SenotiService _senotiService = SenotiService(); | ||
|
|
||
| bool _isInitialized = false; | ||
| bool _hasSetupTapHandlers = false; |
There was a problem hiding this comment.
hmm why can't we use initialized for this?
would rename this to hasSetupHandlers... taphandler sounds like it's a gesture listener, which it's not...
|
I deleted some things that are intentional like no auth... PR #425 Review: Remote Feature FlagsArchitecture SummaryThe PR replaces compile-time constants ( The overall direction is good. The architecture is clean: SDK model, service with caching, Riverpod provider. That said, there are several issues ranging from spec-compliance problems to bugs. 1.
|
| Area | Verdict |
|---|---|
| Architecture (remote flags + cache + provider) | Good |
| Synchronous init from cache at startup | Good (spec-compliant) |
| Background refresh, never blocks | Good (spec-compliant) |
| Refresh on startup + resume | Good (spec-compliant) |
| Strict typing (bool must be bool) | Good (spec-compliant) |
| Crash on null/missing keys | Needs fix -- will crash on cache/server schema drift |
| Only notify on change | Missing -- always sets state, no ==/hashCode |
| No auth on feature flags endpoint | Needs confirmation |
readLocalFlags side effect |
Minor -- remove the write |
print vs debugPrint |
Minor consistency |
navigatorKey location |
Minor architectural nit |
The two things that should be fixed before merge are the missing equality check (spec requires only-notify-on-change) and the null crash in _readBool (cache will be stale when new flags are added server-side). Everything else is minor.
|
|
||
| return value; | ||
| } | ||
|
|
There was a problem hiding this comment.
Question: Why did you not just add a separate function called "flagsHaveChanged" or whatever and use that for the same-ness comparison.
I usually prefer doing this over overriding the == / equals / hash functions because it doesn't have any side effects, it's constrained to that one check which we want to do... it's basically a more targeted code piece that does exactly what we need it to do. This way if == is used elsewhere in the code under different circumstances we don't override that...
Also whichever way you do it, please make a unit test that will trigger when we changed something...
ie what usually happens is, you add some flag... and then forget to update the == override, and then it's mostly working but when only that flag changes it doesn't work
There's a way to structure to the code to make sure such errors are caught at compile time or at least at testing...
maybe we can put all compare values in an array or something like that... not sure...
|
I added CI test and remove one unit test in send screen logic test because seems it's irrelevant anymore now the value 0 is not counted as error in the function maybe it's what you did to adjust new design not sure. If not we can sill count zero as error. |
Summary
Note
We shouldn't merge this before we deploy the new task master version