Repository navigation
fix(dashboard): keep feature-preview switches on the gateway - #21602
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. Fixes #21396
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that a non-owner dashboard session, whose toggles now revert, is an accepted loss: previews it could switch on locally before are now owner-only. [DESIGN-REVIEWED] 051d058 Description read[DESCRIPTION-READ] d9c561213f4f9a0a5a1d7c281c6212bd6b4b629d6df1a774caca1b270f283b8b 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 The one-time carry-up migration (sync marker, carry counters, carry-failed notice in 13 catalogs) costs more than re-ticking an unreleased preview once. Not justified as shipped
What this change shipsInventory (10 items) — 5 justifiedIntent: keep a Feature previews switch set across every browser and the desktop app using one gateway. FIX.
[FIRST-PRINCIPLES-REVIEWED] 051d058 Description read[DESCRIPTION-READ] 3957afde2f99bc997672473b08afbd350762e80f69c67ad4ed9931b5b9c3f5fd 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 "saved for everyone using this Kiro Crew" copy reads as "other people", so the blind reader got nervous about touching switches in a single-user tool. Watch
Suggestions
[UX-REVIEWED] 051d058 Description read[DESCRIPTION-READ] ebe5eae54913475646c2de3d4d8d5188501c69d5a6722eb748a5ddd552f43178 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 |
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: |
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: |
|
Superseded by #21624 |
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.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 inApp.tsxbeside the shell's existing reader of the same config query, so boot order is unchanged):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.{{productName}}), without the word "gateway".en-XAis regenerated.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: 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(30 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.pending.sizeguard;website/src/test/previewSurfaces.test.tsx: the section shows the owner-only notice naming the switch when the PATCH returns 403.test/test_feature_previews_config.py(25 tests):if_unsetwrites an absent switch and never replaces a stored one;MarkdownRenderer.domGolden.test.tsx, fails the same way onorigin/mainon this host.tsc(app),eslint src/ --max-warnings 0andjscpdare clean.i18n-check.mjsandcheck-i18n-strings.mjspass withI18N_BASE_REFset to the base commit.origin/mainon this host, except 4 signal and process-timing tests that pass when re-run alone. The shared failures come from the host: an enterprise profile, a liveKIROCREW_HOME, and no userns. black, isort, flake8 and mypy are clean on the changed Python.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.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 browser-only switch whose carry-up failed:
Related Issues
Fixes #21396
Related: #16237, #17424, #14232, #9876
Supersedes #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.