Skip to content

Commit 7339feb

Browse files
committed
fix(sandbox): show Shell when a sandbox provider is ready, clearer setup failures, and chart-derived sandbox defaults
1 parent 1cad183 commit 7339feb

31 files changed

Lines changed: 1104 additions & 69 deletions

‎.github/workflows/helm.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
# The image inventory is generated from the chart and checked here, so a
1212
# change to its generator has to run this workflow too.
1313
- 'scripts/generate-image-manifest.ts'
14+
- 'scripts/write-chart-sandbox-images.ts'
1415
- 'package.json'
1516
pull_request:
1617
branches: [main, staging, dev]
@@ -22,6 +23,7 @@ on:
2223
# The image inventory is generated from the chart and checked here, so a
2324
# change to its generator has to run this workflow too.
2425
- 'scripts/generate-image-manifest.ts'
26+
- 'scripts/write-chart-sandbox-images.ts'
2527
- 'package.json'
2628

2729
# Pull requests cancel a superseded run; pushes never do, so a newer push cannot cut off a chart
@@ -302,6 +304,17 @@ jobs:
302304
APP_VERSION: ${{ needs.release-version.outputs.version }}
303305
run: bun run scripts/sync-chart-appversion.ts --version "${APP_VERSION}"
304306

307+
# The published chart pre-pulls the Function sandbox image its appVersion runs,
308+
# read from the release tag; the file is gitignored, so only published charts
309+
# carry it. --verify renders the chart and checks the DaemonSet holds that image.
310+
- name: Bundle the release's sandbox Function image
311+
env:
312+
APP_VERSION: ${{ needs.release-version.outputs.version }}
313+
run: |
314+
set -euo pipefail
315+
git fetch --no-tags --depth=1 origin "refs/tags/${APP_VERSION}:refs/tags/${APP_VERSION}"
316+
bun run scripts/write-chart-sandbox-images.ts --version "${APP_VERSION}" --verify
317+
305318
- name: Package chart
306319
id: package
307320
run: |
@@ -498,6 +511,14 @@ jobs:
498511
APP_VERSION: ${{ needs.release-version.outputs.version }}
499512
run: bun run scripts/sync-chart-appversion.ts --version "${APP_VERSION}"
500513

514+
# Same bundled sandbox image as the OCI publish, so both repos ship the same chart.
515+
# The full-history checkout already has the release tag.
516+
- name: Bundle the release's sandbox Function image
517+
if: steps.pages.outputs.exists == 'true'
518+
env:
519+
APP_VERSION: ${{ needs.release-version.outputs.version }}
520+
run: bun run scripts/write-chart-sandbox-images.ts --version "${APP_VERSION}"
521+
501522
- name: Configure Git
502523
if: steps.pages.outputs.exists == 'true'
503524
env:

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,8 @@ __pycache__/
110110
# `apps/sim/lib/uploads/` — 61 files of tracked source — and silently ignore
111111
# anything added there later.
112112
/uploads
113+
114+
# Written by scripts/write-chart-sandbox-images.ts in the chart publish jobs from the
115+
# release's sandbox image list, so a published chart pre-pulls the function image its
116+
# appVersion runs. Never committed: from a checkout it would not match appVersion.
117+
/helm/sim/files/sandbox-images.json

‎apps/docs/content/docs/platform/self-hosting/sandboxes.mdx‎

Lines changed: 35 additions & 8 deletions
Large diffs are not rendered by default.

‎apps/docs/content/docs/workflows/blocks/function.mdx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ the configured Debian repositories.
6868

