Skip to content

Commit 5b5fdac

Browse files
authored
feat(ui): dock the session progress card beside a wide composer (#129141)
* feat(ui): dock the session progress card beside a wide composer The progress card had two placements: the companion rail when that side panel is open, otherwise a collapsed one-line bar stacked inside the composer box. On a wide chat the composer stays centered at the transcript width, so the space either side of it sits empty while the card is squeezed into the composer. Add a third placement. When the measured free gutter beside the composer is at least 280px, the card docks into it with its full checklist expanded; below that it falls back to the existing composer bar, and an open companion rail still wins. Exactly one placement renders at a time, now expressed as a closed {card, placement} prop so the composer bar and the dock cannot both draw the same card. The gutter is measured from the DOM by a small ResizeObserver controller rather than derived from the pane width: the transcript width is a browser-local setting in arbitrary CSS units, and an open side panel shrinks the conversation column without changing the pane. The dock is positioned absolutely in that gutter, so the transcript and composer never shift when a card appears or is dismissed, and its inline-start edge repeats the composer's own half-width formula through a shared --chat-composer-side-inset token so the two stay in agreement. * fix(ui): keep the new-session composer sized outside the chat surface The composer shell tokens are declared on .chat, but the new-session page reuses .agent-chat__composer-shell outside it. There the var() had no value, so the whole width declaration was invalid and dropped, and the composer stretched full-width instead of holding its 48rem centered box. Give both tokens their literal fallback at the use site, matching the neighbouring --chat-thread-max-width. The custodian surface was already immune because it overrides width outright. Caught by ui/src/e2e/new-session-page.places.e2e.test.ts, which is the regression test for this: it failed on the previous head and passes now.
1 parent 5182513 commit 5b5fdac

11 files changed

Lines changed: 212 additions & 28 deletions

‎docs/tools/progress-card.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ An empty plan plus empty or whitespace-only Markdown also clears it. A successfu
8686
The current chat shows exactly one live card:
8787

8888
- When the session rail is visible, the card appears in the rail.
89-
- At narrow widths where the rail is hidden, the card appears in the collapsible surface beside the composer.
89+
- Otherwise, when the chat is wide enough that the centered composer leaves a free gutter, the card docks in that space beside the composer with its full checklist expanded.
90+
- At narrower widths the card appears in the collapsible surface inside the composer.
9091

91-
The two placements are mutually exclusive. Hover a session row in the sidebar or a session-reference link in chat to see the same card for that session. All card placements read the same Gateway-backed state and refresh after `progressCard.changed` notifications.
92+
The placements are mutually exclusive. Hover a session row in the sidebar or a session-reference link in chat to see the same card for that session. All card placements read the same Gateway-backed state and refresh after `progressCard.changed` notifications.
9293

9394
## Pin the card to the dashboard
9495

‎ui/src/components/session-progress-card.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { t } from "../i18n/index.ts";
55
import { icons } from "./icons.ts";
66
import { toSanitizedMarkdownHtml } from "./markdown.ts";
77

8-
type SessionProgressCardPlacement = "board" | "composer" | "hovercard" | "rail";
8+
type SessionProgressCardPlacement = "board" | "composer" | "dock" | "hovercard" | "rail";
99

1010
const STATUS_LABEL_KEYS: Record<ProgressCardStep["status"], Parameters<typeof t>[0]> = {
1111
completed: "sessionProgressCard.status.completed",

‎ui/src/e2e/session-progress-live-placement.e2e.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,34 @@ suite.define(() => {
9898
await expect.poll(() => gateway.getRequests("progressCard.get")).toHaveLength(1);
9999

100100
const visiblePane = page.locator("openclaw-chat-pane.chat-pane-cache__pane--visible");
101+
// Wide enough for the composer gutter to hold the card: it docks beside
102+
// the composer instead of stacking inside it.
103+
await page.setViewportSize({ height: 900, width: 1600 });
104+
const dock = visiblePane.locator('[data-progress-card-placement="dock"]');
105+
await expect.poll(() => dock.count()).toBe(1);
106+
await expect
107+
.poll(() => visiblePane.locator('[data-progress-card-placement="composer"]').count())
108+
.toBe(0);
109+
await expect
110+
.poll(async () => {
111+
const dockBounds = await dock.boundingBox();
112+
const composerBounds = await visiblePane
113+
.locator(".agent-chat__composer-shell")
114+
.boundingBox();
115+
if (!dockBounds || !composerBounds) {
116+
return false;
117+
}
118+
return (
119+
dockBounds.x >= composerBounds.x + composerBounds.width &&
120+
Math.abs(
121+
dockBounds.y + dockBounds.height - (composerBounds.y + composerBounds.height),
122+
) <= 1
123+
);
124+
})
125+
.toBe(true);
126+
await captureProof(page, "dock-beside-composer.png");
127+
128+
await page.setViewportSize({ height: 900, width: 1280 });
101129
await openChatSidePanelType(page, "Side chat");
102130
await expect
103131
.poll(() => visiblePane.locator('[data-progress-card-placement="rail"]').count())
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import type { ReactiveController, ReactiveControllerHost } from "lit";
2+
3+
type ComposerGutterHost = ReactiveControllerHost & ParentNode;
4+
5+
/**
6+
* Tracks the free space between the centered composer and one pane edge.
7+
* Measured from the DOM rather than derived from the pane width: the transcript
8+
* width is a user setting in arbitrary CSS units, and an open side panel shrinks
9+
* the conversation column without changing the pane. The progress card docks
10+
* into that gutter once it fits.
11+
*/
12+
export class ComposerGutterController implements ReactiveController {
13+
private observer: ResizeObserver | null = null;
14+
private targets: readonly Element[] = [];
15+
private measured = 0;
16+
17+
constructor(private readonly host: ComposerGutterHost) {
18+
host.addController(this);
19+
}
20+
21+
get width(): number {
22+
return this.measured;
23+
}
24+
25+
hostUpdated(): void {
26+
if (typeof ResizeObserver !== "function") {
27+
return;
28+
}
29+
const shell = this.host.querySelector<HTMLElement>(".agent-chat__composer-shell");
30+
const conversation = shell?.parentElement ?? null;
31+
const targets = shell && conversation ? [conversation, shell] : [];
32+
const unchanged =
33+
targets.length === this.targets.length &&
34+
targets.every((target, index) => target === this.targets[index]);
35+
if (unchanged) {
36+
return;
37+
}
38+
this.observer?.disconnect();
39+
this.targets = targets;
40+
if (targets.length === 0) {
41+
return;
42+
}
43+
// Both edges move the gutter: the conversation column follows the side
44+
// panel, and the composer itself resizes with the transcript-width setting.
45+
this.observer ??= new ResizeObserver(() => this.measure());
46+
for (const target of targets) {
47+
this.observer.observe(target);
48+
}
49+
}
50+
51+
hostDisconnected(): void {
52+
this.observer?.disconnect();
53+
this.observer = null;
54+
this.targets = [];
55+
}
56+
57+
private measure(): void {
58+
const shell = this.targets[1];
59+
const conversation = this.targets[0];
60+
if (!(shell instanceof HTMLElement) || !(conversation instanceof HTMLElement)) {
61+
return;
62+
}
63+
const conversationWidth = conversation.clientWidth;
64+
// Hidden panes (split view, pane cache) report 0; keep the last real width.
65+
if (conversationWidth <= 0) {
66+
return;
67+
}
68+
const gutter = Math.max(0, Math.round((conversationWidth - shell.clientWidth) / 2));
69+
if (gutter === this.measured) {
70+
return;
71+
}
72+
this.measured = gutter;
73+
this.host.requestUpdate();
74+
}
75+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { PollController } from "../../lit/poll-controller.ts";
4444
import { SubscriptionsController } from "../../lit/subscriptions-controller.ts";
4545
import type { BoardChatDockSize } from "./board-session-surface.ts";
4646
import { ChatComposerCapabilityHost } from "./chat-composer-capability-host.ts";
47+
import { ComposerGutterController } from "./chat-composer-gutter.ts";
4748
import { sendSessionObserverVisibility } from "./chat-observer.ts";
4849
import {
4950
boardChatDockLayout,
@@ -195,6 +196,7 @@ export abstract class ChatPaneBase extends OpenClawLightDomElement {
195196
this.requestUpdate(),
196197
);
197198
protected readonly transcript = new ChatTranscriptController(this);
199+
protected readonly composerGutter = new ComposerGutterController(this);
198200
protected readonly taskSidebarTranscript = new ChatTranscriptController(this);
199201
protected readonly progressCard = new SessionProgressCardController(this, {
200202
gateway: () => this.context?.gateway,

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
sidebarPanelDefinitions,
1313
sidebarPanelTemplates,
1414
} from "./chat-pane-embedded-panels.ts";
15+
import type { ChatProgressCardPlacement } from "./chat-pane-rails.ts";
1516
import type { ResolvedBoardView } from "./chat-pane-shared.ts";
1617
import { renderSidebarRegion, sidebarRegionCallbacks } from "./chat-pane-sidebar-layout.ts";
1718
import type { ChatPageHost } from "./chat-state-host.ts";
@@ -37,7 +38,7 @@ type ChatPaneLayoutRenderParams = {
3738
currentAgentId: string;
3839
board: ResolvedBoardView;
3940
sidebarLayout: SidebarLayout;
40-
progressCardInRail: boolean;
41+
progressCardPlacement: ChatProgressCardPlacement;
4142
onDismissProgressCard?: (card: ProgressCard) => void;
4243
sessionWorkspace: SessionWorkspaceProps;
4344
backgroundTasks: BackgroundTasksProps;
@@ -59,7 +60,7 @@ export abstract class ChatPaneLayoutRender extends ChatPaneBrowserAnnotationRend
5960
currentAgentId,
6061
board,
6162
sidebarLayout,
62-
progressCardInRail,
63+
progressCardPlacement,
6364
onDismissProgressCard,
6465
sessionWorkspace,
6566
backgroundTasks,
@@ -125,7 +126,7 @@ export abstract class ChatPaneLayoutRender extends ChatPaneBrowserAnnotationRend
125126
startedAt: selectedSession?.startedAt ?? state.chatStreamStartedAt ?? undefined,
126127
lastReadAt: selectedSession?.lastReadAt,
127128
pullRequests: this.sessionPullRequests,
128-
progressCard: progressCardInRail ? this.progressCard.card : null,
129+
progressCard: progressCardPlacement === "rail" ? this.progressCard.card : null,
129130
onDismissProgressCard,
130131
companion: companionThread,
131132
onCompanionSubmit: (question) => void this.submitSessionCompanionQuestion(question),

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,30 @@ import {
1414
type ChatPaneSidebarLayout = Parameters<typeof isSidebarSlotVisible>[0];
1515
type ChatPaneGatewaySnapshot = Parameters<typeof isDesktopPanelAvailable>[0];
1616

17+
export type ChatProgressCardPlacement = "composer" | "dock" | "rail";
18+
19+
/* Narrowest gutter that still holds a readable card: the dock keeps a 12px gap
20+
* from the composer and clears the transcript scrollbar strip on the far side,
21+
* so this leaves it ~250px of its own. */
22+
const PROGRESS_CARD_DOCK_MIN_GUTTER_PX = 280;
23+
24+
/** Picks the single live progress-card placement for one chat pane. */
25+
function chatProgressCardPlacement(params: {
26+
companionRailVisible: boolean;
27+
composerGutter: number;
28+
}): ChatProgressCardPlacement {
29+
if (params.companionRailVisible) {
30+
return "rail";
31+
}
32+
return params.composerGutter >= PROGRESS_CARD_DOCK_MIN_GUTTER_PX ? "dock" : "composer";
33+
}
34+
1735
/** Builds the two rail models and their shared sidebar slot controls. */
1836
export function createChatPaneRails(params: {
1937
state: ChatPageHost;
2038
sidebarLayout: ChatPaneSidebarLayout;
2139
paneWidth: number;
40+
composerGutter: number;
2241
presentationId: string;
2342
presented: boolean;
2443
gatewaySnapshot: ChatPaneGatewaySnapshot;
@@ -70,14 +89,17 @@ export function createChatPaneRails(params: {
7089
narrowLayout: false,
7190
onToggleCollapsed: () => togglePanelSlot("tasks"),
7291
};
73-
const progressCardInRail =
74-
params.paneWidth >= SIDEBAR_NARROW_BREAKPOINT_PX &&
75-
isSidebarSlotVisible(sidebarLayout, "companion");
92+
const progressCardPlacement = chatProgressCardPlacement({
93+
companionRailVisible:
94+
params.paneWidth >= SIDEBAR_NARROW_BREAKPOINT_PX &&
95+
isSidebarSlotVisible(sidebarLayout, "companion"),
96+
composerGutter: params.composerGutter,
97+
});
7698
return {
7799
backgroundTasks,
78100
closePanelSlot,
79101
openPanelSlot,
80-
progressCardInRail,
102+
progressCardPlacement,
81103
sessionWorkspace,
82104
};
83105
}

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

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ProgressCard } from "@openclaw/gateway-protocol";
12
import { html, nothing } from "lit";
23
import { findInlineApproval } from "../../app/approval-presentation.ts";
34
import { hasOperatorAdminAccess, hasOperatorWriteAccess } from "../../app/operator-access.ts";
@@ -181,7 +182,7 @@ export class ChatPane extends ChatPaneLayoutRender {
181182
hasOperatorWriteAccess(gatewaySnapshot.hello?.auth ?? null) &&
182183
isGatewayMethodAdvertised(gatewaySnapshot, "progressCard.put") === true;
183184
const onDismissProgressCard = canDismissProgressCard
184-
? (card: NonNullable<ChatProps["progressCard"]>) => {
185+
? (card: ProgressCard) => {
185186
void this.progressCard
186187
.dismiss(card)
187188
.catch(() => showToast({ message: t("sessionProgressCard.dismissFailed") }));
@@ -225,16 +226,22 @@ export class ChatPane extends ChatPaneLayoutRender {
225226
? t("chat.catalog.remoteViewOnly")
226227
: t("chat.catalog.unsupportedViewOnly")
227228
: null;
228-
const { backgroundTasks, closePanelSlot, openPanelSlot, progressCardInRail, sessionWorkspace } =
229-
createChatPaneRails({
230-
state,
231-
sidebarLayout,
232-
paneWidth: this.paneWidth,
233-
presentationId: this.presentationId,
234-
presented: this.presented,
235-
gatewaySnapshot,
236-
setObserverVisibility: this.setSessionObserverVisibility,
237-
});
229+
const {
230+
backgroundTasks,
231+
closePanelSlot,
232+
openPanelSlot,
233+
progressCardPlacement,
234+
sessionWorkspace,
235+
} = createChatPaneRails({
236+
state,
237+
sidebarLayout,
238+
paneWidth: this.paneWidth,
239+
composerGutter: this.composerGutter.width,
240+
presentationId: this.presentationId,
241+
presented: this.presented,
242+
gatewaySnapshot,
243+
setObserverVisibility: this.setSessionObserverVisibility,
244+
});
238245
const selfUser = resolveCurrentSelfUser({
239246
snapshotUser: gatewaySnapshot.selfUser,
240247
presenceEntries: readPresenceEntries(gatewaySnapshot.hello?.snapshot),
@@ -315,7 +322,10 @@ export class ChatPane extends ChatPaneLayoutRender {
315322
waitingApproval: state.waitingApprovalStatuses.size > 0,
316323
compactionStatus: state.compactionStatus,
317324
fallbackStatus: state.fallbackStatus,
318-
progressCard: progressCardInRail ? null : this.progressCard.card,
325+
progressCard:
326+
progressCardPlacement === "rail" || !this.progressCard.card
327+
? null
328+
: { card: this.progressCard.card, placement: progressCardPlacement },
319329
onDismissProgressCard,
320330
gatewayQuestionPrompts: catalogKey || sessionParticipationBlocked ? [] : this.questionPrompts,
321331
onGatewayQuestionChange: () => {
@@ -639,7 +649,7 @@ export class ChatPane extends ChatPaneLayoutRender {
639649
currentAgentId,
640650
board,
641651
sidebarLayout,
642-
progressCardInRail,
652+
progressCardPlacement,
643653
onDismissProgressCard,
644654
sessionWorkspace,
645655
backgroundTasks,

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { icons } from "../../components/icons.ts";
2222
import type { ImageLightboxItem } from "../../components/image-lightbox.ts";
2323
import type { SessionLinkTarget } from "../../components/markdown-session-links.ts";
2424
import type { PersonActivityRouting } from "../../components/person-activity-link.ts";
25+
import { renderSessionProgressCard } from "../../components/session-progress-card.ts";
2526
import { t } from "../../i18n/index.ts";
2627
import type { BoardProvider } from "../../lib/board/provider.ts";
2728
import type {
@@ -104,7 +105,9 @@ export type ChatProps = ChatTaskSuggestionTrayProps &
104105
waitingApproval?: boolean;
105106
compactionStatus?: CompactionStatus | null;
106107
fallbackStatus?: FallbackStatus | null;
107-
progressCard?: ProgressCard | null;
108+
/* One live placement per view: the pane picks it, so the composer bar and
109+
* the right-gutter dock can never both render the same card. */
110+
progressCard?: { card: ProgressCard; placement: "composer" | "dock" } | null;
108111
onDismissProgressCard?: (card: ProgressCard) => void;
109112
gatewayQuestionPrompts?: readonly QuestionPrompt[];
110113
onGatewayQuestionChange?: () => void;
@@ -409,7 +412,7 @@ export function renderChat(props: ChatProps) {
409412
waitingApproval: props.waitingApproval,
410413
compactionStatus: props.compactionStatus,
411414
fallbackStatus: props.fallbackStatus,
412-
progressCard: props.progressCard,
415+
progressCard: props.progressCard?.placement === "composer" ? props.progressCard.card : null,
413416
onDismissProgressCard: props.onDismissProgressCard,
414417
gatewayQuestionPrompts: props.gatewayQuestionPrompts,
415418
messages: props.messages,
@@ -602,6 +605,13 @@ export function renderChat(props: ChatProps) {
602605
sessions: props.swarmSessions ?? [],
603606
sessionKey: props.sessionKey,
604607
})}
608+
${props.progressCard?.placement === "dock"
609+
? renderSessionProgressCard(
610+
props.progressCard.card,
611+
"dock",
612+
props.onDismissProgressCard,
613+
)
614+
: nothing}
605615
${showModelSetupSplash ? nothing : chatColumnFooter}
606616
</div>
607617
</div>

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ openclaw-chat-page {
1414
--chat-thread-max-width: 48rem;
1515
/* Keep overlays clear of the edge-hugging scrollbar and add room on wide screens. */
1616
--chat-thread-gutter: 18px;
17+
/* Composer box insets. The docked progress card derives its own edge from
18+
both, so the two never overlap and their bottoms stay on one line. */
19+
--chat-composer-side-inset: 36px;
20+
--chat-composer-bottom-gap: 14px;
1721
--chat-thread-side-inset: clamp(6px, 1vw, 12px);
1822

1923
position: relative;
@@ -1686,9 +1690,11 @@ button.chat-reply-preview--message:disabled {
16861690
grid-template-columns: minmax(0, 1fr);
16871691
align-items: end;
16881692
gap: 6px;
1689-
width: calc(100% - 36px);
1693+
/* The new-session page reuses this shell outside .chat, where the tokens are
1694+
not defined; the fallbacks keep its geometry identical there. */
1695+
width: calc(100% - var(--chat-composer-side-inset, 36px));
16901696
max-width: var(--chat-thread-max-width, 48rem);
1691-
margin: 8px auto 14px;
1697+
margin: 8px auto var(--chat-composer-bottom-gap, 14px);
16921698
}
16931699

16941700
/* Floating tray pinned to the conversation's top-right (the positioned

0 commit comments

Comments
 (0)