Skip to content

Commit 088f48a

Browse files
committed
fix(ui): adapt chat workspace rail and detail panel to narrow panes
The workspace rail and message detail panel keyed layout off viewport media queries, so narrow split-view panes and compact windows got crushed side-by-side columns, and below 1120px the rail was display:none with no way to reach workspace files. Chat panes now measure their own width with a ResizeObserver: under 800px the rail presents as the existing bottom-dock strip (side-dock controls hide), and when the chat + detail split has under 680px the detail panel stacks below the thread with a horizontal resize divider. The phone full-screen detail takeover is unchanged. Bottom-strip path and summary rows no longer flex-shrink into clipped text. Closes #104023
1 parent a1571f2 commit 088f48a

7 files changed

Lines changed: 273 additions & 39 deletions

File tree

‎docs/web/control-ui.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ The terminal is also available as a full-screen, terminal-only document at `/?vi
295295
- When a session's checkout sits on a non-default branch of a GitHub repository, the chat view pins pull request chips above the composer: PR number, repo, branch, diff counts, a CI pill, and draft/merged/closed state, each linking to the PR. The row shows at most two chips — live (open/draft) PRs first — and a "Show more" button reveals collapsed merged/closed history. The CI pill opens a small CI monitoring popover with passed/failed/running/skipped check counts and a link to the PR's checks page. Detection runs server-side through `controlUi.sessionPullRequests`, which reuses the Gateway's `GH_TOKEN`/`GITHUB_TOKEN` when set. When the GitHub API rate limit is hit, chips keep the last known status and show a warning that the status may be out of date; dismissing a chip hides it for that session in the current browser profile.
296296
- The session workspace rail in each Chat pane lists session files, project files, and artifacts. It docks to the pane's right edge by default; drag its header (or use the dock button) to move it to the bottom, and the choice is stored in the current browser profile. A collapsed rail takes no space at all: reopen it with ⇧⌘B, the files toggle in the split-pane header, or the floating files button in single-pane chat (both carry a changed-file count badge). The separate file, tool, and Canvas detail panel is unaffected.
297297
- The background tasks rail in each Chat pane lists the current agent's background tasks and subagents (`tasks.list` scoped by agent, kept live by `task` events): running work with a stop control, a collapsible finished section, and a View transcript link that opens the task's child session in the pane. Open it with the activity toggle in the split-pane header or the floating activity button in single-pane chat (both carry a running-count badge once loaded). The Tasks page remains the full cross-agent ledger.
298+
- The workspace rail and detail panel adapt to each pane's own width rather than the window: in a narrow pane or compact window the workspace rail always presents as a bottom strip (side-dock controls hide until the pane widens), and the detail panel stacks below the thread with a horizontal resize handle instead of sharing the row with it. Phone-sized viewports still open the detail panel full-screen.
298299
- The chat header model and thinking pickers patch the active session immediately through `sessions.patch`; they are persistent session overrides, not one-turn-only send options.
299300
- **Split view:** open it from the bottom-right page action, then split the active pane right or down for as many panes as fit. Each pane has its own session, transcript, composer, and tool stream.
300301
- Drag a session from the sidebar into chat to open it in a pane. An animated drop preview glides between zones and labels the outcome — "Split" over the exact half a new pane will occupy, "Open here" over a whole pane — and drops also work from single-pane mode.

‎ui/src/pages/chat/chat-pane.ts‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { consume } from "@lit/context";
22
import { html, nothing } from "lit";
3-
import { property } from "lit/decorators.js";
3+
import { property, state as litState } from "lit/decorators.js";
44
import type {
55
TaskSuggestion,
66
TaskSuggestionEvent,
@@ -133,6 +133,18 @@ const CHAT_SPACE_ACTIVATION_SELECTOR =
133133
"a[href], button, summary, [role='button'], [role='checkbox'], [role='link'], [role='radio'], [role='switch']";
134134
const CHAT_MODAL_SELECTOR = "dialog[open], [aria-modal='true']";
135135

136+
/* Pane-width thresholds (CSS px). Split panes and compact windows can be far
137+
* narrower than the viewport, so side-by-side layouts key off the pane's own
138+
* measured width, never viewport media queries. */
139+
// Side rail (230-280px) plus a readable thread; below this the rail docks bottom.
140+
const WORKSPACE_RAIL_SIDE_MIN_PANE_WIDTH = 800;
141+
// Widest the rail's grid column gets; a side-docked rail takes this from the
142+
// width available to the chat + detail-panel split.
143+
const WORKSPACE_RAIL_MAX_WIDTH = 280;
144+
// .chat-main min-width (312) + divider + .chat-sidebar min-width (300) + slack;
145+
// below this the detail panel stacks under the thread.
146+
const DETAIL_SIDEBAR_SIDE_MIN_WIDTH = 680;
147+
136148
const NEW_SESSION_ACTIVE_RUN_MESSAGE =
137149
"Start a new session after the active run or queued messages finish.";
138150
const NEW_SESSION_LIST_LOADING_MESSAGE =
@@ -174,6 +186,10 @@ class ChatPane extends OpenClawLightDomElement {
174186

175187
private readonly chatState = new ChatStateController<ChatPageHost>(this);
176188
private state: ChatPageHost | undefined;
189+
/* Infinity until the first ResizeObserver tick so an unmeasured pane keeps
190+
* the wide side-by-side layout instead of flashing the stacked one. */
191+
@litState() private paneWidth = Number.POSITIVE_INFINITY;
192+
private paneResizeObserver: ResizeObserver | null = null;
177193
private connectedClient: GatewayBrowserClient | null = null;
178194
private connectionGeneration = 0;
179195
private nativeDraftCleanup: (() => void) | null = null;
@@ -809,6 +825,16 @@ class ChatPane extends OpenClawLightDomElement {
809825

810826
override connectedCallback() {
811827
super.connectedCallback();
828+
if (typeof ResizeObserver === "function") {
829+
this.paneResizeObserver = new ResizeObserver((entries) => {
830+
const width = entries.at(-1)?.contentRect.width;
831+
// Hidden panes (narrow split view) report 0; keep the last real width.
832+
if (typeof width === "number" && width > 0 && width !== this.paneWidth) {
833+
this.paneWidth = width;
834+
}
835+
});
836+
this.paneResizeObserver.observe(this);
837+
}
812838
this.addEventListener("pointerdown", this.handlePaneFocus);
813839
this.addEventListener("focusin", this.handlePaneFocus);
814840
document.addEventListener("keydown", this.handleDocumentKeydown, true);
@@ -915,6 +941,8 @@ class ChatPane extends OpenClawLightDomElement {
915941
}
916942

917943
override disconnectedCallback() {
944+
this.paneResizeObserver?.disconnect();
945+
this.paneResizeObserver = null;
918946
this.connectionGeneration += 1;
919947
this.taskSuggestionsRequestVersion += 1;
920948
this.taskSuggestions = [];
@@ -1189,12 +1217,22 @@ class ChatPane extends OpenClawLightDomElement {
11891217
const canOpenRealtimeTalkSettings = hasOperatorAdminAccess(
11901218
this.context.gateway.snapshot.hello?.auth ?? null,
11911219
);
1192-
const sessionWorkspace = createSessionWorkspaceProps(state);
1220+
const sessionWorkspace = createSessionWorkspaceProps(state, {
1221+
narrowLayout: this.paneWidth < WORKSPACE_RAIL_SIDE_MIN_PANE_WIDTH,
1222+
});
11931223
const backgroundTasks = createBackgroundTasksProps(state, {
11941224
onOpenSession: (sessionKey) => {
11951225
this.onPaneSessionChange?.(this.paneId, sessionKey);
11961226
},
11971227
});
1228+
const railSideDocked =
1229+
!sessionWorkspace.collapsed &&
1230+
!sessionWorkspace.narrowLayout &&
1231+
sessionWorkspace.dock !== "bottom";
1232+
// Every open side rail (workspace and/or background tasks) narrows the
1233+
// room left for the chat + detail split.
1234+
const sideRailCount = (railSideDocked ? 1 : 0) + (backgroundTasks.collapsed ? 0 : 1);
1235+
const detailSplitWidth = this.paneWidth - sideRailCount * WORKSPACE_RAIL_MAX_WIDTH;
11981236
const props: ChatProps = {
11991237
paneId: this.paneId,
12001238
sessionKey: state.sessionKey,
@@ -1405,6 +1443,7 @@ class ChatPane extends OpenClawLightDomElement {
14051443
},
14061444
sidebarOpen: state.sidebarOpen,
14071445
sidebarContent: state.sidebarContent,
1446+
sidebarStacked: detailSplitWidth < DETAIL_SIDEBAR_SIDE_MIN_WIDTH,
14081447
splitRatio: state.splitRatio,
14091448
canvasPluginSurfaceUrl: state.hello?.pluginSurfaceUrls?.canvas ?? null,
14101449
onOpenSidebar: state.handleOpenSidebar,

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,92 @@ describeBrowserLayout.concurrent("chat responsive browser layout", () => {
13691369
},
13701370
);
13711371

1372+
it("stacks the detail sidebar below the thread in a narrow pane", async () => {
1373+
const page = await openBrowserPage(900, 700);
1374+
try {
1375+
// A 620px pane inside a wide viewport: chat-pane sets the stacked class
1376+
// when the pane cannot fit chat + detail panel side by side.
1377+
await page.setContent(
1378+
`<!doctype html><html><head><style>${readUiCss()}</style></head><body>
1379+
<div style="width: 620px; height: 600px; display: flex;">
1380+
<div class="chat-split-container chat-split-container--open chat-split-container--stacked">
1381+
<div class="chat-main" style="flex: 0 1 60%">
1382+
<div class="chat-thread" role="log">
1383+
<div class="chat-thread-inner">
1384+
<div class="chat-group assistant">
1385+
<div class="chat-avatar assistant">A</div>
1386+
<div class="chat-group-messages">
1387+
<div class="chat-bubble"><div class="chat-text">Stacked layout keeps the thread readable.</div></div>
1388+
</div>
1389+
</div>
1390+
</div>
1391+
</div>
1392+
</div>
1393+
<section class="chat-sidebar"><div class="sidebar-panel">Detail panel</div></section>
1394+
</div>
1395+
</div>
1396+
</body></html>`,
1397+
);
1398+
1399+
await expectNoHorizontalOverflow(page);
1400+
const main = await getRect(page, ".chat-main");
1401+
const sidebar = await getRect(page, ".chat-sidebar");
1402+
expect(sidebar.top).toBeGreaterThanOrEqual(main.bottom - 1);
1403+
expect(Math.abs(sidebar.width - main.width)).toBeLessThanOrEqual(1);
1404+
expect(sidebar.width).toBeGreaterThanOrEqual(618);
1405+
expect(sidebar.height).toBeGreaterThanOrEqual(160);
1406+
} finally {
1407+
await closeBrowserPage(page);
1408+
}
1409+
});
1410+
1411+
it("keeps the bottom-docked rail path and summary rows unclipped", async () => {
1412+
const page = await openBrowserPage(760, 700);
1413+
try {
1414+
await page.setContent(
1415+
`<!doctype html><html><head><style>${readUiCss()}</style></head><body>
1416+
<div class="chat-workbench chat-workbench--dock-bottom" style="height: 620px;">
1417+
<div class="chat-workbench__main"></div>
1418+
<aside class="chat-workspace-rail">
1419+
<div class="chat-workspace-rail__header">
1420+
<div class="chat-workspace-rail__title">
1421+
<span class="chat-workspace-rail__eyebrow">Session</span>
1422+
<strong>Workspace</strong>
1423+
</div>
1424+
</div>
1425+
<div class="chat-workspace-rail__path">/Users/steipete/.openclaw/workspace</div>
1426+
<div class="chat-workspace-rail__summary">
1427+
<span>0 changed</span><span>0 read</span><span>0 artifacts</span><span>15 shown</span>
1428+
</div>
1429+
<div class="chat-workspace-rail__scroll">
1430+
<section class="chat-workspace-rail__section">
1431+
<div class="chat-workspace-rail__section-title">Project files</div>
1432+
${Array.from(
1433+
{ length: 12 },
1434+
(_value, index) =>
1435+
`<div class="chat-workspace-rail__file">notes-file-${index}.md</div>`,
1436+
).join("")}
1437+
</section>
1438+
</div>
1439+
</aside>
1440+
</div>
1441+
</body></html>`,
1442+
);
1443+
1444+
const rail = await getRect(page, ".chat-workspace-rail");
1445+
const railPath = await getRect(page, ".chat-workspace-rail__path");
1446+
const summary = await getRect(page, ".chat-workspace-rail__summary");
1447+
// The strip is height-bounded; fixed rows must not shrink below their
1448+
// content, only the scroll section gives way.
1449+
expect(rail.height).toBeLessThanOrEqual(237);
1450+
expect(railPath.height).toBeGreaterThanOrEqual(30);
1451+
expect(summary.height).toBeGreaterThanOrEqual(20);
1452+
expect(summary.top).toBeGreaterThanOrEqual(railPath.bottom - 1);
1453+
} finally {
1454+
await closeBrowserPage(page);
1455+
}
1456+
});
1457+
13721458
it("keeps short-landscape composer adjunct rows scroll-reachable", async () => {
13731459
const page = await openFixture(568, 320, { composerAttachment: true });
13741460
try {

‎ui/src/pages/chat/chat-view.test.ts‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,7 @@ describe("chat composer workbench", () => {
11641164
error: null,
11651165
activeId: "file:/workspace/AGENTS.md",
11661166
dock: "right",
1167+
narrowLayout: false,
11671168
dockDragging: false,
11681169
dockDragZone: null,
11691170
onToggleCollapsed,
@@ -1259,6 +1260,7 @@ describe("chat composer workbench", () => {
12591260
error: null,
12601261
activeId: null,
12611262
dock: "right",
1263+
narrowLayout: false,
12621264
dockDragging: false,
12631265
dockDragZone: null,
12641266
onToggleCollapsed,
@@ -1297,6 +1299,7 @@ describe("chat composer workbench", () => {
12971299
error: null,
12981300
activeId: null,
12991301
dock: "right",
1302+
narrowLayout: false,
13001303
dockDragging: false,
13011304
dockDragZone: null,
13021305
onToggleCollapsed: () => undefined,
@@ -1315,6 +1318,57 @@ describe("chat composer workbench", () => {
13151318
expect(container.querySelector(".chat-workspace-rail")).toBeNull();
13161319
});
13171320

1321+
it("stacks the detail sidebar under the thread with a horizontal divider on narrow panes", () => {
1322+
const sidebarProps = {
1323+
sidebarOpen: true,
1324+
sidebarContent: { kind: "markdown", content: "Stacked detail" } as const,
1325+
onCloseSidebar: () => undefined,
1326+
};
1327+
const wide = renderChatView(sidebarProps);
1328+
const wideContainer = wide.querySelector(".chat-split-container");
1329+
expect(wideContainer?.classList.contains("chat-split-container--open")).toBe(true);
1330+
expect(wideContainer?.classList.contains("chat-split-container--stacked")).toBe(false);
1331+
// Attribute reflection is async; the property binding lands synchronously.
1332+
expect(wide.querySelector("resizable-divider")?.orientation).toBe("vertical");
1333+
1334+
const stacked = renderChatView({ ...sidebarProps, sidebarStacked: true });
1335+
const stackedContainer = stacked.querySelector(".chat-split-container");
1336+
expect(stackedContainer?.classList.contains("chat-split-container--stacked")).toBe(true);
1337+
expect(stacked.querySelector("resizable-divider")?.orientation).toBe("horizontal");
1338+
});
1339+
1340+
it("forces the workspace rail to the bottom dock and drops side-dock controls on narrow panes", () => {
1341+
const container = renderChatView({
1342+
sessionWorkspace: {
1343+
collapsed: false,
1344+
sessionKey: "agent:main",
1345+
list: null,
1346+
loading: false,
1347+
error: null,
1348+
activeId: null,
1349+
dock: "right",
1350+
narrowLayout: true,
1351+
dockDragging: false,
1352+
dockDragZone: null,
1353+
onToggleCollapsed: () => undefined,
1354+
onSetDock: () => undefined,
1355+
onDockDragStart: () => undefined,
1356+
onRefresh: () => undefined,
1357+
onBrowsePath: () => undefined,
1358+
onCopyPath: () => undefined,
1359+
onOpenFile: () => undefined,
1360+
onSearch: () => undefined,
1361+
onOpenArtifact: () => undefined,
1362+
},
1363+
});
1364+
1365+
const workbench = container.querySelector(".chat-workbench");
1366+
expect(workbench?.classList.contains("chat-workbench--dock-bottom")).toBe(true);
1367+
expect(container.querySelector(".chat-workspace-rail")).not.toBeNull();
1368+
expect(container.querySelector(".chat-workspace-rail__dock")).toBeNull();
1369+
expect(container.querySelector(".chat-workspace-rail__grip")).toBeNull();
1370+
});
1371+
13181372
it("keeps the secondary New session and Export controls suppressed in the composer", () => {
13191373
const container = renderChatView({
13201374
messages: [{ role: "assistant", content: "ready" }],

‎ui/src/pages/chat/chat-view.ts‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export type ChatProps = {
9595
) => Promise<DetailFullMessageResult | null | undefined>;
9696
sidebarOpen?: boolean;
9797
sidebarContent?: SidebarContent | null;
98+
/** Pane too narrow for side-by-side chat + detail panel: stack them
99+
* vertically instead (the divider flips to a horizontal handle). */
100+
sidebarStacked?: boolean;
98101
splitRatio?: number;
99102
canvasPluginSurfaceUrl?: string | null;
100103
embedSandboxMode?: EmbedSandboxMode;
@@ -181,6 +184,11 @@ export function renderChat(props: ChatProps) {
181184
const requestUpdate = props.onRequestUpdate ?? (() => {});
182185
const splitRatio = props.splitRatio ?? 0.6;
183186
const sidebarOpen = Boolean(props.sidebarOpen && props.onCloseSidebar);
187+
const sidebarStacked = props.sidebarStacked === true;
188+
const workspaceDockBottom = Boolean(
189+
props.sessionWorkspace &&
190+
(props.sessionWorkspace.dock === "bottom" || props.sessionWorkspace.narrowLayout),
191+
);
184192
const canCompose = props.canSend;
185193
let chatSection: HTMLElement | null = null;
186194

@@ -363,9 +371,10 @@ export function renderChat(props: ChatProps) {
363371
<div
364372
class="chat-workbench ${props.sessionWorkspace?.collapsed
365373
? "chat-workbench--workspace-collapsed"
366-
: ""} ${props.sessionWorkspace?.dock === "bottom"
367-
? "chat-workbench--dock-bottom"
368-
: ""} ${props.backgroundTasks?.collapsed === false ? "chat-workbench--tasks-open" : ""}"
374+
: ""} ${workspaceDockBottom ? "chat-workbench--dock-bottom" : ""} ${props.backgroundTasks
375+
?.collapsed === false
376+
? "chat-workbench--tasks-open"
377+
: ""}"
369378
>
370379
${renderSessionWorkspaceRail(props.sessionWorkspace)}
371380
${renderBackgroundTasksRail(props.backgroundTasks)}
@@ -398,7 +407,11 @@ export function renderChat(props: ChatProps) {
398407
${props.backgroundTasks?.collapsed && !props.paneHeaderActive
399408
? renderBackgroundTasksToggle(props.backgroundTasks, "floating")
400409
: nothing}
401-
<div class="chat-split-container ${sidebarOpen ? "chat-split-container--open" : ""}">
410+
<div
411+
class="chat-split-container ${sidebarOpen
412+
? "chat-split-container--open"
413+
: ""} ${sidebarOpen && sidebarStacked ? "chat-split-container--stacked" : ""}"
414+
>
402415
<div
403416
class="chat-main"
404417
style="flex: ${sidebarOpen ? `0 1 ${splitRatio * 100}%` : "1 1 100%"}"
@@ -427,6 +440,7 @@ export function renderChat(props: ChatProps) {
427440
<resizable-divider
428441
.splitRatio=${splitRatio}
429442
.label=${t("nav.resize")}
443+
.orientation=${sidebarStacked ? "horizontal" : "vertical"}
430444
@resize=${(event: CustomEvent) =>
431445
props.onSplitRatioChange?.(event.detail.splitRatio)}
432446
></resizable-divider>

0 commit comments

Comments
 (0)