Skip to content

The agent that grows with you

refactor(desktop): tool row preview effect gates on view status only

kshitijk4poord00b511da178
diff --git a/apps/desktop/src/components/assistant-ui/tool/fallback-preview-scope.test.tsx b/apps/desktop/src/components/assistant-ui/tool/fallback-preview-scope.test.tsx
index c853f565bfe..fa526f3c2fa 100644
--- a/apps/desktop/src/components/assistant-ui/tool/fallback-preview-scope.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/tool/fallback-preview-scope.test.tsx
@@ -27,6 +27,7 @@ function tileView(): SessionView {
$cwd: atom('/tile/work'),
$messages: atom(messages),
$runtimeId: atom<null | string>(TILE_ID),
+ $storedId: atom<null | string>(null),
kind: 'tile'
}
}
diff --git a/apps/desktop/src/components/assistant-ui/tool/fallback.tsx b/apps/desktop/src/components/assistant-ui/tool/fallback.tsx
index 54d98fa79d0..875e6b0b3b0 100644
--- a/apps/desktop/src/components/assistant-ui/tool/fallback.tsx
+++ b/apps/desktop/src/components/assistant-ui/tool/fallback.tsx
@@ -427,13 +427,7 @@ function ToolEntry({ part }: ToolEntryProps) {
} = useSessionView()
useEffect(() => {
- if (
- isPending ||
- result === undefined ||
- view.status !== 'success' ||
- !previewTarget ||
- !isPreviewableTarget(previewTarget)
- ) {
+ if (view.status !== 'success' || !previewTarget || !isPreviewableTarget(previewTarget)) {
return
}
@@ -441,24 +435,13 @@ function ToolEntry({ part }: ToolEntryProps) {
// target appears, and subscribing re-rendered every tool row on any session
// or cwd change.
const sessionId = $sessionRuntimeId.get()
- const dismissalSessionId = $sessionStoredId?.get() ?? sessionId
// A route switch can paint the previous assistant row while these atoms
// already describe the next chat. Only that chat's own messages may feed it.
if (sessionId && $sessionMessages.get().some(message => message.id === messageId)) {
- recordPreviewArtifact(sessionId, previewTarget, $sessionCwd.get() || '', dismissalSessionId ?? '')
+ recordPreviewArtifact(sessionId, previewTarget, $sessionCwd.get() || '', $sessionStoredId.get() ?? sessionId)
}
- }, [
- $sessionCwd,
- $sessionRuntimeId,
- $sessionStoredId,
- $sessionMessages,
- isPending,
- messageId,
- previewTarget,
- result,
- view.status
- ])
+ }, [$sessionCwd, $sessionRuntimeId, $sessionStoredId, $sessionMessages, messageId, previewTarget, view.status])
const detailSections = useMemo(() => {
if (!view.detail) {