Skip to content

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

Closed
mbriones98 wants to merge 2 commits into
mainfrom
fix/preview-flags-persist-21396-v3
Closed

mbriones98 wants to merge 2 commits into
mainfrom
fix/preview-flags-persist-21396-v3

Conversation

@mbriones98

@mbriones98 mbriones98 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

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

  • 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 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 config refresh frame it already receives.

  • Backend (sections_dashboard.py, loader_builders.py, loader.py, sections.py, handlers/core.py, change_card_catalog.py):
    • One bool per switch under dashboard.feature_previews.<name>, for the 6 live flags: webhooks, artifact_deploy, crew, remote_crew_chat, layout_harness, folder_conductor.
    • The PATCH allowlist accepts only those names, typed bool. The loader drops unknown names and non-bool values.
    • The change card classifies the new paths, and configuration.md and config-baseline.json are updated.
    • The retired mc-preview-instance-sessions key is not kept on the gateway. Its ON is carried up as remote_crew_chat.
  • Dashboard (usePreviewFlagServerSync.ts, mounted in App.tsx beside the shell's existing reader of the same config query, so boot order is unchanged):
    • Reconcile: the server value wins over the cache, except for a flag whose write is still in flight.
    • Write order: each toggle is PATCHed, and writes for one flag are sent one after another so the last click is what the gateway keeps.
    • One-time carry-up: a switch set only in this browser before the gateway kept the switches is carried up once with if_unset, so it never replaces a stored value.
    • Sync marker: afterwards a kc-feature-previews-synced marker 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.
    • Refused toggle: the switch goes back to the last value the gateway accepted, and the section shows an error notice naming the switch. On a 403 it says only the owner can change feature previews. On any other failure, including a 403 from an expired session, it says the save failed.
    • Refused carry: the notice says the switch is on in this browser only.
  • Copy:
    • The section description no longer says "per-device". It now says the switches are saved for everyone using this Kiro Crew ({{productName}}), without the word "gateway".
    • Three new notice strings.
    • All 12 translated catalogs are updated, and en-XA is 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:

    • 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 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;
    • 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.
  • 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 (10 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;
    • the Artifact Deploy and Webhooks links open their pages.

    It lifts FeaturePreviewsSection.tsx above 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):

    • 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: full vitest suite, 3,073 of 3,073 files pass. tsc (app), eslint src/ --max-warnings 0 and jscpd are clean. i18n-check.mjs and the src/i18n tests, including the [changed-values] French and Korean style checks, pass with I18N_BASE_REF set to the base commit.
    • Backend: test_feature_previews_config.py, test_facade_mirror_guards.py, test_config_baseline.py and test_change_card_setting_classes.py pass (116). The full backend run on the previous cut matched origin/main's failure set on this host, which come from the host itself (enterprise profile, live KIROCREW_HOME, no userns). black, isort, flake8 and mypy are clean on the changed Python.
  • 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.

Known CI timeout, unrelated to this diff: Backend Tests (3.12, 7) fails on test/test_session_allocation_bindings.py::test_every_name_patched_through_the_facade_reaches_every_owner_reading_it, which hits pytest-timeout's 120 s limit on all four attempts (latest run). The same test takes 107.65 s on main in CI (main run) and about 81 s locally on both main and this branch. It is the same timeout as #21441. Coverage Gate fails closed only because that backend job failed.

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

Synced from the gateway (Crewmates on, empty browser storage):

Feature previews section synced from the gateway

A toggle refused with 403, naming the switch:

Owner-only notice naming Webhooks

A toggle refused with 500 (the same notice shows for an expired session's 403), naming the switch:

Couldn't save notice naming Webhooks

A browser-only switch whose carry-up failed:

On in this browser only notice

Related Issues

Fixes #21396

Related: #16237, #17424, #14232, #9876

Supersedes #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.

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
@mbriones98
mbriones98 requested review from a team and KiroCrewCaptain as code owners October 17, 2026 14:41
@mbriones98
mbriones98 requested a review from bolichen97 October 17, 2026 14:41
@mbriones98
mbriones98 enabled auto-merge (squash) October 17, 2026 14:41
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of ff3fdb0a7b1872095a9df6036a0f67c021440943 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that a non-owner dashboard session (token or QR) can still use previews now that every toggle needs the owner-only config PATCH.

[DESIGN-REVIEWED] ff3fdb0

Description read

[DESCRIPTION-READ] b320da9371ee5dbaf7da9ff2ae55297f2c0470cbd9069c5a4a2b2d1a1cdd0440

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 17, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of ff3fdb0a7b1872095a9df6036a0f67c021440943 — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The cross-surface fix is sound. The per-flag write queue and the one-time carry-up add module-global state that the settings toggles elsewhere don't need.

Not justified as shipped

  • Item 4 — oversized: tails, baselines, and the pending counts plus the "only the last queued write reports and reverts" guard exist only because a switch can still be clicked while its PATCH is in flight. In pages/settings/, 58 controls across 25 files instead use disabled={…isPending}. CrewmatesSection.tsx:84 does this for the same ['kirocrewConfig'] PATCH.
    Subtraction: hold each switch while its write is pending and delete tails, baselines, the per-flag counts and the last-queued-click guard. The revert then becomes "refetch and take the server value".
    Clears when: the queue is removed, or the description names a harm that disabling the switch during a save cannot remove.
  • Item 5 — oversized: the zero option for "carried up once with if_unset" is that someone who turned a preview on before the upgrade turns it on once more. To avoid that, the change adds a persisted kc-feature-previews-synced marker, carriesInFlight/carryFailed/carried, a third notice string in 13 catalogs, and the item 7 rider.
    Subtraction: delete the carry-up, the marker and feature_previews_carry_failed, and make the gateway copy the only source on first read.
    Clears when: the carry is removed, or a report shows a one-time re-toggle costs someone more than this state does.

What this change ships

Inventory (9 items) — 6 justified

Intent: keep a Feature previews switch on across every browser and the desktop app that use one gateway. FIX (#21396).

  1. A preview switch stays set on every browser, the desktop app and every dashboard address — justified
  2. A non-owner's toggle is refused with an owner-only notice — justified
  3. New dashboard.feature_previews.<name> config keys, six of them, in the PATCH allowlist — justified
  4. Switches stay clickable during a save; writes are queued per flag with a revert baseline — oversized
  5. A browser-only ON is carried up once; the sync marker afterwards turns a cache-only ON off — oversized
  6. A notice names the refused switch (save failed / owner only) — justified
  7. Retired "Remote crew sessions" ON is carried up as Chat on a crew — rides along with item 5
  8. The change card marks the new paths cannot-widen; docs and config baseline updated — justified
  9. The section copy no longer says "per-device" — justified

[FIRST-PRINCIPLES-REVIEWED] ff3fdb0

Description read

[DESCRIPTION-READ] 3fb5d1801f97857352fb30ec363f96f1201a162402e1fa930649601d90991e70

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 17, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — 🟡 CONCERNS

UX-level review of ff3fdb0a7b1872095a9df6036a0f67c021440943 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

The new "saved for everyone using this Kiro Crew" wording makes a single-user setting read as a shared change, and it made the cold reader hesitant to flip switches.

Watch

  • "Everyone" suggests other people are affected. feature_previews_desc and feature_previews_carry_failed both say "saved for everyone using this {{productName}}". The point of the change is that one person's browsers and desktop app all stay in sync, but "everyone" describes a group of users. The blind reader said: "It makes me nervous, because it says my click affects other people", and on Crewmates: "I don't know who turned it on or what turning it off would break for others." This is the section intro, read on every visit, and it puts people off trying previews, which is the job of this page. Medium severity. Fix: "saved in this {{productName}}, so they stay set in every browser and the desktop app."
  • The partial-success notice is unclear and styled as a failure. In shot-04 the switch stayed on, but the notice uses the same red error styling as a full refusal. Its next step, "Reload the page to try again", also leaves the outcome unclear. The reader: "I can't tell whether reloading keeps Webhooks on or turns it back off." This only appears after a refused carry, so it is rare but confusing when it happens. Low–medium severity. Fix: say what the reload does ("Reload to save it for every browser; it stays on here either way"), and use a warning tone if ErrorNotice supports one.

Suggestions

  • feature_previews_save_denied: the reader doubted that "Ask the agent" could help someone who is not the owner ("not sure the AI can do anything about it"). Drop askAgent for the denied case, or name who to ask.

[UX-REVIEWED] ff3fdb0

Description read

[DESCRIPTION-READ] d4f9ad7a732351b328595336b5322a6f49116db97821c70917b92c37c1170dbc

That sha256 names everything this verdict read: the PR description, plus the 7 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 17, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] ff3fdb0

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable ff3fdb0a7b1872095a9df6036a0f67c021440943: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging ff3fdb0a7b1872095a9df6036a0f67c021440943. 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

This comment is updated in place on each push.

BLOCKING -- website/src/hooks/usePreviewFlagServerSync.ts:251 -- A failed carry lets another flag resurrect a deleted config value

void persist(qc, flag, true, true).then(ok => {
Unsynced owner browser has Webhooks cached ON and receives crew: true; Webhooks carry fails with 500 → deleting crew and refetching runs reconcilePreviewFlags while the global sync marker remains unset → it PATCHes the server-derived cache back as crew: true, undoing the deletion.
Anchor: residual/crash-data-loss-corruption
Fix: Persist sync provenance per flag; previously server-backed flags must become OFF when absent, independently of another flag’s failed carry.
[BLOCK-MERGE] ff3fdb0
[GPT-REVIEWED] ff3fdb0

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

F1 (fenced): I'm flagging this, not upholding it, but it keeps blocking either way. The defect is real. It can only happen when four rare things line up, and the damage is a visible preview switch that one click fixes.

  • Conditions:

    • The browser must never have synced: synced is false at website/src/hooks/usePreviewFlagServerSync.ts:223.
    • The same open page must have had a carry fail with something other than a 409: the failure returns false at :180 and sets carryFailed at :253. That keeps the page from marking itself synced, at both :254 and :257.
    • The crew key must then be deleted outright on the server. Switching it off from the UI writes false, which :237-238 handles.
    • The cache must still hold the old ON, so :241-243 treats it as a value set before the server kept the switches. crew was never added to carried, so :248 doesn't stop it, and :251 sends it back up with if_unset.
  • Consequence: a Feature-previews switch comes back ON in config. That's a dashboard feature toggle, not a credential, a privilege or user data. The switch shows ON, so it isn't silent. Switching it off sends persist(..., false) at :278 → :157, and an explicit false is kept from then on (:237). The real fix (tracking per flag whether the value came from the server) would add new stored state for a one-time migration path.

    [ADJUDICATION] ff3fdb0 total=0 uphold=0 downgrade=0
    [GPT-ADJUDICATED] ff3fdb0

    [ADJUDICATION-FENCED] ff3fdb0 fenced=1 flagged=1
    FLAG F1 website/src/hooks/usePreviewFlagServerSync.ts:251 -- Needs a never-synced browser (:223), a non-409 carry failure in the same open page (:180/:253), and the crew key deleted outright on the server rather than switched off (:237); the result is a visible preview switch back ON that one toggle-off fixes (:278), so the residual risk is plausibly acceptable.
    [GPT-ADJUDICATED-FENCED] ff3fdb0

🏷️ Fenced finding(s) machine-flagged as likely edge case

The security fence keeps these findings blocking regardless of adjudication; the only clearance path is a human override. The annotate-only pass judged the condition combination each one requires extreme, and pre-drafted the override rationale below. A repository writer must independently verify a rationale before posting it — it is machine-authored, and a wrong override on a security-class finding ships exactly the class the fence exists to stop.

  • F1 website/src/hooks/usePreviewFlagServerSync.ts:251 — Needs a never-synced browser (:223), a non-409 carry failure in the same open page (:180/:253), and the crew key deleted outright on the server rather than switched off (:237); the result is a visible preview switch back ON that one toggle-off fixes (:278), so the residual risk is plausibly acceptable.

    /ai-review override gpt ff3fdb0a7b1872095a9df6036a0f67c021440943: Needs a never-synced browser (:223), a non-409 carry failure in the same open page (:180/:253), and the crew key deleted outright on the server rather than switched off (:237); the result is a visible preview switch back ON that one toggle-off fixes (:278), so the residual risk is plausibly acceptable.
    

False positive or not applicable? A repository writer can comment:
/ai-review override gpt ff3fdb0a7b1872095a9df6036a0f67c021440943: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 17, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 17, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ready yet. The design is sound: gateway config as the source of truth with localStorage as a cache fixes the root cause in #21396, and the PATCH allowlist and loader only accept the six known names as bools. Two things remain.

Head reviewed: ff3fdb0. Bots read: Design PASS, First Principles CONCERNS, UX CONCERNS, Opus no blocking, GPT BLOCK (fenced), readiness action required.

🔴 0 must-fix · 🟡 2 should-fix (inline).

  1. The GPT fenced finding at usePreviewFlagServerSync.ts:251 keeps readiness blocked. I traced it on this head and it is real: in a browser that has not synced, a failed carry of one switch leaves the next reconcile free to carry up a different switch whose cached ON came from the server. The fix is small (see inline 2), so fixing it is cheaper than an override.
  2. A non-owner session (for example a QR session) reads config, so its cached ON is carried up on every load and gets a 403. The notice then says "Reload the page to try again", which never helps (inline 1).

A question, not a blocker: Design Review asked whether a non-owner dashboard session can still use previews. After this change such a session cannot turn any preview on; the switch bounces back with the owner-only notice. The Backwards compatibility section names the take-away, but no Reader line covers that session. If this is the intended behaviour for the issue owner, please say so in the description and I will withdraw this point.

The First Principles and UX CONCERNS on this head have no reply yet. Please answer or rebut each one.

Verified by reading: the backend allowlist, loader filter and if_unset path on main; that the config GET route is not owner-gated while PATCH is; that a config refresh frame invalidates ['kirocrewConfig']. Not verified: the cause of the Backend Tests (Windows) (1) failure on this head (log not available yet).

{writeError && (
<ErrorNotice
testId="feature-previews-save-error"
message={writeError.carry

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 A carry refused with 403 tells the user to reload, but a reload repeats the same 403.

persist() records { flag, denied, carry: true }, and this branch checks carry before denied. A non-owner session can read config, so each page load finds the cached ON, sends the if_unset carry, and gets a 403. The notice then says the switch "couldn't be saved for everyone" and asks for a reload. The reload sends the same request and fails the same way, so the user is told to repeat a step that cannot work.

message={writeError.carry
  ? i18nT('pages.settings.developerPanel.feature_previews_carry_failed', { name: previewFlagLabel(writeError.flag) })

Why it matters: the only next step offered is a dead end, and each load also logs one more denied config write for that session.

Suggestion: when writeError.carry && writeError.denied, show a message that says only the owner can save it for every browser and that it stays on here, without the reload step. Optionally, do not retry a carry that was refused with 403 on later loads. A test for a 403 carry notice would pin it (the current carry tests use 500 or assert only the error object).

continue
}
const server = fp[previewFlagName(flag)]
if (typeof server === 'boolean') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 A switch whose cached value came from the server can still be carried up as if it were a pre-upgrade value.

This confirms the GPT fenced finding at line 251 and suggests a fix on these lines. In a browser that has not synced, a failed carry of one switch sets carryFailed, so the marker is never written. If another switch was applied from the server here (line 238) and that key is later removed from config, the next reconcile sees a cache-only ON, finds the switch missing from carried, and sends it back with if_unset. The removed key comes back on.

if (typeof server === 'boolean') {
  if (readPreviewFlag(flag) !== server) cachePreviewFlag(flag, server)
  continue
}

Why it matters: the impact is small (a visible preview switch turns back on), but this fenced finding is the only open BLOCK on readiness. A fix in a few lines clears it without an override.

Suggestion: record that the value came from the server when you apply it, for example carried.add(flag) in this branch. That stops the carry in the same document. To also cover later loads of a browser that never synced, keep a per-flag marker in localStorage when the server value is applied, and treat a cache-only ON as off for a flag with that marker. A test: unsynced browser, carry of switch A fails with 500, the server returns crew: true, then a body without crew; assert no if_unset PATCH for crew.
Rule: GPT 6.1 Review fenced finding on this head.

@mbriones98

Copy link
Copy Markdown
Contributor Author

Superseded by #21722.

@mbriones98 mbriones98 closed this Oct 17, 2026
auto-merge was automatically disabled October 17, 2026 23:54

Pull request was closed

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 17, 2026
@mbriones98

Copy link
Copy Markdown
Contributor Author

@bolichen97 thanks for the review. This PR is superseded by #21722, which addresses all three points:

  1. Switch carried back up after the gateway dropped it: each browser now records, per switch, whether it has seen the gateway hold that switch (kc-feature-previews-server-backed, with an in-memory copy if storage is full). A recorded switch the gateway no longer holds reads as off, whatever happened to another switch's carry. There's a test for the exact sequence you described.
  2. Reload loop on a 403 carry: a carry refused as owner-only now says only the owner can save the switch for everyone and that it stays on in this browser, with no reload step. Tested.
  3. Non-owner sessions: intended, and it follows from config saves being owner-only. A non-owner session sees every switch the owner set, its own toggle is switched back with the owner-only notice, and a switch it had already turned on in that browser stays on there. fix(dashboard): keep feature-preview switches on the gateway #21722's description now has a Reader line for this.

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)

2 participants