From 38208a9a2ff7dd067896d0ed05b42a263b7cd826 Mon Sep 17 00:00:00 2001 From: Ammar Date: Wed, 3 Dec 2025 13:12:39 -0600 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A4=96=20fix:=20use=20double=20RAF=20?= =?UTF-8?q?in=20jumpToBottom=20for=20reliable=20scroll=20position?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When switching workspaces, jumpToBottom was executing synchronously before browser layout was complete. This caused scrolling to land 'almost at the bottom' instead of fully at the bottom. The fix uses double requestAnimationFrame (matching performAutoScroll): - First frame: allows DOM updates to complete - Second frame: measures accurate scrollHeight after layout setAutoScroll(true) is set immediately to prevent flicker of the 'jump to bottom' button. --- src/browser/hooks/useAutoScroll.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/browser/hooks/useAutoScroll.ts b/src/browser/hooks/useAutoScroll.ts index 540adf47be..5ac5c3706a 100644 --- a/src/browser/hooks/useAutoScroll.ts +++ b/src/browser/hooks/useAutoScroll.ts @@ -38,10 +38,18 @@ export function useAutoScroll() { }, []); // No deps - ref ensures we always check current value const jumpToBottom = useCallback(() => { - if (contentRef.current) { - contentRef.current.scrollTop = contentRef.current.scrollHeight; - setAutoScroll(true); - } + if (!contentRef.current) return; + + // Double RAF: First frame for DOM updates (async highlighting, image loads), + // second frame to scroll after layout is complete + requestAnimationFrame(() => { + requestAnimationFrame(() => { + if (contentRef.current) { + contentRef.current.scrollTop = contentRef.current.scrollHeight; + } + }); + }); + setAutoScroll(true); }, []); const handleScroll = useCallback((e: React.UIEvent) => { From f711b651f1e840c5eba845722e944d83400fa675 Mon Sep 17 00:00:00 2001 From: Ammar Date: Wed, 3 Dec 2025 13:16:41 -0600 Subject: [PATCH 2/2] chore: fix formatting in cli/index.ts (pre-existing issue) --- src/cli/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index 5c3d6f1134..c1df6cbce1 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -42,7 +42,10 @@ if (subcommand === "run") { process.argv.splice(2, 1); // eslint-disable-next-line @typescript-eslint/no-require-imports require("./api"); -} else if (subcommand === "desktop" || (isElectron && (subcommand === undefined || isElectronLaunchArg))) { +} else if ( + subcommand === "desktop" || + (isElectron && (subcommand === undefined || isElectronLaunchArg)) +) { // Explicit `mux desktop`, or Electron runtime with no subcommand / Electron launch args launchDesktop(); } else {