Skip to content

Commit 03c7b94

Browse files
author
Theodore Li
committed
fix(resource): fix resource view disappearing on ats
1 parent 0f6c16d commit 03c7b94

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
@@ -2391,18 +2391,30 @@ export function useChat(
23912391
: undefined
23922392

23932393
const requestChatId = selectedChatIdRef.current ?? chatIdRef.current
2394+
const messageContexts = contexts?.map((c) => ({
2395+
kind: c.kind,
2396+
label: c.label,
2397+
...('workflowId' in c && c.workflowId ? { workflowId: c.workflowId } : {}),
2398+
...('knowledgeId' in c && c.knowledgeId ? { knowledgeId: c.knowledgeId } : {}),
2399+
...('tableId' in c && c.tableId ? { tableId: c.tableId } : {}),
2400+
...('fileId' in c && c.fileId ? { fileId: c.fileId } : {}),
2401+
...('folderId' in c && c.folderId ? { folderId: c.folderId } : {}),
2402+
}))
2403+
23942404
if (requestChatId) {
23952405
const cachedUserMsg: PersistedMessage = {
23962406
id: userMessageId,
23972407
role: 'user' as const,
23982408
content: message,
23992409
timestamp: new Date().toISOString(),
24002410
...(storedAttachments && { fileAttachments: storedAttachments }),
2411+
...(messageContexts && messageContexts.length > 0 ? { contexts: messageContexts } : {}),
24012412
}
24022413
queryClient.setQueryData<TaskChatHistory>(taskKeys.detail(requestChatId), (old) => {
24032414
return old
24042415
? {
24052416
...old,
2417+
resources: resourcesRef.current.filter((r) => r.id !== 'streaming-file'),
24062418
messages: [...old.messages, cachedUserMsg],
24072419
activeStreamId: userMessageId,
24082420
}
@@ -2420,16 +2432,6 @@ export function useChat(
24202432
: undefined,
24212433
}))
24222434

2423-
const messageContexts = contexts?.map((c) => ({
2424-
kind: c.kind,
2425-
label: c.label,
2426-
...('workflowId' in c && c.workflowId ? { workflowId: c.workflowId } : {}),
2427-
...('knowledgeId' in c && c.knowledgeId ? { knowledgeId: c.knowledgeId } : {}),
2428-
...('tableId' in c && c.tableId ? { tableId: c.tableId } : {}),
2429-
...('fileId' in c && c.fileId ? { fileId: c.fileId } : {}),
2430-
...('folderId' in c && c.folderId ? { folderId: c.folderId } : {}),
2431-
}))
2432-
24332435
setMessages((prev) => [
24342436
...prev,
24352437
{

0 commit comments

Comments
 (0)