From ca2b3c232fd6563661c6e3cf19fea0391c944d6f Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Sat, 28 Feb 2026 14:13:42 +0000 Subject: [PATCH] perf(ui): drop virtualized DOM in hidden panes Add DOM instrumentation tags and harden VirtualItem visibility for hidden/zero-sized roots to prevent inactive instances from keeping heavy tool-call markup mounted; restore message stream virtualization margin. --- packages/ui/src/App.tsx | 29 ++++--- .../components/instance/instance-shell2.tsx | 12 ++- packages/ui/src/components/markdown.tsx | 12 ++- .../ui/src/components/message-block-list.tsx | 2 +- packages/ui/src/components/message-item.tsx | 10 ++- packages/ui/src/components/message-part.tsx | 7 +- .../ui/src/components/message-section.tsx | 23 +++++- .../ui/src/components/message-timeline.tsx | 9 ++- packages/ui/src/components/tool-call.tsx | 6 ++ packages/ui/src/components/virtual-item.tsx | 76 ++++++++++++++++++- 10 files changed, 161 insertions(+), 25 deletions(-) diff --git a/packages/ui/src/App.tsx b/packages/ui/src/App.tsx index 62caf483..cee2ab06 100644 --- a/packages/ui/src/App.tsx +++ b/packages/ui/src/App.tsx @@ -496,17 +496,24 @@ const App: Component = () => { const isActiveInstance = () => activeInstanceId() === instance.id const isVisible = () => isActiveInstance() && !showFolderSelection() return ( -
- - handleCloseSession(instance.id, sessionId)} - onNewSession={() => handleNewSession(instance.id)} - handleSidebarAgentChange={(sessionId, agent) => handleSidebarAgentChange(instance.id, sessionId, agent)} - handleSidebarModelChange={(sessionId, model) => handleSidebarModelChange(instance.id, sessionId, model)} - onExecuteCommand={executeCommand} +
+ + handleCloseSession(instance.id, sessionId)} + onNewSession={() => handleNewSession(instance.id)} + handleSidebarAgentChange={(sessionId, agent) => handleSidebarAgentChange(instance.id, sessionId, agent)} + handleSidebarModelChange={(sessionId, model) => handleSidebarModelChange(instance.id, sessionId, model)} + onExecuteCommand={executeCommand} tabBarOffset={isPhoneLayout() && mobileFullscreenMode() ? 0 : instanceTabBarHeight()} mobileFullscreenMode={isPhoneLayout() && mobileFullscreenMode()} onEnterMobileFullscreen={() => void enterMobileFullscreen()} diff --git a/packages/ui/src/components/instance/instance-shell2.tsx b/packages/ui/src/components/instance/instance-shell2.tsx index 464a2acb..84e55578 100644 --- a/packages/ui/src/components/instance/instance-shell2.tsx +++ b/packages/ui/src/components/instance/instance-shell2.tsx @@ -62,6 +62,9 @@ const log = getLogger("session") interface InstanceShellProps { instance: Instance + // Provided by App-level instance tabs; lets us pause heavy rendering + // work for inactive instances while keeping them mounted for fast switching. + isActiveInstance?: boolean escapeInDebounce: boolean paletteCommands: Accessor onCloseSession: (sessionId: string) => Promise | void @@ -800,12 +803,14 @@ const InstanceShell2: Component = (props) => { > {(sessionId) => { - const isActive = () => activeSessionIdForInstance() === sessionId + const isActive = () => Boolean(props.isActiveInstance) && activeSessionIdForInstance() === sessionId return (
= (props) => { return ( <> -
+
}> {sessionLayout} diff --git a/packages/ui/src/components/markdown.tsx b/packages/ui/src/components/markdown.tsx index 39638e1b..9e4d170a 100644 --- a/packages/ui/src/components/markdown.tsx +++ b/packages/ui/src/components/markdown.tsx @@ -202,5 +202,15 @@ export function Markdown(props: MarkdownProps) { const proseClass = () => "markdown-body" - return
+ return ( +
+ ) } diff --git a/packages/ui/src/components/message-block-list.tsx b/packages/ui/src/components/message-block-list.tsx index a0e89134..de5b8890 100644 --- a/packages/ui/src/components/message-block-list.tsx +++ b/packages/ui/src/components/message-block-list.tsx @@ -8,7 +8,7 @@ export function getMessageAnchorId(messageId: string) { return `message-anchor-${messageId}` } -const VIRTUAL_ITEM_MARGIN_PX = 300 +const VIRTUAL_ITEM_MARGIN_PX = 800 interface MessageBlockListProps { instanceId: string diff --git a/packages/ui/src/components/message-item.tsx b/packages/ui/src/components/message-item.tsx index a6df84b8..98e754dd 100644 --- a/packages/ui/src/components/message-item.tsx +++ b/packages/ui/src/components/message-item.tsx @@ -381,7 +381,15 @@ export default function MessageItem(props: MessageItemProps) { return ( -
+
(topRowEl = el)}>
diff --git a/packages/ui/src/components/message-part.tsx b/packages/ui/src/components/message-part.tsx index 7178eb93..038b3dfb 100644 --- a/packages/ui/src/components/message-part.tsx +++ b/packages/ui/src/components/message-part.tsx @@ -131,7 +131,12 @@ export default function MessagePart(props: MessagePartProps) { -
+
{plainTextContent()}}> +
-
-
+
+