Skip to content

[backport cloud/1.54] fix(agent): resolve the agent gate off /features - #19178

Merged
christian-byrne merged 1 commit into
cloud/1.54from
backport-19074-to-cloud-1.54
Sep 28, 2026
Merged

christian-byrne merged 1 commit into
cloud/1.54from
backport-19074-to-cloud-1.54

Conversation

@christian-byrne

Copy link
Copy Markdown
Contributor

Backport of #19074 to cloud/1.54.\n\nManual fallback after the automatic backport run remained queued; release-branch conflicts were reconciled against the reviewed implementation and the branch's existing test layout.

@christian-byrne christian-byrne added backport Backporting a PR onto a release candidate agent-backport Agent changes targeting a stable cloud/core release branch greenlight labels Sep 28, 2026
@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
billing-web-test Error Error Sep 28, 2026 3:55am UTC
1 Skipped Deployment
Project Deployment Actions Updated
billing-web Ignored Ignored Sep 28, 2026 3:55am UTC

Request Review

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright: ✅ 1963 passed, 0 failed

📊 Browser Reports
  • chromium: View Report (✅ 1942 / ❌ 0 / ⚠️ 0 / ⏭️ 13)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 18 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 09/28/2026, 04:02:21 AM UTC

Links

…og-js flag path (#19074)

*PR Created by the Glary-Bot Agent*

---

Fixes the root cause behind
[PM-1707](https://linear.app/comfyorg/issue/PM-1707/test-agentcomfyorg-shows-the-agent-on-my-phone-but-not-on-desktop-in)
/
[PM-1706](https://linear.app/comfyorg/issue/PM-1706/fix-agent-does-not-appear-on-desktop-browsers-for-a-user-while-it)
— an allowlisted user saw the agent on one browser but not another.
Supersedes #18842, which only characterized the old behaviour.

`agent-in-app-experience` was already published on `/features` (it's in
`FrontendFlags` in the cloud repo, evaluated server-side per
authenticated user) and the app already fetched that payload into
`window.__CONFIG__` at bootstrap. The agent gate ignored it and re-asked
PostHog over a second, independently-failing client path — the only flag
in the codebase still doing so. Billing was migrated to this rail in

Because posthog-js keys flags by its own `distinct_id` and caches them
per-origin in `localStorage` while sharing identity cross-subdomain via
cookie, two browsers on the same account could disagree. That's the
divergence users saw.

`agent-in-app-experience` is now a `ServerFeatureFlag` resolved through
`useFeatureFlags` off `remoteConfig`, via a new
`resolveWhitelistFlag()`:

- `false` off the Cloud build, and `false` before the first
authenticated answer (the anonymous bootstrap payload cannot answer a
per-user allowlist)
- after an authenticated answer, a *failed* refresh falls back to that
answer, held **in memory for the session only** — never storage. A
persisted grant is precisely what made two browsers disagree.
- revocation propagates on the next successful poll; 401/403 and
sign-out clear it

`setupFlagGate` loses the dynamic imports, the `onFeatureFlags`
subscription and the delivery plumbing, becoming two reactive watches.
Deleted: `postHogFlagSource.ts`, `useAgentFeatureGate.ts` (dead code —
nothing but its own test imported it, and it lacked the `errorsLoading`
guard, so the two copies behaved differently), and their tests.

`posthog-js` stays — telemetry still uses it. This removes only the flag
path.

Every guard is mutation-tested; each of these turns the suite red:

| Mutation | |
|---|---|
| anonymous-window guard removed (fail-open before auth) | caught |
| `isCloud` guard removed | caught |
| fail-open before the first authenticated answer | caught |
| grant fallback removed (a blip unmounts the panel) | caught |
| grant survives sign-out / 401 | caught |
| grant never recorded on a successful load | caught |
| **grant persisted via `useStorage`** — the PM-1707 shape, under either
the flag key *or* a renamed key | caught |
| gate `enabled` unwired from the flag | caught |
| gate settles on the anonymous config | caught |
| signed-out settle fallback removed | caught |

`pnpm typecheck`, `lint`, `knip`, `format:check` clean; 12,129 unit
tests pass. The one broad-run failure (`agentSubgraphDefinitions`)
reproduces identically on `main`.

Two bugs were caught during review and fixed here rather than shipped: a
transient `/features` failure would have unmounted the panel mid-session
for a granted user (`DockedAgentPanel` is `v-if`, so composer draft and
in-flight turn UI are destroyed), and the E2E fixtures were still
feeding the flag through the deleted posthog channel, which would have
regressed the whole agent E2E suite to a dead panel.

- **E2E fixtures changed.** All three now put the key at the top level
of the `/features` body. Specs can't be executed in my sandbox; the
static chain is verified end to end (`cloudBootMocks` serves that body
to both fetches, and `WorkspaceAuthGate` throws unless state is
`authenticated`, so any spec that renders has reached the state the
resolver needs). **One CI run of `--project=cloud` on a single agent
spec would settle it conclusively.**
- **Retired telemetry slug.** `agent_flag_gate_load_failure` no longer
exists — the guarded dynamic import it reported on is gone. Any monitor
keyed on it will go silently to zero.
- **New Datadog facet.** The flag is added to
`startFeatureFlagTelemetry`. It's the first dashed `ServerFeatureFlag`,
and the sanitiser rewrites dashes — the RUM facet is
`agent_in_app_experience`, not the hyphenated name.
- **Deliberately dropped:** an in-session re-offer retry that existed
only because `posthog.onFeatureFlags` re-delivered unchanged values. The
real retry triggers (`offerHeld && screenIsClear`, identity change) are
unaffected and still covered.
- **Known residue:** the grant-retention window is unbounded, so a
sustained `/features` outage leaves a revoked user with an inert panel
until reload. Low impact — the backend enforces the flag independently
at four choke points, so every call 404s regardless.

---------

Co-authored-by: Glary-Bot <glary-bot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords (2)
  • [release]
  • [backport

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 93bd8d9b-3dfb-4316-8426-5ed43712d460

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the risk:high PR risk grade (advisory shadow check; grader-owned) label Sep 28, 2026
@christian-byrne
christian-byrne merged commit 7cebfe1 into cloud/1.54 Sep 28, 2026
62 of 63 checks passed
@christian-byrne
christian-byrne deleted the backport-19074-to-cloud-1.54 branch September 28, 2026 04:03
@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@              Coverage Diff              @@
##             cloud/1.54   #19178   +/-   ##
=============================================
  Coverage              ?   79.05%           
=============================================
  Files                 ?     2026           
  Lines                 ?   113154           
  Branches              ?    34151           
=============================================
  Hits                  ?    89457           
  Misses                ?    23519           
  Partials              ?      178           
Flag Coverage Δ
unit 79.05% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/composables/useFeatureFlags.ts 100.00% <100.00%> (ø)
src/extensions/core/agentPanel.ts 99.00% <100.00%> (ø)
src/extensions/core/index.ts 0.00% <ø> (ø)
src/platform/remoteConfig/refreshRemoteConfig.ts 98.59% <100.00%> (ø)
src/platform/remoteConfig/remoteConfig.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch had an error being deployed

1 failed deployment
Preview – billing-web-test — 85a0da68 Deployed Sep 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-backport Agent changes targeting a stable cloud/core release branch backport Backporting a PR onto a release candidate greenlight risk:high PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants