@@ -241,7 +241,6 @@ import { isCommandPaletteOpen } from "../commandPaletteBus";
241241import { subscribeSnapShotComposerFocus } from "../lib/desktopSnapShot" ;
242242import { useMediaQuery } from "../hooks/useMediaQuery" ;
243243import { useTurnDiffSummaries } from "../hooks/useTurnDiffSummaries" ;
244- import { useElementWidth } from "../hooks/useElementWidth" ;
245244import { usePreviewPanelInlineSize } from "../hooks/usePreviewPanelInlineSize" ;
246245import {
247246 RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY ,
@@ -606,6 +605,7 @@ import {
606605 ATTACHMENT_ONLY_BOOTSTRAP_PROMPT ,
607606 recallableComposerPrompt ,
608607} from "./chat/composerPromptHistory" ;
608+ import { observeResize } from "~/lib/observeResize" ;
609609
610610const EMPTY_PROVIDERS : ServerProvider [ ] = [ ] ;
611611const EMPTY_PROVIDER_MODELS : ServerProvider [ "models" ] = [ ] ;
@@ -1938,7 +1938,7 @@ export default function ChatView(props: ChatViewProps) {
19381938 useState < Record < string , number > > ( { } ) ;
19391939 const shouldUsePlanSidebarSheet = useMediaQuery ( RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY ) ;
19401940 const isMobileViewport = useMediaQuery ( "max-sm" ) ;
1941- const [ workspaceLayoutRef , workspaceLayoutWidth ] = useElementWidth < HTMLDivElement > ( ) ;
1941+ const [ workspaceLayoutElement , setWorkspaceLayoutElement ] = useState < HTMLDivElement | null > ( null ) ;
19421942 const threadPanelPopoverAnchorRef = useRef < HTMLElement | null > ( null ) ;
19431943 // Tracks whether the user explicitly dismissed the sidebar for the active turn.
19441944 // When set, the thread-change reset effect will open the sidebar instead of closing it.
@@ -2255,7 +2255,7 @@ export default function ChatView(props: ChatViewProps) {
22552255 // Electron hosts its own browser tabs; other clients need the environment to host them.
22562256 const browserAvailable = isPreviewSupportedInRuntime ( ) || activeEnvironmentServerBrowser ;
22572257 const previewPanelInlineSize = usePreviewPanelInlineSize ( undefined , {
2258- containerWidth : workspaceLayoutWidth ?? undefined ,
2258+ container : workspaceLayoutElement ,
22592259 widthStorageKey : `t3code:preview-panel-width:${ activeThreadKey } ` ,
22602260 } ) ;
22612261 const activeThreadShell = useThreadShell ( isServerThread ? activeThreadRef : null ) ;
@@ -7053,13 +7053,7 @@ export default function ChatView(props: ChatViewProps) {
70537053 } ;
70547054
70557055 updateHeight ( ) ;
7056- if ( typeof ResizeObserver === "undefined" ) return ;
7057-
7058- const resizeObserver = new ResizeObserver ( updateHeight ) ;
7059- resizeObserver . observe ( composerOverlayElement ) ;
7060- return ( ) => {
7061- resizeObserver . disconnect ( ) ;
7062- } ;
7056+ return observeResize ( composerOverlayElement , updateHeight ) ;
70637057 } , [ composerOverlayElement , publishComposerOverlayHeight , showScrollToBottom ] ) ;
70647058 // Swapping the composer for the status bar (or back) changes what the
70657059 // overlay holds, so rebuild the reservation from the new content.
@@ -11248,7 +11242,7 @@ export default function ChatView(props: ChatViewProps) {
1124811242
1124911243 return (
1125011244 < div
11251- ref = { workspaceLayoutRef }
11245+ ref = { setWorkspaceLayoutElement }
1125211246 className = "relative flex min-h-0 min-w-0 flex-1 overflow-hidden bg-background"
1125311247 >
1125411248 < Dialog
0 commit comments