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) => { 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 {