Skip to content

fix(dashboard): keep feature-preview switches on the gateway - #22913

Merged
bolichen97 merged 1 commit into
mainfrom
fix/preview-flags-persist-21396-v9
Oct 30, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/preview-flags-persist-21396-v9

Conversation

@mbriones98

@mbriones98 mbriones98 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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

  • No change to what any preview does once it is on.
  • No new route and no auth change: writes go through the existing owner-only config PATCH.
  • No per-user scope. The switches belong to the gateway, like every other dashboard setting in config.
  • No change to the DURABLE_PREF_KEYS / /api/ui-prefs backup, so there is one source of truth.
  • No 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 the refresh frame it already gets.

  • Backend (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):
    • One bool per switch under 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.
    • The PATCH allowlist accepts only those names, typed bool; the loader drops unknown names and non-bool values. Writes go through the existing owner-only PATCH.
    • The change card classifies the new paths; configuration.md and config-baseline.json are updated.
    • A change to dashboard.feature_previews pushes a config refresh, so other open dashboards update without a reload.
    • The retired mc-preview-instance-sessions key is not kept; its ON is carried up as remote_crew_chat.
  • Dashboard (usePreviewFlagServerSync.ts, mounted in shell/appShell.tsx beside the shell's existing config reader):
    • Reconcile: the server value wins over the cache, except for a flag whose write is in flight.
    • Write order: each toggle is PATCHed; one flag's writes go one after another, so the last click wins.
    • One-time carry-up: a browser-only switch from before this change is carried up once with if_unset, never replacing a stored value.
    • Sync marker (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.
    • Refused toggle: the switch goes back to the last accepted value and a notice names it (403: only the owner can change feature previews; otherwise: the save failed).
    • Refused carry: the notice says the switch is on in this browser only (403: only the owner can save it, no reload step). It clears once the gateway holds a value for that switch.
  • Copy (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-XA regenerated.
  • Docs: the Preview-gated surfaces paragraph in learn-cron-dashboard.md describes the gateway copy, the cache and usePreviewFlagServerSync.

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:

    • writes, in-flight protection, and rapid toggles applied in click order;
    • a refused toggle reverting in synced and unsynced browsers, with no config body, after two or three refused clicks, and behind a refused carry;
    • the notice waiting for the last queued click, and being cleared only by a save of the same switch;
    • a refused carry-up notice clearing once the gateway holds a value for that switch (it fails without the fix), while a refused toggle's notice stays;
    • a 403 from an expired session reported as a failed save;
    • the one-time if_unset carry-up, not replacing a stored value, a 409 counted as synced, and a refused carry reported and kept on;
    • the sync marker not being set while a toggle is in flight, whether the in-flight read lands from the config read or from another switch's carry;
    • a switch the gateway held and then dropped reads as off when another switch's carry-up failed, also when the per-switch record cannot be stored, and the browser-only switch stays on;
    • an unreadable per-switch record reads as empty;
    • the retired key;
    • parity between PREVIEW_FLAGS and every declared flag constant.
  • I removed each of these lines on a scratch copy, and each removal makes a test fail:

    • the revert itself;
    • the per-flag baseline;
    • the in-flight guards;
    • the pending.size guard;
    • the last-queued-click guard on the notice;
    • the same-switch notice clear;
    • the per-switch record check, and its in-memory copy.
  • 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:

    • a 403 on each of the 6 switches shows the owner-only notice naming that switch;
    • a 500 shows the "couldn't save" notice;
    • a refused one-time carry says the switch is on in this browser only, and it stays on;
    • a one-time carry refused as owner-only names the owner and has no reload step;
    • the Artifact Deploy and Webhooks links open their pages.

    It lifts FeaturePreviewsSection.tsx above the 80% per-file coverage floor (90.9% of lines locally, in the coverage run over the preview and src/i18n tests).

  • test/test_config_live_server_appliers.py: a change to dashboard.feature_previews pushes one config refresh, and an unrelated change pushes none.

  • test/test_feature_previews_config.py (25 tests):

    • the gateway list matches the dashboard flags, and nothing is on by default;
    • the loader keeps only known names with bool values;
    • each switch is writable, and unknown names or non-bools write nothing;
    • if_unset writes an absent switch and never replaces a stored one;
    • a non-owner cannot write a switch.
  • Local runs on this commit:

    • Frontend: 117 test files (2,145 tests) pass on this commit: the preview sync, notice and surfaces tests, every test that mounts the shell, the settings tests, and the whole src/i18n folder including the style/ French U+202F and Korean checks. FeaturePreviewsSection.tsx is at 90.9% of lines and usePreviewFlagServerSync.ts at 100%. tsc (app), eslint src --max-warnings 0, check-i18n-strings.mjs, check-i18n-keys.mjs, check-dnt-catalogs.mjs and i18n-check.mjs are clean with I18N_BASE_REF set to the base commit, and the regenerated en-XA is part of this commit.
    • Backend: the config loader, live-config and config-watcher, schema, patch, baseline, change-card, docs-lint, default sidebar folder, facade-mirror and test_feature_previews_config.py tests 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/kirocrew returning crew: true:

  • With empty localStorage, Crewmates shows on.
  • With the PATCH returning 403, flipping Webhooks puts it back and the notice names it.
  • With the PATCH returning 500, flipping Webhooks puts it back and the notice says it couldn't be saved.
  • With a browser-only Webhooks ON and the carry PATCH returning 500, the notice says it is on in this browser only.

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…":

Feature previews intro, synced from the gateway

A browser-only Webhooks switch whose one-time carry-up failed (PATCH 500). The notice says it stays on until the reload:

On in this browser only, stays on until 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:

Turned on in this browser before it could be saved here

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)

  • Rebased onto current main as one commit. Main split change_card_catalog.py, so the dashboard.feature_previews.* cannot-widen entries now live in change_card_catalog_kinds.py, and the facade lists FEATURE_PREVIEW_FLAGS among its type-checker names. The spec paragraph keeps main's newer wording.
  • Main renamed the Crewmates card to "Mates"; featurePreviewsSectionNotice.test.tsx follows it.
  • UX copy: feature_previews_carry_failed and feature_previews_carry_denied no longer say "for everyone". They say "saved on this {{productName}}". carry_denied now starts with what happened first, and carry_failed says the switch stays on until the reload. All 12 catalogs updated, en-XA regenerated.
  • Follow-up for the carry-up and synced marker: chore(dashboard): remove the feature-preview one-time carry-up and synced marker #24963.

Update (rebase onto main, newer flags)

The maintainer (bolichen97) rebased this onto current main for the author; the design is unchanged.

  • Conflicts resolved in previewFlags.ts, FeaturePreviewsSection.tsx, previewSurfaces.test.tsx, change_card_catalog_kinds.py and the spec paragraph, keeping main's newer cards and wording (incl. the switch-only Ultra Mode card) and this PR's sync.
  • The persisted set now matches main's live flags: added crew_mode (mc-preview-crew-mode) and crewmate_harness; session_environments was already in. Dropped crew, 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.
  • Tests that used the retired crew key now use crew_mode; the notice test covers Ultra Mode, Agent harness per mate and Session Environments. config-baseline.json regenerated.
  • The screenshots and manual checks above are from the earlier head and show the Mates card, which main has since removed.

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:

  • a refused carry-up notice now clears once the gateway holds a value for that switch;
  • the section intro no longer says the switches are saved "for everyone".

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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@mbriones98
mbriones98 requested review from a team and KiroCrewCaptain as code owners October 21, 2026 21:46
@mbriones98
mbriones98 enabled auto-merge (squash) October 21, 2026 21:46
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of e8e9289f4654822249a6e5014cd60c8620debabd — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 2 — inherited: "a non-owner's toggle no longer overrides the gateway's stored value". This replaces each browser's own opt-in with one owner-only switch per gateway. The base RFC list has no entry for previews, and the deleted pin said "Putting it in config.json would imply a fleet-wide setting". Crewmates feature-preview toggle does not persist (stored only in browser localStorage) #21396 asked for sync, not for taking the switch away from non-owners.
  • Item 6 — oversized: kc-feature-previews-server-backed plus documentBacked add a second persisted marker next to kc-feature-previews-synced, only for "a switch the gateway held then dropped while another switch's carry failed". Subtraction: delete PREVIEW_FLAGS_SERVER_BACKED_KEY, documentBacked, serverBacked() and markServerBacked(), and keep the single sync marker.
  • Item 8 — oversized: feature_previews_carry_denied and feature_previews_carry_failed are two strings in 12 catalogs for a one-time migration notice. Subtraction: delete carry_denied and the writeError.denied branch under carry, keeping one carry notice.

What this change ships

Inventory (10 items) — 7 justified

Intent: keep a Feature previews switch on across every browser and the desktop app on one gateway. FIX.

  1. Preview switches are stored on the gateway and apply on every surface — justified
  2. Non-owner sessions can no longer turn a preview on for themselves; the switch reverts with a notice — inherited (scope change not recorded)
  3. New dashboard.feature_previews.<name> booleans, writable through the existing PATCH — justified
  4. Other open dashboards update live through a config refresh frame — justified
  5. A switch set only in this browser is carried up once with if_unset — justified
  6. Two persisted browser markers (synced, per-switch server-backed) — oversized
  7. Notice naming a refused switch (owner-only or save failed) — justified
  8. Separate notices for a refused carry-up (denied and failed) — oversized
  9. Section text drops "per-device" and says choices are saved on this Kiro Crew — justified
  10. The retired instance-sessions key is carried up as remote_crew_chat, then cleared — justified

[FIRST-PRINCIPLES-REVIEWED] e8e9289

Description read

[DESCRIPTION-READ] 211c92090305ceca00b0aff002a9bc2973692d4e71b0698e96d74c6be27a96d6

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of e8e9289f4654822249a6e5014cd60c8620debabd — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • The frontend now tracks sync state in two extra places (the kc-feature-previews-synced marker and the kc-feature-previews-server-backed per-switch record). That state can drift, so once the one-time carry-up has done its job, plan a follow-up that removes the carry-up and both markers.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

UX-level review of e8e9289f4654822249a6e5014cd60c8620debabd — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • feature_previews_save_denied ("Only the owner of this {{productName}} can change feature previews, so "{{name}}" was switched back."): no screenshot shows it. Attach a still of a non-owner toggling a switch: the notice under the intro, with the switch back off.
  • feature_previews_save_failed ("Couldn't save "{{name}}", so it was switched back. Try again."): no screenshot shows it. Attach a still of a failed save after clicking a switch, showing the switch back in its stored position.

Notes

  • The reload notice (feature_previews_carry_failed) left the blind reader asking "would reloading turn it back off?" Change "it stays on until then" to say it stays on after the reload as well, for example "Reload the page to try saving again. It stays on in this browser either way."
  • "saved on this {{productName}}" made the reader think "Kiro Crew" is a place or machine, and "the owner" in carry_denied left them unsure "whether that's me". Use something like "saved by this {{productName}} server" and "the person who set up this {{productName}}".
  • carry_denied puts the explanation first. Lead with the result: "“{{name}}” is on in this browser only. Only the owner of this {{productName}} can save it."

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed e8e9289f4654822249a6e5014cd60c8620debabd — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] e8e9289

Verdict parsed from the review's SHA-scoped output markers for commit e8e9289f4654822249a6e5014cd60c8620debabd.

False positive or not applicable? A repository writer can comment:
/ai-review override fable e8e9289f4654822249a6e5014cd60c8620debabd false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 6.1 flagged blocking issues on e8e9289f4654822249a6e5014cd60c8620debabd; Opus 5.5 adjudication downgraded every one of them. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

This comment is updated in place on each push.

Review details

BLOCKING -- website/src/hooks/usePreviewFlagServerSync.ts:273 -- Another tab can revert a switch whose save is pending

if (readPreviewFlag(flag) !== server) cachePreviewFlag(flag, server)
Trigger: With crew_mode: false stored, enable Ultra Mode in tab A, then load a same-origin dashboard in tab B before A’s PATCH persists. B’s config query calls reconcilePreviewFlags; its document-local pending map has no entry for A’s write.
Outcome: B overwrites their shared localStorage flag with OFF. A’s usePreviewFlag storage listener turns the switch off and hides Ultra Mode surfaces until the save completes.
Anchor: defect
Fix: Coordinate per-flag pending writes across same-origin tabs so reconciliation cannot overwrite another tab’s in-flight toggle.

[BLOCK-MERGE-DOWNGRADED] e8e9289
[GPT-REVIEWED] e8e9289

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 — LOW. I checked the conditions it needs. Tab B has to run reconcilePreviewFlags while tab A's PATCH is still in flight, and B's module-local pending check (usePreviewFlagServerSync.ts:22,267) can't see A's write. B's config body then still holds the old value (:271-273), and cachePreviewFlag writes it to the shared storage (previewFlags.ts:282). The damage stops itself. When A's write lands, it stores the accepted value (:185-187), then settle refetches and reconciles (:159-160,273), so both tabs end up showing the saved ON. Nothing is lost, and the wrong state lasts only about one round-trip, in a rare two-tab timing.
The real fix is a new cross-tab mechanism: shared pending markers or a BroadcastChannel, with expiry for crashed tabs. That adds state and ordering to the reconcile path, and future readers carry it permanently, for a brief UI flicker that corrects itself. The cost outweighs the harm.

[ADJUDICATION] e8e9289f4654822249a6e5014cd60c8620debabd total=1 uphold=0 downgrade=1
DOWNGRADE F1 website/src/hooks/usePreviewFlagServerSync.ts:273 reason=disproportionate-remedy
[GPT-ADJUDICATED] e8e9289f4654822249a6e5014cd60c8620debabd

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e8e9289f4654822249a6e5014cd60c8620debabd false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 21, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

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 if_unset. The backend gates nothing on these flags, so classifying them as cannot-widen is accurate. But no lane on this head has a disposition, and auto-merge is already armed. To clear:

  1. UX evidence gap: every screenshot shows the old intro text. Attach a fresh shot of the shipped feature_previews_desc.
  2. UX copy: feature_previews_carry_failed and feature_previews_carry_denied still say "saved for everyone" (en.manual.json#L7528), the wording the description says was dropped. Fix the strings or explain why they keep it, and answer the other two UX copy notes.
  3. Reply to the First Principles item 4 subtraction (the browser-wide synced marker repeats the per-switch record) and to both Design notes. For the legacy-key note, reconcile already clears it (usePreviewFlagServerSync.ts#L259), so a short reply is enough. If removing the carry-up later is planned, link an issue for it.

— crew-pr-reviewer (r119)

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 22, 2026
@iamwhatever
iamwhatever force-pushed the fix/preview-flags-persist-21396-v9 branch from 27baa6e to 203b6e1 Compare October 27, 2026 19:59
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 27, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

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 feature_previews_desc.

UX copy notes: all three are fixed in all 12 catalogs, and en-XA is regenerated.

  • carry_failed and carry_denied no longer say "for everyone". They now say "saved on this {{productName}}".
  • carry_denied now starts with what happened first: "“{{name}}” was turned on in this browser before it could be saved here. Only the owner of this {{productName}} can save it, so it stays on in this browser only."
  • carry_failed now ends with "Reload the page to try again; it stays on until then."
  • featurePreviewsSectionNotice.test.tsx now asserts the new wording and asserts that "for everyone" is gone.

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:

  • It can be lost when storage is full. Its in-memory copy does not survive a reload, and the case is tested ("also when the per-switch record cannot be stored").
  • Without the synced marker, an unrecorded cache-only ON would be carried up again with if_unset on every page load, so a switch the operator removed from config could come back.

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 mc-preview-instance-sessions key): this is already handled. Reconcile clears the legacy key once the browser is synced, once remote_crew_chat is server-backed, or once the gateway holds a boolean for it (usePreviewFlagServerSync.ts around L259). The "never lets the retired key turn Chat on a crew back on after it was turned off" test covers it.

Design note 2 (remove the carry-up and marker later): agreed. It is tracked in #24963.

Rebase notes:

  • Main split change_card_catalog.py, so the dashboard.feature_previews.* cannot-widen entries moved to change_card_catalog_kinds.py. The facade lists FEATURE_PREVIEW_FLAGS among its type-checker names.
  • Main renamed the Crewmates card to "Mates", and the notice test follows the rename.

Local runs on 203b6e1:

  • Frontend: the preview sync, notice and surfaces tests pass (81). The whole src/i18n folder passes (1,036). eslint is clean on the touched files.
  • i18n: check-i18n-strings, check-i18n-keys, check-dnt-catalogs and i18n-check all pass.
  • Backend: the feature-preview config, live appliers, change-card, config loader, schema, patch and docs-lint tests pass (1,569). The 2 failures in test_config_loader_stt.py also fail on a clean main checkout in this environment, so this PR does not cause them.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 27, 2026
@iamwhatever iamwhatever self-assigned this Oct 27, 2026
@iamwhatever
iamwhatever force-pushed the fix/preview-flags-persist-21396-v9 branch from 1d3d985 to 1617c39 Compare October 28, 2026 17:13
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 28, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

[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:

  1. Could you rebase on current main? The PR is CONFLICTING right now.
  2. Could you include the flags added since this was opened: crew_mode (Ultra Mode, key mc-preview-crew-mode), crewmate_harness (mc-preview-crewmate-harness) and session_environments (mc-preview-session-environments)?

Happy to help with either if that's useful.

@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Maintainer note: I'm helping land this. I'll rebase it onto current main, resolve the conflicts, and add the preview flags that landed since (crew_mode, crewmate_harness, session_environments) to the persisted set. The design stays as you wrote it, and you keep ownership of the PR. @mbriones98 shout if you'd rather do the rebase yourself.

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
@bolichen97
bolichen97 force-pushed the fix/preview-flags-persist-21396-v9 branch from 1617c39 to e8e9289 Compare October 30, 2026 20:13
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 30, 2026
@bolichen97

bolichen97 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

[operator: bolichen97]

  • span=105ac70de45d Another tab can revert a switch whose save is pending

Rebutted: disproportionate remedy, not a data-loss defect. The gateway write is never lost: tab A's accepted PATCH stores the value (usePreviewFlagServerSync.ts:185-187) and settle refetches and reconciles (:159-160), so both tabs converge on the saved value within one round-trip.
The window needs a second same-origin tab to load during A's in-flight PATCH; the effect is a brief UI flip that self-corrects. A fix needs a new cross-tab pending protocol (shared markers or BroadcastChannel with crash expiry) on the reconcile path, which outweighs the harm. Adjudication downgraded it on this head.
self-added: no

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 30, 2026
@bolichen97
bolichen97 disabled auto-merge October 30, 2026 21:03
@bolichen97
bolichen97 merged commit 60f3160 into main Oct 30, 2026
96 checks passed
@bolichen97
bolichen97 deleted the fix/preview-flags-persist-21396-v9 branch October 30, 2026 21:03
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 30, 2026
bolichen97 added a commit that referenced this pull request Nov 7, 2026
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.
bolichen97 added a commit that referenced this pull request Nov 7, 2026
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.
bolichen97 added a commit that referenced this pull request Nov 7, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crewmates feature-preview toggle does not persist (stored only in browser localStorage)

3 participants