Repository navigation
fix(dashboard): keep feature-preview switches on the gateway - #22544
mbriones98 wants to merge 2 commits into
Conversation
The Feature previews switches lived only in browser localStorage, so a new origin, the desktop app beside a browser tab, or cleared site data turned them back off. Each switch is now stored in the gateway config under dashboard.feature_previews.<name>, written through the existing owner-only config PATCH, with localStorage kept as a cache. A switch set only in this browser is carried up once with if_unset; a refused toggle names the switch that went back and says why. A carry-up refused as owner-only says the switch stays on in this browser only, with no reload step. Each browser records which switches it has seen the gateway hold, so a switch removed there reads as off even when another switch's carry-up failed. An accepted save is written into the cached config with the shared setConfigPathValue helper. Fixes #21396
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the client reconcile logic in [DESIGN-REVIEWED] bdb8e75 Description read[DESCRIPTION-READ] 50f9e9d4194928ea58a776586c02e4c6220924c40e980174ef1a8192b49f1507 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Carrying old browser-only switches up to the gateway costs two permanent localStorage concepts, two notices and a retired-key path, all to spare one re-toggle of an unreleased preview. Not justified as shipped
What this change shipsInventory (9 items) — 4 justifiedIntent: keep a Feature previews switch on across every browser and the desktop app using one gateway. FIX.
[FIRST-PRINCIPLES-REVIEWED] bdb8e75 Description read[DESCRIPTION-READ] 5a1e5003a767987e1d89e13142b67b6f5ed5112b7cb847ab80a606ca4933e729 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS The new notices and intro talk about "everyone" and "the owner" without saying who that is, and two non-owner results read as contradictory. Watch
Suggestions
[UX-REVIEWED] bdb8e75 Description read[DESCRIPTION-READ] 4fd31a1b1700d7cc12332b94852a62f425b3551ce970c749c5170220aef94baa That sha256 names everything this verdict read: the PR description, plus the 8 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
bolichen97
left a comment
There was a problem hiding this comment.
Looks good apart from one should-fix. Not approving yet: required checks and the two code review lanes are still running on this head, and readiness is "checking".
Head reviewed: 664d1d8.
What I checked:
- The config PATCH stays owner-only, and the allowlist adds only the six
dashboard.feature_previews.<name>bool paths. The loader drops unknown names and non-bool values. if_unsetis already supported on main by the config PATCH (checked under the write lock), so the one-time carry-up cannot replace a stored value.- Main does not already contain this change. Linked issue is a T1 bug.
- No file is on the security path list. No secret, auth or sandbox change.
🔴 0 must-fix, 🟡 1 should-fix (inline).
Still open from the bots on this head: First Principles CONCERNS (the per-switch server-backed record) and UX CONCERNS (the four notices read alike). Neither has a reply yet. Please answer both, either with a change or a short reason. I do not repeat them here.
| * own API is unaffected either way), which is exactly the shape of the existing | ||
| * Developer Mode gate (`mc-dev-mode`). Putting it in `config.json` would imply | ||
| * a fleet-wide setting and a backend contract that does not exist. | ||
| * Stored in the gateway config (`dashboard.feature_previews.<name>`), with |
There was a problem hiding this comment.
🟡 The owning spec still says preview flags are a per-device localStorage opt-in.
This PR moves the source of truth to dashboard.feature_previews.<name> and keeps localStorage as a cache. The dashboard spec was not updated. docs/system-specs/modules/learn-cron-dashboard.md (the "Preview-gated surfaces" paragraph) still reads:
a registry entry may carry `previewFlag`, the localStorage key of a per-device opt-in (`utils/previewFlags.ts`, all keys prefixed `mc-preview-`)
Why it matters: The next reader of the spec will believe a switch is per device and per origin. That is the exact assumption this PR removes, so a later change can bring the bug back.
Suggestion: In the same commit, update that paragraph. Say the switch is kept on the gateway under dashboard.feature_previews.<name>, that localStorage is a cache, that writes are owner-only, and name usePreviewFlagServerSync.
Rule: AGENTS.md "Read before you touch" (owning spec updated in the same commit).
There was a problem hiding this comment.
Updated in bdb8e75. The opening of the "Preview-gated surfaces" paragraph in docs/system-specs/modules/learn-cron-dashboard.md now says each switch is kept on the gateway under dashboard.feature_previews.<name>, that localStorage is a cache, that writes go through the owner-only config PATCH, and that usePreviewFlagServerSync keeps the two in step. It also notes where a browser's cache can differ (a write in flight, a refused carry-up) and what a non-owner session sees. No code changed.
The Preview-gated surfaces paragraph still described each switch as a per-device localStorage opt-in. It now says the switch is kept under dashboard.feature_previews.<name>, that localStorage is a cache, that writes go through the owner-only config PATCH, and names usePreviewFlagServerSync.
|
Disposition for the First Principles CONCERNS (item 6, the per-switch record): keeping it. Without the record, a switch the operator turned off on the gateway can be written back ON for everyone, not just shown again in one browser. That happens when another switch's one-time carry-up fails, because the sync marker then stays unset and the browser's old ON looks like a value still waiting to be carried. An earlier version of this change had exactly that gap, and the GPT review blocked it. |
|
Disposition for the UX CONCERNS: no copy change in this PR.
The suggested rewording is reasonable as a later copy pass across all four notices and 13 catalogs, separate from this fix. |
bolichen97
left a comment
There was a problem hiding this comment.
Re-reviewed at bdb8e75.
The earlier finding is fixed: the Preview-gated surfaces paragraph in docs/system-specs/modules/learn-cron-dashboard.md now says the switch is kept on the gateway under dashboard.feature_previews.<name>, that localStorage is a cache, and how usePreviewFlagServerSync reconciles the two, including the refused-write rollback, the if_unset carry-up and the non-owner case. That matches the code in this PR. No new findings on the incremental change, which touches only that one paragraph.
Backend Tests (Windows) (1) is red again, on the same two tests as the previous head: test_ci_ipv6_routing.py::test_real_collected_nodes_are_the_disjoint_fleet_and_hosted_union and test_a_nested_collection_reads_only_the_named_files, both a subprocess.TimeoutExpired in a nested --collect-only. That collection reads only a fixed set of target files this PR does not touch, and the same two tests fail on Windows shard 1 on several other open PRs right now, so I read it as a shared Windows timeout, not something this change caused.
The change looks good to ship. Approval waits on the maintainer gates: readiness is still checking, four Linux and four Windows backend shards are still running, and Windows shard 1 needs a green rerun.
Pull request was closed
Problem / Motivation
Goal: A Feature previews switch (such as Crewmates) stays on once you turn it on, in every browser and in the desktop app that use the same Kiro Crew.
The switches under Settings > Developer > Feature previews were kept only in browser localStorage (
mc-preview-*). A new origin or port, the desktop app next to a browser tab, or cleared site data each read the switch as off, so Crewmates and the other previews kept turning themselves off.Why it matters
Anyone trying a preview has to turn it on again on every surface and after every storage reset. A preview that seems to switch itself off reads as broken.
Not a goal
DURABLE_PREF_KEYS//api/ui-prefsbackup, so there is one source of truth.configKey/ settings-registry entries for the new paths (<SettingRef>deep links). That is a separate navigation feature.What changed (motivation → approach → change)
Symptom: a switch turned on in one surface is off in another. Root cause: localStorage was the only copy.
#21396 was filed by its owner asking for the switches to sync across surfaces, so moving them from per-device to gateway-wide is the requested behaviour, not a side effect.
Approach: the gateway config keeps each switch, and localStorage stays as a fast cache. Config rather than adding the keys to
DURABLE_PREF_KEYS: the uiPrefs backup restores only on a cold profile, so a warm desktop app and a warm browser tab would never pick up each other's change. The config route reaches every open dashboard through the configrefreshframe it already receives.sections_dashboard.py,loader_builders.py,loader.py,sections.py,handlers/core_config_schema.py,handlers/core.py,change_card_catalog.py):dashboard.feature_previews.<name>, for the 6 live flags:webhooks,artifact_deploy,crew,remote_crew_chat,layout_harness,folder_conductor.configuration.mdandconfig-baseline.jsonare updated.mc-preview-instance-sessionskey is not kept on the gateway. Its ON is carried up asremote_crew_chat.usePreviewFlagServerSync.ts, mounted inshell/appShell.tsxbeside the shell's existing reader of the same config query, so boot order is unchanged):setConfigPathValuehelper.if_unset, so it never replaces a stored value.kc-feature-previews-syncedmarker makes a cache-only ON read as off, so a key the operator removed stays off. The marker is not set while a toggle is in flight, or after a refused toggle or a refused carry, so a browser-only value is never wiped.kc-feature-previews-server-backed, with an in-memory copy for when storage is full). A recorded switch that the gateway no longer holds reads as off even before the browser is marked synced, so another switch's failed carry-up cannot send a removed switch back up.{{productName}}), without the word "gateway".en-XAis regenerated.Why this does not use
useOptimisticConfigPaths: that hook gives one settings component an in-flight display value per config path and lets saves run side by side. The switches here are shared by every surface outside any one component, so the sync keeps its own small queue. It sends one switch's writes in click order, so the gateway keeps the last click, and when a write is refused it puts the switch back to the last value the gateway accepted, in the cache and in localStorage. The hook does neither of those, so only its path-write helper is reused.Overlap: open PR #20420 also edits
DURABLE_PREF_KEYS. This PR does not touch that list, so the two do not conflict.Backwards compatibility
Compatible: the new config fields are optional and default to off, the PATCH allowlist only gains names, and an existing browser-only ON is carried up once instead of being dropped.
The diff takes one thing away: localStorage is no longer the source of truth for a switch. Once synced, a cache-only ON that the gateway does not hold reads as off, and a non-owner's toggle no longer overrides the gateway's stored value.
Reader: website/src/utils/previewFlags.ts:readPreviewFlag -- chat|crew page -- still reads the cache, which reconcile keeps equal to the gateway copy | previewFlagServerSync.test.tsx "lets the server copy win over a stale browser copy"
Reader: website/src/hooks/usePreviewFlag.ts:usePreviewFlag / useRemoteCrewChat -- chat|crew page -- re-renders on the same cache write event | previewFlagServerSync.test.tsx "turns Crewmates on from the server when this browser has no copy"
Reader: website/src/surfaces/registry.ts:surfacePreviewEnabled (nav rail, pagesProvider, appNavHidden, CommandBarOverlay) -- chat|crew page -- reads the cache via readPreviewFlag | previewSurfaces.test.tsx
Reader: website/src/pages/settings/FeaturePreviewsSection.tsx -- crew page -- toggles still write the cache first, then the gateway | previewSurfaces.test.tsx "says why a switch went back when the gateway refuses the write"
Reader: non-owner dashboard session (e.g. a QR session) -- chat|crew page -- intended: config saves are owner-only, so it sees every switch the owner set (the config GET is not owner-gated), its own toggle is refused and switched back with the owner-only notice, and a switch it had already turned on in that browser stays on there | featurePreviewsSectionNotice.test.tsx "names the %s switch when the owner-only write is refused", "names the owner, not a reload, when a one-time carry is refused as owner-only"
Reader: retired mc-preview-instance-sessions -- chat -- carried up as remote_crew_chat, then cleared | previewFlagServerSync.test.tsx "carries the retired Remote crew sessions switch up as Chat on a crew", "never lets the retired key turn Chat on a crew back on after it was turned off"
Tests
website/src/test/previewFlagServerSync.test.tsx(33 tests). The repro: Crewmates turns on from the server when localStorage is empty, and it fails with the sync disabled. The other tests cover:if_unsetcarry-up, not replacing a stored value, a 409 counted as synced, and a refused carry reported and kept on;PREVIEW_FLAGSand every declared flag constant.I removed each of these lines on a scratch copy, and each removal makes a test fail:
pending.sizeguard;website/src/test/previewSurfaces.test.tsx: the section shows the owner-only notice naming the switch when the PATCH returns 403.website/src/test/featurePreviewsSectionNotice.test.tsx(11 tests), with the sync mounted as the shell mounts it:It lifts
FeaturePreviewsSection.tsxabove the 80% per-file coverage floor (93.9% of lines locally, across the tests that render it).test/test_feature_previews_config.py(25 tests):if_unsetwrites an absent switch and never replaces a stored one;Local runs on this commit:
useOptimisticConfigPaths, the settings pages, the wholesrc/i18nfolder including thestyle/French U+202F and Korean checks, and everyAppand shell test.FeaturePreviewsSection.tsxis at 93.9% of lines andusePreviewFlagServerSync.tsat 100% in that run.tsc(app),eslint src/ --max-warnings 0,check-i18n-strings.mjs,check-i18n-keys.mjsandi18n-check.mjsare clean withI18N_BASE_REFset to the base commit, and the regenerateden-XAhas no diff.test_feature_previews_config.py,test_facade_mirror_guards.py,test_config_patch.py,test_config_schema.pyandtest_dashboard_config_gitlab_hosts.pypass (305), with the slowest tree scan well under the 120 s limit.Local AI review: GPT (
gpt-6.1-sol) and Opus read-only reviews ran over several rounds. Each quoted the commit SHA it read, and I checked those against the worktree. Every Critical/High/Medium finding is fixed in this commit, and the final round on the last code change found none open. On this rebuild, a GPT (gpt-6.1-sol) and an Opus review of the new commit each quoted its SHA, confirmed the diff matches fix(dashboard): keep feature-preview switches on the gateway #22298 apart from thesetConfigPathValuewrite, and found nothing Critical or High.Manual verification
I took screenshots against the built SPA, with
/api/config/kirocrewreturningcrew: true:Screenshots / video
Synced from the gateway (Crewmates on, empty browser storage):
A toggle refused with 403, naming the switch:
A toggle refused with 500 (the same notice shows for an expired session's 403), naming the switch:
A browser-only switch whose carry-up failed:
A browser-only switch whose carry-up was refused as owner-only (403): the switch stays on, the notice names the owner and has no reload step:
Known unrelated CI failure: Backend Tests (Windows) (1) hits the
test_ci_ipv6_routingcollect timeout (#21943). This change does not touch that test.Related Issues
Fixes #21396
Related: #16237, #17424, #14232, #9876
Replaces #22298, which already had the two commits PR Hygiene allows, so the switch to the shared
setConfigPathValuehelper could not be added there. This is the same change as one commit off current main, with that cache write as the only code difference. Earlier versions: #22000, #21722, #21624, #21602 and #21569.Pattern harvest
Rule candidate: review-prompt
Pattern: a user-visible setting persisted only in browser localStorage, when it is meant to hold across surfaces of the same gateway; check whether it should live in gateway config with localStorage as a cache.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.