feat(agents): add "Fit conversation to the window width" chat setting (#3455)

Settings › Agents › Chat › Conversation gets an opt-in toggle (agents.fitWindowWidth, off by default). When on, the conversation stream, composer, question card, user message bubbles and the New Task page drop their max-width caps and follow the pane width; when off, the readable 900 px column stays.

Co-authored-by: dengliu <[email protected]>
Цей коміт міститься в:
Deng Liuтаdengliu authored and GitHub committed 2026-11-15 09:50:13 +08:00
1 джерело 59fba1a65d
коміт 8432bf9997
15 files changed
+186 -4

No files matched your search

+4
Переглянути файл
@@ -2253,6 +2253,8 @@ export type AgentSettings_Deserialize = {
foldTurns?: boolean,
/** Streaming text is revealed at a steady pace rather than chunk by chunk. */
smoothText?: boolean,
/** Conversations and the composer expand to the full width of the pane instead of staying in a centred column. */
fitWindowWidth?: boolean,
thinking?: ThinkingDisplay,
toolCalls?: ToolCallDisplay,
/** A tool call's output (a command's, a diff) is shown without opening it. */
@@ -2291,6 +2293,8 @@ export type AgentSettings_Serialize = {
foldTurns: boolean,
/** Streaming text is revealed at a steady pace rather than chunk by chunk. */
smoothText: boolean,
/** Conversations and the composer expand to the full width of the pane instead of staying in a centred column. */
fitWindowWidth: boolean,
thinking: ThinkingDisplay,
toolCalls: ToolCallDisplay,
/** A tool call's output (a command's, a diff) is shown without opening it. */
+3
Переглянути файл
@@ -17,6 +17,9 @@
flex-direction: column;
gap: 8px;
}
.fitWidth .inner {
width: 100%;
}
.heading {
margin: 0 0 10px;
font-size: 18px;
+16
Переглянути файл
@@ -3,6 +3,7 @@ import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import type { AgentConfigOption, AgentProvider, NewAgentTask } from "@/bindings";
import { useProject } from "@/platform/project";
import { HomeEditor } from "./HomeEditor";
import homeStyles from "./Home.module.css";
import { HOME, disconnect, savedDraft, updateComposer, useAgents } from "./store";
const backend = vi.hoisted(() => ({ providers: [] as AgentProvider[], create: vi.fn() }));
@@ -150,3 +151,18 @@ it.each([
useProject.setState({ settings });
}
});
it("applies fitWidth on the New Task page only when fitWindowWidth is enabled", () => {
const settings = useProject.getState().settings;
try {
useProject.setState({ settings: { ...settings, agents: { ...settings?.agents, fitWindowWidth: false } } as never });
const { container, rerender } = render(<HomeEditor />);
const root = container.querySelector(`.${homeStyles.home}`)!;
expect(root).not.toHaveClass(homeStyles.fitWidth!);
useProject.setState({ settings: { ...settings, agents: { ...settings?.agents, fitWindowWidth: true } } as never });
rerender(<HomeEditor />);
expect(root).toHaveClass(homeStyles.fitWidth!);
} finally {
useProject.setState({ settings });
}
});
+2 -2
Переглянути файл
@@ -93,7 +93,7 @@ export function HomeEditor({ docked = false }: { docked?: boolean; input?: Edito
window.addEventListener("focus", refresh);
return () => window.removeEventListener("focus", refresh);
}, [provider?.id, provider?.installed, launch, project?.root]);
const defaults = useAgentSettings().defaults;
const { defaults, fitWindowWidth } = useAgentSettings();
const config = draftConfig(provider, draft, (provider && defaults[provider.id]) || {});
const homeRoot = useRef<HTMLDivElement>(null);
const shown = useEditorShown();
@@ -127,7 +127,7 @@ export function HomeEditor({ docked = false }: { docked?: boolean; input?: Edito
};
return (
<div ref={homeRoot} className={clsx(styles.home, docked && styles.docked)}>
<div ref={homeRoot} className={clsx(styles.home, docked && styles.docked, fitWindowWidth && styles.fitWidth)}>
<div className={styles.inner}>
{!docked && (
<h1 className={styles.heading}>
+13
Переглянути файл
@@ -66,6 +66,19 @@
.withChanges {
grid-template-columns: minmax(min(240px, 50%), 1fr) minmax(0, var(--agent-changes-width, 280px));
}
.fitWidth .stream > * {
width: 100%;
}
.fitWidth .userMessage > .user {
max-width: var(--session-card-width);
}
.fitWidth .composerArea {
max-width: none;
}
.fitWidth .questionCard {
width: calc(100% - var(--space-3) * 2);
max-width: none;
}
.providerIcon {
color: var(--fg-muted);
+7 -1
Переглянути файл
@@ -209,6 +209,7 @@ function TaskSession({ id, docked }: { id: string; docked: boolean }) {
const [finding, setFinding] = useState(false);
const [findFocus, setFindFocus] = useState(0);
const [inputFocus, setInputFocus] = useState(0);
const { fitWindowWidth } = useAgentSettings();
const sessionRoot = useRef<HTMLDivElement>(null);
const canFocusInput = shown && !!task && task.status !== "archived" && !view;
const session = useMemo<FocusedSession>(
@@ -236,7 +237,12 @@ function TaskSession({ id, docked }: { id: string; docked: boolean }) {
return (
<div
ref={sessionRoot}
className={clsx(styles.session, docked && styles.docked, changesOpen && !docked && styles.withChanges)}
className={clsx(
styles.session,
docked && styles.docked,
changesOpen && !docked && styles.withChanges,
fitWindowWidth && styles.fitWidth,
)}
style={changesWidth}
onFocusCapture={() => shown && setFocusedSession(session)}
onBlurCapture={(e) => {
+1
Переглянути файл
@@ -12,6 +12,7 @@ export const AGENT_SETTINGS_DEFAULTS: ResolvedAgentSettings = {
showCost: false,
foldTurns: true,
smoothText: true,
fitWindowWidth: false,
thinking: "auto",
toolCalls: "grouped",
expandToolOutput: false,
+26
Переглянути файл
@@ -1817,6 +1817,32 @@ describe("meters in the task header", () => {
expect(screen.getByText("$0.42")).toBeInTheDocument();
});
it("toggles fitWidth on the session root from settings.agents.fitWindowWidth", () => {
const { container } = render(<SessionEditor input={input("A")} />);
const root = container.querySelector(`.${styles.session}`)!;
expect(root).not.toHaveClass(styles.fitWidth!);
act(() =>
useProject.setState({
settings: {
agents: {
fitWindowWidth: true,
},
} as never,
}),
);
expect(root).toHaveClass(styles.fitWidth!);
act(() =>
useProject.setState({
settings: {
agents: {
fitWindowWidth: false,
},
} as never,
}),
);
expect(root).not.toHaveClass(styles.fitWidth!);
});
it("hides the status-bar Terminal button in the local checkout and opens the worktree's terminal otherwise", async () => {
const opened: unknown[] = [];
const disposeTerminal = registerActions([
+6 -1
Переглянути файл
@@ -10,6 +10,7 @@ describe("agent chat settings", () => {
showCost: false,
foldTurns: true,
smoothText: true,
fitWindowWidth: false,
thinking: "auto",
toolCalls: "grouped",
expandToolOutput: false,
@@ -19,13 +20,17 @@ describe("agent chat settings", () => {
defaults: {},
mcpServers: {},
});
const stored = validateSettings({ agents: { showUsageLimits: false, showCost: true, showWorkTime: "no" } }).agents;
const stored = validateSettings({
agents: { showUsageLimits: false, showCost: true, showWorkTime: "no", fitWindowWidth: true },
}).agents;
expect(stored).toMatchObject({
showContextUsage: true,
showWorkTime: true,
showUsageLimits: false,
showCost: true,
fitWindowWidth: true,
});
expect(validateSettings({ agents: { fitWindowWidth: "yes" } }).agents.fitWindowWidth).toBe(false);
});
it("keeps valid chat choices and per-agent defaults", () => {
+2
Переглянути файл
@@ -212,6 +212,7 @@ export const DEFAULT_SETTINGS: ValidSettings = {
showCost: false,
foldTurns: true,
smoothText: true,
fitWindowWidth: false,
thinking: "auto",
toolCalls: "grouped",
expandToolOutput: false,
@@ -391,6 +392,7 @@ export function validateSettings(raw: Settings | unknown): ValidSettings {
showCost: bool(agents.showCost, d.agents.showCost),
foldTurns: bool(agents.foldTurns, d.agents.foldTurns),
smoothText: bool(agents.smoothText, d.agents.smoothText),
fitWindowWidth: bool(agents.fitWindowWidth, d.agents.fitWindowWidth),
thinking: oneOf(agents.thinking, ["auto", "expanded", "collapsed"] as const, d.agents.thinking),
toolCalls: oneOf(agents.toolCalls, ["grouped", "each"] as const, d.agents.toolCalls),
expandToolOutput: bool(agents.expandToolOutput, d.agents.expandToolOutput),
+6
Переглянути файл
@@ -672,6 +672,7 @@ export const TOOLS_PAGES: PageSpec[] = [
"approval",
"permission",
"bypass",
"width",
],
sections: [
{
@@ -727,6 +728,11 @@ export const TOOLS_PAGES: PageSpec[] = [
label: "Reveal streaming text smoothly",
hint: "Text appears at a steady pace instead of in bursts",
},
{
kind: "toggle",
key: "agents.fitWindowWidth",
label: "Fit conversation to the window width",
},
],
},
{
+1
Переглянути файл
@@ -1160,6 +1160,7 @@
"Show tool output without opening it": "Show tool output without opening it",
"Reveal streaming text smoothly": "Reveal streaming text smoothly",
"Text appears at a steady pace instead of in bursts": "Text appears at a steady pace instead of in bursts",
"Fit conversation to the window width": "Fit conversation to the window width",
"⌘Enter": "⌘Enter",
"No checksum provided: the download can't be verified.": "No checksum provided: the download can't be verified.",
"Sign In": "Sign In",
+1
Переглянути файл
@@ -7530,6 +7530,7 @@
"Show tool output without opening it": "默认展开工具输出",
"Reveal streaming text smoothly": "平滑显示生成中的文字",
"Text appears at a steady pace instead of in bursts": "文字匀速出现,而不是一段一段地跳出",
"Fit conversation to the window width": "对话适应窗口宽度",
"⌘Enter": "⌘Enter",
"No checksum provided: the download can't be verified.": "未提供校验和:无法校验下载的文件。",
"Sign In": "登录",