Scope feature flags to RuntimeClient instead of a module-level singleton#9394
Draft
ericpgreen2 wants to merge 8 commits intomainfrom
Draft
Scope feature flags to RuntimeClient instead of a module-level singleton#9394ericpgreen2 wants to merge 8 commits intomainfrom
RuntimeClient instead of a module-level singleton#9394ericpgreen2 wants to merge 8 commits intomainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the module-level
featureFlagssingleton with a per-runtimeuseFeatureFlags()hook backed by the existingGetInstancequery, plus a smallapp-flags.tsfor the three flags that depend on the frontend app rather than the runtime (adminServer,readOnly,legacyArchiveDeploy).<RuntimeProvider>mount now owns its own query lifecycle, so two providers can't stomp each other across a{#key}re-mount.RemoteProjectManagerself-gates on$deploy; newEmbedShell.sveltehosts the embed layout's runtime-flag-dependent chrome inside the provider so nothing reads runtime flags above it.generateMetricsView.ts,generateCanvas.ts,import.ts) now receive resolvedaiEnabledfrom their component callers.Closes APP-857
Checklist:
Developed in collaboration with Claude Code