Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
73dadf8
Edit workflow returns workflow
Sg312 Nov 12, 2025
2ce87fc
Condense workflkow conosle
Sg312 Nov 12, 2025
0e113ef
Limit console results to 2
Sg312 Nov 12, 2025
0a8d4c4
mark checkoff v1
Sg312 Nov 12, 2025
07e7a57
Mark and checkoff todo
Sg312 Nov 12, 2025
0cf0761
Fixes
Sg312 Nov 12, 2025
611b23a
Plan mode
Sg312 Nov 13, 2025
446206a
fix agent output
Sg312 Nov 13, 2025
8d6c0d8
broken
Sg312 Nov 13, 2025
f00e110
Fixes
Sg312 Nov 13, 2025
2a023ad
Fix diff mode persist
Sg312 Nov 13, 2025
9a9c842
Fix diff coloring
Sg312 Nov 14, 2025
c7e1b26
Undo/redo
Sg312 Nov 14, 2025
fe68acb
Checkpoint udno redo
Sg312 Nov 14, 2025
57753a2
fix(templates): fix templates details page (#1942)
Sg312 Nov 12, 2025
168b5a1
fix(templates-details): restore approval feature, and keep details UI…
icecrasher321 Nov 12, 2025
b00d4a1
fix(landing): need to propagate landing page copilot prompt (#1944)
icecrasher321 Nov 12, 2025
46363cc
fix(wand): subblocks should not be overwritten after wand gen (#1946)
icecrasher321 Nov 12, 2025
e6ecda7
fix(settings): fix broken api keys, help modal, logs, workflow renami…
waleedlatif1 Nov 12, 2025
242d47e
fix(files): changed file input value sample from string -> object (#1…
waleedlatif1 Nov 12, 2025
d6516ea
improvement: usage-indicator UI (#1948)
emir-karabeg Nov 12, 2025
4b4bc11
fix(deploy): fix button (#1949)
waleedlatif1 Nov 12, 2025
37e8864
fix(executor): consolidate execution hooks (#1950)
Sg312 Nov 12, 2025
db15335
fix(autoconnect): should check if triggermode is set from the toolbar…
icecrasher321 Nov 12, 2025
2af9fba
improvement: templates styling (#1952)
emir-karabeg Nov 12, 2025
9d0f715
improvement: template use button (#1954)
emir-karabeg Nov 13, 2025
a9d6d13
feat(newgifs): added new gifs (#1953)
aadamgough Nov 13, 2025
9925a6f
feat(drizzle): added ods for analytics from drizzle (#1956)
waleedlatif1 Nov 13, 2025
e0176e0
fix(sheets): file selector had incorrect provider (#1958)
icecrasher321 Nov 13, 2025
257286c
feat(docs): added docs analytics drizzle ods (#1957)
waleedlatif1 Nov 13, 2025
e66d16f
fix provider for docs selector (#1959)
icecrasher321 Nov 13, 2025
4be9262
fix(custom-tools): updates to legacy + copilot generated custom tools…
icecrasher321 Nov 13, 2025
bca2994
fix(slack): remove update message incorrect canonical param (#1964)
icecrasher321 Nov 13, 2025
152178e
improvement(templates): add share button, serve public templates rout…
waleedlatif1 Nov 13, 2025
6880e17
fix(onedrive): incorrect canonical param (#1966)
icecrasher321 Nov 13, 2025
ec9c3fe
fix(executor): streaming after tool calls (#1963)
Sg312 Nov 13, 2025
d6d7aeb
fix(code): readd wand to code subblock (#1969)
icecrasher321 Nov 13, 2025
9ad42f0
fix(cmd-k): z-index + reoder tools, triggers (#1970)
icecrasher321 Nov 13, 2025
0817917
fix(executor): streaming response format (#1972)
Sg312 Nov 13, 2025
3092dc9
fix(workflow-block): fix redeploy header to not repeatedly show redep…
waleedlatif1 Nov 13, 2025
c210bdf
improvement(platform): chat, emcn, terminal, usage-limit (#1974)
emir-karabeg Nov 14, 2025
0e59610
fix lint
emir-karabeg Nov 14, 2025
367b087
feat(settings): added reactquery for settings, removed zustand stores…
waleedlatif1 Nov 14, 2025
c12dbfd
fix(copilot-subflows): copilot-added subflows id mismatch (#1977)
icecrasher321 Nov 14, 2025
4449be1
feat(i18n): update translations (#1978)
waleedlatif1 Nov 14, 2025
ec33028
fix(logs): show block inputs (#1979)
Sg312 Nov 14, 2025
95585b8
fix(onedrive): parse array values correctly (#1981)
icecrasher321 Nov 14, 2025
15b3d8d
feat(files): add presigned URL generation support for execution files…
waleedlatif1 Nov 14, 2025
e7abeb1
fix(popovers): billed account + async example command (#1982)
icecrasher321 Nov 14, 2025
3809202
fix(settings): update usage data in settings > subs to use reactquery…
waleedlatif1 Nov 14, 2025
4693947
fix(output-selector): z-index in chat deploy modal (#1984)
icecrasher321 Nov 14, 2025
eb212c7
improvement(logs): improved logs search (#1985)
waleedlatif1 Nov 14, 2025
3b1c9ae
feat(slack): added slack full message object in response (#1987)
waleedlatif1 Nov 14, 2025
e6734ee
feat(slack): add better error messages, reminder to add bot to app (#…
waleedlatif1 Nov 14, 2025
cffe319
feat(i18n): update translations (#1989)
waleedlatif1 Nov 14, 2025
c50fc88
fix(landing): hero stripe icon (#1988)
emir-karabeg Nov 14, 2025
8dc8414
Temp
Sg312 Nov 14, 2025
69e5d09
Update
Sg312 Nov 14, 2025
df8914a
Update
Sg312 Nov 14, 2025
ee3bff8
Update
Sg312 Nov 14, 2025
78d8d4b
Progress
Sg312 Nov 14, 2025
a3f427d
Diff store fixes
Sg312 Nov 16, 2025
6c7c86d
simplify sockets ops for diff store
icecrasher321 Nov 17, 2025
75a7dbc
Search patterns tool
Sg312 Nov 17, 2025
c93dd74
Better tool calls
Sg312 Nov 17, 2025
96eb075
Fix sanitizationg
Sg312 Nov 18, 2025
4b12568
Context window display
Sg312 Nov 18, 2025
8f0ef58
v0.5.7: combobox selectors, usage indicator, workflow loading race co…
icecrasher321 Nov 18, 2025
1077feb
fix(variables): fix double stringification (#1991)
Sg312 Nov 14, 2025
f06f716
improvement(variables): support dot notation for nested objects (#1992)
Sg312 Nov 14, 2025
c24564e
improvement(tanstack): migrate multiple stores (#1994)
icecrasher321 Nov 14, 2025
cbd55c1
fix(folders): duplicate (#1996)
icecrasher321 Nov 14, 2025
3b86ae3
fix(variables): fix variables block json resolution (#1997)
Sg312 Nov 15, 2025
6a06b7a
Improvement(ui/ux): signup, command-list, cursors, search modal, work…
emir-karabeg Nov 15, 2025
c389462
test(pr): hackathon (#1999)
icecrasher321 Nov 15, 2025
22272ed
test(pr): github trigger (#2000)
icecrasher321 Nov 15, 2025
98ac31a
fix(usage-indicator): conditional rendering, upgrade, and ui/ux (#2001)
emir-karabeg Nov 15, 2025
334516d
fix(notes): fix notes, tighten spacing, update deprecated zustand fun…
waleedlatif1 Nov 15, 2025
ee58685
fix(pdfs): use unpdf instead of pdf-parse (#2004)
waleedlatif1 Nov 15, 2025
6c0ad3e
fix(modals): fix z-index for various modals and output selector and v…
waleedlatif1 Nov 15, 2025
9453e85
fix(condition): treat condition input the same as the code subblock (…
waleedlatif1 Nov 15, 2025
4e15db4
feat(models): added gpt-5.1 (#2007)
waleedlatif1 Nov 15, 2025
2b08ace
improvement: runpath edges, blocks, active (#2008)
emir-karabeg Nov 15, 2025
9da5865
feat(i18n): update translations (#2009)
waleedlatif1 Nov 15, 2025
d0dbaac
fix(triggers): check triggermode and consolidate block type (#2011)
Sg312 Nov 15, 2025
ff246c0
fix(triggers): disabled trigger shouldn't be added to dag (#2012)
Sg312 Nov 15, 2025
df4c6bd
fix(tags): only show start block upstream if is ancestor (#2013)
Sg312 Nov 15, 2025
01752ef
fix(variables): Fix resolution on double < (#2016)
Sg312 Nov 15, 2025
d2eb33a
feat(billing): add notif for first failed payment, added upgrade emai…
waleedlatif1 Nov 16, 2025
b2dcb2a
feat(performance): added reactquery hooks for workflow operations, fo…
waleedlatif1 Nov 16, 2025
963d8d6
fix(copilot): run workflow supports input format and fix run id (#2018)
Sg312 Nov 16, 2025
0b17fac
fix(router): fix error edge in router block + fix source handle probl…
Sg312 Nov 16, 2025
d598b8a
improvement: code subblock, action bar, connections (#2024)
emir-karabeg Nov 17, 2025
6254515
fix(response): fix response block http format (#2027)
Sg312 Nov 17, 2025
65d5146
fix(notes): fix notes block spacing, additional logs for billing tran…
waleedlatif1 Nov 17, 2025
ab4d800
fix(usage-data): refetch on usage limit update in settings (#2032)
waleedlatif1 Nov 17, 2025
86b383b
fix(overage): fix pill calculation in the usage indicator to be consi…
waleedlatif1 Nov 18, 2025
0c0c6bf
fix(workflows): fixed workflow loading in without start block, added …
waleedlatif1 Nov 18, 2025
a1d6d6d
fix(triggers): dedup + not surfacing deployment status log (#2033)
icecrasher321 Nov 18, 2025
fe1e39f
improvement(undo-redo): expand undo-redo store to store 100 ops inste…
waleedlatif1 Nov 18, 2025
c71ff53
improvement(docs): remove copy page from mobile view on docs (#2037)
waleedlatif1 Nov 18, 2025
6f5f0b2
fix(workflow-block): clearing child workflow input format field must …
icecrasher321 Nov 18, 2025
9f22d28
Error tools
Sg312 Nov 18, 2025
6fbfe9a
Ui tools
Sg312 Nov 18, 2025
11b85cc
Navigate ui tool
Sg312 Nov 18, 2025
02e0652
Merge origin/staging - unified selector components
Sg312 Nov 18, 2025
a620930
Combine env vars and oauth tools
Sg312 Nov 18, 2025
2fc1a42
Plan mode section
Sg312 Nov 18, 2025
aa6555a
Plan mode v1
Sg312 Nov 19, 2025
ec7fd9e
Plan mode v1
Sg312 Nov 19, 2025
f4234b1
Plan mode improvements
Sg312 Nov 19, 2025
1098d12
Build plan button
Sg312 Nov 19, 2025
f272fb8
Make workflow plan editable
Sg312 Nov 19, 2025
578b9ad
Tool improvements
Sg312 Nov 19, 2025
84aa36b
Fix build plan button
Sg312 Nov 20, 2025
10a63a0
Lint
Sg312 Nov 20, 2025
27f8177
Fix
Sg312 Nov 20, 2025
3ce0780
Fix lint
Sg312 Nov 20, 2025
0d6dc21
Fix plan
Sg312 Nov 20, 2025
31c34b2
v0.5.8: notifications, billing, ui changes, store loading state machine
icecrasher321 Nov 20, 2025
842ef27
v0.5.9: add backwards compatibility for agent messages array
waleedlatif1 Nov 20, 2025
42942b1
Remove migrations
Sg312 Nov 20, 2025
b2cc749
Merge remote-tracking branch 'origin' into improvement/copilot-3
Sg312 Nov 20, 2025
c766dde
fix undo/redo settling of ops
icecrasher321 Nov 20, 2025
5ea0520
Add migratinos back
Sg312 Nov 21, 2025
5398cac
Merge branch 'origin/improvement/copilot-diff-store' into improvement…
Sg312 Nov 21, 2025
7f0bf2d
Smoothen out diff store
Sg312 Nov 21, 2025
fecc24f
Hide plan mode
Sg312 Nov 21, 2025
b173ccf
Fix lint
Sg312 Nov 21, 2025
ceddb1b
Edit run workflow params
Sg312 Nov 21, 2025
e3f4a05
Fix lint
Sg312 Nov 21, 2025
a5ec906
Fix tests
Sg312 Nov 21, 2025
64ad305
Fix typing
Sg312 Nov 21, 2025
5bb4961
Fix build errors and lint
Sg312 Nov 21, 2025
2e55af8
Merge staging
Sg312 Nov 21, 2025
f3041d0
Fix build
Sg312 Nov 21, 2025
3f7baf4
Fix tests
Sg312 Nov 21, 2025
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
17 changes: 9 additions & 8 deletions apps/sim/app/api/chat/manage/[id]/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Chat Edit API Route', () => {
const mockCreateErrorResponse = vi.fn()
const mockEncryptSecret = vi.fn()
const mockCheckChatAccess = vi.fn()
const mockGetSession = vi.fn()

beforeEach(() => {
vi.resetModules()
Expand All @@ -42,6 +43,10 @@ describe('Chat Edit API Route', () => {
chat: { id: 'id', identifier: 'identifier', userId: 'userId' },
}))

vi.doMock('@/lib/auth', () => ({
getSession: mockGetSession,
}))

vi.doMock('@/lib/logs/console/logger', () => ({
createLogger: vi.fn().mockReturnValue({
info: vi.fn(),
Expand Down Expand Up @@ -89,9 +94,7 @@ describe('Chat Edit API Route', () => {

describe('GET', () => {
it('should return 401 when user is not authenticated', async () => {
vi.doMock('@/lib/auth', () => ({
getSession: vi.fn().mockResolvedValue(null),
}))
mockGetSession.mockResolvedValueOnce(null)

const req = new NextRequest('http://localhost:3000/api/chat/manage/chat-123')
const { GET } = await import('@/app/api/chat/manage/[id]/route')
Expand All @@ -102,11 +105,9 @@ describe('Chat Edit API Route', () => {
})

it('should return 404 when chat not found or access denied', async () => {
vi.doMock('@/lib/auth', () => ({
getSession: vi.fn().mockResolvedValue({
user: { id: 'user-id' },
}),
}))
mockGetSession.mockResolvedValueOnce({
user: { id: 'user-id' },
})

mockCheckChatAccess.mockResolvedValue({ hasAccess: false })

Expand Down
4 changes: 4 additions & 0 deletions apps/sim/app/api/copilot/chat/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ describe('Copilot Chat API Route', () => {
],
messageCount: 4,
previewYaml: null,
config: null,
planArtifact: null,
createdAt: '2024-01-01T00:00:00.000Z',
updatedAt: '2024-01-02T00:00:00.000Z',
},
Expand All @@ -576,6 +578,8 @@ describe('Copilot Chat API Route', () => {
],
messageCount: 2,
previewYaml: null,
config: null,
planArtifact: null,
createdAt: '2024-01-03T00:00:00.000Z',
updatedAt: '2024-01-04T00:00:00.000Z',
},
Expand Down
6 changes: 5 additions & 1 deletion apps/sim/app/api/copilot/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ChatMessageSchema = z.object({
])
.optional()
.default('claude-4.5-sonnet'),
mode: z.enum(['ask', 'agent']).optional().default('agent'),
mode: z.enum(['ask', 'agent', 'plan']).optional().default('agent'),
prefetch: z.boolean().optional(),
createNewChat: z.boolean().optional().default(false),
stream: z.boolean().optional().default(true),
Expand Down Expand Up @@ -880,6 +880,8 @@ export async function GET(req: NextRequest) {
title: copilotChats.title,
model: copilotChats.model,
messages: copilotChats.messages,
planArtifact: copilotChats.planArtifact,
config: copilotChats.config,
createdAt: copilotChats.createdAt,
updatedAt: copilotChats.updatedAt,
})
Expand All @@ -897,6 +899,8 @@ export async function GET(req: NextRequest) {
messages: Array.isArray(chat.messages) ? chat.messages : [],
messageCount: Array.isArray(chat.messages) ? chat.messages.length : 0,
previewYaml: null, // Not needed for chat list
planArtifact: chat.planArtifact || null,
config: chat.config || null,
createdAt: chat.createdAt,
updatedAt: chat.updatedAt,
}))
Expand Down
37 changes: 27 additions & 10 deletions apps/sim/app/api/copilot/chat/update-messages/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ const UpdateMessagesSchema = z.object({
.optional(),
})
),
planArtifact: z.string().nullable().optional(),
config: z
.object({
mode: z.enum(['ask', 'build', 'plan']).optional(),
model: z.string().optional(),
})
.nullable()
.optional(),
})

export async function POST(req: NextRequest) {
Expand All @@ -49,7 +57,7 @@ export async function POST(req: NextRequest) {
}

const body = await req.json()
const { chatId, messages } = UpdateMessagesSchema.parse(body)
const { chatId, messages, planArtifact, config } = UpdateMessagesSchema.parse(body)

// Verify that the chat belongs to the user
const [chat] = await db
Expand All @@ -62,18 +70,27 @@ export async function POST(req: NextRequest) {
return createNotFoundResponse('Chat not found or unauthorized')
}

// Update chat with new messages
await db
.update(copilotChats)
.set({
messages: messages,
updatedAt: new Date(),
})
.where(eq(copilotChats.id, chatId))
// Update chat with new messages, plan artifact, and config
const updateData: Record<string, any> = {
messages: messages,
updatedAt: new Date(),
}

if (planArtifact !== undefined) {
updateData.planArtifact = planArtifact
}

if (config !== undefined) {
updateData.config = config
}

await db.update(copilotChats).set(updateData).where(eq(copilotChats.id, chatId))

logger.info(`[${tracker.requestId}] Successfully updated chat messages`, {
logger.info(`[${tracker.requestId}] Successfully updated chat`, {
chatId,
newMessageCount: messages.length,
hasPlanArtifact: !!planArtifact,
hasConfig: !!config,
})

return NextResponse.json({
Expand Down
140 changes: 140 additions & 0 deletions apps/sim/app/api/templates/approved/sanitized/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { db } from '@sim/db'
import { templates } from '@sim/db/schema'
import { eq } from 'drizzle-orm'
import { type NextRequest, NextResponse } from 'next/server'
import { checkInternalApiKey } from '@/lib/copilot/utils'
import { createLogger } from '@/lib/logs/console/logger'
import { generateRequestId } from '@/lib/utils'
import { sanitizeForCopilot } from '@/lib/workflows/json-sanitizer'

const logger = createLogger('TemplatesSanitizedAPI')

export const revalidate = 0

/**
* GET /api/templates/approved/sanitized
* Returns all approved templates with their sanitized JSONs, names, and descriptions
* Requires internal API secret authentication via X-API-Key header
*/
export async function GET(request: NextRequest) {
const requestId = generateRequestId()

try {
const url = new URL(request.url)
const hasApiKey = !!request.headers.get('x-api-key')

// Check internal API key authentication
const authResult = checkInternalApiKey(request)
if (!authResult.success) {
logger.warn(`[${requestId}] Authentication failed for approved sanitized templates`, {
error: authResult.error,
hasApiKey,
howToUse: 'Add header: X-API-Key: <INTERNAL_API_SECRET>',
})
return NextResponse.json(
{
error: authResult.error,
hint: 'Include X-API-Key header with INTERNAL_API_SECRET value',
},
{ status: 401 }
)
}

// Fetch all approved templates
const approvedTemplates = await db
.select({
id: templates.id,
name: templates.name,
details: templates.details,
state: templates.state,
tags: templates.tags,
requiredCredentials: templates.requiredCredentials,
})
.from(templates)
.where(eq(templates.status, 'approved'))

// Process each template to sanitize for copilot
const sanitizedTemplates = approvedTemplates
.map((template) => {
try {
const copilotSanitized = sanitizeForCopilot(template.state as any)

if (copilotSanitized?.blocks) {
Object.values(copilotSanitized.blocks).forEach((block: any) => {
if (block && typeof block === 'object') {
block.outputs = undefined
block.position = undefined
block.height = undefined
block.layout = undefined
block.horizontalHandles = undefined

// Also clean nested nodes recursively
if (block.nestedNodes) {
Object.values(block.nestedNodes).forEach((nestedBlock: any) => {
if (nestedBlock && typeof nestedBlock === 'object') {
nestedBlock.outputs = undefined
nestedBlock.position = undefined
nestedBlock.height = undefined
nestedBlock.layout = undefined
nestedBlock.horizontalHandles = undefined
}
})
}
}
})
}

const details = template.details as { tagline?: string; about?: string } | null
const description = details?.tagline || details?.about || ''

return {
id: template.id,
name: template.name,
description,
tags: template.tags,
requiredCredentials: template.requiredCredentials,
sanitizedJson: copilotSanitized,
}
} catch (error) {
logger.error(`[${requestId}] Error sanitizing template ${template.id}`, {
error: error instanceof Error ? error.message : String(error),
})
return null
}
})
.filter((t): t is NonNullable<typeof t> => t !== null)

const response = {
templates: sanitizedTemplates,
count: sanitizedTemplates.length,
}

return NextResponse.json(response)
} catch (error) {
logger.error(`[${requestId}] Error fetching approved sanitized templates`, {
error: error instanceof Error ? error.message : String(error),
stack: error instanceof Error ? error.stack : undefined,
})
return NextResponse.json(
{
error: 'Internal server error',
requestId,
},
{ status: 500 }
)
}
}

// Add a helpful OPTIONS handler for CORS preflight
export async function OPTIONS(request: NextRequest) {
const requestId = generateRequestId()
logger.info(`[${requestId}] OPTIONS request received for /api/templates/approved/sanitized`)

return new NextResponse(null, {
status: 200,
headers: {
'Access-Control-Allow-Methods': 'GET, OPTIONS',
'Access-Control-Allow-Headers': 'X-API-Key, Content-Type',
},
})
}
21 changes: 21 additions & 0 deletions apps/sim/app/api/workflows/[id]/state/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { eq } from 'drizzle-orm'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { getSession } from '@/lib/auth'
import { env } from '@/lib/env'
import { createLogger } from '@/lib/logs/console/logger'
import { generateRequestId } from '@/lib/utils'
import { extractAndPersistCustomTools } from '@/lib/workflows/custom-tools-persistence'
Expand Down Expand Up @@ -248,6 +249,26 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
const elapsed = Date.now() - startTime
logger.info(`[${requestId}] Successfully saved workflow ${workflowId} state in ${elapsed}ms`)

try {
const socketUrl = env.SOCKET_SERVER_URL || 'http://localhost:3002'
const notifyResponse = await fetch(`${socketUrl}/api/workflow-updated`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ workflowId }),
})

if (!notifyResponse.ok) {
logger.warn(
`[${requestId}] Failed to notify Socket.IO server about workflow ${workflowId} update`
)
}
} catch (notificationError) {
logger.warn(
`[${requestId}] Error notifying Socket.IO server about workflow ${workflowId} update`,
notificationError
)
}

return NextResponse.json({ success: true, warnings }, { status: 200 })
} catch (error: any) {
const elapsed = Date.now() - startTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ export function OutputSelect({
const popoverRef = useRef<HTMLDivElement>(null)
const contentRef = useRef<HTMLDivElement>(null)
const blocks = useWorkflowStore((state) => state.blocks)
const { isShowingDiff, isDiffReady, diffWorkflow } = useWorkflowDiffStore()
const { isShowingDiff, isDiffReady, hasActiveDiff, baselineWorkflow } = useWorkflowDiffStore()
const subBlockValues = useSubBlockStore((state) =>
workflowId ? state.workflowValues[workflowId] : null
)

/**
* Uses diff blocks when in diff mode, otherwise main blocks
*/
const workflowBlocks = isShowingDiff && isDiffReady && diffWorkflow ? diffWorkflow.blocks : blocks
const shouldUseBaseline = hasActiveDiff && isDiffReady && !isShowingDiff && baselineWorkflow
const workflowBlocks =
shouldUseBaseline && baselineWorkflow ? baselineWorkflow.blocks : (blocks as any)

/**
* Extracts all available workflow outputs for the dropdown
Expand All @@ -100,7 +102,7 @@ export function OutputSelect({
const blockArray = Object.values(workflowBlocks)
if (blockArray.length === 0) return outputs

blockArray.forEach((block) => {
blockArray.forEach((block: any) => {
if (block.type === 'starter' || !block?.id || !block?.type) return

const blockName =
Expand All @@ -110,8 +112,8 @@ export function OutputSelect({

const blockConfig = getBlock(block.type)
const responseFormatValue =
isShowingDiff && isDiffReady && diffWorkflow
? diffWorkflow.blocks[block.id]?.subBlocks?.responseFormat?.value
shouldUseBaseline && baselineWorkflow
? baselineWorkflow.blocks?.[block.id]?.subBlocks?.responseFormat?.value
: subBlockValues?.[block.id]?.responseFormat
const responseFormat = parseResponseFormatSafely(responseFormatValue, block.id)

Expand Down Expand Up @@ -164,7 +166,16 @@ export function OutputSelect({
})

return outputs
}, [workflowBlocks, workflowId, isShowingDiff, isDiffReady, diffWorkflow, blocks, subBlockValues])
}, [
workflowBlocks,
workflowId,
isShowingDiff,
isDiffReady,
baselineWorkflow,
blocks,
subBlockValues,
shouldUseBaseline,
])

/**
* Checks if an output is currently selected by comparing both ID and label
Expand Down
Loading