6969
JavaScript is the default. The language field is part of the saved workflow and is
7070
never removed when Sandbox configuration changes. Python remains available as a
71-
language choice; Shell and custom Sandbox controls appear when a remote Function
72-
sandbox provider is enabled. Reference an earlier output directly, with no quotes
71+
language choice; Shell appears when a remote Function sandbox provider is ready.
72+
The custom **Sandbox** selector also needs sandbox access (see
73+
[Sandboxes](#sandboxes)). Reference an earlier output directly, with no quotes
7374
around the tag, and read an environment variable with `{{VAR}}`:
7475

7576
<Tabs items={['JavaScript', 'Python', 'Shell']}>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { resetEnvFlagsMock, setEnvFlags } from '@sim/testing'
2+
import { afterEach, describe, expect, it } from 'vitest'
3+
import { CodeLanguage } from '@/lib/execution/languages'
4+
import { FunctionBlock } from '@/blocks/blocks/function'
5+
6+
afterEach(resetEnvFlagsMock)
7+
8+
function languageIds(): string[] {
9+
const options = FunctionBlock.subBlocks.find((subBlock) => subBlock.id === 'language')?.options
10+
if (typeof options !== 'function') throw new Error('language options are static')
11+
return options().map((option) => option.id)
12+
}
13+
14+
describe('Function language options', () => {
15+
it('offers Shell when a remote provider is ready, without the custom-Sandbox entitlement', () => {
16+
setEnvFlags({ isRemoteSandboxEnabled: true, isSandboxesEnabled: false })
17+
18+
expect(languageIds()).toContain(CodeLanguage.Shell)
19+
})
20+
21+
it('hides Shell when no remote provider is ready, even with the entitlement', () => {
22+
setEnvFlags({ isRemoteSandboxEnabled: false, isSandboxesEnabled: true })
23+
24+
expect(languageIds()).not.toContain(CodeLanguage.Shell)
25+
})
26+
})

‎apps/sim/blocks/blocks/function.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const FunctionBlock: BlockConfig = {
3636
options: () => [
3737
{ label: getLanguageDisplayName(CodeLanguage.JavaScript), id: CodeLanguage.JavaScript },
3838
{ label: getLanguageDisplayName(CodeLanguage.Python), id: CodeLanguage.Python },
39-
...(getDeploymentShape().features.sandboxes
39+
...(getDeploymentShape().remoteCodeEnabled
4040
? [{ label: getLanguageDisplayName(CodeLanguage.Shell), id: CodeLanguage.Shell }]
4141
: []),
4242
],

‎apps/sim/instrumentation-node.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ export async function register() {
387387
const { getConfiguredRedisUrl } = await import('@/lib/core/config/redis')
388388
getConfiguredRedisUrl()
389389

390+
const { reportSandboxConfiguration } = await import('@/lib/core/config/env-capabilities.server')
391+
reportSandboxConfiguration()
392+
390393
await initializeOpenTelemetry()
391394

392395
const { reportAccountTokenSealing } = await import('@sim/db/sealed-text')

‎apps/sim/lib/api/contracts/workspaces.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,11 @@ export const deploymentShapeSchema = z.object({
278278
* for rolling compatibility with app versions that predate projecting them; readers
279279
* treat absent as `false`. `e2bEnabled` means the selected sandbox provider runs Pi's
280280
* cloud modes; it keeps the name it had before providers were selectable.
281+
* `remoteCodeEnabled` means the selected provider runs Function code (Python, Shell,
282+
* JavaScript with imports), independent of the custom-Sandbox entitlement.
281283
*/
282284
e2bEnabled: z.boolean().optional(),
285+
remoteCodeEnabled: z.boolean().optional(),
283286
slackExtendedScopes: z.boolean().optional(),
284287
invitationsDisabled: z.boolean().optional(),
285288
publicApiDisabled: z.boolean().optional(),

‎apps/sim/lib/core/config/deployment-projection.dom.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ vi.hoisted(() => {
2828
cohereConfigured: false,
2929
registrationMode: 'closed-no-email',
3030
e2bEnabled: true,
31+
remoteCodeEnabled: true,
3132
slackExtendedScopes: true,
3233
invitationsDisabled: true,
3334
features: {
@@ -55,6 +56,7 @@ import {
5556
isOrganizationsEnabled,
5657
isPiCloudEnabled,
5758
isPublicApiDisabled,
59+
isRemoteSandboxEnabled,
5860
isSandboxesEnabled,
5961
isSelfServeRegistrationClosed,
6062
isSessionPoliciesEnabled,
@@ -89,6 +91,7 @@ describe('browser registration flags', () => {
8991
describe('browser deployment switches', () => {
9092
it('take the projected server answer over the browser environment', () => {
9193
expect(isPiCloudEnabled).toBe(true)
94+
expect(isRemoteSandboxEnabled).toBe(true)
9295
expect(isSlackExtendedScopesEnabled).toBe(true)
9396
expect(isInvitationsDisabled).toBe(true)
9497
})

‎apps/sim/lib/core/config/deployment-shape.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
isOrganizationsEnabled,
2727
isPiCloudEnabled,
2828
isPublicApiDisabled,
29+
isRemoteSandboxEnabled,
2930
isSandboxesEnabled,
3031
isScimEnabled,
3132
isSessionPoliciesEnabled,
@@ -102,7 +103,8 @@ function browserFallbackShape(): DeploymentShape {
102103
* this is the `env-flags` fallback, used only when no projection exists.
103104
*
104105
* `features.sandboxes` is Sandbox *availability* (entitlement and a ready remote
105-
* provider), not the entitlement alone.
106+
* provider), not the entitlement alone. `remoteCodeEnabled` is provider readiness
107+
* alone: the Function runtimes (Python, Shell) need a provider, not the entitlement.
106108
*/
107109
export function resolveDeploymentShape(): DeploymentShape {
108110
return {
@@ -113,6 +115,7 @@ export function resolveDeploymentShape(): DeploymentShape {
113115
cohereConfigured: isCohereConfigured,
114116
registrationMode: getRegistrationMode(),
115117
e2bEnabled: isPiCloudEnabled,
118+
remoteCodeEnabled: isRemoteSandboxEnabled,
116119
slackExtendedScopes: isSlackExtendedScopesEnabled,
117120
invitationsDisabled: isInvitationsDisabled,
118121
publicApiDisabled: isPublicApiDisabled,

0 commit comments

Comments
 (0)