Skip to content

Scope feature flags to RuntimeClient instead of a module-level singleton#9394

Draft
ericpgreen2 wants to merge 8 commits intomainfrom
ericgreen/app-857-scope-featureflags-to-runtimeclient-instead-of-a-module
Draft

Scope feature flags to RuntimeClient instead of a module-level singleton#9394
ericpgreen2 wants to merge 8 commits intomainfrom
ericgreen/app-857-scope-featureflags-to-runtimeclient-instead-of-a-module

Conversation

@ericpgreen2
Copy link
Copy Markdown
Contributor

Replaces the module-level featureFlags singleton with a per-runtime useFeatureFlags() hook backed by the existing GetInstance query, plus a small app-flags.ts for the three flags that depend on the frontend app rather than the runtime (adminServer, readOnly, legacyArchiveDeploy).

  • Fixes the branch-swap bug in Rill Cloud where new branch flags didn't apply until a page refresh: each <RuntimeProvider> mount now owns its own query lifecycle, so two providers can't stomp each other across a {#key} re-mount.
  • RemoteProjectManager self-gates on $deploy; new EmbedShell.svelte hosts the embed layout's runtime-flag-dependent chrome inside the provider so nothing reads runtime flags above it.
  • Non-Svelte AI helpers (generateMetricsView.ts, generateCanvas.ts, import.ts) now receive resolved aiEnabled from their component callers.

Closes APP-857

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

Developed in collaboration with Claude Code

Introduce a per-runtime feature-flag hook that derives reactive stores
from the existing GetInstance query against the nearest RuntimeProvider's
RuntimeClient. The legacy `featureFlags` singleton stays in place so that
follow-up commits can migrate consumers piecemeal.
Three plain writables for `adminServer`, `readOnly`, and
`legacyArchiveDeploy` — flags whose values depend on the frontend app
(web-admin / web-local / embed) rather than on the connected runtime.
Move readers and setters of `adminServer`, `readOnly`, and
`legacyArchiveDeploy` off the legacy singleton and onto the plain
writables in `app-flags.ts`. Mixed destructures keep the singleton
import for now; runtime flags follow in the next commit.
Swap `featureFlags` singleton imports for the per-runtime hook across
~32 Svelte components. Each call returns reactive stores derived from
the current `<RuntimeProvider>`'s `GetInstance` query, so different
runtimes (e.g. different branches) report independent flag values.
Refactor `generateMetricsView.ts`, `generateCanvas.ts`, and
`import.ts` to receive the AI flag value as a parameter rather than
reading it from a global singleton. Component callers source the
value from `useFeatureFlags()`.

Drop the unused `getEnabledStore()` from `MeasureSelection`, which
was the only consumer of `featureFlags.dashboardChat` in this layer.
`RemoteProjectManager` self-gates on `$deploy` instead of relying on
the web-local layout to wrap it in `{#if}`. The layout always renders
the component and the gate moves into context.

Extract `EmbedShell` to host the embed layout's runtime-flag-dependent
chrome (`dashboardChat`, `showTopBar`, `correctedKindForChat`) inside
`<RuntimeProvider>`. The outer embed layout no longer reads runtime
flags above the provider.
Remove the legacy singleton class from `feature-flags.ts` and the
`featureFlags.setRuntimeClient`/`clearRuntimeClient` calls from
`RuntimeProvider`. The provider is now pure context propagation; each
`<RuntimeProvider>` mount owns its own feature-flag query lifecycle
through `useFeatureFlags()`, so two providers cannot stomp each other
across a `{#key}` re-mount.

Closes APP-857.
Two callsites were missed in the previous AI-helper signature change.
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.

1 participant