Skip to content

Commit 5f7b98d

Browse files
TheodoreSpeaksTheodore Li
andauthored
fix(resource): fix resource view disappearing on ats (#4103)
Co-authored-by: Theodore Li <theo@sim.ai>
1 parent 227d73d commit 5f7b98d

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ export function UserInput({
445445
sttPrefixRef.current = ''
446446
resetTranscript()
447447
currentFiles.clearAttachedFiles()
448+
prevSelectedContextsRef.current = []
448449
currentContext.clearContexts()
449450

450451
if (textareaRef.current) {

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,18 +2412,30 @@ export function useChat(
24122412
: undefined
24132413

24142414
const requestChatId = selectedChatIdRef.current ?? chatIdRef.current
2415+
const messageContexts = contexts?.map((c) => ({
2416+
kind: c.kind,
2417+
label: c.label,
2418+
...('workflowId' in c && c.workflowId ? { workflowId: c.workflowId } : {}),
2419+
...('knowledgeId' in c && c.knowledgeId ? { knowledgeId: c.knowledgeId } : {}),
2420+
...('tableId' in c && c.tableId ? { tableId: c.tableId } : {}),
2421+
...('fileId' in c && c.fileId ? { fileId: c.fileId } : {}),
2422+
...('folderId' in c && c.folderId ? { folderId: c.folderId } : {}),
2423+
}))
2424+
24152425
if (requestChatId) {
24162426
const cachedUserMsg: PersistedMessage = {
24172427
id: userMessageId,
24182428
role: 'user' as const,
24192429
content: message,
24202430
timestamp: new Date().toISOString(),
24212431
...(storedAttachments && { fileAttachments: storedAttachments }),
2432+
...(messageContexts && messageContexts.length > 0 ? { contexts: messageContexts } : {}),
24222433
}
24232434
queryClient.setQueryData<TaskChatHistory>(taskKeys.detail(requestChatId), (old) => {
24242435
return old
24252436
? {
24262437
...old,
2438+
resources: resourcesRef.current.filter((r) => r.id !== 'streaming-file'),
24272439
messages: [...old.messages, cachedUserMsg],
24282440
activeStreamId: userMessageId,
24292441
}
@@ -2441,16 +2453,6 @@ export function useChat(
24412453
: undefined,
24422454
}))
24432455

2444-
const messageContexts = contexts?.map((c) => ({
2445-
kind: c.kind,
2446-
label: c.label,
2447-
...('workflowId' in c && c.workflowId ? { workflowId: c.workflowId } : {}),
2448-
...('knowledgeId' in c && c.knowledgeId ? { knowledgeId: c.knowledgeId } : {}),
2449-
...('tableId' in c && c.tableId ? { tableId: c.tableId } : {}),
2450-
...('fileId' in c && c.fileId ? { fileId: c.fileId } : {}),
2451-
...('folderId' in c && c.folderId ? { folderId: c.folderId } : {}),
2452-
}))
2453-
24542456
setMessages((prev) => [
24552457
...prev,
24562458
{

0 commit comments

Comments
 (0)