mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-21 15:55:58 +00:00
fix(app): keep composer and chat column on the outline rail
Previously only WebStreamViewport reserved the 44px chat outline gutter and clamped right gutter on wide web panes (>= 918px), leaving the composer, floating track bar, and callouts at symmetric 16px padding. On Full width, on Wide (1200px) below 1320px pane width, and on Default (820px) between 918px and 939px, the composer extended off the timeline's vertical rail. Move outline gutter ownership to a platform-split chat-rail module mounted at the chat pane surface. On web it measures the pane width once against the 918px threshold and publishes the shared left and clamped right gutters via CSS custom properties so composer, tracks, and callouts stay aligned with zero resize re-renders or dynamic Unistyles rules, while native stays a zero-hook pass-through. Removing direct outline measurement from AgentStreamView also stops ProviderSubagentPanel from reserving space for an outline it never renders.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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<void> {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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, useChatOutlineInset } 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 (
|
||||
<View style={containerStyle} pointerEvents="box-none">
|
||||
<View style={containerStyle} dataSet={CHAT_COLUMN_RAIL_DATASET} pointerEvents="box-none">
|
||||
<Animated.View entering={scrollIndicatorFadeIn} exiting={scrollIndicatorFadeOut}>
|
||||
<Pressable
|
||||
style={stylesheet.scrollToBottomButton}
|
||||
@@ -365,7 +366,6 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
|
||||
const { t } = useTranslation();
|
||||
const autoExpandReasoning = useSettings((settings) => settings.autoExpandReasoning);
|
||||
const chatDisplay = useSettings((settings) => settings.chatDisplay);
|
||||
const chatOutlineEnabled = useSettings((settings) => settings.chatOutlineEnabled);
|
||||
const contentMaxWidth = useSettings(resolveContentMaxWidth);
|
||||
const viewportRef = useRef<StreamViewportHandle | null>(null);
|
||||
const pendingClientMessageIds = useMemo(
|
||||
@@ -404,10 +404,6 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
|
||||
(state) =>
|
||||
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,7 +613,8 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
|
||||
mountedHistoryMessageIds.has(messageId) || liveHeadMessageIds.has(messageId),
|
||||
};
|
||||
}, [baseRenderModel.segments.liveHead, mountedHistoryMessageIds]);
|
||||
const outlineEnabled = supportsChatOutline && chatOutlineEnabled;
|
||||
const outlineInset = useChatOutlineInset();
|
||||
const outlineEnabled = outlineInset > 0;
|
||||
const chatOutline = useChatOutline({
|
||||
agentId,
|
||||
serverId: resolvedServerId,
|
||||
@@ -631,8 +628,6 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
|
||||
revealLoadedMessage: revealLoadedHistory,
|
||||
});
|
||||
|
||||
const outlineLayout = useChatOutlineRailLayout(outlineEnabled);
|
||||
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => ({
|
||||
@@ -1176,10 +1171,7 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
|
||||
visibleMessageIds={mountedMessageIds}
|
||||
>
|
||||
<ToolCallSheetProvider>
|
||||
<AssistantSelectionCopySurface
|
||||
style={stylesheet.container}
|
||||
onLayout={outlineLayout.onLayout}
|
||||
>
|
||||
<AssistantSelectionCopySurface style={stylesheet.container}>
|
||||
<MessageOuterSpacingProvider disableOuterSpacing>
|
||||
<ToolCallExpansionContext.Provider value={toolCallExpansion}>
|
||||
<UserMessageExpansionContext.Provider value={userMessageExpansion}>
|
||||
@@ -1208,12 +1200,12 @@ const AgentStreamViewComponent = forwardRef<AgentStreamViewHandle, AgentStreamVi
|
||||
baseListContentContainerStyle: stylesheet.listContentContainer,
|
||||
forwardListContentContainerStyle: stylesheet.forwardListContentContainer,
|
||||
contentMaxWidth,
|
||||
outlineInset: outlineLayout.inset,
|
||||
outlineInset,
|
||||
})}
|
||||
</UserMessageExpansionContext.Provider>
|
||||
</ToolCallExpansionContext.Provider>
|
||||
</MessageOuterSpacingProvider>
|
||||
{outlineLayout.inset > 0 && chatOutline.prompts.length >= 2 ? (
|
||||
{outlineInset > 0 && chatOutline.prompts.length >= 2 ? (
|
||||
<ChatOutlineRail
|
||||
prompts={chatOutline.prompts}
|
||||
activePrompt={chatOutline.activePrompt}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { View, type LayoutChangeEvent, type StyleProp, type ViewStyle } from "react-native";
|
||||
import { View, type StyleProp, type ViewStyle } from "react-native";
|
||||
|
||||
interface AssistantSelectionCopySurfaceProps {
|
||||
children: ReactNode;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
onLayout?: (event: LayoutChangeEvent) => void;
|
||||
}
|
||||
|
||||
export function AssistantSelectionCopySurface({
|
||||
children,
|
||||
style,
|
||||
onLayout,
|
||||
}: AssistantSelectionCopySurfaceProps) {
|
||||
return (
|
||||
<View style={style} onLayout={onLayout}>
|
||||
{children}
|
||||
</View>
|
||||
);
|
||||
return <View style={style}>{children}</View>;
|
||||
}
|
||||
|
||||
@@ -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<ViewStyle>;
|
||||
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<HTMLDivElement>) => {
|
||||
const content = createAssistantSelectionClipboardContent(window.getSelection());
|
||||
@@ -28,9 +26,7 @@ export function AssistantSelectionCopySurface({
|
||||
|
||||
return (
|
||||
<div onCopy={handleCopy} style={DISPLAY_CONTENTS}>
|
||||
<View style={style} onLayout={onLayout}>
|
||||
{children}
|
||||
</View>
|
||||
<View style={style}>{children}</View>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
useChatOutlineInset as useNativeChatOutlineInset,
|
||||
} 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(useNativeChatOutlineInset()).toBe(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);
|
||||
});
|
||||
});
|
||||
@@ -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 };
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
export interface ChatColumnRailSurfaceProps {
|
||||
serverId: string;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<string, string> | 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;
|
||||
}
|
||||
|
||||
/** Current left gutter inset reserved for the chat outline in this pane (always 0 on native). */
|
||||
export function useChatOutlineInset(): number {
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export {
|
||||
CHAT_COLUMN_RAIL_DATASET,
|
||||
ChatColumnRailSurface,
|
||||
useChatOutlineInset,
|
||||
type ChatColumnRailSurfaceProps,
|
||||
} from "./index.native";
|
||||
@@ -0,0 +1,133 @@
|
||||
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 } from "./index";
|
||||
|
||||
export type { ChatColumnRailSurfaceProps };
|
||||
|
||||
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 ChatOutlineInsetContext = createContext(0);
|
||||
|
||||
export const CHAT_COLUMN_RAIL_DATASET: Record<string, string> | 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 boolean
|
||||
* inset value (`0` or `44`) enters React context for `AgentStreamView`.
|
||||
*/
|
||||
export function ChatColumnRailSurface({ serverId, children }: ChatColumnRailSurfaceProps) {
|
||||
const surfaceRef = useRef<HTMLDivElement | null>(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 outlineInset =
|
||||
supportsChatOutline && chatOutlineEnabled && !isBelow ? CHAT_OUTLINE_GUTTER_INSET : 0;
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (outlineInset > 0) {
|
||||
ensureChatColumnRailStyle();
|
||||
}
|
||||
}, [outlineInset]);
|
||||
|
||||
const surfaceStyle = useMemo((): CSSProperties => {
|
||||
if (outlineInset === 0) {
|
||||
return BASE_SURFACE_STYLE;
|
||||
}
|
||||
const gutters = resolveChatColumnGutters({
|
||||
gutter: CHAT_COLUMN_BASE_GUTTER,
|
||||
outlineInset,
|
||||
contentMaxWidth,
|
||||
});
|
||||
return {
|
||||
...BASE_SURFACE_STYLE,
|
||||
"--paseo-chat-rail-left": cssLength(gutters.paddingLeft),
|
||||
"--paseo-chat-rail-right": cssLength(gutters.paddingRight),
|
||||
} as CSSProperties;
|
||||
}, [contentMaxWidth, outlineInset]);
|
||||
|
||||
return (
|
||||
<ChatOutlineInsetContext.Provider value={outlineInset}>
|
||||
<div
|
||||
ref={surfaceRef}
|
||||
style={surfaceStyle}
|
||||
data-chat-rail-active={outlineInset > 0 ? "true" : undefined}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</ChatOutlineInsetContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function useChatOutlineInset(): number {
|
||||
return useContext(ChatOutlineInsetContext);
|
||||
}
|
||||
@@ -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 (
|
||||
<KeyboardTranslateView style={styles.container}>
|
||||
<View style={styles.inputAreaContainer}>
|
||||
<View style={styles.inputAreaContainer} dataSet={CHAT_COLUMN_RAIL_DATASET}>
|
||||
<View style={styles.inputAreaContent}>
|
||||
<View style={styles.calloutStack}>
|
||||
<View style={styles.callout}>
|
||||
|
||||
@@ -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,14 @@ export function WorkspaceDraftComposer({
|
||||
return (
|
||||
<View style={animatedStaticStyles.inputAreaWrapper} onLayout={onInputAreaLayout}>
|
||||
{formErrorMessage ? (
|
||||
<View style={styles.formErrorRow}>
|
||||
<View style={styles.formErrorRow} dataSet={CHAT_COLUMN_RAIL_DATASET}>
|
||||
<View style={styles.formError}>
|
||||
<Text style={styles.errorText}>{formErrorMessage}</Text>
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
{importPillPress && !isComposerFullscreen ? (
|
||||
<View style={styles.importPillRow}>
|
||||
<View style={styles.importPillRow} dataSet={CHAT_COLUMN_RAIL_DATASET}>
|
||||
<View style={styles.importPillContent}>
|
||||
<ComposerImportPill onPress={importPillPress} />
|
||||
</View>
|
||||
|
||||
@@ -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({
|
||||
>
|
||||
<AttachmentLightbox source={lightboxSource} onClose={handleLightboxClose} />
|
||||
{/* Input area */}
|
||||
<View style={inputAreaContainerStyle}>
|
||||
<View
|
||||
style={inputAreaContainerStyle}
|
||||
dataSet={isFullscreen ? undefined : CHAT_COLUMN_RAIL_DATASET}
|
||||
>
|
||||
<View style={inputAreaContentStyle}>
|
||||
{isFullscreen ? null : queueList}
|
||||
{!isFullscreen && sendErrorNode}
|
||||
|
||||
@@ -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 (
|
||||
<View style={styles.bar} pointerEvents="box-none">
|
||||
<View style={styles.bar} dataSet={CHAT_COLUMN_RAIL_DATASET} pointerEvents="box-none">
|
||||
<View style={styles.trackViewport} pointerEvents="box-none">
|
||||
<GestureDetector gesture={scrollGesture}>
|
||||
<Animated.ScrollView
|
||||
|
||||
@@ -22,6 +22,7 @@ import { shallow, useShallow } from "zustand/shallow";
|
||||
import { useStoreWithEqualityFn } from "zustand/traditional";
|
||||
import { useAgentStreamTail } from "@/agent-stream/use-agent-stream-tail";
|
||||
import { AgentStreamView, type AgentStreamViewHandle } from "@/agent-stream/view";
|
||||
import { CHAT_COLUMN_RAIL_DATASET, ChatColumnRailSurface } from "@/chat-rail";
|
||||
import { ArchivedAgentCallout } from "@/components/archived-agent-callout";
|
||||
import { ComposerDock } from "@/composer/dock";
|
||||
import { FileDropZone } from "@/components/file-drop/file-drop-zone";
|
||||
@@ -1267,7 +1268,11 @@ const ChatAgentReadyContent = memo(function ChatAgentReadyContent({
|
||||
);
|
||||
|
||||
const dock = (
|
||||
<ChatSurface disabled={isArchivingCurrentAgent} fullscreen={isComposerFullscreen}>
|
||||
<ChatSurface
|
||||
serverId={serverId}
|
||||
disabled={isArchivingCurrentAgent}
|
||||
fullscreen={isComposerFullscreen}
|
||||
>
|
||||
{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 (
|
||||
<OverlayDismissalScope>
|
||||
<FileDropZone style={styles.container} disabled={disabled}>
|
||||
<ComposerDock fullscreen={fullscreen}>{children}</ComposerDock>
|
||||
</FileDropZone>
|
||||
<ChatColumnRailSurface serverId={serverId}>
|
||||
<FileDropZone style={styles.container} disabled={disabled}>
|
||||
<ComposerDock fullscreen={fullscreen}>{children}</ComposerDock>
|
||||
</FileDropZone>
|
||||
</ChatColumnRailSurface>
|
||||
</OverlayDismissalScope>
|
||||
);
|
||||
}
|
||||
@@ -1365,7 +1374,7 @@ function TimelineSyncErrorCallout({
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<View style={styles.timelineSyncCalloutRail}>
|
||||
<View style={styles.timelineSyncCalloutRail} dataSet={CHAT_COLUMN_RAIL_DATASET}>
|
||||
<View style={styles.timelineSyncCalloutContent}>
|
||||
<View style={styles.timelineSyncCallout} testID="agent-timeline-sync-error">
|
||||
<Text style={styles.timelineSyncCalloutText}>
|
||||
|
||||
@@ -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 (
|
||||
<View style={styles.rail}>
|
||||
<View style={styles.rail} dataSet={CHAT_COLUMN_RAIL_DATASET}>
|
||||
<View style={styles.callout} testID="parent-agent-callout">
|
||||
<StatusIcon statusBucket={parent.statusBucket} size={ICON_SIZE} backdrop="surface1">
|
||||
<ThemedParentIcon icon={parent.icon} size={ICON_SIZE} uniProps={foregroundColorMapping} />
|
||||
|
||||
Reference in New Issue
Block a user