Skip to content

Commit 7ef8ae7

Browse files
committed
fix(copilot): close resources before chat creation
1 parent 8f45b0c commit 7ef8ae7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tabs.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ export function ResourceTabs({
396396
const handleRemove = useCallback(
397397
(e: React.SyntheticEvent, resource: MothershipResource) => {
398398
e.stopPropagation()
399-
if (!chatId) return
400399
const isMulti = selectedIds.has(resource.id) && selectedIds.size > 1
401400
const targets = isMulti ? resources.filter((r) => selectedIds.has(r.id)) : [resource]
402401
// Update parent state immediately for all targets
@@ -413,6 +412,11 @@ export function ResourceTabs({
413412
if (anchorIdRef.current && removedIds.has(anchorIdRef.current)) {
414413
anchorIdRef.current = null
415414
}
415+
// Mirrors `handleAdd`: a resource opened while composing the first prompt
416+
// has to be closable before there is a chat to attach it to. Only the
417+
// server call is conditional — the local removal above also drops the
418+
// queued write, so nothing resurrects it once the chat exists.
419+
if (!chatId) return
416420
for (const r of targets) {
417421
if (isEphemeralResource(r)) continue
418422
removeResource.mutate({ chatId, resourceType: r.type, resourceId: r.id })

0 commit comments

Comments
 (0)