fix(config): resolve the deployment shape on the server and read it through one client reader - #7461
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThe PR moves workspace deployment-feature resolution from browser module constants to a server-resolved host-context value with a shared client reader.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/core/config/deployment-shape.ts | Introduces server resolution plus imperative and subscribed browser readers, with host-context seeds taking precedence over the environment fallback. |
| apps/sim/app/workspace/[workspaceId]/providers/workspace-host-provider.tsx | Seeds the deployment reader from SSR host context during provider render and refreshes it when queried context changes. |
| apps/sim/lib/workspaces/host-context.ts | Projects the server-resolved deployment shape into workspace host context. |
| apps/sim/lib/api/contracts/workspaces.ts | Extends the workspace host-context contract with an optional deployment shape for rolling compatibility. |
| apps/sim/components/settings/navigation.ts | Makes the unified settings catalog deployment-agnostic and defers environment-specific availability to explicit access resolution. |
| apps/sim/lib/settings/application/workspace-section-access.ts | Applies deployment-aware server-side settings-section access checks using the shared reader. |
| apps/sim/blocks/utils.ts | Moves runtime model and credential conditions from frozen browser environment constants to the deployment-shape reader. |
Sequence Diagram
sequenceDiagram
participant Server as Workspace server layout
participant HostAPI as Host-context resolver
participant Provider as WorkspaceHostProvider
participant Reader as Deployment-shape store
participant UI as Workspace consumers
Server->>HostAPI: Resolve workspace host context
HostAPI-->>Server: Context with deployment shape
Server->>Provider: Render with initial context
Provider->>Reader: Seed deployment shape during provider render
Reader-->>UI: Provide hosted, billing, chat, and feature flags
Provider->>HostAPI: Refetch host context on client
HostAPI-->>Provider: Updated context
Provider->>Reader: Refresh deployment shape
Reader-->>UI: Notify subscribed components
Reviews (3): Last reviewed commit: "fix(config): re-evaluate option lists wh..." | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed across 60 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
c16efce to
a4c84b5
Compare
|
@cubic-dev-ai review this PR |
@icecrasher321 I have started the AI code review. It will take a few minutes to complete. |
…hrough one client reader Client-side deployment flags (`isHosted`, `isBillingEnabled`, `isChatEnabled`, provider-configured flags, and the enterprise feature set) were module constants computed once from the `NEXT_PUBLIC_*` transport the root layout emits. A document that never runs the root layout — Next's bare `__next_error__` 404 shell, or `global-error` after the root or workspace layout throws — leaves every one of them unset for the life of the tab, including after `retry()` or a client-side navigation recovers the app in place. Sim Cloud then rendered as self-hosted: an API Key field on every hosted-model block, no Auto model, no billing sections, "Self hosting" in settings. Project the deployment shape into the workspace host context, resolved on the server per request (`resolveDeploymentShape`), and give browser code one reader: `useDeploymentShape()` for components and `getDeploymentShape()` for block conditions, sub-block visibility, stores, and helpers. The host provider seeds the reader during its own render, ahead of any workspace child, so the first paint already reads the server value; outside a workspace, where the root layout always runs, the env constants remain the fallback. Parameterize the settings catalog on the shape instead of module constants: `selfHostedOverride` names a feature key resolved by `isSelfHostedOverrideEnabled`, `buildUnifiedSettingsCatalog` is unfiltered so `/settings/self-host` redirects to General on hosted instead of 404ing, and the server section gate passes the same shape. Retire the browser-hostname fallback for `isHosted` (superseded) and the module-scope env reads in the catalog. Tests cover the resolver, the env-less document with and without a seeded shape, provider seeding order, catalog resolution on both deployment kinds, and the billing gate reading the host context; four component suites move from partial `env-flags` factories to `setEnvFlags`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… mount A host context served by an app version that predates the deployment field leaves the browser on the env fallback until a refetch carries the shape. Block option builders read the shape outside React, so the sub-block combobox now subscribes to it and keys its option memo on it; the reader hands out one stable fallback object per document so that dependency only changes when the shape does. The host-provider test now renders without query data first and then lets a refetch land, so the effect path that follows a later host context is exercised rather than the initial seed twice. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
a4c84b5 to
94a296b
Compare
|
@cubic-dev-ai review this PR |
@icecrasher321 I have started the AI code review. It will take a few minutes to complete. |
Summary
Client-side deployment flags (
isHosted,isBillingEnabled,isChatEnabled, the provider-configured flags, and the enterprise feature set) were module constants computed once from theNEXT_PUBLIC_*transport the root layout emits. A document that never runs the root layout — Next's bare__next_error__404 shell, orglobal-errorafter the root or workspace layout throws — leaves every one of them unset for the life of the tab, including afterretry()or a client-side navigation recovers the app in place. Sim Cloud then renders as self-hosted: an API Key field on every hosted-model block, no Auto model, no billing sections, and "Self hosting" in settings.This resolves the deployment shape on the server and delivers it through the workspace host context, which is SSR-seeded and client-refetched, so it is correct on every document type:
deploymenton the host-context contract, resolved per request byresolveDeploymentShape(); optional for rolling compatibility.lib/core/config/deployment-shape.ts:useDeploymentShape()for components,getDeploymentShape()for block conditions, sub-block visibility, stores, and helpers. The host provider seeds it during its own render, ahead of any workspace child. Outside a workspace the env constants remain the fallback, since the root layout always runs there.selfHostedOverridenames a feature key resolved byisSelfHostedOverrideEnabled,buildUnifiedSettingsCatalogis unfiltered so/settings/self-hostredirects to General on hosted instead of 404ing, and the server section gate passes the same shape. Supersedes fix(settings): resolve deployment shape from the server, not module env #7222.env-flags.The reader deliberately imports no React hooks: block definitions import it, which places it in React Server Component graphs (auth route → workflow lifecycle → block registry), and Next rejects a hook import there. The seeding hook lives in the client-side host provider.
Type of Change
Testing
Unit and static:
bun run type-check, Biome,check:api-validation, and the 45-audit aggregate pass. Fullapps/simsuite: 2,944 files, 40,686 tests, 0 failures. New tests cover the resolver, the env-less document with and without a seeded shape, provider seeding order, catalog resolution on both deployment kinds, and the billing gate reading the host context. Four component suites moved from partialenv-flagsfactories tosetEnvFlags.End to end (uncommitted Playwright harness against
next devin forced-hosted mode, fresh signup, Agent block ongpt-5.6-sol; the browser env transport overridden from a document-start init script):fdbc7a7f50host-context.deploymenthosted=trueReviewers: the contract diff (
lib/api/contracts/workspaces.ts), the seeding order inworkspace-host-provider.tsx, and the settings catalog refactor incomponents/settings/navigation.tsare the places to read closely. Intentionally left onenv-flagsbecause they are module-init reads with no render-time replacement: the panel store's default tab, the Slack approval-gated scope list, and the auth client's plugin registration.Checklist
🤖 Generated with Claude Code