Commit db4311e
feat(remote-feature-flag-controller): merge localOverrides into remoteFeatureFlags (#9259)
## Summary
- `remoteFeatureFlags` now exposes the **effective** flag values
consumers should read: processed remote flags merged with
`localOverrides`
- Override mutations (`setFlagOverride`, `removeFlagOverride`,
`clearAllFlagOverrides`) update `remoteFeatureFlags` directly instead of
requiring callers to merge state themselves
- Remote flag fetches re-apply active overrides after processing so
cached overrides survive refresh
## Behavior
Previously, `remoteFeatureFlags` contained only processed remote values
and `localOverrides` was a separate map. Consumers that needed the
effective value had to merge both manually, e.g. `{
...remoteFeatureFlags, ...localOverrides }`.
With this change, the controller owns that merge:
| State field | Purpose |
|-------------|---------|
| `remoteFeatureFlags` | Effective values (`{ ...processedRemote,
...localOverrides }`) — **read this** |
| `localOverrides` | Which flags are locally overridden and their
override values |
| `rawRemoteFeatureFlags` | Unprocessed API response |
### When merging happens
- **`updateRemoteFeatureFlags()`** — after version/threshold processing,
overrides are spread onto the processed result
- **`setFlagOverride()`** — writes the override value directly into
`remoteFeatureFlags`
- **`removeFlagOverride()` / `clearAllFlagOverrides()`** — restores
processed remote values (tracked in a private in-memory cache refreshed
on fetch)
### Consumer impact
- **Before:** merge `remoteFeatureFlags` + `localOverrides` at the call
site
- **After:** read `remoteFeatureFlags` directly for effective values
- Call sites that already merge manually should drop the extra merge to
avoid double-applying overrides
## Test plan
- [x] `yarn workspace @metamask/remote-feature-flag-controller run jest
--no-coverage remote-feature-flag-controller.test.ts`
- [ ] Verify extension/mobile consumers that read `remoteFeatureFlags`
no longer need a manual merge with `localOverrides`
Made with [Cursor](https://cursor.com)
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 750d1b5 commit db4311e
3 files changed
Lines changed: 144 additions & 3 deletions
File tree
- packages/remote-feature-flag-controller
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
Lines changed: 100 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
127 | 139 | | |
128 | 140 | | |
129 | 141 | | |
| |||
1093 | 1105 | | |
1094 | 1106 | | |
1095 | 1107 | | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
1096 | 1111 | | |
1097 | 1112 | | |
1098 | 1113 | | |
| |||
1113 | 1128 | | |
1114 | 1129 | | |
1115 | 1130 | | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
1116 | 1134 | | |
1117 | 1135 | | |
1118 | 1136 | | |
1119 | 1137 | | |
1120 | 1138 | | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
1121 | 1142 | | |
1122 | 1143 | | |
1123 | 1144 | | |
| |||
1134 | 1155 | | |
1135 | 1156 | | |
1136 | 1157 | | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
1137 | 1162 | | |
1138 | 1163 | | |
1139 | 1164 | | |
1140 | 1165 | | |
1141 | 1166 | | |
1142 | 1167 | | |
1143 | 1168 | | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
1144 | 1174 | | |
1145 | 1175 | | |
1146 | 1176 | | |
| |||
1156 | 1186 | | |
1157 | 1187 | | |
1158 | 1188 | | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
1159 | 1193 | | |
1160 | 1194 | | |
1161 | 1195 | | |
1162 | 1196 | | |
1163 | 1197 | | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
1164 | 1201 | | |
1165 | 1202 | | |
1166 | 1203 | | |
| |||
1175 | 1212 | | |
1176 | 1213 | | |
1177 | 1214 | | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
1178 | 1218 | | |
1179 | 1219 | | |
1180 | 1220 | | |
1181 | 1221 | | |
1182 | 1222 | | |
1183 | 1223 | | |
1184 | 1224 | | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
1185 | 1230 | | |
1186 | 1231 | | |
1187 | 1232 | | |
| |||
1192 | 1237 | | |
1193 | 1238 | | |
1194 | 1239 | | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1195 | 1243 | | |
1196 | 1244 | | |
1197 | 1245 | | |
| |||
1233 | 1281 | | |
1234 | 1282 | | |
1235 | 1283 | | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
1236 | 1336 | | |
1237 | 1337 | | |
1238 | 1338 | | |
| |||
Lines changed: 43 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
158 | 160 | | |
159 | 161 | | |
160 | 162 | | |
| |||
202 | 204 | | |
203 | 205 | | |
204 | 206 | | |
| 207 | + | |
| 208 | + | |
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
211 | 219 | | |
212 | 220 | | |
213 | 221 | | |
214 | 222 | | |
215 | 223 | | |
216 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
217 | 234 | | |
218 | 235 | | |
219 | 236 | | |
| |||
298 | 315 | | |
299 | 316 | | |
300 | 317 | | |
| 318 | + | |
| 319 | + | |
301 | 320 | | |
302 | 321 | | |
303 | 322 | | |
304 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
305 | 327 | | |
306 | 328 | | |
307 | 329 | | |
| |||
419 | 441 | | |
420 | 442 | | |
421 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
422 | 449 | | |
423 | 450 | | |
424 | | - | |
425 | | - | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
426 | 454 | | |
427 | 455 | | |
428 | 456 | | |
| |||
437 | 465 | | |
438 | 466 | | |
439 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
440 | 478 | | |
441 | 479 | | |
442 | 480 | | |
443 | 481 | | |
| 482 | + | |
444 | 483 | | |
445 | 484 | | |
446 | 485 | | |
| |||
453 | 492 | | |
454 | 493 | | |
455 | 494 | | |
| 495 | + | |
456 | 496 | | |
457 | 497 | | |
458 | 498 | | |
| |||
0 commit comments