Skip to content

Commit 73d3ee0

Browse files
committed
improve(ui): consolidate dashboard chat visibility into one Chat/Split/Dashboard toggle
The dashboard face spread chat visibility across three separate affordances: a two-option face toggle, an icon-only dock dropdown among the header actions, and a floating vertically-rotated "Show chat" button on the board edge that users could not discover. One concept, three controls. The header now renders a single segmented control - Chat | Split | Dashboard - where Split is dashboard plus docked chat and Dashboard is board-only (the former "Hide chat"). A compact caret attached to the pill picks the dock side (left/right/bottom) and only appears in Split mode when dock mutation is allowed; read-only sessions keep the plain two-option Chat | Dashboard toggle. The floating reopen button, the standalone dock menu button, and their CSS (including the mobile overrides) are deleted, so the header ends up with fewer buttons than before. Verified in the mock-gateway dev harness: mode mapping, caret dropdown, unhide-to-remembered-side, and hidden dock rendering board-only.
1 parent de93143 commit 73d3ee0

8 files changed

Lines changed: 254 additions & 209 deletions

File tree

‎ui/src/i18n/locales/en.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4465,14 +4465,13 @@ export const en: TranslationMap = {
44654465
board: {
44664466
faceLabel: "Thread face",
44674467
chatFace: "Chat",
4468+
splitFace: "Split",
44684469
dashboardFace: "Dashboard",
44694470
dockMenu: "Chat dock: {dock}",
44704471
dockLeft: "Dock chat left",
44714472
dockRight: "Dock chat right",
44724473
dockBottom: "Dock chat bottom",
4473-
dockHidden: "Hide chat",
44744474
resizeDock: "Resize chat dock",
4475-
reopenChat: "Show chat",
44764475
workboardCard: "Workboard card: {title}, {status}",
44774476
defaultTab: "Main",
44784477
mockPlaceholder: "Board view seam · {tabs} tabs · {widgets} widgets",

‎ui/src/pages/chat/board-session-surface.test.ts‎

Lines changed: 124 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
import { html, render } from "lit";
44
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
55
import { boardProviderForSession } from "../../lib/board/provider.ts";
6-
import type { BoardTab } from "../../lib/board/types.ts";
76
import { installBrowserHistoryIsolation } from "../../test-helpers/browser-history.ts";
8-
import { renderBoardFaceToggle, renderBoardSessionSurface } from "./board-session-surface.ts";
7+
import { renderBoardSessionSurface, renderBoardViewSwitch } from "./board-session-surface.ts";
98

109
const containers: HTMLElement[] = [];
1110

@@ -41,7 +40,6 @@ describe("board session shell", () => {
4140
snapshot: provider.snapshot$.value,
4241
activeTabId: "main",
4342
dock: "right" as const,
44-
reopenDock: "right" as const,
4543
dockSize: { height: 300 },
4644
chat: html`<div>chat</div>`,
4745
divider: html`<div></div>`,
@@ -53,7 +51,6 @@ describe("board session shell", () => {
5351
selectTab: () => {},
5452
},
5553
widgetFrameUrl: (name: string, revision: number) => provider.widgetFrameUrl(name, revision),
56-
onDockChange: () => {},
5754
};
5855

5956
render(
@@ -77,35 +74,142 @@ describe("board session shell", () => {
7774
expect(unlinked.querySelector("openclaw-workboard-card-chip")).toBeNull();
7875
});
7976

80-
it("shows the face toggle only when a board exists", () => {
81-
const withoutBoard = createContainer();
82-
const withBoard = createContainer();
77+
it("renders nothing without a board", () => {
78+
const container = createContainer();
79+
render(
80+
renderBoardViewSwitch({
81+
hasBoard: false,
82+
face: "chat",
83+
dock: "right",
84+
canChangeDock: true,
85+
onSelectMode: () => {},
86+
onDockSideChange: () => {},
87+
}),
88+
container,
89+
);
90+
91+
expect(container.querySelector(".chat-pane__face-switch")).toBeNull();
92+
expect(container.querySelector("wa-radio-group")).toBeNull();
93+
expect(container.querySelector("wa-dropdown")).toBeNull();
94+
});
8395

96+
it.each([
97+
["chat", "left", "chat"],
98+
["chat", "right", "chat"],
99+
["chat", "bottom", "chat"],
100+
["chat", "hidden", "chat"],
101+
["dashboard", "left", "split"],
102+
["dashboard", "right", "split"],
103+
["dashboard", "bottom", "split"],
104+
["dashboard", "hidden", "dashboard"],
105+
] as const)("maps %s with a %s dock to the %s mode", (face, dock, activeMode) => {
106+
const container = createContainer();
84107
render(
85-
renderBoardFaceToggle(false, "chat", () => {}),
86-
withoutBoard,
108+
renderBoardViewSwitch({
109+
hasBoard: true,
110+
face,
111+
dock,
112+
canChangeDock: true,
113+
onSelectMode: () => {},
114+
onDockSideChange: () => {},
115+
}),
116+
container,
87117
);
118+
119+
expect(
120+
[...container.querySelectorAll("wa-radio")].map((radio) => radio.getAttribute("value")),
121+
).toEqual(["chat", "split", "dashboard"]);
122+
expect(
123+
container.querySelector("wa-radio.settings-segmented__btn--active")?.getAttribute("value"),
124+
).toBe(activeMode);
125+
});
126+
127+
it("falls back to the two face options when dock changes are unavailable", () => {
128+
const container = createContainer();
88129
render(
89-
renderBoardFaceToggle(true, "chat", () => {}),
90-
withBoard,
130+
renderBoardViewSwitch({
131+
hasBoard: true,
132+
face: "dashboard",
133+
dock: "right",
134+
canChangeDock: false,
135+
onSelectMode: () => {},
136+
onDockSideChange: () => {},
137+
}),
138+
container,
91139
);
92140

93-
expect(withoutBoard.querySelector("wa-radio-group")).toBeNull();
94-
expect(withBoard.querySelectorAll("wa-radio")).toHaveLength(2);
141+
expect(
142+
[...container.querySelectorAll("wa-radio")].map((radio) => radio.getAttribute("value")),
143+
).toEqual(["chat", "dashboard"]);
144+
expect(
145+
container.querySelector("wa-radio.settings-segmented__btn--active")?.getAttribute("value"),
146+
).toBe("dashboard");
147+
expect(container.querySelector("wa-dropdown")).toBeNull();
95148
});
96149

97-
it("supports keyboard face selection", () => {
150+
it.each([
151+
["chat", "right", true, false],
152+
["dashboard", "right", true, true],
153+
["dashboard", "hidden", true, false],
154+
["dashboard", "right", false, false],
155+
] as const)(
156+
"shows the dock caret for face=%s dock=%s canChangeDock=%s: %s",
157+
(face, dock, canChangeDock, hasCaret) => {
158+
const container = createContainer();
159+
const onDockSideChange = vi.fn();
160+
render(
161+
renderBoardViewSwitch({
162+
hasBoard: true,
163+
face,
164+
dock,
165+
canChangeDock,
166+
onSelectMode: () => {},
167+
onDockSideChange,
168+
}),
169+
container,
170+
);
171+
172+
const dropdown = container.querySelector("wa-dropdown.chat-pane__dock-caret");
173+
expect(dropdown !== null).toBe(hasCaret);
174+
if (!dropdown) {
175+
return;
176+
}
177+
const items = [...dropdown.querySelectorAll("wa-dropdown-item")];
178+
expect(items.map((item) => item.getAttribute("value"))).toEqual(["left", "right", "bottom"]);
179+
expect(items.find((item) => item.hasAttribute("checked"))?.getAttribute("value")).toBe(
180+
"right",
181+
);
182+
const left = dropdown.querySelector('wa-dropdown-item[value="left"]');
183+
Reflect.set(left ?? {}, "value", "left");
184+
dropdown.dispatchEvent(
185+
new CustomEvent("wa-select", { bubbles: true, detail: { item: left } }),
186+
);
187+
expect(onDockSideChange).toHaveBeenCalledWith("left");
188+
},
189+
);
190+
191+
it("emits the selected view mode", () => {
98192
const container = createContainer();
99-
const onChange = vi.fn();
100-
render(renderBoardFaceToggle(true, "chat", onChange), container);
193+
const onSelectMode = vi.fn();
194+
render(
195+
renderBoardViewSwitch({
196+
hasBoard: true,
197+
face: "chat",
198+
dock: "right",
199+
canChangeDock: true,
200+
onSelectMode,
201+
onDockSideChange: () => {},
202+
}),
203+
container,
204+
);
101205

102206
const group = container.querySelector<HTMLElement & { value: string }>("wa-radio-group");
103207
if (group) {
104-
group.value = "dashboard";
208+
group.value = "split";
105209
group.dispatchEvent(new Event("change", { bubbles: true }));
106210
}
107211

108-
expect(onChange).toHaveBeenCalledWith("dashboard");
212+
expect(onSelectMode).toHaveBeenCalledWith("split");
109213
});
110214

111215
it.each(["left", "right", "bottom"] as const)("lays out the %s dock", (dock) => {
@@ -116,7 +220,6 @@ describe("board session shell", () => {
116220
snapshot: provider.snapshot$.value,
117221
activeTabId: "main",
118222
dock,
119-
reopenDock: "right",
120223
dockSize: { height: 300 },
121224
chat: html`<div data-test-chat>chat</div>`,
122225
divider: html`<div class="board-session-surface__divider" data-test-divider></div>`,
@@ -128,7 +231,6 @@ describe("board session shell", () => {
128231
selectTab: () => {},
129232
},
130233
widgetFrameUrl: (name, revision) => provider.widgetFrameUrl(name, revision),
131-
onDockChange: () => {},
132234
}),
133235
container,
134236
);
@@ -139,16 +241,14 @@ describe("board session shell", () => {
139241
expect(container.querySelector("openclaw-board-view")).not.toBeNull();
140242
});
141243

142-
it("collapses hidden chat to a reopen affordance", () => {
244+
it("renders the hidden dock as board-only", () => {
143245
const container = createContainer();
144246
const provider = boardProviderForSession("agent:main:main");
145-
const onDockChange = vi.fn<(dock: BoardTab["chatDock"]) => void>();
146247
render(
147248
renderBoardSessionSurface({
148249
snapshot: provider.snapshot$.value,
149250
activeTabId: "main",
150251
dock: "hidden",
151-
reopenDock: "left",
152252
dockSize: { height: 300 },
153253
chat: html`<div data-test-chat>chat</div>`,
154254
divider: html`<div class="board-session-surface__divider"></div>`,
@@ -160,16 +260,13 @@ describe("board session shell", () => {
160260
selectTab: () => {},
161261
},
162262
widgetFrameUrl: (name, revision) => provider.widgetFrameUrl(name, revision),
163-
onDockChange,
164263
}),
165264
container,
166265
);
167266

168267
expect(container.querySelector("[data-test-chat]")).toBeNull();
169268
expect(container.querySelector(".board-session-surface--dock-hidden")).not.toBeNull();
170-
const reopen = container.querySelector<HTMLButtonElement>(".board-session-surface__reopen");
171-
reopen?.click();
172-
expect(onDockChange).toHaveBeenCalledWith("left");
269+
expect(container.querySelector("openclaw-board-view")).not.toBeNull();
173270
});
174271

175272
it("preserves the board while the bottom chat mounts only for that dock", () => {
@@ -178,7 +275,6 @@ describe("board session shell", () => {
178275
const props = {
179276
snapshot: provider.snapshot$.value,
180277
activeTabId: "main",
181-
reopenDock: "left" as const,
182278
dockSize: { height: 300 },
183279
chat: html`<div data-test-chat>chat</div>`,
184280
divider: html`<div class="board-session-surface__divider"></div>`,
@@ -190,7 +286,6 @@ describe("board session shell", () => {
190286
selectTab: () => {},
191287
},
192288
widgetFrameUrl: (name: string, revision: number) => provider.widgetFrameUrl(name, revision),
193-
onDockChange: () => {},
194289
};
195290

196291
render(renderBoardSessionSurface({ ...props, dock: "right" }), container);

0 commit comments

Comments
 (0)