Skip to content

Commit 26d0052

Browse files
committed
Materialization shows up
1 parent 65e99f4 commit 26d0052

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

apps/sim/app/api/mothership/chat/route.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const FileAttachmentSchema = z.object({
3131
const ResourceAttachmentSchema = z.object({
3232
type: z.enum(['workflow', 'table', 'file', 'knowledgebase']),
3333
id: z.string().min(1),
34+
title: z.string().optional(),
35+
active: z.boolean().optional(),
3436
})
3537

3638
const MothershipMessageSchema = z.object({
@@ -124,9 +126,19 @@ export async function POST(req: NextRequest) {
124126

125127
if (Array.isArray(resourceAttachments) && resourceAttachments.length > 0) {
126128
const results = await Promise.allSettled(
127-
resourceAttachments.map((r) =>
128-
resolveActiveResourceContext(r.type, r.id, workspaceId, authenticatedUserId)
129-
)
129+
resourceAttachments.map(async (r) => {
130+
const ctx = await resolveActiveResourceContext(
131+
r.type,
132+
r.id,
133+
workspaceId,
134+
authenticatedUserId
135+
)
136+
if (!ctx) return null
137+
return {
138+
...ctx,
139+
tag: r.active ? '@active_tab' : '@open_tab',
140+
}
141+
})
130142
)
131143
for (const result of results) {
132144
if (result.status === 'fulfilled' && result.value) {

apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -880,12 +880,15 @@ export function useChat(
880880
try {
881881
const currentActiveId = activeResourceIdRef.current
882882
const currentResources = resourcesRef.current
883-
const activeRes = currentActiveId
884-
? currentResources.find((r) => r.id === currentActiveId)
885-
: undefined
886-
const resourceAttachments = activeRes
887-
? [{ type: activeRes.type, id: activeRes.id }]
888-
: undefined
883+
const resourceAttachments =
884+
currentResources.length > 0
885+
? currentResources.map((r) => ({
886+
type: r.type,
887+
id: r.id,
888+
title: r.title,
889+
active: r.id === currentActiveId,
890+
}))
891+
: undefined
889892

890893
const response = await fetch(MOTHERSHIP_CHAT_API_PATH, {
891894
method: 'POST',

apps/sim/lib/copilot/orchestrator/tool-executor/materialize-file.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ async function executeSave(fileName: string, chatId: string): Promise<ToolCallRe
7474
fileId: updated.id,
7575
path: `files/${fileName}`,
7676
},
77+
resources: [{ type: 'file', id: updated.id, title: fileName }],
7778
}
7879
}
7980

0 commit comments

Comments
 (0)