@@ -350,6 +350,7 @@ import {
350350 shouldDockDraftHeroForSubmission ,
351351 shouldReleaseTimelineAnchorForToolActivity ,
352352 shouldShowBranchMismatchBanner ,
353+ shoulderTabReserve ,
353354 shouldShowPlanFollowUpPrompt ,
354355 getStartedThreadModelChangeBlockReason ,
355356 LAST_INVOKED_SCRIPT_BY_PROJECT_KEY ,
@@ -1507,32 +1508,14 @@ function ChatViewContent(props: ChatViewProps) {
15071508 const legendListRef = useRef < LegendListRef | null > ( null ) ;
15081509 const [ composerOverlayElement , setComposerOverlayElement ] = useState < HTMLDivElement | null > ( null ) ;
15091510 const [ composerOverlayHeight , setComposerOverlayHeight ] = useState ( 0 ) ;
1511+ const [ scrollToEndClearance , setScrollToEndClearance ] = useState ( 0 ) ;
15101512 const isAtEndRef = useRef ( true ) ;
15111513 const attachmentPreviewHandoffByMessageIdRef = useRef < Record < string , string [ ] > > ( { } ) ;
15121514 const attachmentPreviewPromotionInFlightByMessageIdRef = useRef < Record < string , true > > ( { } ) ;
15131515 const sendInFlightRef = useRef ( false ) ;
15141516 const feedbackUploadsInFlightRef = useRef ( new Set < string > ( ) ) ;
15151517 const terminalUiOpenByThreadRef = useRef < Record < string , boolean > > ( { } ) ;
15161518
1517- useLayoutEffect ( ( ) => {
1518- if ( ! composerOverlayElement ) return ;
1519-
1520- const updateHeight = ( ) => {
1521- const nextHeight = Math . ceil ( composerOverlayElement . getBoundingClientRect ( ) . height ) ;
1522- if ( nextHeight <= 0 ) return ;
1523- setComposerOverlayHeight ( ( currentHeight ) =>
1524- currentHeight === nextHeight ? currentHeight : nextHeight ,
1525- ) ;
1526- } ;
1527-
1528- updateHeight ( ) ;
1529- if ( typeof ResizeObserver === "undefined" ) return ;
1530-
1531- const observer = new ResizeObserver ( updateHeight ) ;
1532- observer . observe ( composerOverlayElement ) ;
1533- return ( ) => observer . disconnect ( ) ;
1534- } , [ composerOverlayElement ] ) ;
1535-
15361519 const terminalUiState = useTerminalUiStateStore ( ( state ) =>
15371520 selectThreadTerminalUiState ( state . terminalUiStateByThreadKey , routeThreadRef ) ,
15381521 ) ;
@@ -4467,6 +4450,35 @@ function ChatViewContent(props: ChatViewProps) {
44674450 activeComposerTasksProgress && activePlan && activePlan . turnId === activeLatestTurn ?. turnId
44684451 ? activePlan . steps
44694452 : null ;
4453+
4454+ useLayoutEffect ( ( ) => {
4455+ if ( ! composerOverlayElement ) return ;
4456+
4457+ const updateHeight = ( ) => {
4458+ const nextHeight = Math . ceil ( composerOverlayElement . getBoundingClientRect ( ) . height ) ;
4459+ if ( nextHeight <= 0 ) return ;
4460+ setComposerOverlayHeight ( ( currentHeight ) =>
4461+ currentHeight === nextHeight ? currentHeight : nextHeight ,
4462+ ) ;
4463+ const nextClearance = Math . max ( 0 , nextHeight - shoulderTabReserve ( composerOverlayElement ) ) ;
4464+ setScrollToEndClearance ( ( currentClearance ) =>
4465+ currentClearance === nextClearance ? currentClearance : nextClearance ,
4466+ ) ;
4467+ } ;
4468+
4469+ updateHeight ( ) ;
4470+ if ( typeof ResizeObserver === "undefined" ) return ;
4471+
4472+ const resizeObserver = new ResizeObserver ( updateHeight ) ;
4473+ resizeObserver . observe ( composerOverlayElement ) ;
4474+ const tabObserver = new MutationObserver ( updateHeight ) ;
4475+ tabObserver . observe ( composerOverlayElement , { childList : true , subtree : true } ) ;
4476+ return ( ) => {
4477+ resizeObserver . disconnect ( ) ;
4478+ tabObserver . disconnect ( ) ;
4479+ } ;
4480+ } , [ composerOverlayElement ] ) ;
4481+
44704482 const autoSettleAfterDays = useClientSettings ( ( settings ) => settings . sidebarAutoSettleAfterDays ) ;
44714483 const autoSettleOnMerge = useClientSettings ( ( settings ) => settings . sidebarAutoSettleOnMerge ) ;
44724484 const linkedPullRequestStatus = useLinkedThreadPullRequest (
@@ -7148,7 +7160,7 @@ function ChatViewContent(props: ChatViewProps) {
71487160 { showScrollToBottom && (
71497161 < div
71507162 className = "pointer-events-none absolute left-1/2 z-30 flex -translate-x-1/2 justify-center py-1.5"
7151- style = { { bottom : composerOverlayHeight + 4 } }
7163+ style = { { bottom : scrollToEndClearance + 4 } }
71527164 >
71537165 < Button
71547166 aria-label = "Scroll to end"
@@ -7178,11 +7190,11 @@ function ChatViewContent(props: ChatViewProps) {
71787190 ref = { attachDraftHeroTransitionGroupRef }
71797191 className = "w-full ps-[calc(env(safe-area-inset-left)+0.75rem)] pe-[calc(env(safe-area-inset-right)+0.75rem)] sm:ps-[calc(env(safe-area-inset-left)+1.25rem)] sm:pe-[calc(env(safe-area-inset-right)+1.25rem)]"
71807192 >
7181- < div className = "pointer-events-auto relative z-10" >
7193+ < div className = "group/composer-stack pointer-events-auto relative z-10" >
71827194 { isDraftHeroState ? (
71837195 < div className = "absolute inset-x-0 bottom-full z-0" >
71847196 < div
7185- className = "pb-8"
7197+ className = "pb-8 group-has-[.chat-composer-shoulder-tab]/composer-stack:pb-4 "
71867198 style = {
71877199 forceExpandedMobileComposer
71887200 ? {
0 commit comments