Skip to content

fix(config): resolve the deployment shape on the server and read it through one client reader - #7461

Merged
icecrasher321 merged 2 commits into
stagingfrom
fix/deployment-shape-host-context
Sep 3, 2026
Merged

fix(config): resolve the deployment shape on the server and read it through one client reader#7461
icecrasher321 merged 2 commits into
stagingfrom
fix/deployment-shape-host-context

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Client-side deployment flags (isHosted, isBillingEnabled, isChatEnabled, the 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 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:

  • deployment on the host-context contract, resolved per request by resolveDeploymentShape(); optional for rolling compatibility.
  • One browser reader in 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.
  • Every client consumer inside the workspace tree migrated (about thirty files).
  • The settings catalog no longer reads 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. Supersedes fix(settings): resolve deployment shape from the server, not module env #7222.
  • Retires the browser-hostname fallback from fix(env): preserve hosted detection during client recovery #7445, now redundant, and the module-scope env reads in the settings catalog.
  • Adds a one-line rule to the project standards so client code does not regress to 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

  • Bug fix

Testing

Unit and static: bun run type-check, Biome, check:api-validation, and the 45-audit aggregate pass. Full apps/sim suite: 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 partial env-flags factories to setEnvFlags.

End to end (uncommitted Playwright harness against next dev in forced-hosted mode, fresh signup, Agent block on gpt-5.6-sol; the browser env transport overridden from a document-start init script):

scenario probe staging fdbc7a7f50 this branch
control (transport intact) API Key row / Auto model / Self hosting / Subscription hidden / yes / no / yes hidden / yes / no / yes
browser env says self-hosted, direct load same shown / no / yes / no hidden / yes / no / yes
browser env says self-hosted, in-app navigation same shown / no / yes / no hidden / yes / no / yes
both transports absent (settings page) Self hosting / Subscription / BYOK yes / no / no no / yes / yes
all host-context.deployment absent hosted=true

Reviewers: the contract diff (lib/api/contracts/workspaces.ts), the seeding order in workspace-host-provider.tsx, and the settings catalog refactor in components/settings/navigation.ts are the places to read closely. Intentionally left on env-flags because 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

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Sep 3, 2026 11:25pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR moves workspace deployment-feature resolution from browser module constants to a server-resolved host-context value with a shared client reader.

  • Adds the deployment shape to the workspace host-context contract and seeds it before workspace children render.
  • Migrates workspace components, block conditions, stores, settings gates, and helpers to the new reader.
  • Refactors settings navigation so catalog construction and deployment-specific access checks are separate.
  • Adds resolver, provider-seeding, navigation, billing, and deployment-fallback coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

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
Loading

Reviews (3): Last reviewed commit: "fix(config): re-evaluate option lists wh..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 60 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/blocks/blocks/function.ts
Comment thread apps/sim/blocks/blocks/function.ts
Comment thread apps/sim/app/workspace/[workspaceId]/providers/workspace-host-provider.test.tsx Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 65 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

icecrasher321 and others added 2 commits September 3, 2026 16:23
…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>
@icecrasher321
icecrasher321 force-pushed the fix/deployment-shape-host-context branch from a4c84b5 to 94a296b Compare September 3, 2026 23:23
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 66 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@icecrasher321
icecrasher321 merged commit 44a1612 into staging Sep 3, 2026
31 checks passed
@icecrasher321
icecrasher321 deleted the fix/deployment-shape-host-context branch September 3, 2026 23:34
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