Skip to content

Commit 7a6c2a1

Browse files
committed
add filefolder ChatContext kind and wire through schema and resolver
1 parent f8134a4 commit 7a6c2a1

4 files changed

Lines changed: 13 additions & 0 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ const RESOURCE_TO_CONTEXT: Record<
9090
table: (r) => ({ kind: 'table', tableId: r.id, label: r.title }),
9191
file: (r) => ({ kind: 'file', fileId: r.id, label: r.title }),
9292
folder: (r) => ({ kind: 'folder', folderId: r.id, label: r.title }),
93+
filefolder: (r) => ({ kind: 'filefolder', fileFolderId: r.id, label: r.title }),
9394
task: (r) => ({ kind: 'past_chat', chatId: r.id, label: r.title }),
9495
log: (r) => ({ kind: 'logs', executionId: r.id, label: r.title }),
9596
generic: (r) => ({ kind: 'docs', label: r.title }),

apps/sim/lib/copilot/chat/post.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const ChatContextSchema = z.object({
101101
'table',
102102
'file',
103103
'folder',
104+
'filefolder',
104105
]),
105106
label: z.string(),
106107
chatId: z.string().optional(),
@@ -113,6 +114,7 @@ const ChatContextSchema = z.object({
113114
tableId: z.string().optional(),
114115
fileId: z.string().optional(),
115116
folderId: z.string().optional(),
117+
fileFolderId: z.string().optional(),
116118
})
117119

118120
const ChatMessageSchema = z.object({

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ export async function processContextsServer(
131131
if (!result) return null
132132
return { type: 'folder', tag: ctx.label ? `@${ctx.label}` : '@', content: result.content }
133133
}
134+
if (ctx.kind === 'filefolder' && ctx.fileFolderId && currentWorkspaceId) {
135+
const result = await resolveFileFolderResource(ctx.fileFolderId, currentWorkspaceId)
136+
if (!result) return null
137+
return {
138+
type: 'filefolder',
139+
tag: ctx.label ? `@${ctx.label}` : '@',
140+
content: result.content,
141+
}
142+
}
134143
if (ctx.kind === 'docs') {
135144
try {
136145
const { searchDocumentationServerTool } = await import(

apps/sim/stores/panel/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export type ChatContext =
3030
| { kind: 'table'; tableId: string; label: string }
3131
| { kind: 'file'; fileId: string; label: string }
3232
| { kind: 'folder'; folderId: string; label: string }
33+
| { kind: 'filefolder'; fileFolderId: string; label: string }
3334
| { kind: 'templates'; templateId?: string; label: string }
3435
| { kind: 'docs'; label: string }
3536
| { kind: 'slash_command'; command: string; label: string }

0 commit comments

Comments
 (0)