Skip to content

Commit 6d31c36

Browse files
committed
fix(chat): use resource ID for context removal identity check
1 parent 7b8fa00 commit 6d31c36

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

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

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,26 @@ export function UserInput({
179179
useEffect(() => {
180180
const prev = prevSelectedContextsRef.current
181181
const curr = contextManagement.selectedContexts
182-
const removed = prev.filter((p) => !curr.some((c) => c.kind === p.kind && c.label === p.label))
182+
const contextId = (ctx: ChatContext): string => {
183+
switch (ctx.kind) {
184+
case 'workflow':
185+
case 'current_workflow':
186+
return `${ctx.kind}:${ctx.workflowId}`
187+
case 'knowledge':
188+
return `knowledge:${ctx.knowledgeId ?? ''}`
189+
case 'table':
190+
return `table:${ctx.tableId}`
191+
case 'file':
192+
return `file:${ctx.fileId}`
193+
case 'folder':
194+
return `folder:${ctx.folderId}`
195+
case 'past_chat':
196+
return `past_chat:${ctx.chatId}`
197+
default:
198+
return `${ctx.kind}:${ctx.label}`
199+
}
200+
}
201+
const removed = prev.filter((p) => !curr.some((c) => contextId(c) === contextId(p)))
183202
if (removed.length > 0) removed.forEach((ctx) => onContextRemoveRef.current?.(ctx))
184203
prevSelectedContextsRef.current = curr
185204
}, [contextManagement.selectedContexts])

0 commit comments

Comments
 (0)