Skip to content

Commit f6376eb

Browse files
feat(feature-flags): migrate 3 env-flags to AppConfig-backed runtime flags
1 parent 3fe061e commit f6376eb

18 files changed

Lines changed: 110 additions & 97 deletions

File tree

apps/sim/app/api/files/serve/[...path]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ async function compileDocumentIfNeeded(
117117
return { buffer: stored.buffer, contentType: stored.contentType }
118118
}
119119

120-
if (isE2BDocEnabled && getE2BDocFormat(filename)) {
120+
if (isE2BDocEnabled && (await getE2BDocFormat(filename))) {
121121
// Artifact not built yet (still generating, or the source didn't compile at
122122
// write time). Signal "not ready" without compiling — handled as 409.
123123
throw new DocCompileUserError('Document is still being generated')

apps/sim/app/api/workspaces/[id]/files/[fileId]/compiled-check/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const GET = withRouteHandler(
5757
// In the E2B regime ALL four formats compile in the doc sandbox (Node for
5858
// pptx/docx, Python for pdf/xlsx). Gate on the flag (not the stored MIME) so
5959
// a stale file can't trigger an E2B compile when the sandbox is disabled.
60-
const e2bFmt = isE2BDocEnabled ? getE2BDocFormat(fileRecord.name) : null
60+
const e2bFmt = isE2BDocEnabled ? await getE2BDocFormat(fileRecord.name) : null
6161
const taskId = BINARY_DOC_TASKS[ext]
6262
const isMermaidFile = ext === 'mmd' || ext === 'mermaid'
6363
if (!e2bFmt && !taskId && !isMermaidFile) {

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/new-column-dropdown/new-column-dropdown.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@ import {
1313
DropdownMenuTrigger,
1414
Plus,
1515
} from '@/components/emcn'
16-
import { isWorkflowColumnsEnabledClient } from '@/lib/core/config/env-flags'
1716
import type { ColumnDefinition } from '@/lib/table'
1817
import { COLUMN_TYPE_OPTIONS } from '../column-config-sidebar'
1918

20-
const VISIBLE_COLUMN_TYPE_OPTIONS = isWorkflowColumnsEnabledClient
21-
? COLUMN_TYPE_OPTIONS
22-
: COLUMN_TYPE_OPTIONS.filter((o) => o.type !== 'workflow')
23-
2419
const CELL_HEADER =
2520
'border-[var(--border)] border-r border-b bg-[var(--bg)] px-2 py-[7px] text-left align-middle'
2621

@@ -32,6 +27,7 @@ interface NewColumnDropdownProps {
3227
onPickType: (type: ColumnDefinition['type']) => void
3328
onPickWorkflow: () => void
3429
onPickEnrichment: () => void
30+
workflowColumnsEnabled: boolean
3531
}
3632

3733
/**
@@ -45,7 +41,12 @@ export function NewColumnDropdown({
4541
onPickType,
4642
onPickWorkflow,
4743
onPickEnrichment,
44+
workflowColumnsEnabled,
4845
}: NewColumnDropdownProps) {
46+
const visibleColumnTypeOptions = workflowColumnsEnabled
47+
? COLUMN_TYPE_OPTIONS
48+
: COLUMN_TYPE_OPTIONS.filter((o) => o.type !== 'workflow')
49+
4950
const menu = (
5051
<DropdownMenu>
5152
<DropdownMenuTrigger asChild>
@@ -67,7 +68,7 @@ export function NewColumnDropdown({
6768
)}
6869
</DropdownMenuTrigger>
6970
<DropdownMenuContent align='start' side='bottom' sideOffset={4}>
70-
{isWorkflowColumnsEnabledClient && (
71+
{workflowColumnsEnabled && (
7172
<>
7273
<DropdownMenuItem onSelect={onPickEnrichment}>
7374
<Sparkles className='size-[14px] text-[var(--text-icon)]' />
@@ -76,7 +77,7 @@ export function NewColumnDropdown({
7677
<DropdownMenuSeparator />
7778
</>
7879
)}
79-
{VISIBLE_COLUMN_TYPE_OPTIONS.map((option) => {
80+
{visibleColumnTypeOptions.map((option) => {
8081
const Icon = option.icon
8182
const onSelect =
8283
option.type === 'workflow'

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/table-grid.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ interface TableGridProps {
230230
pushTableRenameUndoSinkRef: React.MutableRefObject<
231231
((previousName: string, newName: string) => void) | null
232232
>
233+
workflowColumnsEnabled: boolean
233234
}
234235

235236
/** Serialize a cell value to its tab-separated clipboard representation. */
@@ -300,6 +301,7 @@ export function TableGrid({
300301
afterDeleteAllSinkRef,
301302
confirmDeleteColumnsSinkRef,
302303
pushTableRenameUndoSinkRef,
304+
workflowColumnsEnabled,
303305
}: TableGridProps) {
304306
const params = useParams()
305307
const workspaceId = propWorkspaceId || (params.workspaceId as string)
@@ -3738,6 +3740,7 @@ export function TableGrid({
37383740
onPickType={handleAddColumnOfType}
37393741
onPickWorkflow={handleAddWorkflowColumn}
37403742
onPickEnrichment={onOpenEnrichments}
3743+
workflowColumnsEnabled={workflowColumnsEnabled}
37413744
/>
37423745
)}
37433746
</tr>
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import type { Metadata } from 'next'
2+
import { headers } from 'next/headers'
3+
import { getSession } from '@/lib/auth'
4+
import { isFeatureEnabled } from '@/lib/core/config/feature-flags'
25
import { Table } from './table'
36

47
export const metadata: Metadata = {
58
title: 'Table',
69
}
710

8-
export default function TablePage() {
9-
return <Table />
11+
export default async function TablePage() {
12+
const session = await getSession(await headers())
13+
const workflowColumnsEnabled = await isFeatureEnabled('workflow-columns', {
14+
userId: session?.user?.id,
15+
})
16+
return <Table workflowColumnsEnabled={workflowColumnsEnabled} />
1017
}

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ interface TableProps {
6464
/** Identifiers — only set in embedded mode. Page mode reads from `useParams()`. */
6565
workspaceId?: string
6666
tableId?: string
67+
/** Resolved server-side from the workflow-columns feature flag. */
68+
workflowColumnsEnabled?: boolean
6769
}
6870

6971
/**
@@ -116,6 +118,7 @@ export function Table({
116118
embedded,
117119
workspaceId: propWorkspaceId,
118120
tableId: propTableId,
121+
workflowColumnsEnabled = false,
119122
}: TableProps = {}) {
120123
const params = useParams()
121124
const router = useRouter()
@@ -558,6 +561,7 @@ export function Table({
558561
onPickType={handleAddColumnOfType}
559562
onPickWorkflow={handleAddWorkflowColumn}
560563
onPickEnrichment={onOpenEnrichments}
564+
workflowColumnsEnabled={workflowColumnsEnabled}
561565
/>
562566
) : null
563567

@@ -691,6 +695,7 @@ export function Table({
691695
afterDeleteAllSinkRef={afterDeleteAllSinkRef}
692696
confirmDeleteColumnsSinkRef={confirmDeleteColumnsSinkRef}
693697
pushTableRenameUndoSinkRef={pushTableRenameUndoSinkRef}
698+
workflowColumnsEnabled={workflowColumnsEnabled}
694699
/>
695700
{userPermissions.canEdit && (
696701
<TableActionBar

apps/sim/lib/copilot/tools/handlers/function-execute.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createLogger } from '@sim/logger'
22
import { decodeVfsPathSegments, encodeVfsPathSegments } from '@/lib/copilot/vfs/path-utils'
33
import { resolveWorkflowAliasForWorkspace } from '@/lib/copilot/vfs/workflow-alias-resolver'
44
import { isPlanAliasPath, workflowAliasSandboxPath } from '@/lib/copilot/vfs/workflow-aliases'
5-
import { isMothershipBetaFeaturesEnabled } from '@/lib/core/config/env-flags'
5+
import { isFeatureEnabled } from '@/lib/core/config/feature-flags'
66
import { queryRows } from '@/lib/table/rows/service'
77
import { getTableById, listTables } from '@/lib/table/service'
88
import { listWorkspaceFileFolders } from '@/lib/uploads/contexts/workspace/workspace-file-folder-manager'
@@ -71,10 +71,11 @@ async function resolveInputFiles(
7171
): Promise<SandboxFile[]> {
7272
const sandboxFiles: SandboxFile[] = []
7373
let totalSize = 0
74+
const betaEnabled = await isFeatureEnabled('mothership-beta')
7475

7576
if (inputFiles?.length && workspaceId) {
7677
const allFiles = await listWorkspaceFiles(workspaceId, {
77-
includeReservedSystemFiles: isMothershipBetaFeaturesEnabled,
78+
includeReservedSystemFiles: betaEnabled,
7879
})
7980
for (const fileRef of inputFiles) {
8081
const filePath =
@@ -136,11 +137,11 @@ async function resolveInputFiles(
136137

137138
if (inputDirectories?.length && workspaceId) {
138139
const folders = await listWorkspaceFileFolders(workspaceId, {
139-
includeReservedSystemFolders: isMothershipBetaFeaturesEnabled,
140+
includeReservedSystemFolders: betaEnabled,
140141
})
141142
const allFiles = await listWorkspaceFiles(workspaceId, {
142143
folders,
143-
includeReservedSystemFiles: isMothershipBetaFeaturesEnabled,
144+
includeReservedSystemFiles: betaEnabled,
144145
})
145146
for (const dirRef of inputDirectories) {
146147
const dirPath =

apps/sim/lib/copilot/tools/server/files/doc-compile.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createLogger } from '@sim/logger'
2-
import { isMothershipBetaFeaturesEnabled } from '@/lib/core/config/env-flags'
2+
import { isFeatureEnabled } from '@/lib/core/config/feature-flags'
33
import { executeInE2B, executeShellInE2B, type SandboxFile } from '@/lib/execution/e2b'
44
import { CodeLanguage } from '@/lib/execution/languages'
55
import {
@@ -53,7 +53,7 @@ export interface E2BDocFormat {
5353
* pptx/docx → node, pdf/xlsx → python. Only meaningful when the E2B doc sandbox
5454
* is enabled; callers gate on isE2BDocEnabled before using this.
5555
*/
56-
export function getE2BDocFormat(fileName: string): E2BDocFormat | null {
56+
export async function getE2BDocFormat(fileName: string): Promise<E2BDocFormat | null> {
5757
const l = fileName.toLowerCase()
5858
if (l.endsWith('.pptx'))
5959
return {
@@ -79,10 +79,10 @@ export function getE2BDocFormat(fileName: string): E2BDocFormat | null {
7979
contentType: PDF_MIME,
8080
sourceMime: PYTHON_PDF_SOURCE_MIME,
8181
}
82-
// xlsx is gated behind the mothership beta flag (like plans/changelog): the
82+
// xlsx is gated behind the mothership-beta feature flag (like plans/changelog): the
8383
// skill + prompt are gated on the Go side, and this is the single Sim chokepoint
8484
// that keeps the compile/serve/check/recalc paths off for xlsx when beta is off.
85-
if (l.endsWith('.xlsx') && isMothershipBetaFeaturesEnabled)
85+
if (l.endsWith('.xlsx') && (await isFeatureEnabled('mothership-beta')))
8686
return {
8787
ext: 'xlsx',
8888
engine: 'python',
@@ -385,7 +385,7 @@ export async function compileDoc(
385385
args: CompileArgs
386386
): Promise<{ buffer: Buffer; contentType: string }> {
387387
const { source, fileName, workspaceId } = args
388-
const fmt = getE2BDocFormat(fileName)
388+
const fmt = await getE2BDocFormat(fileName)
389389
if (!fmt) throw new Error(`Unsupported document format: ${fileName}`)
390390

391391
const existing = await loadCompiledDoc(workspaceId, source, fmt.ext)
@@ -409,7 +409,7 @@ export async function loadCompiledDocByExt(
409409
source: string,
410410
ext: string
411411
): Promise<{ buffer: Buffer; contentType: string } | null> {
412-
const fmt = getE2BDocFormat(`x.${ext}`)
412+
const fmt = await getE2BDocFormat(`x.${ext}`)
413413
if (!fmt) return null
414414
const buffer = await loadCompiledDoc(workspaceId, source, fmt.ext)
415415
return buffer ? { buffer, contentType: fmt.contentType } : null

apps/sim/lib/copilot/tools/server/files/edit-content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const editContentServerTool: BaseServerTool<EditContentArgs, EditContentR
6464
try {
6565
const { operation, fileRecord } = intent
6666
const docInfo = getDocumentFormatInfo(fileRecord.name)
67-
const e2bFmt = isE2BDocEnabled ? getE2BDocFormat(fileRecord.name) : null
67+
const e2bFmt = isE2BDocEnabled ? await getE2BDocFormat(fileRecord.name) : null
6868

6969
let finalContent: string
7070
switch (operation) {

apps/sim/lib/copilot/tools/server/files/workspace-file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,13 @@ export async function compileDocForWrite(args: {
203203
}): Promise<CompileForWriteResult> {
204204
const { source, fileName, workspaceId, ownerKey, signal, fallbackMime } = args
205205
const docInfo = getDocumentFormatInfo(fileName)
206-
const e2bFmt = isE2BDocEnabled ? getE2BDocFormat(fileName) : null
206+
const e2bFmt = isE2BDocEnabled ? await getE2BDocFormat(fileName) : null
207207

208208
if (!e2bFmt && fileName.toLowerCase().endsWith('.xlsx')) {
209209
return {
210210
ok: false,
211211
message: isE2BDocEnabled
212-
? 'Excel (.xlsx) generation is currently behind a beta flag (MOTHERSHIP_BETA_FEATURES) and is not available.'
212+
? 'Excel (.xlsx) generation is currently behind the mothership-beta feature flag and is not available.'
213213
: 'Excel (.xlsx) generation requires the E2B document sandbox, which is not enabled in this environment.',
214214
}
215215
}

0 commit comments

Comments
 (0)