Skip to content

Commit e6ffc30

Browse files
fazxesclaude
andcommitted
fix(chat): improve layout centering and reduce max-width to 650px
- Remove scrollbar-gutter issues by using stable both-edges - Simplify message width hierarchy: single mx-auto on parent wrapper - Use padding (9px each side) for assistant messages instead of max-width - Reduce chat max-width from 800px to 650px for narrower layout - Centralize spacing constants in CHAT_SPACING for maintainability - Remove unused --chat-width-secondary CSS variable 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 22d670b commit e6ffc30

3 files changed

Lines changed: 25 additions & 31 deletions

File tree

‎apps/agent/src/components/chat/messages/message-item.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import type { ToolExecution } from '@/stores/tool-store';
2323
import type { FC } from 'react';
2424

2525
import { FileIcon } from '@/components/files';
26-
import { CHAT_WIDTH, CHAT_WIDTH_VAR } from '@/lib/constants';
26+
import { CHAT_SPACING, CHAT_WIDTH, CHAT_WIDTH_VAR } from '@/lib/constants';
2727

2828
export interface ChatMessage {
2929
id: string;
@@ -268,17 +268,18 @@ export const MessageItem: FC<MessageItemProps> = memo(function MessageItem({
268268
{message.role === 'user' ? (
269269
/* User message bubble */
270270
<div
271-
className="p-2 mx-auto rounded-xl bg-card border border-border/40 shadow-[0_1px_3px_rgba(0,0,0,0.05)]"
271+
className="p-2 rounded-xl bg-card border border-border/40 shadow-[0_1px_3px_rgba(0,0,0,0.05)]"
272272
style={{ maxWidth: `var(${CHAT_WIDTH_VAR.primary}, ${String(CHAT_WIDTH.primary)}px)` }}
273273
>
274274
<p className="text-sm leading-relaxed whitespace-pre-wrap">{message.displayedContent}</p>
275275
</div>
276276
) : (
277277
/* Assistant message - no bubble, content flows naturally */
278278
<div
279-
className="py-1 mx-auto"
279+
className="py-1"
280280
style={{
281-
maxWidth: `var(${CHAT_WIDTH_VAR.secondary}, ${String(CHAT_WIDTH.secondary)}px)`,
281+
paddingLeft: CHAT_SPACING.assistantPadding,
282+
paddingRight: CHAT_SPACING.assistantPadding,
282283
}}
283284
>
284285
{/* Thinking Box - show when thinking content exists */}

‎apps/agent/src/globals.css‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,10 @@
201201
--terminal-cursor: oklch(0.85 0.01 75);
202202

203203
/* Chat Layout Width System
204-
Primary = input box, user message bubbles (full width)
205-
Secondary = assistant content, tools (slightly narrower for visual hierarchy) */
206-
--chat-max-width: 800px;
204+
Primary = input box, user message bubbles, content wrapper
205+
Assistant messages use padding for consistent narrower width at all screen sizes */
206+
--chat-max-width: 650px;
207207
--chat-width-primary: var(--chat-max-width);
208-
--chat-width-secondary: calc(var(--chat-max-width) - 32px);
209208
}
210209

211210
/* Responsive chat widths - scales down on smaller screens */

‎apps/agent/src/lib/constants.ts‎

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,33 @@ export const PANEL_SIZES = {
4949
/**
5050
* Chat Layout Width System
5151
*
52-
* Width hierarchy:
53-
* - Primary (800px): Input box, user message bubbles
54-
* - Secondary (768px): Assistant messages, tool widgets
52+
* Layout approach:
53+
* - Primary (650px max-width): Input box, user message bubbles, content wrapper
54+
* - Assistant messages: Use padding for consistent narrower width at all screen sizes
5555
*
56-
* Uses CSS custom properties for responsive behavior.
57-
* Components should use CHAT_WIDTH_VAR with fallbacks.
56+
* Uses CSS custom properties (--chat-width-primary) for responsive behavior.
57+
* The responsive breakpoints in globals.css scale --chat-max-width on smaller screens.
5858
*/
5959
export const CHAT_WIDTH = {
6060
/** Base max-width for all chat content */
61-
base: 800,
62-
/** Input box and user message bubbles */
63-
primary: 800,
64-
/** Assistant messages, tool widgets, markdown content (32px narrower) */
65-
secondary: 768,
61+
base: 650,
62+
/** Input box, user message bubbles, content wrapper */
63+
primary: 650,
6664
/** Dropdown menus */
6765
dropdown: 200,
6866
/** File name truncation */
6967
fileName: 200,
7068
} as const;
7169

70+
/**
71+
* Chat layout spacing
72+
* Used for consistent margins/padding in chat messages
73+
*/
74+
export const CHAT_SPACING = {
75+
/** Horizontal padding for assistant messages (9px each side = 18px narrower than user bubble) */
76+
assistantPadding: 9,
77+
} as const;
78+
7279
/**
7380
* CSS variable names for chat widths
7481
* Use these with var() in style props for responsive behavior
@@ -78,19 +85,6 @@ export const CHAT_WIDTH = {
7885
*/
7986
export const CHAT_WIDTH_VAR = {
8087
primary: '--chat-width-primary',
81-
secondary: '--chat-width-secondary',
82-
} as const;
83-
84-
/**
85-
* @deprecated Use CHAT_WIDTH instead
86-
* Legacy export for backwards compatibility
87-
*/
88-
export const CONTENT_WIDTH = {
89-
inputBox: CHAT_WIDTH.primary,
90-
messageFeed: CHAT_WIDTH.secondary,
91-
dropdown: CHAT_WIDTH.dropdown,
92-
fileName: CHAT_WIDTH.fileName,
93-
expandedContent: 400,
9488
} as const;
9589

9690
/**

0 commit comments

Comments
 (0)