Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
2cf59c8
fix(telegram): allow URL strings in advanced mode media inputs
guoyangzhen Mar 14, 2026
a52d7fd
fix: import randomUUID from node:crypto for non-secure contexts
guoyangzhen Mar 14, 2026
e38b27b
fix: use generateId() utility for all client-side UUID generation
guoyangzhen Mar 14, 2026
dc6f3cb
fix: ensure 'use client' directive remains first line in Next.js comp…
guoyangzhen Mar 14, 2026
44761a6
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
49233a6
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
bb773f8
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
425a3b9
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
ccbbfdc
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
e467d58
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
ae08cda
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
bf99af9
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
c21dfc0
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
541fc1c
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
608a0a4
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
0801398
fix: remove duplicate 'use client' and fix import ordering
guoyangzhen Mar 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/sim/app/chat/[identifier]/chat.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../lib/utils/uuid'

import { type RefObject, useCallback, useEffect, useRef, useState } from 'react'
import { createLogger } from '@sim/logger'
Expand Down Expand Up @@ -303,7 +304,7 @@ export default function ChatClient({ identifier }: { identifier: string }) {
setUserHasScrolled(false)

const userMessage: ChatMessage = {
id: crypto.randomUUID(),
id: generateId(),
content: messageToSend || (files && files.length > 0 ? `Sent ${files.length} file(s)` : ''),
type: 'user',
timestamp: new Date(),
Expand Down Expand Up @@ -416,7 +417,7 @@ export default function ChatClient({ identifier }: { identifier: string }) {
logger.error('Error sending message:', error)
setIsLoading(false)
const errorMessage: ChatMessage = {
id: crypto.randomUUID(),
id: generateId(),
content: CHAT_ERROR_MESSAGES.GENERIC_ERROR,
type: 'assistant',
timestamp: new Date(),
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/app/chat/components/input/input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../lib/utils/uuid'

import type React from 'react'
import { useEffect, useRef, useState } from 'react'
Expand Down Expand Up @@ -147,7 +148,7 @@ export const ChatInput: React.FC<{
}

newFiles.push({
id: crypto.randomUUID(),
id: generateId(),
name: file.name,
size: file.size,
type: file.type,
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/app/chat/hooks/use-chat-streaming.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../../lib/utils/uuid'

import { useRef, useState } from 'react'
import { createLogger } from '@sim/logger'
Expand Down Expand Up @@ -141,7 +142,7 @@ export function useChatStreaming() {

// Track which blocks have streamed content (like chat panel)
const messageIdMap = new Map<string, string>()
const messageId = crypto.randomUUID()
const messageId = generateId()
setMessages((prev) => [
...prev,
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../lib/utils/uuid'

import {
createContext,
Expand Down Expand Up @@ -87,7 +88,7 @@ export function GlobalCommandsProvider({ children }: { children: ReactNode }) {
const register = useCallback((commands: GlobalCommand[]) => {
const createdIds: string[] = []
for (const cmd of commands) {
const id = cmd.id ?? crypto.randomUUID()
const id = cmd.id ?? generateId()
const parsed = parseShortcut(cmd.shortcut)
registryRef.current.set(id, {
...cmd,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../lib/utils/uuid'

import { type KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { createLogger } from '@sim/logger'
Expand Down Expand Up @@ -601,7 +602,7 @@ export function Chat() {
if (typeof result !== 'object') return

if ('stream' in result && result.stream instanceof ReadableStream) {
const responseMessageId = crypto.randomUUID()
const responseMessageId = generateId()
addMessage({
id: responseMessageId,
content: '',
Expand Down Expand Up @@ -799,7 +800,7 @@ export function Chat() {
const defaultType = fieldName === 'files' ? 'file[]' : 'string'

return {
id: crypto.randomUUID(),
id: generateId(),
name: fieldName,
type: defaultType,
value: '',
Expand All @@ -814,7 +815,7 @@ export function Chat() {

const userId = session?.user?.id || 'unknown'
addToQueue({
id: crypto.randomUUID(),
id: generateId(),
operation: {
operation: 'subblock-update',
target: 'subblock',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { generateId } from '../../../../../../../../lib/utils/uuid'
import { useCallback, useState } from 'react'

export interface ChatFile {
Expand Down Expand Up @@ -53,7 +54,7 @@ export function useChatFileUpload() {
}

validNewFiles.push({
id: crypto.randomUUID(),
id: generateId(),
name: file.name,
size: file.size,
type: file.type,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../../../../../../../../../../../lib/utils/uuid'

import { useCallback, useEffect, useRef, useState } from 'react'
import { createLogger } from '@sim/logger'
Expand Down Expand Up @@ -123,7 +124,7 @@ export function useFileAttachments(props: UseFileAttachmentsProps) {
}

const tempFile: AttachedFile = {
id: crypto.randomUUID(),
id: generateId(),
name: file.name,
size: file.size,
type: file.type,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../lib/utils/uuid'

import { useCallback, useEffect, useMemo, useState } from 'react'
import { createLogger } from '@sim/logger'
Expand Down Expand Up @@ -155,7 +156,7 @@ export function A2aDeploy({
// Add input field if missing (for TextPart)
if (missingFields.input) {
newFields.push({
id: crypto.randomUUID(),
id: generateId(),
name: 'input',
type: 'string',
value: '',
Expand All @@ -166,7 +167,7 @@ export function A2aDeploy({
// Add data field if missing (for DataPart)
if (missingFields.data) {
newFields.push({
id: crypto.randomUUID(),
id: generateId(),
name: 'data',
type: 'object',
value: '',
Expand All @@ -177,7 +178,7 @@ export function A2aDeploy({
// Add files field if missing (for FilePart)
if (missingFields.files) {
newFields.push({
id: crypto.randomUUID(),
id: generateId(),
name: 'files',
type: 'file[]',
value: '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../lib/utils/uuid'

import { useMemo, useRef } from 'react'
import { Plus } from 'lucide-react'
Expand Down Expand Up @@ -45,7 +46,7 @@ interface DocumentTagEntryProps {
* Creates a new document tag with default values
*/
const createDefaultTag = (): DocumentTag => ({
id: crypto.randomUUID(),
id: generateId(),
tagName: '',
fieldType: 'text',
value: '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { generateId } from '../../../../../../../../../../../../../lib/utils/uuid'
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import isEqual from 'lodash/isEqual'
import { useStoreWithEqualityFn } from 'zustand/traditional'
Expand Down Expand Up @@ -276,7 +277,7 @@ export const Dropdown = memo(function Dropdown({
fieldType === 'object' || fieldType === 'array' ? JSON.stringify(value, null, 2) : value

return {
id: crypto.randomUUID(),
id: generateId(),
name: key,
type: fieldType,
value: fieldValue,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { generateId } from '../../../../../../../../../../../../../lib/utils/uuid'
import { useMemo, useRef } from 'react'
import { Plus } from 'lucide-react'
import { Button, Input, Textarea, Tooltip } from '@/components/emcn'
Expand Down Expand Up @@ -30,7 +31,7 @@ interface EvalInputProps {

// Default values
const createDefaultMetric = (): EvalMetric => ({
id: crypto.randomUUID(),
id: generateId(),
name: '',
description: '',
range: { min: 0, max: 1 },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../lib/utils/uuid'

import { useCallback, useMemo } from 'react'
import type { ComboboxOption } from '@/components/emcn'
Expand All @@ -20,7 +21,7 @@ interface FilterBuilderProps {
}

const createDefaultRule = (columns: ComboboxOption[]): FilterRule => ({
id: crypto.randomUUID(),
id: generateId(),
logicalOperator: 'and',
column: columns[0]?.value || '',
operator: 'eq',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../lib/utils/uuid'

import { useRef } from 'react'
import { Plus } from 'lucide-react'
Expand Down Expand Up @@ -48,7 +49,7 @@ interface KnowledgeTagFiltersProps {
* Creates a new filter with default values
*/
const createDefaultFilter = (): TagFilter => ({
id: crypto.randomUUID(),
id: generateId(),
tagName: '',
fieldType: 'text',
operator: 'eq',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../lib/utils/uuid'

import { useCallback, useMemo } from 'react'
import type { ComboboxOption } from '@/components/emcn'
Expand All @@ -18,7 +19,7 @@ interface SortBuilderProps {
}

const createDefaultRule = (columns: ComboboxOption[]): SortRule => ({
id: crypto.randomUUID(),
id: generateId(),
column: columns[0]?.value || '',
direction: 'asc',
collapsed: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { generateId } from '../../../../../../../../../../../../../lib/utils/uuid'
import { useCallback, useRef } from 'react'
import { Plus } from 'lucide-react'
import { Trash } from '@/components/emcn/icons/trash'
Expand Down Expand Up @@ -72,7 +73,7 @@ const BOOLEAN_OPTIONS: ComboboxOption[] = [
* Creates a new field with default values
*/
const createDefaultField = (): Field => ({
id: crypto.randomUUID(),
id: generateId(),
name: '',
type: 'string',
value: '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { generateId } from '../../../../../../../../../../../../../lib/utils/uuid'
import { useEffect, useMemo, useRef } from 'react'
import { createLogger } from '@sim/logger'
import { useParams } from 'next/navigation'
Expand Down Expand Up @@ -74,7 +75,7 @@ export function Table({
useEffect(() => {
if (!isPreview && !disabled && (!Array.isArray(storeValue) || storeValue.length === 0)) {
const initialRow: WorkflowTableRow = {
id: crypto.randomUUID(),
id: generateId(),
cells: { ...emptyCellsTemplate },
}
setStoreValue([initialRow])
Expand All @@ -86,7 +87,7 @@ export function Table({
if (!Array.isArray(value) || value.length === 0) {
return [
{
id: crypto.randomUUID(),
id: generateId(),
cells: { ...emptyCellsTemplate },
},
]
Expand All @@ -105,7 +106,7 @@ export function Table({
}

return {
id: row?.id ?? crypto.randomUUID(),
id: row?.id ?? generateId(),
cells: normalizedCells,
}
})
Expand Down Expand Up @@ -133,7 +134,7 @@ export function Table({

if (rowIndex === rows.length - 1 && newValue !== '') {
updatedRows.push({
id: crypto.randomUUID(),
id: generateId(),
cells: { ...emptyCellsTemplate },
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { generateId } from '../../../../../../../../../../../../../lib/utils/uuid'
import { useEffect, useRef, useState } from 'react'
import { Plus } from 'lucide-react'
import { useParams } from 'next/navigation'
Expand Down Expand Up @@ -124,7 +125,7 @@ export function VariablesInput({
if (!isReadOnly && assignments.length === 0 && currentWorkflowVariables.length > 0) {
const initialAssignment: VariableAssignment = {
...DEFAULT_ASSIGNMENT,
id: crypto.randomUUID(),
id: generateId(),
}
setStoreValue([initialAssignment])
}
Expand All @@ -151,7 +152,7 @@ export function VariablesInput({

const newAssignment: VariableAssignment = {
...DEFAULT_ASSIGNMENT,
id: crypto.randomUUID(),
id: generateId(),
}
setStoreValue([...assignments, newAssignment])
}
Expand All @@ -160,7 +161,7 @@ export function VariablesInput({
if (isReadOnly) return

if (assignments.length === 1) {
setStoreValue([{ ...DEFAULT_ASSIGNMENT, id: crypto.randomUUID() }])
setStoreValue([{ ...DEFAULT_ASSIGNMENT, id: generateId() }])
return
}

Expand Down
13 changes: 7 additions & 6 deletions apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import { generateId } from '../../lib/utils/uuid'

import React, { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useParams, useRouter } from 'next/navigation'
Expand Down Expand Up @@ -1541,7 +1542,7 @@ const WorkflowContent = React.memo(() => {
const createEdgeObject = useCallback(
(sourceId: string, targetId: string, sourceHandle: string): Edge => {
const edge = {
id: crypto.randomUUID(),
id: generateId(),
source: sourceId,
target: targetId,
sourceHandle,
Expand Down Expand Up @@ -1718,7 +1719,7 @@ const WorkflowContent = React.memo(() => {
clearDragHighlights()

if (data.type === 'loop' || data.type === 'parallel') {
const id = crypto.randomUUID()
const id = generateId()
const baseName = data.type === 'loop' ? 'Loop' : 'Parallel'
const name = getUniqueBlockName(baseName, blocks)

Expand Down Expand Up @@ -1797,7 +1798,7 @@ const WorkflowContent = React.memo(() => {
}

// Generate id and name here so they're available in all code paths
const id = crypto.randomUUID()
const id = generateId()
// Prefer semantic default names for triggers; then ensure unique numbering centrally
const defaultTriggerNameDrop = TriggerUtils.getDefaultTriggerName(data.type)
const baseName = defaultTriggerNameDrop || blockConfig.name
Expand Down Expand Up @@ -1916,7 +1917,7 @@ const WorkflowContent = React.memo(() => {
const basePosition = getViewportCenter()

if (type === 'loop' || type === 'parallel') {
const id = crypto.randomUUID()
const id = generateId()
const baseName = type === 'loop' ? 'Loop' : 'Parallel'
const name = getUniqueBlockName(baseName, blocks)

Expand Down Expand Up @@ -1950,7 +1951,7 @@ const WorkflowContent = React.memo(() => {

if (checkTriggerConstraints(type)) return

const id = crypto.randomUUID()
const id = generateId()
const defaultTriggerName = TriggerUtils.getDefaultTriggerName(type)
const baseName = defaultTriggerName || blockConfig.name
const name = getUniqueBlockName(baseName, blocks)
Expand Down Expand Up @@ -2887,7 +2888,7 @@ const WorkflowContent = React.memo(() => {
const targetParentId = blocks[targetNode.id]?.data?.parentId

// Generate a unique edge ID
const edgeId = crypto.randomUUID()
const edgeId = generateId()

// Special case for container start source: Always allow connections to nodes within the same container
if (
Expand Down
Loading