diff --git a/packages/app/e2e/browser/content-width.spec.ts b/packages/app/e2e/browser/content-width.spec.ts index bed1b1849a..468a9eb771 100644 --- a/packages/app/e2e/browser/content-width.spec.ts +++ b/packages/app/e2e/browser/content-width.spec.ts @@ -10,16 +10,19 @@ import { expectColumnAtLeftGutter, expectColumnClearOfOutline, expectContentColumnWidth, + expectSharedHorizontalRail, } from "../support/helpers/content-width"; import { openFileExplorer, openFileFromExplorer } from "../support/helpers/file-explorer"; import { openAgentRoute, seedMockAgentWorkspace } from "../support/helpers/mock-agent"; const ULTRAWIDE_VIEWPORT = { width: 2560, height: 1080 }; +const DESKTOP_VIEWPORT = { width: 1440, height: 900 }; +const TRANSITION_VIEWPORT = { width: 1250, height: 900 }; const DEFAULT_COLUMN = { min: 800, max: 820 }; const WIDE_COLUMN = { min: 1180, max: 1200 }; const FULL_COLUMN = { min: 2000, max: ULTRAWIDE_VIEWPORT.width }; -test("resizes mounted chat content and leaves room for the outline at full width", async ({ +test("resizes mounted chat content and keeps timeline and composer on one rail beside the outline", async ({ page, }) => { test.setTimeout(120_000); @@ -37,26 +40,46 @@ test("resizes mounted chat content and leaves room for the outline at full width await openAgentRoute(page, agent); await expectChatOutlinePrompts(page, 2); const reply = page.getByTestId("assistant-message").first(); + const turnFooter = page.getByTestId("turn-footer").first(); const composer = page.getByTestId("message-input-root"); await expectContentColumnWidth(reply, DEFAULT_COLUMN); + await expectSharedHorizontalRail(turnFooter, composer); const originalReply = await reply.elementHandle(); + // In the transition band (pane ~930px >= 918px, < 820 + 120), Default clears the outline on one rail. + await page.setViewportSize(TRANSITION_VIEWPORT); + await expectColumnClearOfOutline(composer, chatOutlineRail(page)); + await expectSharedHorizontalRail(turnFooter, composer); + + await page.setViewportSize(ULTRAWIDE_VIEWPORT); await chooseContentWidth(page, "Wide"); await expectContentColumnWidth(reply, WIDE_COLUMN); await expectContentColumnWidth(composer, WIDE_COLUMN); + await expectSharedHorizontalRail(turnFooter, composer); + // At 1440px (pane ~1120px < 1200 + 120), Wide clears the outline and keeps timeline and composer aligned. + await page.setViewportSize(DESKTOP_VIEWPORT); + await expectColumnClearOfOutline(composer, chatOutlineRail(page)); + await expectSharedHorizontalRail(turnFooter, composer); + + await page.setViewportSize(ULTRAWIDE_VIEWPORT); await chooseContentWidth(page, "Full"); await expectContentColumnWidth(reply, FULL_COLUMN); await expectContentColumnWidth(composer, FULL_COLUMN); await expectColumnClearOfOutline(reply, chatOutlineRail(page)); + await expectColumnClearOfOutline(composer, chatOutlineRail(page)); + await expectSharedHorizontalRail(turnFooter, composer); await disableChatOutline(page); await expectNoChatOutline(page); await expectColumnAtLeftGutter(page, reply); + await expectColumnAtLeftGutter(page, composer); + await expectSharedHorizontalRail(turnFooter, composer); await chooseContentWidth(page, "Default"); await expectContentColumnWidth(reply, DEFAULT_COLUMN); await expectContentColumnWidth(composer, DEFAULT_COLUMN); + await expectSharedHorizontalRail(turnFooter, composer); expect(await originalReply?.evaluate((node) => node.isConnected)).toBe(true); } finally { await agent.cleanup(); diff --git a/packages/app/e2e/support/helpers/content-width.ts b/packages/app/e2e/support/helpers/content-width.ts index 501a4f65cf..8615cb82e7 100644 --- a/packages/app/e2e/support/helpers/content-width.ts +++ b/packages/app/e2e/support/helpers/content-width.ts @@ -51,3 +51,18 @@ export async function expectColumnAtLeftGutter(page: Page, column: Locator): Pro }) .toBeLessThanOrEqual(24); } + +/** Checks that two column surfaces sit on the same left and right vertical rails. */ +export async function expectSharedHorizontalRail(first: Locator, second: Locator): Promise { + await expect(first).toBeVisible({ timeout: 30_000 }); + await expect(second).toBeVisible({ timeout: 30_000 }); + await expect + .poll(async () => { + const [a, b] = await Promise.all([first.boundingBox(), second.boundingBox()]); + if (!a || !b) return Infinity; + const leftDelta = Math.abs(a.x - b.x); + const rightDelta = Math.abs(a.x + a.width - (b.x + b.width)); + return Math.max(leftDelta, rightDelta); + }) + .toBeLessThanOrEqual(1); +} diff --git a/packages/app/src/agent-stream/chat-outline/geometry.ts b/packages/app/src/agent-stream/chat-outline/geometry.ts new file mode 100644 index 0000000000..eb67c179af --- /dev/null +++ b/packages/app/src/agent-stream/chat-outline/geometry.ts @@ -0,0 +1,7 @@ +import { SPACING } from "@/styles/theme"; + +// Outline rail geometry shared between the rail overlay and the chat pane's column rail. +export const CHAT_OUTLINE_RAIL_WIDTH = 36; +export const CHAT_OUTLINE_RAIL_LEFT = SPACING[2]; +export const CHAT_OUTLINE_MIN_PANEL_WIDTH = 918; +export const CHAT_OUTLINE_GUTTER_INSET = CHAT_OUTLINE_RAIL_LEFT + CHAT_OUTLINE_RAIL_WIDTH; diff --git a/packages/app/src/agent-stream/chat-outline/rail.tsx b/packages/app/src/agent-stream/chat-outline/rail.tsx index d6db6c1251..0736ee21a2 100644 --- a/packages/app/src/agent-stream/chat-outline/rail.tsx +++ b/packages/app/src/agent-stream/chat-outline/rail.tsx @@ -11,7 +11,3 @@ export interface ChatOutlineRailProps { export function ChatOutlineRail(_props: ChatOutlineRailProps): null { return null; } - -export function useChatOutlineRailLayout(_enabled: boolean) { - return { onLayout: undefined, inset: 0 }; -} diff --git a/packages/app/src/agent-stream/chat-outline/rail.web.tsx b/packages/app/src/agent-stream/chat-outline/rail.web.tsx index 875d8699cd..7d7442fafb 100644 --- a/packages/app/src/agent-stream/chat-outline/rail.web.tsx +++ b/packages/app/src/agent-stream/chat-outline/rail.web.tsx @@ -2,19 +2,17 @@ import { memo, useCallback, useEffect, useMemo, useState, useSyncExternalStore } import { Pressable, Text, View, type PointerEvent as RNPointerEvent } from "react-native"; import { StyleSheet } from "react-native-unistyles"; import { useReducedMotion } from "react-native-reanimated"; -import { useContainerWidthBelow } from "@/hooks/use-container-width"; -import { SPACING } from "@/styles/theme"; import { inlineUnistylesStyle } from "@/styles/unistyles-inline-style"; +import { CHAT_OUTLINE_RAIL_LEFT, CHAT_OUTLINE_RAIL_WIDTH } from "./geometry"; import { createChatOutlineHoverIntent } from "./hover-intent"; import { promptTickMagnification } from "./model"; import type { ChatOutlineRailProps } from "./rail"; // Hover tracking lives on the rail and the slots, never on the Pressable inside them: // magnifying a slot must not move the box the pointer is resting on. See docs/hover.md. -const RAIL_WIDTH = 36; -const RAIL_LEFT = SPACING[2]; +const RAIL_WIDTH = CHAT_OUTLINE_RAIL_WIDTH; +const RAIL_LEFT = CHAT_OUTLINE_RAIL_LEFT; const SLOT_HEIGHT = 8; -const MIN_PANEL_WIDTH = 918; const RESTING_PILL_HEIGHT = 2; const MAGNIFIED_PILL_HEIGHT = 4; const RESTING_PILL_WIDTH = 10; @@ -24,11 +22,6 @@ const PREVIEW_WIDTH = 260; const PREVIEW_HEIGHT = 48; const PREVIEW_GAP = 4; -export function useChatOutlineRailLayout(enabled: boolean) { - const { onLayout, isBelow } = useContainerWidthBelow(MIN_PANEL_WIDTH); - return { onLayout, inset: enabled && !isBelow ? RAIL_LEFT + RAIL_WIDTH : 0 }; -} - export const ChatOutlineRail = memo(function ChatOutlineRail({ prompts, activePrompt, diff --git a/packages/app/src/agent-stream/strategy-web.tsx b/packages/app/src/agent-stream/strategy-web.tsx index ccc789f6b5..e4e5b23825 100644 --- a/packages/app/src/agent-stream/strategy-web.tsx +++ b/packages/app/src/agent-stream/strategy-web.tsx @@ -40,6 +40,7 @@ import { type HistoryStartSettleScheduler, } from "./history-start-settle-scheduler"; import { useChatFindSelectedMessageId } from "@/agent-stream/chat-find"; +import { CHAT_COLUMN_BASE_GUTTER, resolveChatColumnGutters } from "@/chat-rail/gutters"; import { useScrollToMessage } from "./use-scroll-to-message.web"; interface CreateWebStreamStrategyInput { @@ -1228,21 +1229,20 @@ function WebStreamViewport(props: StreamRenderInput & { isMobileBreakpoint: bool ]); const contentContainerStyle = useMemo((): CSSProperties => { - const gutter = isMobileBreakpoint ? 8 : 16; - const leftGutter = gutter + outlineInset; - // Balance the outline gutter using only the space the capped column has left over. - const rightGutter = - outlineInset > 0 && contentMaxWidth !== undefined - ? `clamp(${gutter}px, calc(100% - ${leftGutter + contentMaxWidth}px), ${leftGutter}px)` - : gutter; + const gutter = isMobileBreakpoint ? 8 : CHAT_COLUMN_BASE_GUTTER; + const { paddingLeft, paddingRight } = resolveChatColumnGutters({ + gutter, + outlineInset, + contentMaxWidth, + }); return { display: "flex", flexDirection: "column", minHeight: "100%", paddingTop: CONTENT_PADDING_TOP_PX, paddingBottom: 16, - paddingLeft: leftGutter, - paddingRight: rightGutter, + paddingLeft, + paddingRight, boxSizing: "border-box", }; }, [contentMaxWidth, isMobileBreakpoint, outlineInset]); diff --git a/packages/app/src/agent-stream/view.tsx b/packages/app/src/agent-stream/view.tsx index 149e863400..225c2aaa90 100644 --- a/packages/app/src/agent-stream/view.tsx +++ b/packages/app/src/agent-stream/view.tsx @@ -80,8 +80,9 @@ import { resolveStreamRenderStrategy } from "./strategy-resolver"; import { type StreamSegmentRenderers, type StreamViewportHandle } from "./strategy"; import { renderStreamRow, type RenderStreamItem } from "./stream-row"; import { type NearBottom, useIsNearBottom, useNearBottom } from "./near-bottom"; -import { ChatOutlineRail, useChatOutlineRailLayout } from "@/agent-stream/chat-outline/rail"; +import { ChatOutlineRail } from "@/agent-stream/chat-outline/rail"; import { useChatOutline } from "@/agent-stream/chat-outline/use-chat-outline"; +import { CHAT_COLUMN_RAIL_DATASET, useChatOutlineRail } from "@/chat-rail"; import { getHostRuntimeStore } from "@/runtime/host-runtime"; import { planTimelineTailFetch } from "@/timeline/timeline-sync-plan"; import { @@ -322,7 +323,7 @@ function ScrollToBottomButton({ ); if (isNearBottom && !isTimelineDetached) return null; return ( - + settings.autoExpandReasoning); const chatDisplay = useSettings((settings) => settings.chatDisplay); - const chatOutlineEnabled = useSettings((settings) => settings.chatOutlineEnabled); const contentMaxWidth = useSettings(resolveContentMaxWidth); const viewportRef = useRef(null); const pendingClientMessageIds = useMemo( @@ -404,10 +404,6 @@ const AgentStreamViewComponent = forwardRef state.sessions[resolvedServerId]?.serverInfo?.features?.agentForkContextCursor === true, ); - const supportsChatOutline = useSessionStore( - (state) => - state.sessions[resolvedServerId]?.serverInfo?.features?.agentTimelinePromptIndex === true, - ); const timelineEpoch = useSessionStore( (state) => state.sessions[resolvedServerId]?.agentTimelineCursor.get(agentId)?.epoch ?? null, ); @@ -617,22 +613,21 @@ const AgentStreamViewComponent = forwardRef ({ @@ -1176,10 +1171,7 @@ const AgentStreamViewComponent = forwardRef - + @@ -1208,12 +1200,12 @@ const AgentStreamViewComponent = forwardRef - {outlineLayout.inset > 0 && chatOutline.prompts.length >= 2 ? ( + {outlineInset > 0 && chatOutline.prompts.length >= 2 ? ( ; - onLayout?: (event: LayoutChangeEvent) => void; } export function AssistantSelectionCopySurface({ children, style, - onLayout, }: AssistantSelectionCopySurfaceProps) { - return ( - - {children} - - ); + return {children}; } diff --git a/packages/app/src/assistant-selection-copy/surface.web.tsx b/packages/app/src/assistant-selection-copy/surface.web.tsx index 57ddd94e61..280688b61e 100644 --- a/packages/app/src/assistant-selection-copy/surface.web.tsx +++ b/packages/app/src/assistant-selection-copy/surface.web.tsx @@ -1,11 +1,10 @@ import { useCallback, type ClipboardEvent, type CSSProperties, type ReactNode } from "react"; -import { View, type LayoutChangeEvent, type StyleProp, type ViewStyle } from "react-native"; +import { View, type StyleProp, type ViewStyle } from "react-native"; import { createAssistantSelectionClipboardContent } from "./content.web"; interface AssistantSelectionCopySurfaceProps { children: ReactNode; style?: StyleProp; - onLayout?: (event: LayoutChangeEvent) => void; } const DISPLAY_CONTENTS: CSSProperties = { display: "contents" }; @@ -13,7 +12,6 @@ const DISPLAY_CONTENTS: CSSProperties = { display: "contents" }; export function AssistantSelectionCopySurface({ children, style, - onLayout, }: AssistantSelectionCopySurfaceProps) { const handleCopy = useCallback((event: ClipboardEvent) => { const content = createAssistantSelectionClipboardContent(window.getSelection()); @@ -28,9 +26,7 @@ export function AssistantSelectionCopySurface({ return (
- - {children} - + {children}
); } diff --git a/packages/app/src/chat-rail/gutters.test.ts b/packages/app/src/chat-rail/gutters.test.ts new file mode 100644 index 0000000000..245fdc0374 --- /dev/null +++ b/packages/app/src/chat-rail/gutters.test.ts @@ -0,0 +1,77 @@ +import { describe, expect, it } from "vitest"; +import { CHAT_OUTLINE_GUTTER_INSET } from "@/agent-stream/chat-outline/geometry"; +import { CHAT_COLUMN_BASE_GUTTER, resolveChatColumnGutters } from "./gutters"; +import { + CHAT_COLUMN_RAIL_DATASET as NATIVE_CHAT_COLUMN_RAIL_DATASET, + ChatColumnRailSurface as NativeChatColumnRailSurface, + useChatOutlineRail as useNativeChatOutlineRail, +} from "./index.native"; +import { CHAT_COLUMN_RAIL_DATASET as WEB_CHAT_COLUMN_RAIL_DATASET } from "./index.web"; + +describe("resolveChatColumnGutters", () => { + it("uses symmetric base gutters when no outline inset is reserved", () => { + expect( + resolveChatColumnGutters({ + gutter: CHAT_COLUMN_BASE_GUTTER, + outlineInset: 0, + contentMaxWidth: 820, + }), + ).toEqual({ paddingLeft: 16, paddingRight: 16 }); + + expect( + resolveChatColumnGutters({ + gutter: CHAT_COLUMN_BASE_GUTTER, + outlineInset: 0, + contentMaxWidth: undefined, + }), + ).toEqual({ paddingLeft: 16, paddingRight: 16 }); + }); + + it("reserves only the left outline gutter when content width is Full", () => { + expect( + resolveChatColumnGutters({ + gutter: CHAT_COLUMN_BASE_GUTTER, + outlineInset: CHAT_OUTLINE_GUTTER_INSET, + contentMaxWidth: undefined, + }), + ).toEqual({ paddingLeft: 60, paddingRight: 16 }); + }); + + it("balances capped columns with a clamped right gutter from the remaining width", () => { + expect( + resolveChatColumnGutters({ + gutter: CHAT_COLUMN_BASE_GUTTER, + outlineInset: CHAT_OUTLINE_GUTTER_INSET, + contentMaxWidth: 820, + }), + ).toEqual({ + paddingLeft: 60, + paddingRight: "clamp(16px, calc(100% - 880px), 60px)", + }); + + expect( + resolveChatColumnGutters({ + gutter: CHAT_COLUMN_BASE_GUTTER, + outlineInset: CHAT_OUTLINE_GUTTER_INSET, + contentMaxWidth: 1200, + }), + ).toEqual({ + paddingLeft: 60, + paddingRight: "clamp(16px, calc(100% - 1260px), 60px)", + }); + }); +}); + +describe("native and web chat-rail boundaries", () => { + it("keeps native as a zero-overhead pass-through with no dataset or outline inset", () => { + const sentinel = "child"; + expect(NATIVE_CHAT_COLUMN_RAIL_DATASET).toBeUndefined(); + expect(useNativeChatOutlineRail()).toEqual({ enabled: false, inset: 0 }); + expect(NativeChatColumnRailSurface({ serverId: "srv-1", children: sentinel })).toBe(sentinel); + }); + + it("tags web rail lanes with a frozen dataset reference", () => { + expect(WEB_CHAT_COLUMN_RAIL_DATASET).toEqual({ chatRailLane: "true" }); + expect(Object.isFrozen(WEB_CHAT_COLUMN_RAIL_DATASET)).toBe(true); + }); +}); diff --git a/packages/app/src/chat-rail/gutters.ts b/packages/app/src/chat-rail/gutters.ts new file mode 100644 index 0000000000..9db1ad9b11 --- /dev/null +++ b/packages/app/src/chat-rail/gutters.ts @@ -0,0 +1,30 @@ +import { SPACING } from "@/styles/theme"; + +export const CHAT_COLUMN_BASE_GUTTER = SPACING[4]; + +export interface ChatColumnGutters { + paddingLeft: number; + paddingRight: number | string; +} + +/** + * Horizontal padding for a chat column on web. + * + * When the chat outline reserves `outlineInset` on the left, a capped column matches + * that inset on the right using only the horizontal slack left over after fitting + * `contentMaxWidth`. Default and Wide stay centered while the pane has room, shift + * smoothly away from the outline as the pane narrows, and fall back to the base gutter + * on the right when uncapped (`Full`) or tight. + */ +export function resolveChatColumnGutters(input: { + gutter: number; + outlineInset: number; + contentMaxWidth: number | undefined; +}): ChatColumnGutters { + const paddingLeft = input.gutter + input.outlineInset; + const paddingRight = + input.outlineInset > 0 && input.contentMaxWidth !== undefined + ? `clamp(${input.gutter}px, calc(100% - ${paddingLeft + input.contentMaxWidth}px), ${paddingLeft}px)` + : input.gutter; + return { paddingLeft, paddingRight }; +} diff --git a/packages/app/src/chat-rail/index.native.tsx b/packages/app/src/chat-rail/index.native.tsx new file mode 100644 index 0000000000..89f50dade6 --- /dev/null +++ b/packages/app/src/chat-rail/index.native.tsx @@ -0,0 +1,39 @@ +import type { ReactNode } from "react"; + +export interface ChatColumnRailSurfaceProps { + serverId: string; + children: ReactNode; +} + +export interface ChatOutlineRailState { + /** Whether the chat outline feature is enabled for this pane (independent of pane width). */ + readonly enabled: boolean; + /** Left gutter inset currently reserved for the outline rail (`0` or `44` on web). */ + readonly inset: number; +} + +const DISABLED_CHAT_OUTLINE_RAIL: ChatOutlineRailState = Object.freeze({ + enabled: false, + inset: 0, +}); + +/** + * Marker for chat surfaces (composer, track bar, callouts) that share the pane's + * horizontal column rail. On web, an active `ChatColumnRailSurface` applies the + * pane's outline-aware gutters via CSS custom properties without re-rendering + * children. Native never reserves an outline gutter, so this is undefined. + */ +export const CHAT_COLUMN_RAIL_DATASET: Record | undefined = undefined; + +/** + * Native pass-through: the chat outline is a wide-layout web affordance, so native + * renders no wrapper view, registers no subscriptions, and reserves no outline inset. + */ +export function ChatColumnRailSurface({ children }: ChatColumnRailSurfaceProps) { + return children; +} + +/** Chat outline state for this pane (always disabled with 0 inset on native). */ +export function useChatOutlineRail(): ChatOutlineRailState { + return DISABLED_CHAT_OUTLINE_RAIL; +} diff --git a/packages/app/src/chat-rail/index.tsx b/packages/app/src/chat-rail/index.tsx new file mode 100644 index 0000000000..3669dcf1fc --- /dev/null +++ b/packages/app/src/chat-rail/index.tsx @@ -0,0 +1,7 @@ +export { + CHAT_COLUMN_RAIL_DATASET, + ChatColumnRailSurface, + useChatOutlineRail, + type ChatColumnRailSurfaceProps, + type ChatOutlineRailState, +} from "./index.native"; diff --git a/packages/app/src/chat-rail/index.web.tsx b/packages/app/src/chat-rail/index.web.tsx new file mode 100644 index 0000000000..51a5483f22 --- /dev/null +++ b/packages/app/src/chat-rail/index.web.tsx @@ -0,0 +1,143 @@ +import { + createContext, + useContext, + useLayoutEffect, + useMemo, + useRef, + useState, + type CSSProperties, +} from "react"; +import { + CHAT_OUTLINE_GUTTER_INSET, + CHAT_OUTLINE_MIN_PANEL_WIDTH, +} from "@/agent-stream/chat-outline/geometry"; +import { resolveContentMaxWidth, useSettings } from "@/hooks/use-settings"; +import { useSessionStore } from "@/stores/session-store"; +import { CHAT_COLUMN_BASE_GUTTER, resolveChatColumnGutters } from "./gutters"; +import type { ChatColumnRailSurfaceProps, ChatOutlineRailState } from "./index"; + +export type { ChatColumnRailSurfaceProps, ChatOutlineRailState }; + +const STYLE_ID = "paseo-chat-column-rail"; +// React Native Web turns `dataSet={{ chatRailLane: "true" }}` into `data-chat-rail-lane="true"`. +// When the enclosing pane reserves an outline gutter, every tagged rail consumer receives +// the same horizontal gutters in the browser's layout pass without re-rendering React subtrees +// or growing Unistyles' CSS registry. +const RAIL_RULE = + '[data-chat-rail-active="true"] [data-chat-rail-lane="true"]{padding-left:var(--paseo-chat-rail-left)!important;padding-right:var(--paseo-chat-rail-right)!important;}'; + +const BASE_SURFACE_STYLE: CSSProperties = { + display: "flex", + flexDirection: "column", + flex: 1, + minWidth: 0, + minHeight: 0, +}; + +const DISABLED_CHAT_OUTLINE_RAIL: ChatOutlineRailState = Object.freeze({ + enabled: false, + inset: 0, +}); + +const ChatOutlineRailContext = createContext(DISABLED_CHAT_OUTLINE_RAIL); + +export const CHAT_COLUMN_RAIL_DATASET: Record | undefined = Object.freeze({ + chatRailLane: "true", +}); + +function ensureChatColumnRailStyle(): void { + if (typeof document === "undefined") return; + if (document.getElementById(STYLE_ID)) return; + const style = document.createElement("style"); + style.id = STYLE_ID; + style.textContent = RAIL_RULE; + document.head.appendChild(style); +} + +function cssLength(value: number | string): string { + return typeof value === "number" ? `${value}px` : value; +} + +/** + * Pane-level owner of the chat column rail on web. + * + * Measures the pane width once against `CHAT_OUTLINE_MIN_PANEL_WIDTH` (ignoring 0px + * measurements from hidden retained tabs) and publishes the resolved horizontal gutters + * via CSS custom properties to the composer, track bar, and callouts. Only the outline + * enabled flag and reserved inset (`0` or `44`) enter React context for `AgentStreamView`. + */ +export function ChatColumnRailSurface({ serverId, children }: ChatColumnRailSurfaceProps) { + const surfaceRef = useRef(null); + const [isBelow, setIsBelow] = useState(true); + const chatOutlineEnabled = useSettings((settings) => settings.chatOutlineEnabled); + const contentMaxWidth = useSettings(resolveContentMaxWidth); + const supportsChatOutline = useSessionStore( + (state) => state.sessions[serverId]?.serverInfo?.features?.agentTimelinePromptIndex === true, + ); + + useLayoutEffect(() => { + const node = surfaceRef.current; + if (!node) return; + const update = (width: number) => { + // Retained inactive tabs sit under `display: none` and report 0; ignore them. + if (width <= 0) return; + const next = width < CHAT_OUTLINE_MIN_PANEL_WIDTH; + setIsBelow((current) => (current === next ? current : next)); + }; + update(node.getBoundingClientRect().width); + if (typeof ResizeObserver === "undefined") return; + const observer = new ResizeObserver((entries) => { + const width = + entries[entries.length - 1]?.contentRect.width ?? node.getBoundingClientRect().width; + update(width); + }); + observer.observe(node); + return () => observer.disconnect(); + }, []); + + const enabled = supportsChatOutline && chatOutlineEnabled; + const inset = enabled && !isBelow ? CHAT_OUTLINE_GUTTER_INSET : 0; + + useLayoutEffect(() => { + if (inset > 0) { + ensureChatColumnRailStyle(); + } + }, [inset]); + + const outlineRail = useMemo( + () => (enabled ? { enabled, inset } : DISABLED_CHAT_OUTLINE_RAIL), + [enabled, inset], + ); + + const surfaceStyle = useMemo((): CSSProperties => { + if (inset === 0) { + return BASE_SURFACE_STYLE; + } + const gutters = resolveChatColumnGutters({ + gutter: CHAT_COLUMN_BASE_GUTTER, + outlineInset: inset, + contentMaxWidth, + }); + return { + ...BASE_SURFACE_STYLE, + "--paseo-chat-rail-left": cssLength(gutters.paddingLeft), + "--paseo-chat-rail-right": cssLength(gutters.paddingRight), + } as CSSProperties; + }, [contentMaxWidth, inset]); + + return ( + +
0 ? "true" : undefined} + > + {children} +
+
+ ); +} + +export function useChatOutlineRail(): ChatOutlineRailState { + return useContext(ChatOutlineRailContext); +} diff --git a/packages/app/src/components/archived-agent-callout.tsx b/packages/app/src/components/archived-agent-callout.tsx index 8930bf44c3..69694457e6 100644 --- a/packages/app/src/components/archived-agent-callout.tsx +++ b/packages/app/src/components/archived-agent-callout.tsx @@ -2,6 +2,7 @@ import { useCallback, useState } from "react"; import { View, Text } from "react-native"; import { useTranslation } from "react-i18next"; import { StyleSheet } from "react-native-unistyles"; +import { CHAT_COLUMN_RAIL_DATASET } from "@/chat-rail"; import { FOOTER_HEIGHT } from "@/constants/layout"; import { useHostRuntimeClient, useHostRuntimeIsConnected } from "@/runtime/host-runtime"; import { KeyboardTranslateView } from "@/keyboard/shift"; @@ -35,7 +36,7 @@ export function ArchivedAgentCallout({ serverId, agentId }: ArchivedAgentCallout return ( - + diff --git a/packages/app/src/composer/draft/workspace-tab.tsx b/packages/app/src/composer/draft/workspace-tab.tsx index fcd4efa915..7e8e430296 100644 --- a/packages/app/src/composer/draft/workspace-tab.tsx +++ b/packages/app/src/composer/draft/workspace-tab.tsx @@ -4,6 +4,7 @@ import type { JsonValue } from "@getpaseo/protocol/agent-types"; import { Keyboard, StyleSheet as RNStyleSheet, Text, View } from "react-native"; import { useTranslation } from "react-i18next"; import { StyleSheet } from "react-native-unistyles"; +import { CHAT_COLUMN_RAIL_DATASET } from "@/chat-rail"; import { useContainerWidthBelow } from "@/hooks/use-container-width"; import invariant from "tiny-invariant"; import { Composer } from "@/composer"; @@ -536,14 +537,17 @@ export function WorkspaceDraftComposer({ return ( {formErrorMessage ? ( - + {formErrorMessage} ) : null} {importPillPress && !isComposerFullscreen ? ( - + diff --git a/packages/app/src/composer/index.tsx b/packages/app/src/composer/index.tsx index 829dabcfd9..5e530245bf 100644 --- a/packages/app/src/composer/index.tsx +++ b/packages/app/src/composer/index.tsx @@ -30,6 +30,7 @@ import { } from "react"; import { useTranslation } from "react-i18next"; import { StyleSheet, withUnistyles } from "react-native-unistyles"; +import { CHAT_COLUMN_RAIL_DATASET } from "@/chat-rail"; import { useIsCompactFormFactor } from "@/constants/layout"; import { controlSizingForLayout, @@ -2575,7 +2576,10 @@ function ComposerContentImpl({ > {/* Input area */} - + {isFullscreen ? null : queueList} {!isFullscreen && sendErrorNode} diff --git a/packages/app/src/composer/tracks.tsx b/packages/app/src/composer/tracks.tsx index 44906333d8..7ae42e8122 100644 --- a/packages/app/src/composer/tracks.tsx +++ b/packages/app/src/composer/tracks.tsx @@ -21,6 +21,7 @@ import { useHorizontalScrollBoundary, } from "@/components/ui/horizontal-scroll-boundary"; import { STATUS_RING_HALO_INSET } from "@/components/status-ring/geometry"; +import { CHAT_COLUMN_RAIL_DATASET } from "@/chat-rail"; import { isWeb } from "@/constants/platform"; import { usePanelAwareHorizontalScrollGesture } from "@/mobile-panels/gestures"; import { getStatusDotColor } from "@/utils/status-dot-color"; @@ -45,7 +46,7 @@ export function ComposerTrackBar({ children }: { children: ReactNode }): ReactEl const scrollGesture = usePanelAwareHorizontalScrollGesture(); const scrollBoundary = useHorizontalScrollBoundary(); return ( - + + {dockContent} {composerSection} {dockOverlay} @@ -1337,10 +1342,12 @@ function wrapAgentCommandProvider({ } function ChatSurface({ + serverId, children, disabled, fullscreen, }: { + serverId: string; children: [ReactNode, ReactNode, ReactNode]; disabled: boolean; fullscreen: boolean; @@ -1349,9 +1356,11 @@ function ChatSurface({ // closes everything the chat opened. return ( - - {children} - + + + {children} + + ); } @@ -1365,7 +1374,7 @@ function TimelineSyncErrorCallout({ }) { const { t } = useTranslation(); return ( - + diff --git a/packages/app/src/subagents/parent/callout.tsx b/packages/app/src/subagents/parent/callout.tsx index d1bb31204a..e20058355b 100644 --- a/packages/app/src/subagents/parent/callout.tsx +++ b/packages/app/src/subagents/parent/callout.tsx @@ -3,6 +3,7 @@ import { Text, View } from "react-native"; import { useTranslation } from "react-i18next"; import { CornerUpLeft } from "lucide-react-native"; import { StyleSheet, withUnistyles } from "react-native-unistyles"; +import { CHAT_COLUMN_RAIL_DATASET } from "@/chat-rail"; import { StatusIcon } from "@/components/status-icon"; import { Button } from "@/components/ui/button"; import { FOOTER_HEIGHT } from "@/constants/layout"; @@ -37,7 +38,7 @@ export function ParentAgentCallout({ const parent = useParentAgent(serverId, parentAgentId); return ( - +