Skip to content
TypeScript

feat(web): add chat width setting for wide screens (#11594)

Otavio Salvador04c15f34b756
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index cacb432f870..b08bf12176a 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -10060,7 +10060,7 @@ export default function ChatView(props: ChatViewProps) {
>
<div
data-chat-composer-stack="true"
- className="group/composer-stack pointer-events-auto relative z-10 mx-auto w-full max-w-3xl"
+ className="group/composer-stack pointer-events-auto relative z-10 mx-auto w-full max-w-(--chat-max-width)"
>
{isDraftHeroState ? (
<div className="absolute inset-x-0 bottom-full z-0">
diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx
index fafe24e4397..d168c6db4e5 100644
--- a/apps/web/src/components/chat/ChatComposer.tsx
+++ b/apps/web/src/components/chat/ChatComposer.tsx
@@ -6165,7 +6165,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
if (isInsideRestingComposerControlScope(event.target)) return;
composerMentionDragHandlers.onDrop(event);
}}
- className="mx-auto w-full min-w-0 max-w-3xl"
+ className="mx-auto w-full min-w-0 max-w-(--chat-max-width)"
data-chat-composer-form="true"
>
{composerControlsInStrip && restingControlsHost
diff --git a/apps/web/src/components/chat/ComposerSurface.tsx b/apps/web/src/components/chat/ComposerSurface.tsx
index bcb994085eb..83e94895edd 100644
--- a/apps/web/src/components/chat/ComposerSurface.tsx
+++ b/apps/web/src/components/chat/ComposerSurface.tsx
@@ -13,7 +13,7 @@ function Shell({
data-slot="composer-shell"
data-with-context={contextStrip || undefined}
className={cn(
- "@container/composer-surface group/composer-surface relative isolate mx-auto w-full max-w-3xl",
+ "@container/composer-surface group/composer-surface relative isolate mx-auto w-full max-w-(--chat-max-width)",
"[--chat-composer-drawer-inset:1.375rem] [--chat-composer-glass-surface:var(--card)] [--chat-composer-outline:rgb(0_0_0/8%)]",
"dark:[--chat-composer-glass-surface:var(--surface-raised)] dark:[--chat-composer-highlight:rgb(255_255_255/3%)] dark:[--chat-composer-outline:color-mix(in_srgb,var(--color-white)_5%,transparent)]",
"[html[data-theme-id]_&]:[--chat-composer-glass-surface:var(--app-theme-surface-raised)] [html[data-theme-id]_&]:[--chat-composer-outline:var(--app-theme-toolbar-border)]",
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts
index 57ed45a89d1..21508a9663a 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts
@@ -42,7 +42,6 @@ import { formatWorkspaceRelativePath } from "../../filePathDisplay";
const TIMELINE_MINIMAP_ITEM_SPACING = 8;
export const TIMELINE_MINIMAP_MIN_ITEMS = 2;
const TIMELINE_MINIMAP_MAX_HEIGHT_CSS = "calc(100vh - 18rem)";
-const TIMELINE_CONTENT_MAX_WIDTH = 768;
const TIMELINE_MINIMAP_PERSISTENT_GUTTER = 48;
function singleToolCallLabel(entry: WorkLogEntry): string {
@@ -233,14 +232,25 @@ export function resolveTimelineMinimapCurrentIndex(input: {
return precedingIndex;
}
-export function resolveTimelineMinimapHasPersistentGutter(viewportWidth: number): boolean {
- if (!Number.isFinite(viewportWidth) || viewportWidth <= 0) {
- return false;
+/**
+ * Side gutter between the viewport edge and the centered content column.
+ * `contentWidth` is the rendered column width, which follows the Chat width
+ * setting, so callers measure it rather than assume a fixed maximum.
+ */
+function resolveTimelineSideGutter(viewportWidth: number, contentWidth: number): number {
+ if (!Number.isFinite(viewportWidth) || viewportWidth <= 0 || !Number.isFinite(contentWidth)) {
+ return 0;
}
+ return Math.max(0, (viewportWidth - Math.min(viewportWidth, contentWidth)) / 2);
+}
- const contentWidth = Math.min(viewportWidth, TIMELINE_CONTENT_MAX_WIDTH);
- const sideGutter = Math.max(0, (viewportWidth - contentWidth) / 2);
- return sideGutter >= TIMELINE_MINIMAP_PERSISTENT_GUTTER;
+export function resolveTimelineMinimapHasPersistentGutter(
+ viewportWidth: number,
+ contentWidth: number,
+): boolean {
+ return (
+ resolveTimelineSideGutter(viewportWidth, contentWidth) >= TIMELINE_MINIMAP_PERSISTENT_GUTTER
+ );
}
const TIMELINE_MINIMAP_HIT_STRIP_LEFT = 12;
@@ -249,18 +259,16 @@ const TIMELINE_MINIMAP_EXPANDED_HIT_STRIP_WIDTH = "22rem";
/**
* The minimap overlays the viewport's left edge while the content column is
- * centered, so the side gutter between them shrinks under browser zoom or a
- * narrow pane. A fixed-width hover strip would then sit on top of the message
+ * centered, so the side gutter between them shrinks under browser zoom, a
+ * narrow pane, or a wider Chat width setting. A fixed-width hover strip would then sit on top of the message
* text and swallow its pointer events. Cap the strip's width so it never
* extends past the gutter into the content column; 0 disables the strip.
*/
-export function resolveTimelineMinimapHitStripWidth(viewportWidth: number): number {
- if (!Number.isFinite(viewportWidth) || viewportWidth <= 0) {
- return 0;
- }
-
- const contentWidth = Math.min(viewportWidth, TIMELINE_CONTENT_MAX_WIDTH);
- const sideGutter = Math.max(0, (viewportWidth - contentWidth) / 2);
+export function resolveTimelineMinimapHitStripWidth(
+ viewportWidth: number,
+ contentWidth: number,
+): number {
+ const sideGutter = resolveTimelineSideGutter(viewportWidth, contentWidth);
return Math.max(
0,
Math.min(
@@ -270,6 +278,19 @@ export function resolveTimelineMinimapHitStripWidth(viewportWidth: number): numb
);
}
+// The prev/next buttons are centered 4px into the strip and 20px wide, so
+// their hitbox reaches 14px past the strip's left edge.
+const TIMELINE_MINIMAP_NAVIGATION_REACH = 14;
+
+/**
+ * The prev/next buttons hang outside the strip's height, so the strip's own
+ * width cap does not cover them. Keep them inert to the pointer unless the
+ * gutter can hold them; keyboard focus still reaches them.
+ */
+export function resolveTimelineMinimapNavigationInteractive(collapsedWidth: number): boolean {
+ return collapsedWidth >= TIMELINE_MINIMAP_NAVIGATION_REACH;
+}
+
/**
* Once the preview is open, keep the full preview and the space leading to it
* interactive. The collapsed strip remains gutter-capped so it cannot block
diff --git a/apps/web/src/components/chat/MessagesTimeline.test.tsx b/apps/web/src/components/chat/MessagesTimeline.test.tsx
index 016e621be1d..a87dc2c2a44 100644
--- a/apps/web/src/components/chat/MessagesTimeline.test.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.test.tsx
@@ -571,6 +571,7 @@ describe("MessagesTimeline", () => {
resolveTimelineMinimapHitStripWidth,
resolveTimelineMinimapIndexFromPointer,
resolveTimelineMinimapInteractiveWidth,
+ resolveTimelineMinimapNavigationInteractive,
resolveTimelineMinimapTopPercent,
} = await import("./MessagesTimeline.logic");
@@ -655,22 +656,39 @@ describe("MessagesTimeline", () => {
itemBounds: [{ top: 80, height: 20 }],
}),
).toBeNull();
- expect(resolveTimelineMinimapHasPersistentGutter(832)).toBe(false);
- expect(resolveTimelineMinimapHasPersistentGutter(863)).toBe(false);
- expect(resolveTimelineMinimapHasPersistentGutter(864)).toBe(true);
+ // Comfortable width: the column is capped at 768px.
+ expect(resolveTimelineMinimapHasPersistentGutter(832, 768)).toBe(false);
+ expect(resolveTimelineMinimapHasPersistentGutter(863, 768)).toBe(false);
+ expect(resolveTimelineMinimapHasPersistentGutter(864, 768)).toBe(true);
+ // Wider Chat width settings consume the gutter the minimap relies on.
+ expect(resolveTimelineMinimapHasPersistentGutter(1400, 1152)).toBe(true);
+ expect(resolveTimelineMinimapHasPersistentGutter(1200, 1152)).toBe(false);
+ expect(resolveTimelineMinimapHasPersistentGutter(2560, 2560)).toBe(false);
// No usable gutter (zoomed in / narrow pane): the strip must go inert
// instead of overlaying the centered content column.
- expect(resolveTimelineMinimapHitStripWidth(768)).toBe(0);
- expect(resolveTimelineMinimapHitStripWidth(792)).toBe(0);
+ expect(resolveTimelineMinimapHitStripWidth(768, 768)).toBe(0);
+ expect(resolveTimelineMinimapHitStripWidth(792, 768)).toBe(0);
// Partial gutter: strip shrinks to what fits between the viewport edge
// and the content column.
- expect(resolveTimelineMinimapHitStripWidth(820)).toBe(14);
+ expect(resolveTimelineMinimapHitStripWidth(820, 768)).toBe(14);
// Full gutter: unchanged 40px-wide strip.
- expect(resolveTimelineMinimapHitStripWidth(872)).toBe(40);
- expect(resolveTimelineMinimapHitStripWidth(1400)).toBe(40);
- expect(resolveTimelineMinimapHitStripWidth(0)).toBe(0);
- expect(resolveTimelineMinimapHitStripWidth(Number.NaN)).toBe(0);
+ expect(resolveTimelineMinimapHitStripWidth(872, 768)).toBe(40);
+ expect(resolveTimelineMinimapHitStripWidth(1400, 768)).toBe(40);
+ // Full Chat width: the column spans the viewport, so the strip is inert
+ // however wide the window gets.
+ expect(resolveTimelineMinimapHitStripWidth(2560, 2560)).toBe(0);
+ // Wide Chat width on a window just wider than the column: partial strip.
+ expect(resolveTimelineMinimapHitStripWidth(1204, 1152)).toBe(14);
+ expect(resolveTimelineMinimapHitStripWidth(0, 0)).toBe(0);
+ expect(resolveTimelineMinimapHitStripWidth(Number.NaN, 768)).toBe(0);
+
+ // Prev/next buttons reach 14px past the strip's left edge; a narrower
+ // strip means they would sit on the content column.
+ expect(resolveTimelineMinimapNavigationInteractive(40)).toBe(true);
+ expect(resolveTimelineMinimapNavigationInteractive(14)).toBe(true);
+ expect(resolveTimelineMinimapNavigationInteractive(8)).toBe(false);
+ expect(resolveTimelineMinimapNavigationInteractive(0)).toBe(false);
// The collapsed target stays narrow, but an open preview keeps its full
// 20rem width plus the 2rem offset from the minimap rail interactive.
diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx
index 755657e794a..f812f67f2bd 100644
--- a/apps/web/src/components/chat/MessagesTimeline.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.tsx
@@ -189,6 +189,7 @@ import {
resolveTimelineMinimapHitStripWidth,
resolveTimelineMinimapIndexFromPointer,
resolveTimelineMinimapInteractiveWidth,
+ resolveTimelineMinimapNavigationInteractive,
resolveTimelineMinimapTopPercent,
resolveWorkGroupScrollIndex,
shouldFollowWorkGroupAppend,
@@ -239,6 +240,7 @@ import { chatMarkdownClipboardPayload } from "../../markdown-clipboard";
import { ContextChip, ContextChipLabel, type ContextChipKind } from "../ContextChip";
import { createContextPresentationRegistry } from "../contextPresentationRegistry";
import { useOpenPrLink } from "~/lib/openPullRequestLink";
+import { useClientSettings } from "~/hooks/useSettings";
import type { ChatMarkdownContextReference } from "../ChatMarkdown";
import { useMediaQuery } from "~/hooks/useMediaQuery";
import { cn } from "~/lib/utils";
@@ -346,7 +348,7 @@ function TimelineLoadEarlierHeader({
}) {
return (
<div className={fade ? "pt-(--workspace-titlebar-scroll-fade-height)" : "pt-3 sm:pt-4"}>
- <div className="mx-auto w-full max-w-3xl pb-2">
+ <div className="mx-auto w-full max-w-(--chat-max-width) pb-2">
<button
type="button"
onClick={onLoadEarlier}
@@ -936,6 +938,8 @@ export const MessagesTimeline = memo(function MessagesTimeline({
const [timelineViewportElement, setTimelineViewportElement] = useState<HTMLDivElement | null>(
null,
);
+ // Re-measure the minimap gutter when the chat column changes width without a viewport resize.
+ const chatWidth = useClientSettings((settings) => settings.chatWidth);
const {
target: readyCitationRequest,
positioning: citationPositioning,
@@ -1107,11 +1111,19 @@ export const MessagesTimeline = memo(function MessagesTimeline({
const measure = () => {
const viewportWidth = timelineViewportElement.getBoundingClientRect().width;
- const nextHasPersistentGutter = resolveTimelineMinimapHasPersistentGutter(viewportWidth);
+ // Without a mounted row, treat the column as full width so the strip stays inert.
+ const contentWidth =
+ timelineViewportElement
+ .querySelector<HTMLElement>("[data-timeline-root]")
+ ?.getBoundingClientRect().width ?? viewportWidth;
+ const nextHasPersistentGutter = resolveTimelineMinimapHasPersistentGutter(
+ viewportWidth,
+ contentWidth,
+ );
setMinimapHasPersistentGutter((current) =>
current === nextHasPersistentGutter ? current : nextHasPersistentGutter,
);
- setMinimapHitStripWidth(resolveTimelineMinimapHitStripWidth(viewportWidth));
+ setMinimapHitStripWidth(resolveTimelineMinimapHitStripWidth(viewportWidth, contentWidth));
reportContentOverflow();
};
@@ -1124,7 +1136,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
cancelAnimationFrame(frame);
observer.disconnect();
};
- }, [timelineViewportElement, rows.length, reportContentOverflow]);
+ }, [timelineViewportElement, rows.length, reportContentOverflow, chatWidth]);
const sharedState = useMemo<TimelineRowSharedState>(
() => ({
@@ -1239,7 +1251,10 @@ export const MessagesTimeline = memo(function MessagesTimeline({
// from TimelineRowCtx, which propagates through LegendList's memo.
const renderItem = useCallback(
({ item }: { item: MessagesTimelineRow }) => (
- <div className="mx-auto w-full min-w-0 max-w-3xl overflow-x-clip" data-timeline-root="true">
+ <div
+ className="mx-auto w-full min-w-0 max-w-(--chat-max-width) overflow-x-clip"
+ data-timeline-root="true"
+ >
<TimelineRowContent row={item} />
</div>
),
@@ -1405,6 +1420,7 @@ function TimelineMinimap({
),
[items, resolvedActiveIndex],
);
+ const navigationInteractive = resolveTimelineMinimapNavigationInteractive(hitStripWidth);
const activeTopPercent =
resolvedActiveIndex === null
? 0
@@ -1485,6 +1501,7 @@ function TimelineMinimap({
<TimelineMinimapNavigationButton
direction="previous"
disabled={previousItem === null}
+ interactive={navigationInteractive}
onClick={() => {
if (previousItem) onSelect(previousItem);
}}
@@ -1600,6 +1617,7 @@ function TimelineMinimap({
<TimelineMinimapNavigationButton
direction="next"
disabled={nextItem === null}
+ interactive={navigationInteractive}
onClick={() => {
if (nextItem) onSelect(nextItem);
}}
@@ -1613,10 +1631,12 @@ function TimelineMinimap({
function TimelineMinimapNavigationButton({
direction,
disabled,
+ interactive,
onClick,
}: {
direction: "previous" | "next";
disabled: boolean;
+ interactive: boolean;
onClick: () => void;
}) {
const previous = direction === "previous";
@@ -1629,7 +1649,8 @@ function TimelineMinimapNavigationButton({
render={
<span
className={cn(
- "absolute left-1 z-10 inline-flex -translate-x-1/2 opacity-0 pointer-events-auto transition-opacity duration-150 hover:opacity-100 focus-within:opacity-100",
+ "absolute left-1 z-10 inline-flex -translate-x-1/2 opacity-0 transition-opacity duration-150 hover:opacity-100 focus-within:opacity-100",
+ interactive ? "pointer-events-auto" : "pointer-events-none",
previous ? "bottom-[calc(100%+2px)]" : "top-[calc(100%+2px)]",
)}
/>
@@ -1862,7 +1883,7 @@ function ContextCompactionTimelineRow({
<div
role="separator"
aria-label={row.label}
- className="mx-auto flex w-full max-w-3xl items-center gap-3 py-1 text-muted-foreground text-xs"
+ className="mx-auto flex w-full max-w-(--chat-max-width) items-center gap-3 py-1 text-muted-foreground text-xs"
>
<span className="h-px flex-1 bg-border/70" />
<span className="flex shrink-0 items-center gap-1.5">
diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx
index f0a9113981b..fc5082fcf1a 100644
--- a/apps/web/src/components/settings/SettingsPanels.tsx
+++ b/apps/web/src/components/settings/SettingsPanels.tsx
@@ -22,6 +22,7 @@ import {
import {
DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE,
DEFAULT_UNIFIED_SETTINGS,
+ type ChatWidth,
type DiffLayout,
type EnvironmentIdentificationMode,
MAX_APPEARANCE_CONTRAST,
@@ -197,6 +198,12 @@ const TIMESTAMP_FORMAT_LABELS = {
"24-hour": "24-hour",
} as const;
+const CHAT_WIDTH_LABELS: Record<ChatWidth, string> = {
+ comfortable: "Comfortable",
+ wide: "Wide",
+ full: "Full",
+};
+
const DIFF_LAYOUT_LABELS: Record<DiffLayout, string> = {
stacked: "Stacked",
split: "Split",
@@ -532,6 +539,7 @@ export function useSettingsRestore(onRestored?: () => void) {
...(settings.diffColorScheme !== DEFAULT_UNIFIED_SETTINGS.diffColorScheme
? ["Diff colors"]
: []),
+ ...(settings.chatWidth !== DEFAULT_UNIFIED_SETTINGS.chatWidth ? ["Chat width"] : []),
...(settings.panelAnimationDurationMs !== DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs
? ["Panel animations"]
: []),
@@ -641,6 +649,7 @@ export function useSettingsRestore(onRestored?: () => void) {
settings.browserAutoShowFloatingPreview,
settings.appearanceContrast,
settings.diffColorScheme,
+ settings.chatWidth,
settings.enableAgentBrowserAccess,
settings.confirmQuit,
settings.confirmThreadArchive,
@@ -752,6 +761,7 @@ export function useSettingsRestore(onRestored?: () => void) {
updateSettings({
appearanceContrast: DEFAULT_UNIFIED_SETTINGS.appearanceContrast,
diffColorScheme: DEFAULT_UNIFIED_SETTINGS.diffColorScheme,
+ chatWidth: DEFAULT_UNIFIED_SETTINGS.chatWidth,
timestampFormat: DEFAULT_UNIFIED_SETTINGS.timestampFormat,
notificationMode: DEFAULT_UNIFIED_SETTINGS.notificationMode,
inAppNotificationsEnabled: DEFAULT_UNIFIED_SETTINGS.inAppNotificationsEnabled,
@@ -1383,6 +1393,38 @@ export function AppearanceSettingsPanel() {
</div>
}
/>
+ <SettingsRow
+ {...searchableSetting("chat-width")}
+ description="Set how wide messages and the composer can grow on large screens."
+ resetAction={
+ settings.chatWidth !== DEFAULT_UNIFIED_SETTINGS.chatWidth ? (
+ <SettingResetButton
+ label="chat width"
+ onClick={() => updateSettings({ chatWidth: DEFAULT_UNIFIED_SETTINGS.chatWidth })}
+ />
+ ) : null
+ }
+ control={
+ <div className="w-full sm:w-40">
+ <Select
+ value={settings.chatWidth}
+ onValueChange={(value) => {
+ if (value === "comfortable" || value === "wide" || value === "full")
+ updateSettings({ chatWidth: value });
+ }}
+ >
+ <SelectTrigger size="sm" className="w-full min-w-0" aria-label="Chat width">
+ <SelectValue>{CHAT_WIDTH_LABELS[settings.chatWidth]}</SelectValue>
+ </SelectTrigger>
+ <SelectPopup align="end" alignItemWithTrigger={false}>
+ <SelectItem value="comfortable">Comfortable (default)</SelectItem>
+ <SelectItem value="wide">Wide</SelectItem>
+ <SelectItem value="full">Full</SelectItem>
+ </SelectPopup>
+ </Select>
+ </div>
+ }
+ />
</SettingsSection>
<SettingsSection id="motion" title="Motion">
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts
index 539e780baaa..c9cb76401bd 100644
--- a/apps/web/src/components/settings/settingsSearch.ts
+++ b/apps/web/src/components/settings/settingsSearch.ts
@@ -211,6 +211,12 @@ export const SETTINGS_SEARCH_ITEMS = [
to: "/settings/appearance",
searchTerms: ["red green blue orange additions deletions changes counts palette colorblind"],
},
+ {
+ id: "chat-width",
+ title: "Chat width",
+ to: "/settings/appearance",
+ searchTerms: ["wide full width column layout messages composer monitor"],
+ },
{
id: "panel-animations",
title: "Panel animations",
diff --git a/apps/web/src/index.css b/apps/web/src/index.css
index 1039f23b19b..d1ca0f4cf60 100644
--- a/apps/web/src/index.css
+++ b/apps/web/src/index.css
@@ -1994,6 +1994,19 @@ code {
--diff-deletion-foreground: light-dark(var(--color-red-600), var(--color-red-400));
}
+/* Chat timeline and composer column width, set from the Chat width setting. */
+:root {
+ --chat-max-width: 48rem;
+}
+
+:root[data-chat-width="wide"] {
+ --chat-max-width: 72rem;
+}
+
+:root[data-chat-width="full"] {
+ --chat-max-width: 100%;
+}
+
:root[data-diff-color-scheme="blue-orange"] {
--diff-addition: light-dark(var(--color-blue-600), var(--color-blue-400));
--diff-deletion: light-dark(var(--color-orange-600), var(--color-orange-400));
diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsx
index 8480dc70c71..e89240878c3 100644
--- a/apps/web/src/routes/__root.tsx
+++ b/apps/web/src/routes/__root.tsx
@@ -264,6 +264,11 @@ function ContrastAppearanceSync() {
document.documentElement.dataset.diffColorScheme = diffColorScheme;
}, [diffColorScheme]);
+ const chatWidth = useClientSettings((settings) => settings.chatWidth);
+ useEffect(() => {
+ document.documentElement.dataset.chatWidth = chatWidth;
+ }, [chatWidth]);
+
useEffect(() => {
applyAppearanceContrast(document.documentElement, appearanceContrast);
}, [appearanceContrast]);
diff --git a/packages/contracts/src/settings.test.ts b/packages/contracts/src/settings.test.ts
index 16b9418ab7c..1331d2dcb30 100644
--- a/packages/contracts/src/settings.test.ts
+++ b/packages/contracts/src/settings.test.ts
@@ -301,6 +301,23 @@ describe("ClientSettings diff colors", () => {
});
});
+describe("ClientSettings chat width", () => {
+ it("keeps the comfortable width for existing settings without a saved width", () => {
+ expect(decodeClientSettings({}).chatWidth).toBe("comfortable");
+ });
+
+ it.each(["comfortable", "wide", "full"])("round-trips the %s width", (chatWidth) => {
+ const settings = decodeClientSettings({ chatWidth });
+ expect(encodeClientSettings(settings).chatWidth).toBe(chatWidth);
+ expect(decodeClientSettingsPatch({ chatWidth }).chatWidth).toBe(chatWidth);
+ });
+
+ it("rejects unsupported widths", () => {
+ expect(() => decodeClientSettings({ chatWidth: "huge" })).toThrow();
+ expect(() => decodeClientSettingsPatch({ chatWidth: "huge" })).toThrow();
+ });
+});
+
describe("ClientSettings load balancing", () => {
it("requires opt-in when settings are new or omit load balancing", () => {
expect(decodeClientSettings({}).loadBalancingEnabled).toBe(false);
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index a8cce448754..e8dc37bfc83 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -291,6 +291,10 @@ export const LoadBalancingWeights = Schema.Record(
export const DiffColorScheme = Schema.Literals(["red-green", "blue-orange"]);
+/** Maximum width of the chat timeline and composer on wide screens. */
+export const ChatWidth = Schema.Literals(["comfortable", "wide", "full"]);
+export type ChatWidth = typeof ChatWidth.Type;
+
export const ClientSettingsSchema = Schema.Struct({
notificationMode: NotificationMode.pipe(
Schema.withDecodingDefault(Effect.succeed("off" as const)),
@@ -299,6 +303,7 @@ export const ClientSettingsSchema = Schema.Struct({
diffColorScheme: DiffColorScheme.pipe(
Schema.withDecodingDefault(Effect.succeed("red-green" as const)),
),
+ chatWidth: ChatWidth.pipe(Schema.withDecodingDefault(Effect.succeed("comfortable" as const))),
loadBalancingEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
loadBalancingWeights: LoadBalancingWeights.pipe(Schema.withDecodingDefault(Effect.succeed({}))),
appearanceContrast: AppearanceContrast.pipe(
@@ -1566,6 +1571,7 @@ export const ClientSettingsPatch = Schema.Struct({
notificationMode: Schema.optionalKey(NotificationMode),
inAppNotificationsEnabled: Schema.optionalKey(Schema.Boolean),
diffColorScheme: Schema.optionalKey(DiffColorScheme),
+ chatWidth: Schema.optionalKey(ChatWidth),
loadBalancingEnabled: Schema.optionalKey(Schema.Boolean),
loadBalancingWeights: Schema.optionalKey(LoadBalancingWeights),
appearanceContrast: Schema.optionalKey(AppearanceContrast),