The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): settle approval and tool-row layout together
brooklyn!140d12545a1e
diff --git a/apps/desktop/DESIGN.md b/apps/desktop/DESIGN.mdindex 62f513adfe8..effa71f30ca 100644--- a/apps/desktop/DESIGN.md+++ b/apps/desktop/DESIGN.md@@ -109,7 +109,11 @@ represented execution rows appear only when explicitly expanded. Empty textcontinuations must not introduce paragraph gaps. Keep inline approvals besidethe conversation and let genuine content scroll normally; do not inject paddingor write scroll offsets to pin the decision. Preview this order with delayed-start and completion events, not pre-created tool rows.+start and completion events, not pre-created tool rows. Final approval removal+retires both the painted card and its measured layout footprint; restoring tool+rows must not insert their full height before the outgoing stack can settle.+No completion callback may clear the measurement of a newly arrived card.+Reduced motion settles immediately without retaining empty clearance.## Window glassdiff --git a/apps/desktop/src/components/assistant-ui/tool/approval.tsx b/apps/desktop/src/components/assistant-ui/tool/approval.tsxindex 6cb93e2fd63..af755435a6a 100644--- a/apps/desktop/src/components/assistant-ui/tool/approval.tsx+++ b/apps/desktop/src/components/assistant-ui/tool/approval.tsx@@ -2,6 +2,7 @@import { useAuiState } from '@assistant-ui/react'import { useStore } from '@nanostores/react'+import { AnimatePresence, motion, useReducedMotion } from 'motion/react'import { createContext, type FC, useCallback, useContext, useMemo, useRef, useState } from 'react'import { useSessionView } from '@/app/chat/session-view'@@ -51,28 +52,37 @@ export const PendingApprovalStack: FC = () => {const sessionId = useStore(useSessionView().$runtimeId)const requests = useStore(useMemo(() => sessionApprovalRequests(sessionId), [sessionId]))const total = useStore(useMemo(() => sessionApprovalStackSize(sessionId), [sessionId]))+ const reduced = useReducedMotion()return (- <section+ <motion.section+ animate={{ paddingBlock: requests.length ? 8 : 0 }}aria-label={t.assistant.approval.jumpToApproval}className={cn(- 'min-w-0 has-[[data-stack-key]]:py-2',+ 'min-w-0',placement === 'floating' ? 'sticky bottom-4 z-10 mt-auto w-full max-w-xl self-center' : 'w-full max-w-xl')}data-approval-placement={placement}data-approval-stack=""data-slot="tool-approval-stack"+ initial={false}+ transition={reduced || requests.length ? { duration: 0 } : { duration: 0.22, ease: 'easeInOut' }}>- {requests.length > 0 && <ApprovalActivity floating={placement === 'floating'} />}+ <ApprovalActivity floating={placement === 'floating'} visible={requests.length > 0} /><ApprovalQueue floating={placement === 'floating'} requests={requests} total={total} />- </section>+ </motion.section>)}-function ApprovalActivity({ floating }: { floating: boolean }) {+function ApprovalActivity({ floating, visible }: { floating: boolean; visible: boolean }) {const { t } = useI18n()+ const reduced = useReducedMotion()const summary = useAuiState(state => {+ if (!visible) {+ return ''+ }+const start = state.thread.messages.findLastIndex(message => message.role === 'user')const tools = state.thread.messages@@ -89,6 +99,10 @@ function ApprovalActivity({ floating }: { floating: boolean }) {})const disclosureIds = useAuiState(state => {+ if (!visible) {+ return ''+ }+const start = state.thread.messages.findLastIndex(message => message.role === 'user')return state.thread.messages@@ -104,27 +118,40 @@ function ApprovalActivity({ floating }: { floating: boolean }) {})return (- <div- className={cn('mb-1 min-w-0', floating && 'rounded bg-(--ui-chat-surface-background)')}- data-approval-activity=""- data-glass-opaque={floating ? '' : undefined}- data-tool-summary=""- >- <ScaffoldRow- onToggle={- disclosureIds- ? () => {- for (const id of disclosureIds.split('\n')) {- setToolDisclosureOpen(id, true)- }+ <AnimatePresence initial={false}>+ {visible && (+ <motion.div+ animate={{ height: 'auto', opacity: 1 }}+ className="overflow-hidden"+ exit={{ height: 0, opacity: 0 }}+ initial={{ height: 0, opacity: 0 }}+ key="activity"+ transition={{ duration: reduced ? 0 : 0.22, ease: 'easeInOut' }}+ >+ <div+ className={cn('mb-1 min-w-0', floating && 'rounded bg-(--ui-chat-surface-background)')}+ data-approval-activity=""+ data-glass-opaque={floating ? '' : undefined}+ data-tool-summary=""+ >+ <ScaffoldRow+ onToggle={+ disclosureIds+ ? () => {+ for (const id of disclosureIds.split('\n')) {+ setToolDisclosureOpen(id, true)+ }+ }+ : undefined}- : undefined- }- open={false}- >- <span className={cn(SCAFFOLD_LABEL_CLASS, 'truncate')}>{summary || t.assistant.approval.jumpToApproval}</span>- </ScaffoldRow>- </div>+ open={false}+ >+ <span className={cn(SCAFFOLD_LABEL_CLASS, 'truncate')}>{summary || t.assistant.approval.jumpToApproval}</span>+ </ScaffoldRow>+ </div>+ </motion.div>+ )}+ </AnimatePresence>)}diff --git a/apps/desktop/src/components/assistant-ui/tool/fallback.tsx b/apps/desktop/src/components/assistant-ui/tool/fallback.tsxindex 92c2d05c3ef..3cc8c8c41ae 100644--- a/apps/desktop/src/components/assistant-ui/tool/fallback.tsx+++ b/apps/desktop/src/components/assistant-ui/tool/fallback.tsx@@ -2,6 +2,7 @@import { type ToolCallMessagePartProps, useAuiState } from '@assistant-ui/react'import { useStore } from '@nanostores/react'+import { motion, useReducedMotion } from 'motion/react'import {Children,createContext,@@ -964,20 +965,24 @@ const ToolRun: FC<PropsWithChildren<{ endIndex: number; startIndex: number }>> =const enterRef = useEnterAnimation(messageRunning, `tool-run:${key}`)const representedByApproval = !!approval && currentTurn && approvalActivityconst expanded = count < 2 || (persistedOpen ?? rowOpen)+ const collapsed = representedByApproval && !rowOpen && !persistedOpen+ const reduced = useReducedMotion()- // Pending command activity is summarized by the persistent approval host.- // An explicit result disclosure still uses the original tool runtime.- if (representedByApproval && !rowOpen && !persistedOpen) {- return null- }-+ // The original runtime stays mounted while its summary owns the activity.+ // Reveal its footprint gradually when the last approval clears, instead of+ // inserting all represented rows in the outgoing card's first exit frame.return (<ToolRunDisclosureContext.Provider value={disclosureId}>- <div+ <motion.div+ animate={{ height: collapsed ? 0 : 'auto' }}+ aria-hidden={collapsed || undefined}className="grid min-w-0 max-w-full gap-(--tool-row-gap) overflow-hidden"data-slot="tool-block"data-tool-group=""+ inert={collapsed}+ initial={currentTurn && approvalActivity && messageRunning && !reduced ? { height: 0 } : false}ref={enterRef}+ transition={{ duration: reduced ? 0 : 0.22, ease: 'easeInOut' }}>{count > 1 && !representedByApproval && (<ToolRunHeader@@ -991,7 +996,7 @@ const ToolRun: FC<PropsWithChildren<{ endIndex: number; startIndex: number }>> =)}{count > 1 && live && !expanded && <ToolRunTicker>{children}</ToolRunTicker>}{expanded && <div className="grid min-w-0 max-w-full gap-(--tool-row-gap)">{children}</div>}- </div>+ </motion.div></ToolRunDisclosureContext.Provider>)}