Repository navigation
fix(dashboard): keep feature-preview switches on the gateway - #22913
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Moving the switches to the gateway is the real fix for #21396. Two pieces of the browser-side sync are more than that fix needs, and the change of who may flip a switch is not on record as a decision. Notes
What this change shipsInventory (10 items) — 7 justifiedIntent: keep a Feature previews switch on across every browser and the desktop app on one gateway. FIX.
[FIRST-PRINCIPLES-REVIEWED] e8e9289 Description read[DESCRIPTION-READ] 211c92090305ceca00b0aff002a9bc2973692d4e71b0698e96d74c6be27a96d6 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The gateway config is the source of truth and localStorage is a cache, so this fixes the root cause. The one take-away, localStorage losing authority, is listed in Backwards compatibility with its readers. Notes
[DESIGN-REVIEWED] e8e9289 Description read[DESCRIPTION-READ] d110fb835d9efe6d7c2d4a9ce5f86a5488f4207eefd91ab85c7bf6713e23b558 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 |
UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)UX-level review of UX-Verdict: PASS cannot evaluate: missing the refused-toggle notices. No screenshot shows the switch going back with "Only the owner… switched back" or "Couldn't save… Try again". A non-owner session is most likely to hit these two of the four new notices. Evidence gaps
Notes
[UX-REVIEWED] e8e9289 Description read[DESCRIPTION-READ] 1f0dc4e7122494697ab42ced1792b71c9a1bd1acd0a7d03e561cce0304eb8c8d That sha256 names everything this verdict read: the PR description, plus the 6 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 findings (all downgraded on adjudication)GPT 6.1 flagged blocking issues on This comment is updated in place on each push. Review detailsBLOCKING -- website/src/hooks/usePreviewFlagServerSync.ts:273 -- Another tab can revert a switch whose save is pending
Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 — LOW. I checked the conditions it needs. Tab B has to run False positive or not applicable? A repository writer can comment: |
|
HOLD: the current-head review lanes have no replies. Reviewed head 27baa6e. The approach is sound. The gateway config holds each switch, localStorage is a cache, and writes reuse the existing owner-only config PATCH and its
— crew-pr-reviewer (r119) |
27baa6e to
203b6e1
Compare
|
Replies to the crew-pr-reviewer HOLD (r119) and the review notes on 27baa6e. New head: 203b6e1, which is one commit rebased on current main. UX evidence gap (intro): fixed. There are fresh screenshots of this head in the description, and the intro shows the shipped UX copy notes: all three are fixed in all 12 catalogs, and
First Principles item 4 (the synced marker repeats the per-switch record): kept for now, with a follow-up. Both markers are there only to migrate browsers that predate the gateway copy. The per-switch record does not cover every case, for two reasons:
Removing the marker alone would trade one stored key for that regression. The smaller complete change is to remove the carry-up, the synced marker and the per-switch record together once old browsers have migrated. That is tracked in #24963. Design note 1 (the legacy Design note 2 (remove the carry-up and marker later): agreed. It is tracked in #24963. Rebase notes:
Local runs on 203b6e1:
|
1d3d985 to
1617c39
Compare
|
[operator: bolichen97] Thanks for this. We'd like it landed so Feature Preview switches follow the user across devices (turn one on on a laptop, the phone shows it on too). Two asks:
Happy to help with either if that's useful. |
|
[operator: bolichen97] Maintainer note: I'm helping land this. I'll rebase it onto current |
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, and that notice clears once the gateway holds a value for the switch. 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. A switch saved from one dashboard now reaches the other open ones without a reload: the gateway's config watcher pushes a config refresh when dashboard.feature_previews changes. The section intro now says the choices are saved on this gateway and apply wherever the dashboard is opened, instead of "saved for everyone". The Preview-gated surfaces paragraph in the dashboard module spec 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. Fixes #21396
1617c39 to
e8e9289
Compare
|
[operator: bolichen97]
|
v0.12.0 shipped #22913, which keeps the Settings > Developer > Feature previews switches on the gateway. Its migration for browsers that set a switch before then (an if_unset carry-up of a browser-only ON, the kc-feature-previews-synced marker and the per-switch server-backed record) is no longer needed, so the gateway value is now the only source of truth and localStorage a pure cache: a switch the gateway holds no value for reads as off, and the two retired keys are cleared when the sync mounts. The carry-refused notices and their strings go with it in every catalog. Reconcile, in-flight protection and refused-toggle revert are unchanged.
v0.12.0 shipped #22913, which keeps the Settings > Developer > Feature previews switches on the gateway. Its migration for browsers that set a switch before then (an if_unset carry-up of a browser-only ON, the kc-feature-previews-synced marker and the per-switch server-backed record) is no longer needed, so the gateway value is now the only source of truth and localStorage a pure cache: a switch the gateway holds no value for reads as off, and the two retired keys are cleared when the sync mounts. The carry-refused notices and their strings go with it in every catalog. Reconcile, in-flight protection and refused-toggle revert are unchanged.
v0.12.0 shipped #22913, which keeps the Settings > Developer > Feature previews switches on the gateway. Its migration for browsers that set a switch before then (an if_unset carry-up of a browser-only ON, the kc-feature-previews-synced marker and the per-switch server-backed record) is no longer needed, so the gateway value is now the only source of truth and localStorage a pure cache: a switch the gateway holds no value for reads as off, and the two retired keys are cleared when the sync mounts. The carry-refused notices and their strings go with it in every catalog. Reconcile, in-flight protection and refused-toggle revert are unchanged.
Problem / Motivation
Goal: A Feature previews switch (such as Ultra Mode) 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 asked for the switches to sync across surfaces.
Approach: gateway config keeps each switch; localStorage stays as a fast cache. Config, not
DURABLE_PREF_KEYS: the uiPrefs backup restores only on a cold profile, so two warm surfaces would never see each other's change. Config reaches every open dashboard through therefreshframe it already gets.sections_dashboard.py,loader_builders.py,loader.py,sections.py,handlers/core_config_schema.py,handlers/core.py,change_card_catalog.py,change_card_catalog_kinds.py,server_runtime/config_watch.py):dashboard.feature_previews.<name>, for the 8 live flags:webhooks,artifact_deploy,crew_mode,crewmate_harness,remote_crew_chat,layout_harness,folder_conductor,session_environments. Each is default OFF.configuration.mdandconfig-baseline.jsonare updated.dashboard.feature_previewspushes a config refresh, so other open dashboards update without a reload.mc-preview-instance-sessionskey is not kept; its ON is carried up asremote_crew_chat.usePreviewFlagServerSync.ts, mounted inshell/appShell.tsxbeside the shell's existing config reader):if_unset, never replacing a stored value.kc-feature-previews-synced) and per-switch record (kc-feature-previews-server-backed): once synced, a cache-only ON reads as off, and a switch the gateway held then dropped reads as off, so a removed switch cannot come back. Neither is set while a toggle is in flight or after a refusal, so a browser-only value is never wiped.website/src/i18n/locales/*.json): the section description no longer says "per-device" or "for everyone"; it says choices are saved on this{{productName}}. Four new notice strings, all 12 catalogs updated,en-XAregenerated.learn-cron-dashboard.mddescribes the gateway copy, the cache andusePreviewFlagServerSync.Why not
useOptimisticConfigPaths: it gives one component an in-flight value per path and lets saves run side by side. These switches are shared outside any one component, need click-order writes and a revert to the last accepted value, so only its path-write helper is reused.Overlap: #20420 edits
DURABLE_PREF_KEYS; this PR does not, so they 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 Ultra Mode 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(35 tests). The repro: Ultra Mode 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 (90.9% of lines locally, in the coverage run over the preview andsrc/i18ntests).test/test_config_live_server_appliers.py: a change todashboard.feature_previewspushes one config refresh, and an unrelated change pushes none.test/test_feature_previews_config.py(25 tests):if_unsetwrites an absent switch and never replaces a stored one;Local runs on this commit:
src/i18nfolder including thestyle/French U+202F and Korean checks.FeaturePreviewsSection.tsxis at 90.9% of lines andusePreviewFlagServerSync.tsat 100%.tsc(app),eslint src --max-warnings 0,check-i18n-strings.mjs,check-i18n-keys.mjs,check-dnt-catalogs.mjsandi18n-check.mjsare clean withI18N_BASE_REFset to the base commit, and the regenerateden-XAis part of this commit.test_feature_previews_config.pytests pass (1,748), 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 on the earlier versions. Each quoted the commit SHA it read, and I checked those against the worktree. 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 #22830 apart from the two fixes below, and found nothing Critical or High.Manual verification
I took screenshots against the built SPA, with
/api/config/kirocrewreturningcrew: true:Screenshots / video
Taken on head
203b6e1(rebased on current main), against the dev SPA with a stubbed/api/config/kirocrew.Synced from the gateway (Mates on, empty browser storage). The intro shows the shipped
feature_previews_desc: "Your choices here are saved on this Kiro Crew, so they apply wherever you open the dashboard…":A browser-only Webhooks switch whose one-time carry-up failed (PATCH 500). The notice says it stays on until the reload:
A browser-only Webhooks switch whose carry-up was refused as owner-only (PATCH 403). The notice starts with what happened first and has no reload step:
The refused-toggle notices (
save_denied,save_failed) are unchanged since the earlier revision; the tests cover them for each switch.Update (rebase and review replies)
change_card_catalog.py, so thedashboard.feature_previews.*cannot-widen entries now live inchange_card_catalog_kinds.py, and the facade listsFEATURE_PREVIEW_FLAGSamong its type-checker names. The spec paragraph keeps main's newer wording.featurePreviewsSectionNotice.test.tsxfollows it.feature_previews_carry_failedandfeature_previews_carry_deniedno longer say "for everyone". They say "saved on this {{productName}}".carry_deniednow starts with what happened first, andcarry_failedsays the switch stays on until the reload. All 12 catalogs updated,en-XAregenerated.Update (rebase onto main, newer flags)
The maintainer (bolichen97) rebased this onto current main for the author; the design is unchanged.
previewFlags.ts,FeaturePreviewsSection.tsx,previewSurfaces.test.tsx,change_card_catalog_kinds.pyand the spec paragraph, keeping main's newer cards and wording (incl. the switch-only Ultra Mode card) and this PR's sync.crew_mode(mc-preview-crew-mode) andcrewmate_harness;session_environmentswas already in. Droppedcrew, whose preview main retired in feat(members): release Mates by default and retire its preview #24598 (Mates shipped by default). The write path is unchanged: the owner-only PATCH, bool only, unknown names dropped.crewkey now usecrew_mode; the notice test covers Ultra Mode, Agent harness per mate and Session Environments.config-baseline.jsonregenerated.Related Issues
Fixes #21396
Related: #16237, #17424, #14232, #9876
Replaces #22830. The GPT 6.1 and UX review lanes on #22830 each found one thing to fix, and #22830 already had the two commits PR Hygiene allows, so this is #22830's two commits plus both fixes as one commit off current main:
My earlier reply on #22830 about the carry-up notice was premature; this commit fixes it.
Earlier versions: #22544, #22298, #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.