@@ -114,7 +114,10 @@ import Animated, {
114114} from "react-native-reanimated" ;
115115import { useSafeAreaInsets } from "react-native-safe-area-context" ;
116116import { useBarOverlap } from "../../components/ui/useBarInset" ;
117- import { useWorkspaceContentWidth } from "../layout/workspace-content-width" ;
117+ import {
118+ useWorkspaceContentWidth ,
119+ WorkspaceSettledContentWidthContext ,
120+ } from "../layout/workspace-content-width" ;
118121import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context" ;
119122import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns" ;
120123import {
@@ -317,6 +320,17 @@ export interface ThreadDetailScreenProps {
317320
318321// iOS questions overlay the controls; Android questions stack with child approvals.
319322const ComposerPanels = Platform . OS === "android" ? Animated . ScrollView : Animated . View ;
323+
324+ /** Hands the feed the screen width measured for a native column; elsewhere keeps the inherited one. */
325+ function ColumnWidth ( props : { readonly width : number | null ; readonly children : React . ReactNode } ) {
326+ return props . width === null ? (
327+ props . children
328+ ) : (
329+ < WorkspaceSettledContentWidthContext value = { props . width } >
330+ { props . children }
331+ </ WorkspaceSettledContentWidthContext >
332+ ) ;
333+ }
320334const USAGE_LIMITS_PANEL_GAP = 12 ;
321335const USAGE_LIMITS_PANEL_MIN_HEIGHT = 44 ;
322336
@@ -1022,8 +1036,13 @@ function ThreadDetailBody(
10221036 // Android lays the screen out below its opaque header and reports a zero
10231037 // header height, so the window height overstates the room by the header.
10241038 const [ screenHeight , setScreenHeight ] = useState < number | null > ( null ) ;
1039+ const [ screenWidth , setScreenWidth ] = useState < number | null > ( null ) ;
10251040 const handleScreenLayout = ( event : LayoutChangeEvent ) => {
10261041 setScreenHeight ( event . nativeEvent . layout . height ) ;
1042+ const width = Math . round ( event . nativeEvent . layout . width ) ;
1043+ setScreenWidth ( ( current ) =>
1044+ current !== null && Math . abs ( current - width ) <= 1 ? current : width ,
1045+ ) ;
10271046 } ;
10281047 const screenAreaHeight = screenHeight ?? windowHeight ;
10291048 const draftViewportHeight = screenAreaHeight - navigationHeaderHeight - liveKeyboardHeight ;
@@ -1211,6 +1230,13 @@ function ThreadDetailBody(
12111230 }
12121231 : { width : "auto" , right : controlInsets . right } ,
12131232 ) ;
1233+ // A native column resizes the screen before JS hears of it. The feed and the composer take the
1234+ // measured width in one render, so they change size together rather than the composer first.
1235+ const columnWidth = usesNativeWorkspaceColumns && isSplitLayout ? screenWidth : null ;
1236+ const columnComposerWidthStyle =
1237+ columnWidth === null
1238+ ? null
1239+ : { width : Math . max ( 0 , columnWidth - controlInsets . left - controlInsets . right ) } ;
12141240 const selectedInstanceId = props . selectedThread . modelSelection . instanceId ;
12151241 useAtomMount ( threadStreamHaptics ( props . selectedThreadDetailRef ) ) ;
12161242 const selectedProviderSkills = ( ( ) => {
@@ -1436,54 +1462,58 @@ function ThreadDetailBody(
14361462 ) }
14371463 >
14381464 < WorkspaceMutationIdProvider threadRef = { props . selectedThreadDetailRef } >
1439- < ThreadFeed
1440- toolCallVisibility = { toolCallVisibility }
1441- environmentId = { props . environmentId }
1442- threadId = { props . selectedThread . id }
1443- detailRef = { props . selectedThreadDetailRef }
1444- workspaceRoot = { props . threadCwd }
1445- feed = { props . selectedThreadFeed }
1446- pendingHandoff = { props . pendingHandoff }
1447- worktreeSetup = { props . worktreeSetup }
1448- setupWorkingStartedAt = { props . setupWorkingStartedAt }
1449- queuedMessages = { props . queuedMessages }
1450- dispatchingMessageId = { props . dispatchingMessageId }
1451- // A native subagent has no composer to edit a pending message in;
1452- // Cancel on the edit banner would discard it.
1453- onEditPendingMessage = {
1454- isProviderSubagent || pendingMessageEditBlocked ? null : handleEditPendingMessage
1455- }
1456- contentPresentation = { props . contentPresentation }
1457- threadTitle = { props . selectedThread . title }
1458- latestRun = { props . activityRun }
1459- activeWorkStartedAt = { props . activeWorkStartedAt }
1460- runlessWorkActive = { props . runlessWorkActive ?? false }
1461- listRef = { listRef }
1462- freeze = { freeze }
1463- anchorMessageId = { anchorMessageId }
1464- jumpToMessageId = { jumpMessageLoaded ? jumpMessageId : null }
1465- onJumpedToMessage = { ( ) => finishThreadMessageJump ( selectedThreadKey ) }
1466- contentInsetEndAdjustment = { combinedContentInsetEndAdjustment }
1467- keyboardOffset = { composerKeyboardOffset }
1468- sendingWithKeyboard = { sendingWithKeyboard }
1469- fitShortFeedToViewport = { questionInFlow && ! isKeyboardVisible }
1470- contentTopInset = { 0 }
1471- contentBottomInset = {
1472- questionInFlow
1473- ? 0
1474- : estimatedOverlayHeight +
1475- ( showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0 )
1476- }
1477- contentMaxWidth = { contentMaxWidth }
1478- historyControls = { props . historyControls }
1479- contentSideInsets = { nativeMetrics ?. safeArea }
1480- layoutVariant = { layoutVariant }
1481- usesAutomaticContentInsets = { props . usesAutomaticContentInsets }
1482- onHeaderMaterialVisibilityChange = { props . onHeaderMaterialVisibilityChange }
1483- onIsAtEndChange = { setIsAtEnd }
1484- skills = { selectedProviderSkills }
1485- onUseArtifactTemplate = { handleUseArtifactTemplate }
1486- />
1465+ < ColumnWidth width = { columnWidth } >
1466+ < ThreadFeed
1467+ toolCallVisibility = { toolCallVisibility }
1468+ environmentId = { props . environmentId }
1469+ threadId = { props . selectedThread . id }
1470+ detailRef = { props . selectedThreadDetailRef }
1471+ workspaceRoot = { props . threadCwd }
1472+ feed = { props . selectedThreadFeed }
1473+ pendingHandoff = { props . pendingHandoff }
1474+ worktreeSetup = { props . worktreeSetup }
1475+ setupWorkingStartedAt = { props . setupWorkingStartedAt }
1476+ queuedMessages = { props . queuedMessages }
1477+ dispatchingMessageId = { props . dispatchingMessageId }
1478+ // A native subagent has no composer to edit a pending message in;
1479+ // Cancel on the edit banner would discard it.
1480+ onEditPendingMessage = {
1481+ isProviderSubagent || pendingMessageEditBlocked
1482+ ? null
1483+ : handleEditPendingMessage
1484+ }
1485+ contentPresentation = { props . contentPresentation }
1486+ threadTitle = { props . selectedThread . title }
1487+ latestRun = { props . activityRun }
1488+ activeWorkStartedAt = { props . activeWorkStartedAt }
1489+ runlessWorkActive = { props . runlessWorkActive ?? false }
1490+ listRef = { listRef }
1491+ freeze = { freeze }
1492+ anchorMessageId = { anchorMessageId }
1493+ jumpToMessageId = { jumpMessageLoaded ? jumpMessageId : null }
1494+ onJumpedToMessage = { ( ) => finishThreadMessageJump ( selectedThreadKey ) }
1495+ contentInsetEndAdjustment = { combinedContentInsetEndAdjustment }
1496+ keyboardOffset = { composerKeyboardOffset }
1497+ sendingWithKeyboard = { sendingWithKeyboard }
1498+ fitShortFeedToViewport = { questionInFlow && ! isKeyboardVisible }
1499+ contentTopInset = { 0 }
1500+ contentBottomInset = {
1501+ questionInFlow
1502+ ? 0
1503+ : estimatedOverlayHeight +
1504+ ( showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0 )
1505+ }
1506+ contentMaxWidth = { contentMaxWidth }
1507+ historyControls = { props . historyControls }
1508+ contentSideInsets = { nativeMetrics ?. safeArea }
1509+ layoutVariant = { layoutVariant }
1510+ usesAutomaticContentInsets = { props . usesAutomaticContentInsets }
1511+ onHeaderMaterialVisibilityChange = { props . onHeaderMaterialVisibilityChange }
1512+ onIsAtEndChange = { setIsAtEnd }
1513+ skills = { selectedProviderSkills }
1514+ onUseArtifactTemplate = { handleUseArtifactTemplate }
1515+ />
1516+ </ ColumnWidth >
14871517 </ WorkspaceMutationIdProvider >
14881518 </ RenderErrorBoundary >
14891519 </ View >
@@ -1533,18 +1563,25 @@ function ThreadDetailBody(
15331563 pointerEvents = "box-none"
15341564 style = {
15351565 questionInFlow
1536- ? isSplitLayout
1537- ? composerWidthStyle
1538- : undefined
1539- : [
1540- {
1541- position : "absolute" ,
1542- bottom : controlInsets . bottom ,
1543- left : controlInsets . left ,
1544- right : controlInsets . right ,
1545- } ,
1546- composerWidthStyle ,
1547- ]
1566+ ? ( columnComposerWidthStyle ?? ( isSplitLayout ? composerWidthStyle : undefined ) )
1567+ : columnComposerWidthStyle
1568+ ? [
1569+ {
1570+ position : "absolute" ,
1571+ bottom : controlInsets . bottom ,
1572+ left : controlInsets . left ,
1573+ } ,
1574+ columnComposerWidthStyle ,
1575+ ]
1576+ : [
1577+ {
1578+ position : "absolute" ,
1579+ bottom : controlInsets . bottom ,
1580+ left : controlInsets . left ,
1581+ right : controlInsets . right ,
1582+ } ,
1583+ composerWidthStyle ,
1584+ ]
15481585 }
15491586 >
15501587 { /* No paddingTop here: the overlay's measured height becomes the
0 commit comments