@@ -22,7 +22,6 @@ import {
2222import { Columns3 , Eye , Pencil } from '@sim/emcn/icons'
2323import { sendBrowserPanelAction } from '@/lib/browser-agent/transport'
2424import { SIM_RESOURCE_DRAG_TYPE , SIM_RESOURCES_DRAG_TYPE } from '@/lib/copilot/resource-types'
25- import { isEphemeralResource } from '@/lib/copilot/resources/types'
2625import { openTerminal } from '@/lib/terminal/transport'
2726import type { PreviewMode } from '@/app/workspace/[workspaceId]/files/components/file-viewer'
2827import { useMothershipResources } from '@/app/workspace/[workspaceId]/home/components/mothership-resources-context'
@@ -41,11 +40,6 @@ import { useCustomTools } from '@/hooks/queries/custom-tools'
4140import { useFolders } from '@/hooks/queries/folders'
4241import { useKnowledgeBasesQuery } from '@/hooks/queries/kb/knowledge'
4342import { useMcpServers } from '@/hooks/queries/mcp'
44- import {
45- useAddChatResource ,
46- useRemoveChatResource ,
47- useReorderChatResources ,
48- } from '@/hooks/queries/mothership-chats'
4943import { useSkills } from '@/hooks/queries/skills'
5044import { useTablesList } from '@/hooks/queries/tables'
5145import { useWorkflows } from '@/hooks/queries/workflows'
@@ -276,10 +270,6 @@ export function ResourceTabs({
276270 requestResourceTransition,
277271 } = useMothershipResources ( )
278272
279- const addResource = useAddChatResource ( chatId )
280- const removeResource = useRemoveChatResource ( chatId )
281- const reorderResources = useReorderChatResources ( chatId )
282-
283273 const [ selectedIds , setSelectedIds ] = useState < Set < string > > ( new Set ( ) )
284274 const anchorIdRef = useRef < string | null > ( null )
285275 const prevChatIdRef = useRef ( chatId )
@@ -324,19 +314,9 @@ export function ResourceTabs({
324314
325315 const handleAdd = useCallback (
326316 ( resource : MothershipResource ) => {
327- requestResourceTransition ( ( ) => {
328- // Opening a resource before the first message is sent is allowed: there
329- // is simply no chat to attach it to yet. `onAddResource` queues it and
330- // persists once the chat exists, so only the server call is conditional.
331- // Synthetic result/preview panels are in-memory only either way.
332- if ( chatId && ! isEphemeralResource ( resource ) ) {
333- addResource . mutate ( { chatId, resource } )
334- }
335- onAddResource ( resource )
336- } )
317+ requestResourceTransition ( ( ) => onAddResource ( resource ) )
337318 } ,
338- // eslint-disable-next-line react-hooks/exhaustive-deps
339- [ chatId , onAddResource , requestResourceTransition ]
319+ [ onAddResource , requestResourceTransition ]
340320 )
341321
342322 const handleOpenExisting = useCallback (
@@ -436,21 +416,11 @@ export function ResourceTabs({
436416 if ( anchorIdRef . current && removedIds . has ( anchorIdRef . current ) ) {
437417 anchorIdRef . current = null
438418 }
439- // Mirrors `handleAdd`: a resource opened while composing the first prompt
440- // has to be closable before there is a chat to attach it to. Only the
441- // server call is conditional — the local removal above also drops the
442- // queued write, so nothing resurrects it once the chat exists.
443- if ( ! chatId ) return
444- for ( const r of targets ) {
445- if ( isEphemeralResource ( r ) ) continue
446- removeResource . mutate ( { chatId, resourceType : r . type , resourceId : r . id } )
447- }
448419 }
449420 if ( targets . some ( ( target ) => target . id === activeId ) ) requestResourceTransition ( close )
450421 else close ( )
451422 } ,
452- // eslint-disable-next-line react-hooks/exhaustive-deps
453- [ activeId , chatId , onRemoveResource , requestResourceTransition , resources , selectedIds ]
423+ [ activeId , onRemoveResource , requestResourceTransition , resources , selectedIds ]
454424 )
455425
456426 const handleTabDragStart = useCallback (
@@ -497,15 +467,8 @@ export function ResourceTabs({
497467 const [ moved ] = reordered . splice ( fromIndex , 1 )
498468 reordered . splice ( targetIndex , 0 , moved )
499469 onReorderResources ( reordered )
500- if ( chatId ) {
501- const persistable = reordered . filter ( ( r ) => ! isEphemeralResource ( r ) )
502- if ( persistable . length > 0 ) {
503- reorderResources . mutate ( { chatId, resources : persistable } )
504- }
505- }
506470 } ,
507- // eslint-disable-next-line react-hooks/exhaustive-deps
508- [ chatId , resources , onReorderResources ]
471+ [ resources , onReorderResources ]
509472 )
510473
511474 const previewToggle =
0 commit comments