Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(chat): let users drag the conversation content width
vastsac11a7a3b81e8
diff --git a/apps/desktop/src/components/ChatSurface.tsx b/apps/desktop/src/components/ChatSurface.tsxindex c479d65ba..70b3e293e 100644--- a/apps/desktop/src/components/ChatSurface.tsx+++ b/apps/desktop/src/components/ChatSurface.tsx@@ -7,6 +7,7 @@ import { IconX } from "./icons";import { TooltipButton } from "./ui";import { OnboardingChecklist } from "./OnboardingChecklist";import { SessionPane } from "./SessionPane";+import { ConversationWidthHandles } from "./ConversationWidthHandles";import { useAppStore } from "../stores/app-store";import { headPermission } from "../lib/pending-permissions";import { headAsk } from "../lib/pending-asks";@@ -129,6 +130,7 @@ export const ChatSurface = memo(function ChatSurface() {<span /></div>) : null}+ <ConversationWidthHandles />{showEmptyState ? (<divclassName="home-main-content"diff --git a/apps/desktop/src/components/ConversationWidthHandles.tsx b/apps/desktop/src/components/ConversationWidthHandles.tsxnew file mode 100644index 000000000..107a62644--- /dev/null+++ b/apps/desktop/src/components/ConversationWidthHandles.tsx@@ -0,0 +1,258 @@+import {+ useCallback,+ useEffect,+ useLayoutEffect,+ useRef,+ useState,+ type KeyboardEvent as ReactKeyboardEvent,+ type PointerEvent as ReactPointerEvent,+} from "react";+import { useTranslation } from "react-i18next";+import {+ DEFAULT_CHAT_CONTENT_MAX_WIDTH,+ MIN_CHAT_CONTENT_MAX_WIDTH,+ chatContentWidthFromDrag,+ clampChatContentMaxWidth,+ resolveChatContentMaxWidth,+ type ChatContentResizeSide,+} from "@pi-desktop/shared";+import { api } from "../lib/api";+import { useAppStore } from "../stores/app-store";+import { cx } from "./ui";++type DragState = {+ pointerId: number;+ side: ChatContentResizeSide;+ startClientX: number;+ startWidth: number;+ paneWidth: number;+ currentWidth: number;+ frame: number;+};++function surfaceOf(host: HTMLDivElement | null): HTMLElement | null {+ return host?.parentElement ?? null;+}++function applyPreferredWidth(surface: HTMLElement | null, width: number) {+ if (!surface) return;+ const px = `${width}px`;+ surface.style.setProperty("--chat-content-max-width", px);+ surface.style.setProperty("--chat-composer-max-width", px);+}++function setResizing(surface: HTMLElement | null, on: boolean) {+ if (!surface) return;+ if (on) {+ surface.dataset.chatResizing = "true";+ document.documentElement.dataset.chatResizing = "true";+ } else {+ delete surface.dataset.chatResizing;+ delete document.documentElement.dataset.chatResizing;+ }+}++/**+ * Dual edge handles for the centered conversation band (D439). Both sides+ * change one preferred max-width; the live band is `min(100%, preferred)`.+ */+export function ConversationWidthHandles() {+ const { t } = useTranslation();+ const hostRef = useRef<HTMLDivElement>(null);+ const dragRef = useRef<DragState | null>(null);+ const persisted = useAppStore((state) =>+ resolveChatContentMaxWidth(state.settings?.chatContentMaxWidth),+ );+ const [dragWidth, setDragWidth] = useState<number | null>(null);+ const [paneWidth, setPaneWidth] = useState(0);+ const width = dragWidth ?? persisted;++ useLayoutEffect(() => {+ applyPreferredWidth(surfaceOf(hostRef.current), width);+ }, [width]);++ useEffect(() => {+ const surface = surfaceOf(hostRef.current);+ if (!surface) return;+ const sync = () => setPaneWidth(surface.clientWidth);+ sync();+ const observer = new ResizeObserver(sync);+ observer.observe(surface);+ return () => observer.disconnect();+ }, []);++ useEffect(+ () => () => {+ const drag = dragRef.current;+ if (drag?.frame) cancelAnimationFrame(drag.frame);+ dragRef.current = null;+ setResizing(surfaceOf(hostRef.current), false);+ },+ [],+ );++ const persistWidth = useCallback(async (next: number) => {+ const settings = useAppStore.getState().settings;+ if (!settings) return;+ if (settings.chatContentMaxWidth === next) return;+ const payload = { ...settings, chatContentMaxWidth: next };+ try {+ await api.setSettings(payload);+ useAppStore.setState({ settings: payload });+ } catch {+ /* keep the live band; the next drag can retry */+ }+ }, []);++ const finishDrag = useCallback(+ (target: HTMLDivElement, pointerId: number, cancelled: boolean) => {+ const drag = dragRef.current;+ if (drag?.pointerId !== pointerId) return;+ if (drag.frame) cancelAnimationFrame(drag.frame);+ dragRef.current = null;+ if (target.hasPointerCapture(pointerId)) {+ target.releasePointerCapture(pointerId);+ }+ setResizing(surfaceOf(hostRef.current), false);+ const committed = cancelled ? drag.startWidth : drag.currentWidth;+ setDragWidth(null);+ applyPreferredWidth(surfaceOf(hostRef.current), committed);+ if (!cancelled) void persistWidth(committed);+ },+ [persistWidth],+ );++ const onPointerDown = useCallback(+ (side: ChatContentResizeSide) =>+ (event: ReactPointerEvent<HTMLDivElement>) => {+ if (event.button !== 0) return;+ event.preventDefault();+ event.stopPropagation();+ event.currentTarget.focus({ preventScroll: true });+ const surface = surfaceOf(hostRef.current);+ const livePane = surface?.clientWidth ?? paneWidth;+ const startWidth = clampChatContentMaxWidth(width, livePane);+ dragRef.current = {+ pointerId: event.pointerId,+ side,+ startClientX: event.clientX,+ startWidth,+ paneWidth: livePane,+ currentWidth: startWidth,+ frame: 0,+ };+ setDragWidth(startWidth);+ setResizing(surface, true);+ event.currentTarget.setPointerCapture(event.pointerId);+ },+ [paneWidth, width],+ );++ const onPointerMove = useCallback(+ (event: ReactPointerEvent<HTMLDivElement>) => {+ const drag = dragRef.current;+ if (drag?.pointerId !== event.pointerId) return;+ drag.currentWidth = chatContentWidthFromDrag({+ side: drag.side,+ startWidth: drag.startWidth,+ startClientX: drag.startClientX,+ clientX: event.clientX,+ paneWidth: drag.paneWidth,+ });+ if (drag.frame) return;+ drag.frame = requestAnimationFrame(() => {+ if (dragRef.current !== drag) return;+ drag.frame = 0;+ setDragWidth(drag.currentWidth);+ });+ },+ [],+ );++ const onPointerUp = useCallback(+ (event: ReactPointerEvent<HTMLDivElement>) => {+ finishDrag(event.currentTarget, event.pointerId, false);+ },+ [finishDrag],+ );++ const onPointerCancel = useCallback(+ (event: ReactPointerEvent<HTMLDivElement>) => {+ finishDrag(event.currentTarget, event.pointerId, true);+ },+ [finishDrag],+ );++ const onDoubleClick = useCallback(() => {+ setDragWidth(null);+ applyPreferredWidth(surfaceOf(hostRef.current), DEFAULT_CHAT_CONTENT_MAX_WIDTH);+ void persistWidth(DEFAULT_CHAT_CONTENT_MAX_WIDTH);+ }, [persistWidth]);++ const onKeyDown = useCallback(+ (event: ReactKeyboardEvent<HTMLDivElement>) => {+ const drag = dragRef.current;+ if (event.key === "Escape" && drag) {+ event.preventDefault();+ finishDrag(event.currentTarget, drag.pointerId, true);+ return;+ }+ const livePane = surfaceOf(hostRef.current)?.clientWidth ?? paneWidth;+ const step = event.shiftKey ? 32 : 16;+ let next: number | null = null;+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") {+ const towardWider =+ (event.currentTarget.dataset.side === "left" && event.key === "ArrowLeft") ||+ (event.currentTarget.dataset.side === "right" && event.key === "ArrowRight");+ next = width + (towardWider ? step : -step);+ } else if (event.key === "Home") {+ next = DEFAULT_CHAT_CONTENT_MAX_WIDTH;+ } else if (event.key === "End") {+ next = Number.POSITIVE_INFINITY;+ }+ if (next === null) return;+ event.preventDefault();+ const clamped = clampChatContentMaxWidth(next, livePane);+ applyPreferredWidth(surfaceOf(hostRef.current), clamped);+ void persistWidth(clamped);+ },+ [finishDrag, paneWidth, persistWidth, width],+ );++ const max = clampChatContentMaxWidth(Number.POSITIVE_INFINITY, paneWidth || 10_000);+ const label = t("nav.resizeChatWidth");+ const valueText = t("nav.chatWidth", { width });+ const resizing = dragWidth !== null;++ return (+ <div ref={hostRef} className="chat-width-handles">+ {(["left", "right"] as const).map((side) => (+ <div+ key={side}+ role="separator"+ aria-orientation="vertical"+ aria-label={label}+ aria-valuemin={MIN_CHAT_CONTENT_MAX_WIDTH}+ aria-valuemax={max}+ aria-valuenow={width}+ aria-valuetext={valueText}+ data-side={side}+ data-testid={`chat-width-handle-${side}`}+ tabIndex={0}+ className={cx(+ "chat-width-handle",+ `chat-width-handle-${side}`,+ "no-drag",+ resizing && "is-resizing",+ )}+ onPointerDown={onPointerDown(side)}+ onPointerMove={onPointerMove}+ onPointerUp={onPointerUp}+ onPointerCancel={onPointerCancel}+ onDoubleClick={onDoubleClick}+ onKeyDown={onKeyDown}+ />+ ))}+ </div>+ );+}diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.tsindex a16d45383..dcc9fa8ac 100644--- a/apps/desktop/src/lib/api.ts+++ b/apps/desktop/src/lib/api.ts@@ -107,6 +107,7 @@ import {normalizeMode,normalizeNetworkProxy,resolveFontScale,+ normalizeChatContentMaxWidth,validateNetworkProxy,} from "@pi-desktop/shared";@@ -222,6 +223,7 @@ export function validateSettingsWrite(settings: AppSettings): AppSettings {defaultCommandShell?: unknown;largePasteThreshold?: unknown;fontScale?: unknown;+ chatContentMaxWidth?: unknown;networkProxy?: unknown;};if (@@ -249,6 +251,14 @@ export function validateSettingsWrite(settings: AppSettings): AppSettings {errorCode: "INVALID_PARAMS",});}+ if (Object.prototype.hasOwnProperty.call(value, "chatContentMaxWidth")) {+ const next = normalizeChatContentMaxWidth(value.chatContentMaxWidth);+ if (next === undefined || next !== value.chatContentMaxWidth) {+ throw Object.assign(new Error("chatContentMaxWidth is invalid"), {+ errorCode: "INVALID_PARAMS",+ });+ }+ }if (Object.prototype.hasOwnProperty.call(value, "networkProxy")) {const proxy = validateNetworkProxy(value.networkProxy);if (!proxy.ok) {diff --git a/apps/desktop/src/styles/chat-shell.css b/apps/desktop/src/styles/chat-shell.cssindex 9e447d682..47038cc21 100644--- a/apps/desktop/src/styles/chat-shell.css+++ b/apps/desktop/src/styles/chat-shell.css@@ -46,18 +46,16 @@flex-direction: column;background: var(--ds-bg-primary);--chat-content-max-width: 760px;- --chat-composer-max-width: 768px;+ --chat-composer-max-width: var(--chat-content-max-width);+ --chat-prose-max-width: var(--chat-content-max-width);--chat-width-transition: var(--motion-duration-normal) var(--motion-ease-out);}/*- * A collapsed sidebar gives the shell more room, but the chat content should- * not become a wide, low-density reading surface. Keep the outer pane fluid- * while tightening the centered content band to preserve focus.+ * Collapsing the sidebar frees pane width; the centered band keeps the user's+ * preferred max (D439) and only compresses when the pane itself is narrower.*/.app-shell.sidebar-collapsed .main-pane {- --chat-content-max-width: 640px;- --chat-composer-max-width: 640px;--chat-width-transition: var(--motion-duration-fast) var(--motion-ease-in);}@@ -383,6 +381,92 @@padding-top: var(--ds-toolbar-height);}++/* Conversation width handles (D439). Rest: invisible. Hover: glow. Drag: hairline. */+.chat-width-handles {+ position: absolute;+ inset: 0 0 var(--composer-dock-height, 168px);+ z-index: 7;+ pointer-events: none;+}++.chat-width-handle {+ position: absolute;+ top: 0;+ bottom: 0;+ width: 12px;+ pointer-events: auto;+ cursor: col-resize;+ touch-action: none;+ user-select: none;+ -webkit-app-region: no-drag;+ app-region: no-drag;+}++.chat-width-handle-left {+ left: max(0px, calc((100% - min(100%, var(--chat-content-max-width))) / 2 - 6px));+}++.chat-width-handle-right {+ right: max(0px, calc((100% - min(100%, var(--chat-content-max-width))) / 2 - 6px));+}++.chat-width-handle::before {+ content: "";+ position: absolute;+ inset-block: 18%;+ left: 50%;+ width: 2px;+ border-radius: var(--radius-full);+ background: transparent;+ box-shadow: none;+ opacity: 0;+ transform: translateX(-50%);+ transition:+ opacity var(--motion-duration-fast) var(--motion-ease-out),+ background var(--motion-duration-fast) var(--motion-ease-out),+ box-shadow var(--motion-duration-fast) var(--motion-ease-out),+ width var(--motion-duration-fast) var(--motion-ease-out);+}++.chat-width-handle:hover::before,+.chat-width-handle:focus-visible::before {+ opacity: 1;+ width: 2px;+ background: color-mix(in oklab, var(--ds-focus) 28%, transparent);+ box-shadow: 0 0 12px 3px color-mix(in oklab, var(--ds-focus) 22%, transparent);+}++.chat-width-handle:focus-visible {+ outline: none;+}++.chat-width-handle.is-resizing::before,+.chat-surface[data-chat-resizing="true"] .chat-width-handle::before {+ opacity: 1;+ width: 1px;+ background: color-mix(in oklab, var(--ds-focus) 55%, transparent);+ box-shadow: 0 0 16px 4px color-mix(in oklab, var(--ds-focus) 28%, transparent);+}++.chat-surface[data-chat-resizing="true"] .thread-content,+.chat-surface[data-chat-resizing="true"] .composer-stack,+.chat-surface[data-chat-resizing="true"] .home-stack-inner {+ transition: none;+}++:root[data-chat-resizing="true"],+:root[data-chat-resizing="true"] * {+ cursor: col-resize !important;+ user-select: none !important;+}++@media (prefers-reduced-motion: reduce) {+ .chat-width-handle::before {+ transition: none;+ }+}+/* Conversation minimap: packed stack of dashes on the thread's left edge,* centered inside the safe span between titlebar and docked composer. Dense* stacks reduce their gap and marker pitch instead of escaping that span.diff --git a/apps/desktop/src/styles/messages.css b/apps/desktop/src/styles/messages.cssindex 53a899e10..950313d73 100644--- a/apps/desktop/src/styles/messages.css+++ b/apps/desktop/src/styles/messages.css@@ -45,14 +45,14 @@.message-row.assistant .message-col,.message-row.system .message-col,.message-row.tool .message-col {- width: min(100%, 720px);+ width: min(100%, var(--chat-prose-max-width, 720px));align-items: flex-start;}/* Decision cards are soft tiles (D297): risk rides in the tint and the riskpill rather than a coloured rail. */.permission-card {- width: min(100%, 720px);+ width: min(100%, var(--chat-prose-max-width, 720px));margin: 10px 0;padding: 14px 16px;border-radius: var(--radius-md);@@ -60,7 +60,7 @@}.asktool-card {- width: min(100%, 720px);+ width: min(100%, var(--chat-prose-max-width, 720px));margin: 10px 0;padding: 14px 16px;border-radius: var(--radius-md);@@ -256,7 +256,7 @@.working-indicator {box-sizing: border-box;display: flex;- width: min(100%, 720px);+ width: min(100%, var(--chat-prose-max-width, 720px));align-items: center;gap: 7px;margin: 2px 0 8px;@@ -427,7 +427,7 @@.planning-state-indicator {box-sizing: border-box;display: flex;- width: min(100%, 720px);+ width: min(100%, var(--chat-prose-max-width, 720px));align-items: center;gap: 7px;margin: 2px 0 8px;@@ -511,7 +511,7 @@--review-change-rail: var(--ds-text-muted);position: relative;box-sizing: border-box;- width: min(calc(100% - 24px), 720px);+ width: min(calc(100% - 24px), var(--chat-prose-max-width, 720px));margin: 0 0 2px 24px;}@@ -747,7 +747,7 @@}.turn-outcome-card {- width: min(100%, 720px);+ width: min(100%, var(--chat-prose-max-width, 720px));margin: 12px 0 8px;border-radius: var(--radius-md);background: var(--ds-tile);@@ -1345,7 +1345,7 @@28px footer. */.message-edit {display: flex;- width: min(100%, 720px);+ width: min(100%, var(--chat-prose-max-width, 720px));margin: 0;flex-direction: column;border: 0;@@ -1359,7 +1359,7 @@narrow chat-plate clamp for as long as the editor is open. */.message-row.user .message-col:has(.message-edit) {width: 100%;- max-width: min(100%, 720px);+ max-width: min(100%, var(--chat-prose-max-width, 720px));}.message-row.user .message-bubble:has(.message-edit) {@@ -1437,7 +1437,7 @@}.message-bubble {- max-width: min(100%, 720px);+ max-width: min(100%, var(--chat-prose-max-width, 720px));border-radius: var(--radius-lg-plus);padding: 10px 14px;line-height: var(--leading-chat);@@ -1453,7 +1453,7 @@}.message-row.session-message .message-col {- width: min(100%, 720px);+ width: min(100%, var(--chat-prose-max-width, 720px));max-width: 100%;align-items: stretch;}@@ -1781,7 +1781,7 @@/* Live tail while running: last thought line / current tool, single line. */.tool-activity-preview {- max-width: min(100%, 720px);+ max-width: min(100%, var(--chat-prose-max-width, 720px));margin: 1px 0 0 26px;overflow: hidden;color: var(--ds-text-muted);diff --git a/apps/desktop/test/chat-content-width.test.mjs b/apps/desktop/test/chat-content-width.test.mjsnew file mode 100644index 000000000..396dce27f--- /dev/null+++ b/apps/desktop/test/chat-content-width.test.mjs@@ -0,0 +1,46 @@+import assert from "node:assert/strict";+import { readFile } from "node:fs/promises";+import test from "node:test";+import { loadStyles } from "./helpers/styles.mjs";++const surfaceSource = await readFile(+ new URL("../src/components/ChatSurface.tsx", import.meta.url),+ "utf8",+);+const handleSource = await readFile(+ new URL("../src/components/ConversationWidthHandles.tsx", import.meta.url),+ "utf8",+);+const styles = await loadStyles();++test("chat surface mounts dual width handles", () => {+ assert.match(surfaceSource, /<ConversationWidthHandles \/>/);+ assert.match(handleSource, /data-testid=\{`chat-width-handle-\$\{side\}`\}/);+ assert.match(handleSource, /chatContentWidthFromDrag/);+ assert.match(handleSource, /DEFAULT_CHAT_CONTENT_MAX_WIDTH/);+ assert.match(handleSource, /onDoubleClick=\{onDoubleClick\}/);+ assert.match(handleSource, /nav\.resizeChatWidth/);+});++test("chat width handles are invisible at rest and glow on hover or drag", () => {+ const handle = styles.match(/\.chat-width-handle::before\s*\{[\s\S]*?\}/)?.[0] ?? "";+ assert.match(handle, /opacity:\s*0/);+ assert.match(styles, /\.chat-width-handle:hover::before/);+ assert.match(+ styles,+ /\.chat-surface\[data-chat-resizing="true"\] \.chat-width-handle::before/,+ );+ assert.match(styles, /box-shadow:\s*0 0 12px 3px/);+});++test("a squeezed pane keeps min\(100%, preferred\) and does not force 640px", () => {+ assert.match(styles, /--chat-content-max-width:\s*760px/);+ assert.doesNotMatch(+ styles,+ /\.app-shell\.sidebar-collapsed \.main-pane\s*\{[\s\S]*?--chat-content-max-width:\s*640px/,+ );+ assert.match(+ styles,+ /\.thread-content\s*\{[\s\S]*?width:\s*min\(100%,\s*var\(--chat-content-max-width\)\)/,+ );+});diff --git a/apps/desktop/test/settings-general.test.mjs b/apps/desktop/test/settings-general.test.mjsindex 644d50413..c02dc9cba 100644--- a/apps/desktop/test/settings-general.test.mjs+++ b/apps/desktop/test/settings-general.test.mjs@@ -126,6 +126,7 @@ test("Basics and AI tabs expose their respective app and AI controls", () => {}assert.match(sharedTypesSource, /contextUsageDisplay\?: ContextUsageDisplay/);assert.match(sharedTypesSource, /ContextUsageDisplay = "remaining" \| "used"/);+ assert.match(sharedTypesSource, /chatContentMaxWidth\?: number/);assert.match(settingsPageSource, /largePasteThreshold/);assert.match(settingsPageSource, /saveSettings\(\{ largePasteThreshold: next \}\)/);assert.doesNotMatch(settingsPageSource, /commandShellConfigured/);diff --git a/apps/desktop/test/sidebar-collapse-animation.test.mjs b/apps/desktop/test/sidebar-collapse-animation.test.mjsindex 9e4f679ca..534604733 100644--- a/apps/desktop/test/sidebar-collapse-animation.test.mjs+++ b/apps/desktop/test/sidebar-collapse-animation.test.mjs@@ -96,7 +96,7 @@ test("the collapse keyframes cannot reflow the sidebar's content", () => {assert.match(sidebarBlock, /overflow:\s*hidden/);});-test("a collapsed sidebar uses a narrower centered chat content band", () => {+test("a collapsed sidebar keeps the preferred chat band and only changes motion", () => {assert.match(appSource,/sidebarCollapsed && "sidebar-collapsed"/,@@ -104,24 +104,31 @@ test("a collapsed sidebar uses a narrower centered chat content band", () => {const mainPaneBlock = globalStyles.match(/\.main-pane\s*\{[\s\S]*?\}/)?.[0] ?? "";assert.match(mainPaneBlock, /--chat-content-max-width:\s*760px/);- assert.match(mainPaneBlock, /--chat-composer-max-width:\s*768px/);+ assert.match(+ mainPaneBlock,+ /--chat-composer-max-width:\s*var\(--chat-content-max-width\)/,+ );+ assert.match(+ mainPaneBlock,+ /--chat-prose-max-width:\s*var\(--chat-content-max-width\)/,+ );const collapsedBlock =globalStyles.match(/\.app-shell\.sidebar-collapsed \.main-pane\s*\{[\s\S]*?\}/)?.[0] ?? "";- assert.match(collapsedBlock, /--chat-content-max-width:\s*640px/);- assert.match(collapsedBlock, /--chat-composer-max-width:\s*640px/);+ assert.doesNotMatch(collapsedBlock, /--chat-content-max-width:\s*640px/);+ assert.doesNotMatch(collapsedBlock, /--chat-composer-max-width:\s*640px/);assert.match(collapsedBlock,/--chat-width-transition:\s*var\(--motion-duration-fast\) var\(--motion-ease-in\)/,);const threadContentBlock =- globalStyles.match(/\.thread-content\s*\{[\s\S]*?\}/)?.[0] ?? "";+ globalStyles.match(/^\.thread-content\s*\{[\s\S]*?\}/m)?.[0] ?? "";assert.match(threadContentBlock, /width:\s*min\(100%,\s*var\(--chat-content-max-width\)\)/);assert.match(threadContentBlock, /transition:\s*width var\(--chat-width-transition\)/);const homeStackBlock =- globalStyles.match(/\.home-stack-inner\s*\{[\s\S]*?\}/)?.[0] ?? "";+ globalStyles.match(/^\.home-stack-inner\s*\{[\s\S]*?\}/m)?.[0] ?? "";assert.match(homeStackBlock, /width:\s*min\(100%,\s*var\(--chat-composer-max-width\)\)/);assert.match(homeStackBlock, /transition:\s*width var\(--chat-width-transition\)/);diff --git a/apps/desktop/test/transcript-style.test.mjs b/apps/desktop/test/transcript-style.test.mjsindex eb6e3ff28..174148f59 100644--- a/apps/desktop/test/transcript-style.test.mjs+++ b/apps/desktop/test/transcript-style.test.mjs@@ -123,7 +123,7 @@ test("assistant turns stay transparent full-width prose", () => {);assert.match(stylesSource,- /\.message-row\.assistant[\s\S]*?\.message-col[\s\S]*?width:\s*min\(100%,\s*720px\);/,+ /\.message-row\.assistant[\s\S]*?\.message-col[\s\S]*?width:\s*min\(100%,\s*var\(--chat-prose-max-width,\s*720px\)\);/,);// D323: the live parent turn stays transparent; no rail, no reserved// inset, no whole-turn tile. The tile belongs only to the delegation card.diff --git a/docs/adr/0273-draggable-chat-content-width.md b/docs/adr/0273-draggable-chat-content-width.mdnew file mode 100644index 000000000..48d46d97b--- /dev/null+++ b/docs/adr/0273-draggable-chat-content-width.md@@ -0,0 +1,62 @@+# ADR 0273: Draggable Chat Content Width++- Status: Accepted+- Date: 2026-09-16+- Deciders: PI-Desktop desktop UI maintainers+- Amends: D058, D101, the collapsed-sidebar 640px band+- Related: [04-ux/01-ui-ia](../spec/04-ux/01-ui-ia.md) ·+ [04-ux/07-ui-design-system](../spec/04-ux/07-ui-design-system.md) ·+ [04-ux/08-component-spec](../spec/04-ux/08-component-spec.md) ·+ [08-meta/decisions-log](../spec/08-meta/decisions-log.md) (D439) ·+ E2E-CHAT-content-width-handles · E2E-208++## Context++The conversation column, empty-home stack, and composer were capped at+760–768px (640px while the sidebar was collapsed) so a wide shell would not+become a low-density reading surface. Code, tables, diagrams, and tool output+then wrapped inside a second 720px assistant cap, and there was no way to+spend the extra pane width when the user wanted it.++A Comfort/Wide toggle was rejected: two presets cannot match monitor size,+work-panel squeeze, or a one-off wider reading of a diff.++## Decision++1. The transcript, empty-home stack, and composer share one preferred max+ width, default **760px**, persisted as `AppSettings.chatContentMaxWidth`.+ Absent or invalid values keep 760. The live band is always+ `min(available pane minus 24px gutters, preferred)`, so a squeezed+ sidebar or work panel compresses the band without rewriting the+ preference.+2. Two 12px handles sit on the left and right edges of that centered band,+ from the top of `.chat-surface` down to the composer dock. Both handles+ change the same width (1px pointer → 2px band) so the column stays+ centered. Drag minimum is **560px**, or the available pane if smaller.+3. Rest: the handles are invisible. Hover/focus: a soft glow. Drag: a 1px+ hairline plus glow on **both** edges. Double-click resets to 760.+ Arrow keys step 16px (Shift 32px); Home restores 760; End expands to the+ pane; Escape cancels an in-flight drag.+4. User bubbles stay `min(82%, 600px)`. Assistant, tool, permission, ask,+ review, and turn-outcome rows follow `--chat-prose-max-width`, which+ tracks the band. The collapsed-sidebar 640px ceiling is removed.+5. Renderer only: no protocol, storage schema, host, or IPC change. Host-core+ already preserves unknown settings keys.++## Consequences++- Users who never touch the handles keep today's 760px column, including+ after collapsing the sidebar (the pane grows; the band does not jump to+ 640px).+- A saved 1100px preference on a large window compresses cleanly when the+ work panel opens, then returns when it closes.+- Handle hit targets can sit near the minimap when the band is almost full+ pane width; the 24px gutter keeps both usable.++## Rejected alternatives++- **Comfort / Wide presets:** cannot match the live pane or a one-off width.+- **Independent left/right insets:** un-centers the column and fights the+ composer, which is also centered.+- **Full-bleed to the pane edge by default:** reopens the over-wide reading+ surface the 760px cap was there to prevent.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 27917774a..2d8543fb4 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -299,3 +299,4 @@ Each ADR includes:| 0269 | [Move capability documents between the global and project levels](0269-capability-level-transfer.md) | Accepted for implementation (amends ADR 0112) || 0268 | Remove quotes, annotations, and side chats | Accepted (supersedes message-quotes-and-side-chats / response-annotations / floating-annotation-index) || 0272 | [Judge a public-network address on the route the request will dial](0272-connection-time-public-network-route.md) | Accepted for implementation (amends ADR 0243; issue #419 / PR #473) |+| 0273 | [Draggable chat content width](0273-draggable-chat-content-width.md) | Accepted (D439) |diff --git a/docs/spec/04-ux/01-ui-ia.md b/docs/spec/04-ux/01-ui-ia.mdindex 178feb740..cfe20f6f4 100644--- a/docs/spec/04-ux/01-ui-ia.md+++ b/docs/spec/04-ux/01-ui-ia.md@@ -56,9 +56,9 @@ destination, chat as the home surface, tools and permissions inline.pane (they are pages, not modals). Once Settings or Extensions is selected,bootstrap completion and background refreshes must not replace thatdestination with the chat home; only an explicit navigation action may do so.- The outer pane stays fluid while the sidebar is collapsed, but the centered- chat content band tightens to 640px from its expanded 760–768px ceiling so- the wider shell does not create an over-wide, low-density reading surface.+ The outer pane stays fluid while the sidebar is collapsed. The centered chat+ content band defaults to 760px and is user-resizable (D439); it compresses+ with `min(available pane, preferred)` instead of tightening to a 640px ceiling.- **Titlebar**: platform-native desktop chrome (D118). macOS uses`hiddenInset` traffic lights and the system application menu. The expandedsidebar keeps Collapse sidebar in the same 46px row, aligned todiff --git a/docs/spec/04-ux/07-ui-design-system.md b/docs/spec/04-ux/07-ui-design-system.mdindex 5ba914777..9f31d7fbd 100644--- a/docs/spec/04-ux/07-ui-design-system.md+++ b/docs/spec/04-ux/07-ui-design-system.md@@ -817,8 +817,8 @@ model):- Column `flex: 1; min-height: 0; overflow: hidden`- Inner scroller (`.home-scroll`) is the only vertical overflow surface forthe hero and optional checklist-- Stack (`.home-stack-inner`) uses content width **`min(100%, 768px)`** in the- expanded shell and **`min(100%, 640px)`** while the sidebar is collapsed,+- Stack (`.home-stack-inner`) uses content width+ **`min(100%, var(--chat-content-max-width))`** (default 760px, D439),with **`gap: 16px`** (workstation ceiling), and auto margins to center thecolumn when the viewport is tall- The content order is **hero → optional onboarding checklist**. Task entry@@ -1026,7 +1026,7 @@ Codex parity decisions (D034/D070) supersede any older value here.| Composer shell minimum | ~80px | One-line draft + toolbar padding || Composer toolbar | MainChat `≥450px` | Left/right control groups stay on one row and do not shrink; mode/permission labels stay single-line and ellipsize || Composer draft height | 1–7 text lines | Auto-grow; internal scroll beyond line 7 |-| Chat message max width | 720px assistant / 560px user plate | Prevent eye-span over-stretch; user turns stay compact |+| Chat message max width | 760px default band (user-resizable, min 560px) / 600px user plate | Band follows `min(pane, preferred)`; user turns stay compact || Window min width | 1040px | Enforced by Electron for the whole app; opening the panel never changes native bounds || Window min height | 700px | Enforced by Electron |@@ -1222,7 +1222,7 @@ Full component contract and usage rules: [08-component-spec.md §17](08-componen| **Compact list rows 28px height** | Sidebar session items, settings list rows || **Button rows 32px height** | Standard buttons || **Never exceed 24px vertical gap** | Even for "breathing room" — this is a workstation |-| **Max content width 720px** | Chat messages, tool disclosure rows — prevent over-wide eye-span |+| **Max content width 760px default** | Chat band is user-resizable (min 560px); user plates stay compact |## 14. Do / Don'tdiff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 796321b15..2fff4c681 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -717,7 +717,7 @@ reading surface of the workstation.### 4.3 Layout- Background: bg-primary-- Max content width: 720px (messages), centered+- Max content width: 760px default, user-resizable (D439); assistant rows follow the band. User plates stay `min(82%, 600px)`- The transcript keeps one stable scrollbar gutter on the trailing edge. Itnever reserves a matching left gutter, so the minimap and first message donot leave a decorative blank strip beside the session.@@ -1461,10 +1461,16 @@ Single message render — either user (plaintext) or assistant (markdown streami### 8.3 Layout-- Max content band: 760px thread column; assistant body max 720px-- When the sidebar is collapsed, the centered thread column and composer band- use a 640px ceiling. The outer main pane remains fluid and the width- transition follows the sidebar dock transition.+- Max content band: 760px default, user-resizable via dual edge handles+ (D439 / ADR 0273). Assistant, tool, and decision rows follow the band.+ User plates stay `min(82%, 600px)`.+- The live band is `min(available pane, preferred)`. Collapsing the sidebar+ no longer tightens a 640px ceiling; the outer pane stays fluid and the+ width transition follows the sidebar dock.+- Dual 12px handles sit on the band edges: invisible at rest, glow on hover+ or focus, 1px hairline plus glow while dragging. Double-click resets to+ 760px. Arrow keys step the width; Home restores the default; End fills the+ pane.- User: right-aligned, theme-neutral soft plate (`color-mix` on primary ink,never a fixed accent tint), borderless, `radius-lg-plus` with a tighterbottom-right corner, capped at `min(82%, 600px)` so short prompts read as@@ -3427,7 +3433,7 @@ Sidebar footer Popover (360px max)2. All interactive elements have visible focus rings (2px accent, offset 2px)3. Layout shell metrics (46px titlebar row, ~275/48 sidebar, 280 context,compact composer with 1–7-line draft growth) match spec-4. Chat messages constrained to 720px max width+4. Chat content band defaults to 760px and is user-resizable; user plates stay compact5. ToolCallCard shows status, args preview, result preview, duration per [01-ui-ia.md](01-ui-ia.md) §56. PermissionCard shows tool name, risk, args, countdown, and three action buttons per [03-permission-ux.md](03-permission-ux.md)7. Composer: Enter sends when Enter-to-send is on; when it is off, Cmd/Ctrl+Enterdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 3f7b46de5..c83335137 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -4224,27 +4224,47 @@ identify the platform validation still needed.- **Status**: Unit-covered (`sidebar-collapse-animation.test.mjs`); renderedinteraction scenario Draft-#### E2E-208: Collapsed sidebar tightens the centered chat content band+#### E2E-208: Collapsed sidebar does not force a 640px chat band- **Preconditions**: PI-Desktop is open with an active chat session at a- viewport wide enough for the expanded 760–768px chat content band; reduced- motion is off.+ viewport wide enough for the default 760px chat content band; reduced+ motion is off; the user has not resized the band.- **Steps**: 1) Record the width of the centered transcript or empty-homecomposer band with the sidebar expanded. 2) Collapse the sidebar. 3) Inspectthe same content band while the dock transition runs and after it settles.4) Expand the sidebar and inspect the return transition.-- **Expected**: The outer main pane fills the space released by the sidebar,- while the centered chat content band transitions from its expanded- 760–768px ceiling to a 640px ceiling in the collapsed state. The transcript,- empty-home stack, and Composer use the same collapsed width envelope; no- content jumps, horizontal overflow, or clipped controls appear. Expanding- restores the expanded ceiling.+- **Expected**: The outer main pane fills the space released by the sidebar.+ The centered chat content band stays at its preferred 760px ceiling (or+ `min(available, preferred)` if the pane is narrower). It does not jump to+ 640px. The transcript, empty-home stack, and Composer share that envelope.- **Specs linked**: `04-ux/01-ui-ia.md`, `04-ux/07-ui-design-system.md`,- `04-ux/08-component-spec.md`+ `04-ux/08-component-spec.md`, ADR 0273, D439- **Acceptance**: Quality- **Milestone**: M5-- **Status**: Unit-covered (`sidebar-collapse-animation.test.mjs`); rendered- interaction scenario Draft+- **Status**: Unit-covered (`sidebar-collapse-animation.test.mjs`,+ `chat-content-width.test.mjs`); rendered interaction scenario Draft++#### E2E-CHAT-content-width-handles: Dual edge handles resize the centered chat band++- **Preconditions**: PI-Desktop is open on chat (empty home or a transcript)+ at a viewport wider than 760px. Reduced motion off.+- **Steps**: 1) Confirm no divider is visible at rest. 2) Hover the left+ content edge and confirm a glow, then the right edge. 3) Drag the right+ handle outward and confirm both edges move, the composer matches, and a+ hairline is visible while dragging. 4) Open the work panel or expand the+ sidebar until the pane is narrower than the new preference; the band+ compresses without a horizontal scroll. 5) Close the panel / collapse the+ sidebar and confirm the preference returns. 6) Double-click a handle to+ restore 760px. 7) Repeat with Arrow keys on a focused handle.+- **Expected**: Default 760px. Drag floor 560px (or the pane if smaller).+ User bubbles stay compact. Handles stay keyboard-accessible+ (`role="separator"`). Preference persists as `chatContentMaxWidth`.+- **Specs linked**: `04-ux/01-ui-ia.md`, `04-ux/08-component-spec.md`,+ ADR 0273, D439+- **Acceptance**: C (conversation), Quality+- **Milestone**: M5+- **Status**: Unit-covered (`chat-content-width.test.mjs`,+ `packages/shared/src/chat-content-width.test.ts`); rendered scenario Draft#### E2E-UI-tooltip-never-outlives-its-trigger: A themed tooltip always retreats@@ -7433,7 +7453,7 @@ identify the platform validation still needed.| B / F / Security — Provider copy | E2E-PROVIDER-copy-config-without-credentials || A — App startup | E2E-001, E2E-002, E2E-003, E2E-004, E2E-067, E2E-076, E2E-079, E2E-092, E2E-097, E2E-143, E2E-150, E2E-168, E2E-204 || B — Model config | E2E-005, E2E-006, E2E-007, E2E-038, E2E-050, E2E-052, E2E-055, E2E-066, E2E-080, E2E-082, E2E-102c, E2E-102d, E2E-102e, E2E-151, E2E-154, E2E-163, E2E-166, E2E-172, E2E-174, E2E-197, E2E-005G, E2E-005J, E2E-199, E2E-201, E2E-202, E2E-203, E2E-205, E2E-206, E2E-209 |-| C — Conversation & stream | E2E-008, E2E-008d, E2E-008a, E2E-009, E2E-010, E2E-011, E2E-011a, E2E-011b, E2E-011d, E2E-011e, E2E-011g, E2E-031, E2E-040, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-052, E2E-053, E2E-054, E2E-055, E2E-059, E2E-059a, E2E-060c, E2E-060d, E2E-061, E2E-061a, E2E-062, E2E-064, E2E-065, E2E-068, E2E-071, E2E-073, E2E-074, E2E-075, E2E-081, E2E-083, E2E-084, E2E-086, E2E-087, E2E-088, E2E-088b, E2E-089, E2E-090, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-106, E2E-109, E2E-111, E2E-114, E2E-116, E2E-117, E2E-118, E2E-119, E2E-120, E2E-121, E2E-218, E2E-219, E2E-AGENTS-001, E2E-142, E2E-144, E2E-145, E2E-146, E2E-146a, E2E-147, E2E-151, E2E-154, E2E-155, E2E-158, E2E-159, E2E-161, E2E-162, E2E-166, E2E-172, E2E-173, E2E-174, E2E-177, E2E-178, E2E-179, E2E-180, E2E-182, E2E-183, E2E-187, E2E-198, E2E-199, E2E-202, E2E-203, E2E-207, E2E-208, E2E-250, E2E-102i, E2E-PLUGIN-session-orchestrator-real-workers, E2E-SUBAGENT-settlement-updates-before-parent-poll |+| C — Conversation & stream | E2E-008, E2E-008d, E2E-008a, E2E-009, E2E-010, E2E-011, E2E-011a, E2E-011b, E2E-011d, E2E-011e, E2E-011g, E2E-031, E2E-040, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-052, E2E-053, E2E-054, E2E-055, E2E-059, E2E-059a, E2E-060c, E2E-060d, E2E-061, E2E-061a, E2E-062, E2E-064, E2E-065, E2E-068, E2E-071, E2E-073, E2E-074, E2E-075, E2E-081, E2E-083, E2E-084, E2E-086, E2E-087, E2E-088, E2E-088b, E2E-089, E2E-090, E2E-094, E2E-095, E2E-096, E2E-097, E2E-098, E2E-099, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102g, E2E-106, E2E-109, E2E-111, E2E-114, E2E-116, E2E-117, E2E-118, E2E-119, E2E-120, E2E-121, E2E-218, E2E-219, E2E-AGENTS-001, E2E-142, E2E-144, E2E-145, E2E-146, E2E-146a, E2E-147, E2E-151, E2E-154, E2E-155, E2E-158, E2E-159, E2E-161, E2E-162, E2E-166, E2E-172, E2E-173, E2E-174, E2E-177, E2E-178, E2E-179, E2E-180, E2E-182, E2E-183, E2E-187, E2E-198, E2E-199, E2E-202, E2E-203, E2E-207, E2E-208, E2E-CHAT-content-width-handles, E2E-250, E2E-102i, E2E-PLUGIN-session-orchestrator-real-workers, E2E-SUBAGENT-settlement-updates-before-parent-poll || D — Workspace | E2E-012, E2E-013, E2E-022B, E2E-024I, E2E-047, E2E-049, E2E-057, E2E-058, E2E-060, E2E-068, E2E-075, E2E-078, E2E-153, E2E-158, E2E-182, E2E-187, E2E-252 || D — Workspace (project ordering) | E2E-253 || E — Tools & permissions | E2E-008a, E2E-014, E2E-015, E2E-016, E2E-017, E2E-018, E2E-019, E2E-024I, E2E-024K, E2E-040, E2E-049, E2E-074, E2E-093, E2E-097, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102d, E2E-102e, E2E-102g, E2E-103, E2E-105, E2E-106, E2E-107, E2E-111, E2E-112, E2E-113, E2E-114, E2E-115, E2E-116, E2E-119, E2E-121, E2E-122, E2E-142, E2E-145, E2E-147, E2E-155, E2E-158, E2E-166, E2E-181, E2E-PLUGIN-imported-pi-package-skills |@@ -7485,7 +7505,7 @@ identify the platform validation still needed.| M2 | E2E-004, E2E-005, E2E-006, E2E-007, E2E-008, E2E-008d, E2E-009, E2E-010, E2E-011, E2E-011a, E2E-011b, E2E-011d, E2E-011e, E2E-011g, E2E-020, E2E-021, E2E-021a, E2E-027, E2E-031, E2E-036, E2E-037, E2E-042, E2E-087, E2E-088, E2E-088b, E2E-089, E2E-090, E2E-144, E2E-005J, E2E-201, E2E-202, E2E-207, E2E-206 || M3 | E2E-012, E2E-013, E2E-014, E2E-015, E2E-016, E2E-017, E2E-018, E2E-019, E2E-040 || M4 | E2E-022, E2E-023, E2E-024, E2E-025, E2E-026, E2E-030, E2E-038 |-| M5 | E2E-008a, E2E-032, E2E-033, E2E-034, E2E-039, E2E-043, E2E-044, E2E-045, E2E-046, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-050, E2E-051, E2E-052, E2E-053, E2E-054, E2E-055, E2E-056, E2E-057, E2E-058, E2E-059, E2E-060, E2E-061, E2E-062, E2E-063, E2E-064, E2E-065, E2E-066, E2E-067, E2E-068, E2E-069, E2E-070, E2E-071, E2E-072, E2E-073, E2E-074, E2E-075, E2E-076, E2E-077, E2E-078, E2E-079, E2E-080, E2E-081, E2E-082, E2E-083, E2E-084, E2E-085, E2E-086, E2E-092, E2E-093, E2E-096, E2E-097, E2E-098, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102e, E2E-AGENTS-001, E2E-059a, E2E-060b, E2E-060c, E2E-061a, E2E-073a, E2E-094, E2E-095, E2E-143, E2E-145, E2E-146, E2E-146a, E2E-147, E2E-177, E2E-178, E2E-180, E2E-181, E2E-182, E2E-183, E2E-186, E2E-187, E2E-194, E2E-195, E2E-204, E2E-208, E2E-250, E2E-252, E2E-102i |+| M5 | E2E-008a, E2E-032, E2E-033, E2E-034, E2E-039, E2E-043, E2E-044, E2E-045, E2E-046, E2E-047, E2E-048, E2E-048A, E2E-049, E2E-050, E2E-051, E2E-052, E2E-053, E2E-054, E2E-055, E2E-056, E2E-057, E2E-058, E2E-059, E2E-060, E2E-061, E2E-062, E2E-063, E2E-064, E2E-065, E2E-066, E2E-067, E2E-068, E2E-069, E2E-070, E2E-071, E2E-072, E2E-073, E2E-074, E2E-075, E2E-076, E2E-077, E2E-078, E2E-079, E2E-080, E2E-081, E2E-082, E2E-083, E2E-084, E2E-085, E2E-086, E2E-092, E2E-093, E2E-096, E2E-097, E2E-098, E2E-099, E2E-100, E2E-101, E2E-102, E2E-102a, E2E-102b, E2E-102c, E2E-102d, E2E-102e, E2E-AGENTS-001, E2E-059a, E2E-060b, E2E-060c, E2E-061a, E2E-073a, E2E-094, E2E-095, E2E-143, E2E-145, E2E-146, E2E-146a, E2E-147, E2E-177, E2E-178, E2E-180, E2E-181, E2E-182, E2E-183, E2E-186, E2E-187, E2E-194, E2E-195, E2E-204, E2E-208, E2E-CHAT-content-width-handles, E2E-250, E2E-252, E2E-102i || M5 (project ordering) | E2E-253 || M2 (IME slash alias) | E2E-255 || M5 (Skill residency) | E2E-254 |diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex 7cee8dde7..bedec8af0 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -5735,3 +5735,17 @@ that was sitting at the bottom — including after the turn had finished.`--ds-bg-composer` / `--ds-tile-deep`. See`04-ux/11-asktool-question-card.md`, `04-ux/07-ui-design-system.md` §6.4, andE2E-078.++## 2026-09-16 — Draggable chat content width (D439)++- The centered conversation band, empty-home stack, and composer share one+ preferred max width, default 760px, persisted as+ `AppSettings.chatContentMaxWidth`. Dual edge handles (invisible at rest,+ glow on hover, hairline while dragging) change that width together so the+ column stays centered. Drag floor is 560px.+- The live used width is `min(available pane minus 24px gutters, preferred)`,+ so a squeezed sidebar or work panel compresses the band without rewriting+ the preference. The collapsed-sidebar 640px ceiling is removed.+- Assistant, tool, and decision rows follow the band. User plates stay+ `min(82%, 600px)`. Renderer only. See ADR 0273, E2E-208, and+ E2E-CHAT-content-width-handles.diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.mdindex 66747538f..91b977c7b 100644--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@ -4322,3 +4322,10 @@ that amendment are retired by ADR 0268; the upstream work-panel lifecycle stays.`07-plugins/04-plugin-security.md`、`03-runtime/01-ipc-protocol.md`(`NATIVE_MENU_ACTIONS`)、E2E-072 与`apps/desktop/test/window-toggle-shortcut.test.mjs`。++## 2026-09-16 —— 可拖拽的对话内容宽度(D439)++- 居中的对话带、空首页和输入框共用一个首选最大宽度,默认 760px,持久化为+ `AppSettings.chatContentMaxWidth`。左右边缘各一条手柄(静止不可见、悬停光晕、拖拽时显示细线)同步改这个宽度,列保持居中。拖拽下限 560px。+- 实际宽度是 `min(可用窗格减去两侧 24px, 首选值)`,侧栏或工作区挤压时自适应压缩,不改写偏好。收起侧栏不再把内容带到 640px。+- 助手/工具/决策行跟随内容带;用户气泡仍是 `min(82%, 600px)`。仅渲染器。见 ADR 0273、E2E-208、E2E-CHAT-content-width-handles。diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.tsindex aac353bbb..3681da6e2 100644--- a/packages/i18n/src/locales/de/index.ts+++ b/packages/i18n/src/locales/de/index.ts@@ -129,6 +129,8 @@ export const de = {"expandSidebar": "Seitenleiste erweitern","resizeSidebar": "Größe der Seitenleiste ändern","sidebarWidth": "Breite der Seitenleiste: {{width}} Pixel",+ "resizeChatWidth": "Gesprächsbreite ändern",+ "chatWidth": "Gesprächsbreite: {{width}} Pixel","sessionActions": "Sitzungsaktionen","renameTask": "Aufgabe umbenennen","sessionRunning": "In Arbeit",diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.tsindex a00e9031b..ab5d988bd 100644--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@ -136,6 +136,8 @@ export const en = {expandSidebar: "Expand sidebar",resizeSidebar: "Resize sidebar",sidebarWidth: "Sidebar width: {{width}} pixels",+ resizeChatWidth: "Resize conversation width",+ chatWidth: "Conversation width: {{width}} pixels",sessionActions: "Session actions",renameTask: "Rename task",sessionRunning: "Working",diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.tsindex ed1b91e0c..3d54d3bbf 100644--- a/packages/i18n/src/locales/es/index.ts+++ b/packages/i18n/src/locales/es/index.ts@@ -129,6 +129,8 @@ export const es = {"expandSidebar": "Expandir barra lateral","resizeSidebar": "Cambiar tamaño de barra lateral","sidebarWidth": "Ancho de barra lateral: {{width}} píxeles",+ "resizeChatWidth": "Cambiar ancho de la conversación",+ "chatWidth": "Ancho de la conversación: {{width}} píxeles","sessionActions": "Acciones de sesión","renameTask": "Cambiar nombre de tarea","sessionRunning": "Trabajando",diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.tsindex 6697256a5..67c98b8d9 100644--- a/packages/i18n/src/locales/fr/index.ts+++ b/packages/i18n/src/locales/fr/index.ts@@ -129,6 +129,8 @@ export const fr = {"expandSidebar": "Développer la barre latérale","resizeSidebar": "Redimensionner la barre latérale","sidebarWidth": "Largeur de la barre latérale : {{width}} pixels",+ "resizeChatWidth": "Redimensionner la conversation",+ "chatWidth": "Largeur de la conversation : {{width}} pixels","sessionActions": "Actions de session","renameTask": "Renommer la tâche","sessionRunning": "En cours d'exécution",diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.tsindex 9b72755cb..4bb210f71 100644--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@ -138,6 +138,8 @@ export const ko = {expandSidebar: "사이드바 펼치기",resizeSidebar: "사이드바 크기 조절",sidebarWidth: "사이드바 너비: {{width}}픽셀",+ resizeChatWidth: "대화 너비 조절",+ chatWidth: "대화 너비: {{width}}픽셀",sessionActions: "세션 작업",renameTask: "작업 이름 바꾸기",sessionRunning: "작업 중",diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.tsindex 7ed3ec66e..c7698fbc3 100644--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@ -138,6 +138,8 @@ export const tr = {expandSidebar: "Kenar çubuğunu genişlet",resizeSidebar: "Kenar çubuğu genişliğini ayarla",sidebarWidth: "Kenar çubuğu genişliği: {{width}} piksel",+ resizeChatWidth: "Sohbet genişliğini ayarla",+ chatWidth: "Sohbet genişliği: {{width}} piksel",sessionActions: "Oturum eylemleri",renameTask: "Görevi yeniden adlandır",sessionRunning: "Çalışıyor",diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.tsindex 02c99db06..19a002454 100644--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@ -131,6 +131,8 @@ export const zhCN = {expandSidebar: "展开侧边栏",resizeSidebar: "调整侧边栏宽度",sidebarWidth: "侧边栏宽度:{{width}} 像素",+ resizeChatWidth: "调整对话宽度",+ chatWidth: "对话宽度:{{width}} 像素",sessionActions: "会话操作",renameTask: "重命名任务",sessionRunning: "进行中",diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.tsindex 88f8817eb..e7e2c8661 100644--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@ -131,6 +131,8 @@ export const zhTW = {expandSidebar: "展開側邊欄",resizeSidebar: "調整側邊欄寬度",sidebarWidth: "側邊欄寬度:{{width}} 畫素",+ resizeChatWidth: "調整對話寬度",+ chatWidth: "對話寬度:{{width}} 畫素",sessionActions: "會話操作",renameTask: "重新命名任務",sessionRunning: "進行中",diff --git a/packages/shared/src/chat-content-width.test.ts b/packages/shared/src/chat-content-width.test.tsnew file mode 100644index 000000000..6779ea542--- /dev/null+++ b/packages/shared/src/chat-content-width.test.ts@@ -0,0 +1,58 @@+import { describe, expect, it } from "vitest";+import {+ CHAT_CONTENT_WIDTH_GUTTER,+ DEFAULT_CHAT_CONTENT_MAX_WIDTH,+ MIN_CHAT_CONTENT_MAX_WIDTH,+ chatContentWidthFromDrag,+ clampChatContentMaxWidth,+ normalizeChatContentMaxWidth,+ resolveChatContentMaxWidth,+} from "./chat-content-width.js";++describe("chat content width", () => {+ it("defaults absent and invalid values to 760", () => {+ expect(resolveChatContentMaxWidth(undefined)).toBe(+ DEFAULT_CHAT_CONTENT_MAX_WIDTH,+ );+ expect(resolveChatContentMaxWidth(null)).toBe(DEFAULT_CHAT_CONTENT_MAX_WIDTH);+ expect(resolveChatContentMaxWidth("900")).toBe(DEFAULT_CHAT_CONTENT_MAX_WIDTH);+ expect(normalizeChatContentMaxWidth(undefined)).toBeUndefined();+ });++ it("snaps below the drag floor up to 560 and rounds", () => {+ expect(normalizeChatContentMaxWidth(400)).toBe(MIN_CHAT_CONTENT_MAX_WIDTH);+ expect(normalizeChatContentMaxWidth(900.4)).toBe(900);+ expect(resolveChatContentMaxWidth(1200)).toBe(1200);+ });++ it("compresses to the pane when the sidebar squeezes past the preference", () => {+ expect(clampChatContentMaxWidth(1100, 700)).toBe(700 - 2 * CHAT_CONTENT_WIDTH_GUTTER);+ expect(clampChatContentMaxWidth(760, 1400)).toBe(760);+ expect(clampChatContentMaxWidth(400, 1400)).toBe(MIN_CHAT_CONTENT_MAX_WIDTH);+ });++ it("lets a tiny pane drop below the drag floor", () => {+ expect(clampChatContentMaxWidth(760, 500)).toBe(500 - 2 * CHAT_CONTENT_WIDTH_GUTTER);+ });++ it("mirrors left and right drags onto the same centered width", () => {+ expect(+ chatContentWidthFromDrag({+ side: "left",+ startWidth: 760,+ startClientX: 200,+ clientX: 150,+ paneWidth: 1400,+ }),+ ).toBe(860);+ expect(+ chatContentWidthFromDrag({+ side: "right",+ startWidth: 760,+ startClientX: 1000,+ clientX: 1050,+ paneWidth: 1400,+ }),+ ).toBe(860);+ });+});diff --git a/packages/shared/src/chat-content-width.ts b/packages/shared/src/chat-content-width.tsnew file mode 100644index 000000000..5dc626da9--- /dev/null+++ b/packages/shared/src/chat-content-width.ts@@ -0,0 +1,60 @@+/**+ * Centered chat content band width (D439).+ *+ * The transcript, empty-home stack, and composer share one preferred max+ * width. The live used width is `min(available pane, preferred)` so a+ * squeezed sidebar or work panel compresses the band without rewriting the+ * preference.+ */+export const DEFAULT_CHAT_CONTENT_MAX_WIDTH = 760;+export const MIN_CHAT_CONTENT_MAX_WIDTH = 560;+/** Gutter kept on each side of the pane so handles and the minimap stay usable. */+export const CHAT_CONTENT_WIDTH_GUTTER = 24;++export type ChatContentResizeSide = "left" | "right";++/**+ * Persistable preference. Absent / invalid → default 760. Numbers below the+ * drag floor snap up; the live pane may still draw narrower than this.+ */+export function resolveChatContentMaxWidth(value: unknown): number {+ const normalized = normalizeChatContentMaxWidth(value);+ return normalized ?? DEFAULT_CHAT_CONTENT_MAX_WIDTH;+}++export function normalizeChatContentMaxWidth(+ value: unknown,+): number | undefined {+ if (typeof value !== "number" || !Number.isFinite(value)) return undefined;+ return Math.max(MIN_CHAT_CONTENT_MAX_WIDTH, Math.round(value));+}++/** Clamp a drag/keyboard candidate against the live pane. */+export function clampChatContentMaxWidth(+ width: number,+ paneWidth: number,+): number {+ const available = Math.max(+ 0,+ Math.round(paneWidth) - 2 * CHAT_CONTENT_WIDTH_GUTTER,+ );+ if (available <= 0) return MIN_CHAT_CONTENT_MAX_WIDTH;+ const floor = Math.min(MIN_CHAT_CONTENT_MAX_WIDTH, available);+ return Math.min(available, Math.max(floor, Math.round(width)));+}++/** Both handles move the same centered band: 1px pointer → 2px width. */+export function chatContentWidthFromDrag(args: {+ side: ChatContentResizeSide;+ startWidth: number;+ startClientX: number;+ clientX: number;+ paneWidth: number;+}): number {+ const delta = args.clientX - args.startClientX;+ const next =+ args.side === "left"+ ? args.startWidth - 2 * delta+ : args.startWidth + 2 * delta;+ return clampChatContentMaxWidth(next, args.paneWidth);+}diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.tsindex 00916d22b..dd403dc4d 100644--- a/packages/shared/src/index.ts+++ b/packages/shared/src/index.ts@@ -47,6 +47,7 @@ export * from "./github-feedback.js";export * from "./network-proxy.js";export * from "./attachment-limits.js";export * from "./font-size.js";+export * from "./chat-content-width.js";export * from "./racp.js";export * from "./trusted-extensions.js";export * from "./provider-retry.js";diff --git a/packages/shared/src/types/settings.ts b/packages/shared/src/types/settings.tsindex fc3122076..b3754d3ed 100644--- a/packages/shared/src/types/settings.ts+++ b/packages/shared/src/types/settings.ts@@ -86,6 +86,12 @@ export type AppSettings = {* does not change meaning with this preference.*/contextUsageDisplay?: ContextUsageDisplay;+ /**+ * Preferred centered chat band width in CSS px (D439). Absent means 760.+ * The live band is `min(available pane, this value)` so a squeezed sidebar+ * or work panel compresses without rewriting the preference.+ */+ chatContentMaxWidth?: number;onboardingDismissed: boolean;};