Skip to content

Commit 833f132

Browse files
TheodoreSpeaksTheodore Li
andauthored
fix(ui): dont delete resource on clearing from context, set resource closed on new task (#4113)
Co-authored-by: Theodore Li <theo@sim.ai>
1 parent ce6db00 commit 833f132

File tree

1 file changed

+7
-12
lines changed
  • apps/sim/app/workspace/[workspaceId]/home

1 file changed

+7
-12
lines changed

apps/sim/app/workspace/[workspaceId]/home/home.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,13 @@ export function Home({ chatId }: HomeProps = {}) {
201201

202202
useEffect(() => {
203203
wasSendingRef.current = false
204-
if (resolvedChatId) markRead(resolvedChatId)
205-
}, [resolvedChatId, markRead])
204+
if (resolvedChatId) {
205+
markRead(resolvedChatId)
206+
} else {
207+
clearWidth()
208+
setIsResourceCollapsed(true)
209+
}
210+
}, [resolvedChatId, markRead, clearWidth])
206211

207212
useEffect(() => {
208213
if (wasSendingRef.current && !isSending && resolvedChatId) {
@@ -291,14 +296,6 @@ export function Home({ chatId }: HomeProps = {}) {
291296
[resolveResourceFromContext, addResource, handleResourceEvent]
292297
)
293298

294-
const handleContextRemove = useCallback(
295-
(context: ChatContext) => {
296-
const resolved = resolveResourceFromContext(context)
297-
if (resolved) removeResource(resolved.type, resolved.id)
298-
},
299-
[resolveResourceFromContext, removeResource]
300-
)
301-
302299
const handleWorkspaceResourceSelect = useCallback(
303300
(resource: MothershipResource) => {
304301
const wasAdded = addResource(resource)
@@ -348,7 +345,6 @@ export function Home({ chatId }: HomeProps = {}) {
348345
onStopGeneration={handleStopGeneration}
349346
userId={session?.user?.id}
350347
onContextAdd={handleContextAdd}
351-
onContextRemove={handleContextRemove}
352348
/>
353349
</div>
354350
</div>
@@ -380,7 +376,6 @@ export function Home({ chatId }: HomeProps = {}) {
380376
userId={session?.user?.id}
381377
chatId={resolvedChatId}
382378
onContextAdd={handleContextAdd}
383-
onContextRemove={handleContextRemove}
384379
onWorkspaceResourceSelect={handleWorkspaceResourceSelect}
385380
editValue={editingInputValue}
386381
onEditValueConsumed={clearEditingValue}

0 commit comments

Comments
 (0)