Skip to content

Commit 9afcf77

Browse files
committed
add filefolder to chat context kind registry; fix resolver to use workspaceFiles table
1 parent eebf06d commit 9afcf77

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/components/chat-context-kind-registry.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export const CHAT_CONTEXT_KIND_REGISTRY: Record<ChatContextKind, ChatContextKind
6969
label: 'Folder',
7070
renderIcon: ({ className }) => <FolderIcon className={className} />,
7171
},
72+
filefolder: {
73+
label: 'File folder',
74+
renderIcon: ({ className }) => <FolderIcon className={className} />,
75+
},
7276
past_chat: {
7377
label: 'Past chat',
7478
renderIcon: ({ className }) => <Blimp className={className} />,

apps/sim/lib/copilot/chat/process-contents.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ async function resolveFileFolderResource(
796796
workspaceId: string
797797
): Promise<AgentContext | null> {
798798
try {
799-
const { workspaceFileFolder, workspaceFile } = await import('@sim/db/schema')
799+
const { workspaceFileFolder, workspaceFiles } = await import('@sim/db/schema')
800800
const [folder] = await db
801801
.select({ id: workspaceFileFolder.id, name: workspaceFileFolder.name })
802802
.from(workspaceFileFolder)
@@ -811,9 +811,18 @@ async function resolveFileFolderResource(
811811
if (!folder) return null
812812

813813
const files = await db
814-
.select({ id: workspaceFile.id, name: workspaceFile.name, type: workspaceFile.type })
815-
.from(workspaceFile)
816-
.where(and(eq(workspaceFile.folderId, folderId), eq(workspaceFile.workspaceId, workspaceId)))
814+
.select({
815+
name: workspaceFiles.originalName,
816+
type: workspaceFiles.contentType,
817+
})
818+
.from(workspaceFiles)
819+
.where(
820+
and(
821+
eq(workspaceFiles.folderId, folderId),
822+
eq(workspaceFiles.workspaceId, workspaceId),
823+
isNull(workspaceFiles.deletedAt)
824+
)
825+
)
817826

818827
const fileList = files.map((f) => `- ${f.name}${f.type ? ` (${f.type})` : ''}`).join('\n')
819828
const content = `File Folder: ${folder.name} (id: ${folder.id})\nFiles:\n${fileList || '(empty)'}`

0 commit comments

Comments
 (0)