Skip to content

Commit b840a3c

Browse files
fix(ui): widen mobile chat transcript (#128944)
Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
1 parent 3b0cad5 commit b840a3c

3 files changed

Lines changed: 37 additions & 11 deletions

File tree

‎ui/src/pages/chat/chat-responsive.browser.test.ts‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2207,11 +2207,18 @@ describeBrowserLayout.concurrent("chat responsive browser layout", () => {
22072207
[393, 852],
22082208
[1366, 900],
22092209
] as const)(
2210-
"anchors received bubbles left and sent bubbles right at %sx%s",
2210+
"anchors message roles and balances transcript width at %sx%s",
22112211
async (width, height) => {
22122212
const page = await openFixture(width, height);
22132213
try {
22142214
const roles = await page.evaluate(() => {
2215+
const transcriptViewport = document.querySelector<HTMLElement>(".chat-thread")!;
2216+
const widthProbe = document.createElement("div");
2217+
widthProbe.style.width = "100%";
2218+
widthProbe.style.height = "0";
2219+
transcriptViewport.append(widthProbe);
2220+
const transcriptAvailableWidth = widthProbe.getBoundingClientRect().width;
2221+
widthProbe.remove();
22152222
const rectFor = (selector: string) => {
22162223
const node = document.querySelector(selector) as HTMLElement | null;
22172224
if (!node) {
@@ -2228,16 +2235,36 @@ describeBrowserLayout.concurrent("chat responsive browser layout", () => {
22282235
return {
22292236
assistantLane: rectFor(".chat-group.assistant .chat-group-messages"),
22302237
assistantBubble: rectFor(".chat-group.assistant .chat-bubble:first-child"),
2238+
transcript: rectFor(".chat-thread-inner"),
2239+
transcriptViewport: rectFor(".chat-thread"),
2240+
transcriptAvailableWidth,
22312241
userLane: rectFor(".chat-group.user .chat-group-messages"),
22322242
userBubble: rectFor(".chat-group.user .chat-bubble:first-child"),
22332243
};
22342244
});
22352245

22362246
const assistantLane = expectControlRect(roles.assistantLane, "assistant message lane");
22372247
const assistantBubble = expectControlRect(roles.assistantBubble, "assistant bubble");
2248+
const transcript = expectControlRect(roles.transcript, "transcript");
2249+
const transcriptViewport = expectControlRect(
2250+
roles.transcriptViewport,
2251+
"transcript viewport",
2252+
);
22382253
const userLane = expectControlRect(roles.userLane, "user message lane");
22392254
const userBubble = expectControlRect(roles.userBubble, "user bubble");
22402255

2256+
expect(
2257+
Math.abs(
2258+
transcript.x +
2259+
transcript.width / 2 -
2260+
(transcriptViewport.x + transcriptViewport.width / 2),
2261+
),
2262+
).toBeLessThanOrEqual(1);
2263+
if (width <= 768) {
2264+
expect(roles.transcriptAvailableWidth - transcript.width).toBeCloseTo(32, 0);
2265+
} else {
2266+
expect(transcript.width).toBeCloseTo(768, 0);
2267+
}
22412268
expect(Math.abs(assistantBubble.x - assistantLane.x)).toBeLessThanOrEqual(1);
22422269
expect(
22432270
Math.abs(userBubble.x + userBubble.width - (userLane.x + userLane.width)),

‎ui/src/styles/chat/layout.css‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ openclaw-chat-page {
1212

1313
.chat {
1414
--chat-thread-max-width: 48rem;
15-
/* Half of the transcript's shared side gutter. .chat-thread keeps this strip
16-
free on both edges so its scrollbar hugs the pane edge, so overlays that
17-
paint across the thread (the header fade) must stop at it or they cover
18-
the thumb. */
15+
/* Keep overlays clear of the edge-hugging scrollbar and add room on wide screens. */
1916
--chat-thread-gutter: 18px;
17+
--chat-thread-side-inset: clamp(6px, 1vw, 12px);
2018

2119
position: relative;
2220
display: flex;
@@ -366,15 +364,15 @@ openclaw-chat-page {
366364
/* Shared gutter plus the responsive side inset that used to be
367365
.chat-thread's horizontal padding (moved off the scroll container so
368366
overlay scrollbars sit flush at the pane edge). */
369-
width: calc(100% - 2 * var(--chat-thread-gutter) - 2 * clamp(6px, 1vw, 12px));
367+
width: calc(100% - 2 * var(--chat-thread-gutter) - 2 * var(--chat-thread-side-inset));
370368
max-width: var(--chat-thread-max-width);
371369
margin-inline: auto;
372370
}
373371

374372
.chat-inline-approval {
375373
box-sizing: border-box;
376374
flex: 0 0 auto;
377-
width: calc(100% - 2 * var(--chat-thread-gutter) - 2 * clamp(6px, 1vw, 12px));
375+
width: calc(100% - 2 * var(--chat-thread-gutter) - 2 * var(--chat-thread-side-inset));
378376
max-width: var(--chat-thread-max-width);
379377
margin: 8px auto;
380378
}
@@ -4119,6 +4117,11 @@ button.chat-pr__diff {
41194117
}
41204118

41214119
@media (max-width: 768px), (max-width: 932px) and (max-height: 500px) and (orientation: landscape) {
4120+
.chat {
4121+
--chat-thread-gutter: 16px;
4122+
--chat-thread-side-inset: 0px;
4123+
}
4124+
41224125
.agent-chat__input {
41234126
--chat-box-inset: 4px;
41244127
--chat-composer-control-height: 44px;

‎ui/src/styles/layout.mobile.css‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,6 @@ html.openclaw-native-macos body .shell--mobile-nav .topnav-shell__actions {
522522
padding: 0 0 12px;
523523
}
524524

525-
.chat-thread-inner {
526-
width: calc(100% - 36px - 16px);
527-
}
528-
529525
.chat-msg {
530526
max-width: 90%;
531527
}

0 commit comments

Comments
 (0)