Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
fix(home): add folder to API validation and dedup logic
  • Loading branch information
waleedlatif1 committed Apr 7, 2026
commit bb1eda33099bba375c6f3e16c125978b09cdf09c
16 changes: 11 additions & 5 deletions apps/sim/app/api/copilot/chat/resources/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,35 @@ import type { ChatResource, ResourceType } from '@/lib/copilot/resources'

const logger = createLogger('CopilotChatResourcesAPI')

const VALID_RESOURCE_TYPES = new Set<ResourceType>(['table', 'file', 'workflow', 'knowledgebase'])
const GENERIC_TITLES = new Set(['Table', 'File', 'Workflow', 'Knowledge Base'])
const VALID_RESOURCE_TYPES = new Set<ResourceType>([
'table',
'file',
'workflow',
'knowledgebase',
'folder',
])
const GENERIC_TITLES = new Set(['Table', 'File', 'Workflow', 'Knowledge Base', 'Folder'])
Comment thread
waleedlatif1 marked this conversation as resolved.

const AddResourceSchema = z.object({
chatId: z.string(),
resource: z.object({
type: z.enum(['table', 'file', 'workflow', 'knowledgebase']),
type: z.enum(['table', 'file', 'workflow', 'knowledgebase', 'folder']),
id: z.string(),
title: z.string(),
}),
})

const RemoveResourceSchema = z.object({
chatId: z.string(),
resourceType: z.enum(['table', 'file', 'workflow', 'knowledgebase']),
resourceType: z.enum(['table', 'file', 'workflow', 'knowledgebase', 'folder']),
resourceId: z.string(),
})

const ReorderResourcesSchema = z.object({
chatId: z.string(),
resources: z.array(
z.object({
type: z.enum(['table', 'file', 'workflow', 'knowledgebase']),
type: z.enum(['table', 'file', 'workflow', 'knowledgebase', 'folder']),
id: z.string(),
title: z.string(),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export function UserInput({
if (ctx.kind === 'knowledge' && ctx.knowledgeId) keys.add(`knowledgebase:${ctx.knowledgeId}`)
if (ctx.kind === 'table' && ctx.tableId) keys.add(`table:${ctx.tableId}`)
if (ctx.kind === 'file' && ctx.fileId) keys.add(`file:${ctx.fileId}`)
if (ctx.kind === 'folder' && 'folderId' in ctx) keys.add(`folder:${ctx.folderId}`)
Comment thread
waleedlatif1 marked this conversation as resolved.
Outdated
}
return keys
}, [contextManagement.selectedContexts])
Expand Down
Loading