Skip to content

Commit 7cad96e

Browse files
Add mothership tools
1 parent 6829122 commit 7cad96e

9 files changed

Lines changed: 5945 additions & 3494 deletions

File tree

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table/cells/cell-content.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,13 @@ export function CellContent({
108108
} else {
109109
displayContent = <span className='text-[var(--text-tertiary)]'></span>
110110
}
111-
return displayContent
112-
}
113-
if (column.type === 'boolean') {
111+
// Workflow-output cells are hand-editable: hide the status content under
112+
// the InlineEditor when the user opts to edit, then fall through to the
113+
// common return that renders the editor overlay.
114+
if (isEditing) {
115+
displayContent = <div className='invisible'>{displayContent}</div>
116+
}
117+
} else if (column.type === 'boolean') {
114118
displayContent = (
115119
<div
116120
className={cn('flex min-h-[20px] items-center justify-center', isEditing && 'invisible')}

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table/cells/expanded-cell-popover.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
'use client'
22

3-
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
3+
import type React from 'react'
4+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
45
import { Button } from '@/components/emcn'
56
import type { TableRow as TableRowType } from '@/lib/table'
67
import type { EditingCell, SaveReason } from '../../../types'
7-
import {
8-
cleanCellValue,
9-
displayToStorage,
10-
formatValueForInput,
11-
} from '../../../utils'
8+
import { cleanCellValue, displayToStorage, formatValueForInput } from '../../../utils'
129
import type { DisplayColumn } from '../types'
1310

1411
interface ExpandedCellPopoverProps {
@@ -61,9 +58,11 @@ export function ExpandedCellPopover({
6158
return { row, column, colIndex, value: row.data[column.name] }
6259
}, [expandedCell, rows, columns])
6360

64-
const isWorkflowCell = !!target?.column.workflowGroupId
6561
const isBooleanCell = target?.column.type === 'boolean'
66-
const isEditable = Boolean(target) && canEdit && !isWorkflowCell && !isBooleanCell
62+
// Workflow-output cells are editable in the expanded view too — the user
63+
// can override the workflow's value. Booleans toggle inline; the expanded
64+
// popover only handles text-shaped inputs.
65+
const isEditable = Boolean(target) && canEdit && !isBooleanCell
6766

6867
const displayText = useMemo(() => {
6968
if (!target) return ''

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table/headers/workflow-group-meta-cell.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,7 @@ import {
1212
DropdownMenuSubTrigger,
1313
DropdownMenuTrigger,
1414
} from '@/components/emcn'
15-
import {
16-
ArrowLeft,
17-
ArrowRight,
18-
EyeOff,
19-
Pencil,
20-
PlayOutline,
21-
Trash,
22-
} from '@/components/emcn/icons'
15+
import { ArrowLeft, ArrowRight, EyeOff, Pencil, PlayOutline, Trash } from '@/components/emcn/icons'
2316
import { cn } from '@/lib/core/utils/cn'
2417
import type { WorkflowMetadata } from '@/stores/workflows/registry/types'
2518
import { SELECTION_TINT_BG } from '../constants'

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

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
'use client'
22

33
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
4-
import { Circle, Square } from 'lucide-react'
4+
import { Square } from 'lucide-react'
55
import { useParams, useRouter } from 'next/navigation'
66
import { usePostHog } from 'posthog-js/react'
77
import {
88
Button,
99
Checkbox,
10-
DatePicker,
11-
DropdownMenu,
12-
DropdownMenuContent,
13-
DropdownMenuItem,
14-
DropdownMenuSeparator,
15-
DropdownMenuSub,
16-
DropdownMenuSubContent,
17-
DropdownMenuSubTrigger,
18-
DropdownMenuTrigger,
1910
Modal,
2011
ModalBody,
2112
ModalContent,
@@ -25,32 +16,17 @@ import {
2516
Upload,
2617
} from '@/components/emcn'
2718
import {
28-
ArrowLeft,
29-
ArrowRight,
30-
Calendar as CalendarIcon,
31-
ChevronDown,
32-
EyeOff,
3319
Pencil,
3420
PlayOutline,
3521
Plus,
3622
Table as TableIcon,
3723
TableX,
3824
Trash,
39-
TypeBoolean,
40-
TypeJson,
41-
TypeNumber,
42-
TypeText,
4325
} from '@/components/emcn/icons'
4426
import { Loader } from '@/components/emcn/icons/loader'
4527
import { cn } from '@/lib/core/utils/cn'
4628
import { captureEvent } from '@/lib/posthog/client'
47-
import type {
48-
ColumnDefinition,
49-
Filter,
50-
SortDirection,
51-
TableRow as TableRowType,
52-
WorkflowGroup,
53-
} from '@/lib/table'
29+
import type { ColumnDefinition, Filter, SortDirection, TableRow as TableRowType } from '@/lib/table'
5430
import type { ColumnOption, SortConfig } from '@/app/workspace/[workspaceId]/components'
5531
import { ResourceHeader, ResourceOptionsBar } from '@/app/workspace/[workspaceId]/components'
5632
import { LogDetails } from '@/app/workspace/[workspaceId]/logs/components'
@@ -77,7 +53,6 @@ import { useInlineRename } from '@/hooks/use-inline-rename'
7753
import { extractCreatedRowId, useTableUndo } from '@/hooks/use-table-undo'
7854
import { useLogDetailsUIStore } from '@/stores/logs/store'
7955
import type { DeletedRowSnapshot } from '@/stores/table/types'
80-
import type { WorkflowMetadata } from '@/stores/workflows/registry/types'
8156
import { useContextMenu, useRowExecution, useTable } from '../../hooks'
8257
import type { EditingCell, QueryOptions, SaveReason } from '../../types'
8358
import { cleanCellValue, storageToDisplay } from '../../utils'
@@ -89,17 +64,16 @@ import { CellContent } from './cells/cell-content'
8964
import { ExpandedCellPopover } from './cells/expanded-cell-popover'
9065
import { COL_WIDTH, SELECTION_TINT_BG } from './constants'
9166
import { ColumnHeaderMenu } from './headers/column-header-menu'
92-
import { COLUMN_TYPE_ICONS, ColumnTypeIcon } from './headers/column-type-icon'
67+
import { COLUMN_TYPE_ICONS } from './headers/column-type-icon'
9368
import { WorkflowGroupMetaCell } from './headers/workflow-group-meta-cell'
94-
import type { BlockIconInfo, ColumnSourceInfo, DisplayColumn } from './types'
69+
import type { DisplayColumn } from './types'
9570
import {
9671
areRowDepsSatisfied,
9772
buildHeaderGroups,
9873
type CellCoord,
9974
collectRowSnapshots,
10075
computeNormalizedSelection,
10176
expandToDisplayColumns,
102-
type HeaderGroup,
10377
moveCell,
10478
type NormalizedSelection,
10579
readExecution,
@@ -1558,7 +1532,10 @@ export function Table({
15581532
if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {
15591533
if (!canEditRef.current) return
15601534
const col = cols[anchor.colIndex]
1561-
if (!col || col.type === 'boolean' || col.workflowGroupId) return
1535+
// Workflow-output cells are editable: the user can override the
1536+
// workflow's value if they want. Booleans toggle on space/click —
1537+
// typeahead doesn't apply to them.
1538+
if (!col || col.type === 'boolean') return
15621539
if (col.type === 'number' && !/[\d.-]/.test(e.key)) return
15631540
if (col.type === 'date' && !/[\d\-/]/.test(e.key)) return
15641541
e.preventDefault()
@@ -2347,7 +2324,6 @@ export function Table({
23472324
)
23482325
const hasWorkflowColumns = workflowColumnNames.length > 0
23492326

2350-
23512327
const { runningByRowId, totalRunning } = useMemo(() => {
23522328
const byRow = new Map<string, number>()
23532329
let total = 0
@@ -3298,7 +3274,6 @@ const DataRow = React.memo(function DataRow({
32983274
)
32993275
}, dataRowPropsAreEqual)
33003276

3301-
33023277
const TableBodySkeleton = React.memo(function TableBodySkeleton({
33033278
colCount,
33043279
}: {
@@ -3331,8 +3306,6 @@ const TableBodySkeleton = React.memo(function TableBodySkeleton({
33313306
)
33323307
})
33333308

3334-
3335-
33363309
interface RunStatusControlProps {
33373310
running: number
33383311
onStopAll: () => void
@@ -3437,7 +3410,6 @@ const AddRowButton = React.memo(function AddRowButton({ onClick }: { onClick: ()
34373410
)
34383411
})
34393412

3440-
34413413
/**
34423414
* Reuses the logs page's `LogDetails` slideout inside the tables view so a user
34433415
* can inspect a workflow run for a cell without leaving the table. The query is

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
'use client'
22

33
import { useMemo } from 'react'
4-
import type {
5-
ColumnDefinition,
6-
TableDefinition,
7-
TableRow,
8-
WorkflowGroup,
9-
} from '@/lib/table'
4+
import type { ColumnDefinition, TableDefinition, TableRow, WorkflowGroup } from '@/lib/table'
105
import type { FlattenOutputsBlockInput } from '@/lib/workflows/blocks/flatten-outputs'
11-
import type { WorkflowState } from '@/stores/workflows/workflow/types'
6+
import { getBlock } from '@/blocks'
127
import { useTable as useTableQuery, useTableRows } from '@/hooks/queries/tables'
13-
import { useWorkflows, useWorkflowStates } from '@/hooks/queries/workflows'
8+
import { useWorkflowStates, useWorkflows } from '@/hooks/queries/workflows'
149
import type { WorkflowMetadata } from '@/stores/workflows/registry/types'
15-
import { getBlock } from '@/blocks'
16-
import type {
17-
BlockIconInfo,
18-
ColumnSourceInfo,
19-
} from '../components/table/types'
10+
import type { WorkflowState } from '@/stores/workflows/workflow/types'
11+
import type { BlockIconInfo, ColumnSourceInfo } from '../components/table/types'
2012
import type { QueryOptions } from '../types'
2113

2214
const EMPTY_COLUMNS: ColumnDefinition[] = []
@@ -101,8 +93,7 @@ export function useTable({ workspaceId, tableId, queryOptions }: UseTableParams)
10193
const map = new Map<string, ColumnSourceInfo>()
10294
for (const group of tableWorkflowGroups) {
10395
const state = workflowStates.get(group.workflowId)
104-
const blocks = (state as { blocks?: Record<string, FlattenOutputsBlockInput> } | null)
105-
?.blocks
96+
const blocks = (state as { blocks?: Record<string, FlattenOutputsBlockInput> } | null)?.blocks
10697
for (const out of group.outputs) {
10798
const block = blocks?.[out.blockId]
10899
const blockConfig = block?.type ? getBlock(block.type) : undefined

0 commit comments

Comments
 (0)