Skip to content

Commit b228c83

Browse files
authored
feat(dashboard): add session:progress board tile rendering the live progress card (#125438)
* feat(dashboard): add session:progress board tile rendering the live progress card Advertise the core-owned widget kind via hello controlUiWidgetKinds at operator.read. Render it inline without an iframe from the session-progress-cards store. Pin it with dashboard tool widget_put using pluginKind session:progress and optional props.sessionKey. Follow up the progress-card unification from #125125. * fix(dashboard): surface session progress load failures Record protected progress-card read failures in the shared per-session store. Render an actionable board-tile error with retry instead of indefinite loading. Cover the rejected-read and successful-retry flow at the widget boundary. * fix(dashboard): honor progress tile access and activity Avoid progress-card reads while a retained board is inactive. Distinguish sharing denial from transient load failures and show the correct remedy. Qualify cross-session pinning docs and cover activation plus denial behavior.
1 parent b3248bf commit b228c83

13 files changed

Lines changed: 538 additions & 32 deletions

‎docs/tools/progress-card.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,19 @@ The current chat shows exactly one live card:
7979
- At narrow widths where the rail is hidden, the card appears in the collapsible surface beside the composer.
8080

8181
The two placements are mutually exclusive. Other sessions can show their latest card in the sidebar hovercard. All placements read the same Gateway-backed state and refresh after `progressCard.changed` notifications.
82+
83+
## Pin the card to the dashboard
84+
85+
Use the `dashboard` tool to keep the live card on the current session's dashboard:
86+
87+
```json
88+
{
89+
"action": "widget_put",
90+
"name": "session-progress",
91+
"title": "Session progress",
92+
"pluginKind": "session:progress",
93+
"size": "md"
94+
}
95+
```
96+
97+
Omit `props.sessionKey` to follow the dashboard's session. To show another session's card, add `"props": { "sessionKey": "agent:main:release" }`. The current connection must participate in that session; otherwise select an accessible session or change its sharing.

‎scripts/control-ui-mock-dev.ts‎

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,18 @@ function buildWorkboardMocks(baseTime: number) {
956956
revision: 1,
957957
tabs: [{ tabId: "main", title: "Workboard", position: 0, chatDock: "hidden" }],
958958
widgets: [
959+
{
960+
name: "session-progress",
961+
tabId: "main",
962+
title: "Session progress",
963+
contentKind: "plugin",
964+
pluginKind: "session:progress",
965+
sizeW: 6,
966+
sizeH: 5,
967+
position: 0,
968+
grantState: "none",
969+
revision: 1,
970+
},
959971
{
960972
name: "workboard-product-operations",
961973
tabId: "main",
@@ -966,7 +978,7 @@ function buildWorkboardMocks(baseTime: number) {
966978
heightMode: "fixed",
967979
sizeW: 12,
968980
sizeH: 16,
969-
position: 0,
981+
position: 1,
970982
grantState: "none",
971983
revision: 1,
972984
},
@@ -976,6 +988,19 @@ function buildWorkboardMocks(baseTime: number) {
976988
"workboard.cards.list": { boards: [board], cards, statuses },
977989
"workboard.cards.stats": { ...board, byAgent: {} },
978990
"workboard.cards.move": { card: cards[0] },
991+
"progressCard.get": {
992+
card: {
993+
sessionKey,
994+
revision: 2,
995+
updatedAt: baseTime,
996+
markdown: "**Product launch** is moving through final checks.",
997+
steps: [
998+
{ step: "Confirm release scope", status: "completed" },
999+
{ step: "Validate onboarding flow", status: "in_progress" },
1000+
{ step: "Publish support handoff", status: "pending" },
1001+
],
1002+
},
1003+
},
9791004
},
9801005
};
9811006
}
@@ -1608,6 +1633,7 @@ async function createChatPickerScenario(
16081633
"openclaw.changes.list",
16091634
"openclaw.chat",
16101635
"openclaw.chat.history",
1636+
"progressCard.get",
16111637
"sessions.delete",
16121638
"sessions.diff",
16131639
"sessions.files.set",
@@ -1633,15 +1659,16 @@ async function createChatPickerScenario(
16331659
]
16341660
: []),
16351661
],
1636-
...(fixture === "workboard"
1637-
? {
1638-
controlUiWidgetKinds: [
1662+
controlUiWidgetKinds: [
1663+
{ pluginId: "session", kind: "session:progress", label: "Session progress" },
1664+
...(fixture === "workboard"
1665+
? [
16391666
{ pluginId: "workboard", kind: "workboard:board", label: "Workboard board" },
16401667
{ pluginId: "workboard", kind: "workboard:card", label: "Workboard card" },
16411668
{ pluginId: "workboard", kind: "workboard:mini", label: "Workboard summary" },
1642-
],
1643-
}
1644-
: {}),
1669+
]
1670+
: []),
1671+
],
16451672
// Terminal has a second gate beyond the advertised method (see
16461673
// ui/src/lib/terminal-availability.ts).
16471674
terminalEnabled: true,
@@ -1689,6 +1716,7 @@ async function createChatPickerScenario(
16891716
},
16901717
],
16911718
},
1719+
"progressCard.get": { card: null },
16921720
"users.self": { profile: selfProfile },
16931721
// Talk settings page pickers: realtime catalog with the model/voice
16941722
// suggestion lists the gateway emits for provider entries.

‎src/agents/tools/dashboard-tool.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const DashboardToolSchema = Type.Object(
7373
Type.String({
7474
pattern: BOARD_PLUGIN_KIND_PATTERN,
7575
description:
76-
"Plugin widget kind, for example workboard:card, workboard:mini, or workboard:board",
76+
"Plugin widget kind, for example session:progress, workboard:card, workboard:mini, or workboard:board",
7777
}),
7878
),
7979
props: Type.Optional(
@@ -257,7 +257,7 @@ export function createDashboardTool(opts: DashboardToolOptions = {}): AnyAgentTo
257257
label: "Dashboard",
258258
name: "dashboard",
259259
description:
260-
"Read and arrange this session dashboard: read snapshot; tab_create/tab_update/tab_delete/tabs_reorder; widget_put/widget_move/widget_resize/widget_remove; focus_tab; set_chat_dock moves or hides the chat dock (left/right/bottom/hidden). Widgets use stable names. Create trusted plugin widgets with widget_put; examples: workboard:card props {cardId}, workboard:mini props {boardId, limit}, workboard:board props {boardId}. Sizes: sm=3x3, md=6x4, lg=8x6, xl=12x8, full=12x8 single-widget emphasis.",
260+
"Read and arrange this session dashboard: read snapshot; tab_create/tab_update/tab_delete/tabs_reorder; widget_put/widget_move/widget_resize/widget_remove; focus_tab; set_chat_dock moves or hides the chat dock (left/right/bottom/hidden). Widgets use stable names. Create trusted plugin widgets with widget_put; examples: session:progress props {sessionKey?} renders the session's live progress card (omit sessionKey for the current session), workboard:card props {cardId}, workboard:mini props {boardId, limit}, workboard:board props {boardId}. Sizes: sm=3x3, md=6x4, lg=8x6, xl=12x8, full=12x8 single-widget emphasis.",
261261
parameters: DashboardToolSchema,
262262
execute: async (_toolCallId, rawArgs) => {
263263
const params = rawArgs as Record<string, unknown>;

‎src/gateway/control-ui-plugin-tabs.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe("listControlUiPluginTabs", () => {
9595
expect(listControlUiPluginTabs([]).map((tab) => tab.id)).toEqual(["beta", "zed", "alpha"]);
9696
});
9797

98-
it("projects scoped widget descriptors as namespaced kinds", () => {
98+
it("merges the read-scoped core kind into deterministic plugin ordering", () => {
9999
activateDescriptors([
100100
{
101101
pluginId: "workboard",
@@ -119,6 +119,7 @@ describe("listControlUiPluginTabs", () => {
119119

120120
expect(listControlUiPluginWidgetKinds([])).toEqual([]);
121121
expect(listControlUiPluginWidgetKinds(["operator.read"])).toEqual([
122+
{ pluginId: "session", kind: "session:progress", label: "Session progress" },
122123
{ pluginId: "workboard", kind: "workboard:card", label: "Workboard card" },
123124
{ pluginId: "workboard", kind: "workboard:mini", label: "Workboard summary" },
124125
]);

‎src/gateway/control-ui-plugin-tabs.ts‎

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ type ControlUiPluginWidgetKind = {
3131
label: string;
3232
};
3333

34+
// `session` is a core-reserved widget-kind namespace. Core owns progress cards,
35+
// so their availability is scope-gated rather than plugin-gated.
36+
const CORE_CONTROL_UI_WIDGET_KINDS: readonly ControlUiPluginWidgetKind[] = [
37+
{ pluginId: "session", kind: "session:progress", label: "Session progress" },
38+
];
39+
3440
function findControlUiTabGatewayRoute(
3541
registry: PluginRegistry,
3642
tab: ControlUiPluginTab,
@@ -125,28 +131,30 @@ export function listControlUiPluginWidgetKinds(
125131
scopes: readonly string[],
126132
): ControlUiPluginWidgetKind[] {
127133
const entries = getActivePluginSessionExtensionRegistry()?.controlUiDescriptors ?? [];
128-
return entries
129-
.flatMap((entry) => {
130-
const descriptor = entry.descriptor;
131-
if (descriptor.surface !== "widget") {
132-
return [];
133-
}
134-
const visible = (descriptor.requiredScopes ?? []).every(
135-
(scope) => authorizeOperatorScopesForRequiredScope(scope, scopes).allowed,
136-
);
137-
return visible
138-
? [
139-
{
140-
pluginId: entry.pluginId,
141-
kind: `${entry.pluginId}:${descriptor.id}`,
142-
label: descriptor.label,
143-
},
144-
]
145-
: [];
146-
})
147-
.toSorted(
148-
(left, right) => left.label.localeCompare(right.label) || left.kind.localeCompare(right.kind),
134+
const coreEntries = authorizeOperatorScopesForRequiredScope(READ_SCOPE, scopes).allowed
135+
? CORE_CONTROL_UI_WIDGET_KINDS
136+
: [];
137+
const pluginEntries = entries.flatMap((entry) => {
138+
const descriptor = entry.descriptor;
139+
if (descriptor.surface !== "widget") {
140+
return [];
141+
}
142+
const visible = (descriptor.requiredScopes ?? []).every(
143+
(scope) => authorizeOperatorScopesForRequiredScope(scope, scopes).allowed,
149144
);
145+
return visible
146+
? [
147+
{
148+
pluginId: entry.pluginId,
149+
kind: `${entry.pluginId}:${descriptor.id}`,
150+
label: descriptor.label,
151+
},
152+
]
153+
: [];
154+
});
155+
return [...coreEntries, ...pluginEntries].toSorted(
156+
(left, right) => left.label.localeCompare(right.label) || left.kind.localeCompare(right.kind),
157+
);
150158
}
151159

152160
/** Builds least-privilege grants only for visible tabs backed by same-plugin gateway routes. */

‎ui/src/components/board/board-widget-cell-plugin.test.ts‎

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { afterEach, describe, expect, it, vi } from "vitest";
2+
import { GatewayRequestError } from "../../api/gateway.ts";
23
import type { ApplicationContext } from "../../app/context.ts";
34
import type { BoardWidget } from "../../lib/board/types.ts";
45
import { createApplicationContextProvider } from "../../test-helpers/application-context.ts";
@@ -124,6 +125,184 @@ describe("plugin board widget cells", () => {
124125
expect(cell.querySelector('[data-test-id="board-widget-error"]')).toBeNull();
125126
});
126127

128+
it("renders an advertised session progress card and its empty state", async () => {
129+
const dashboardSessionKey = "agent:main:dashboard";
130+
const targetSessionKey = "agent:main:target";
131+
const responses = [
132+
{
133+
props: { sessionKey: targetSessionKey },
134+
response: {
135+
card: {
136+
sessionKey: targetSessionKey,
137+
revision: 1,
138+
updatedAt: 1,
139+
markdown: "**Release** validation is active.",
140+
steps: [{ step: "Run focused checks", status: "in_progress" }],
141+
},
142+
},
143+
text: "Run focused checks",
144+
requestedSessionKey: targetSessionKey,
145+
},
146+
{
147+
props: undefined,
148+
response: { card: null },
149+
text: "No progress card yet",
150+
requestedSessionKey: dashboardSessionKey,
151+
},
152+
] as const;
153+
154+
for (const [index, scenario] of responses.entries()) {
155+
const request = vi.fn(async () => scenario.response);
156+
const context = {
157+
gateway: {
158+
snapshot: {
159+
phase: "connected",
160+
client: { request },
161+
hello: {
162+
features: { methods: ["progressCard.get"] },
163+
controlUiWidgetKinds: [
164+
{ pluginId: "session", kind: "session:progress", label: "Session progress" },
165+
],
166+
},
167+
},
168+
subscribe: () => () => undefined,
169+
subscribeEvents: () => () => undefined,
170+
},
171+
} as unknown as ApplicationContext;
172+
const widget: BoardWidget = {
173+
name: `session-progress-${index}`,
174+
tabId: "main",
175+
title: "Session progress",
176+
contentKind: "plugin",
177+
pluginKind: "session:progress",
178+
...(scenario.props ? { props: scenario.props } : {}),
179+
sizeW: 6,
180+
sizeH: 4,
181+
position: index,
182+
grantState: "none",
183+
revision: 1,
184+
};
185+
const provider = createApplicationContextProvider(context);
186+
const cell = document.createElement("openclaw-board-widget-cell");
187+
cell.widget = widget;
188+
cell.rect = { name: widget.name, x: 0, y: index * 4, w: 6, h: 4 };
189+
cell.sessionKey = dashboardSessionKey;
190+
cell.active = index !== 0;
191+
cell.callbacks = callbacks();
192+
provider.append(cell);
193+
document.body.append(provider);
194+
195+
if (index === 0) {
196+
await cell.updateComplete;
197+
expect(request).not.toHaveBeenCalled();
198+
cell.active = true;
199+
}
200+
201+
await vi.waitFor(
202+
() =>
203+
expect(cell.querySelector("openclaw-session-progress-widget")?.textContent).toContain(
204+
scenario.text,
205+
),
206+
CHUNK_LOAD_WAIT,
207+
);
208+
expect(request).toHaveBeenCalledWith("progressCard.get", {
209+
sessionKey: scenario.requestedSessionKey,
210+
});
211+
}
212+
});
213+
214+
it("surfaces a failed session progress read and retries it", async () => {
215+
const sessionKey = "agent:main:protected";
216+
let attempts = 0;
217+
const deniedSessionKey = "agent:main:private";
218+
const request = vi.fn(async (_method: string, params: { sessionKey: string }) => {
219+
if (params.sessionKey === deniedSessionKey) {
220+
throw new GatewayRequestError({
221+
code: "INVALID_REQUEST",
222+
message: "session is private for this connection",
223+
details: { code: "SESSION_PARTICIPATION_REQUIRED" },
224+
});
225+
}
226+
attempts += 1;
227+
if (attempts === 1) {
228+
throw new Error("session not shared");
229+
}
230+
return {
231+
card: {
232+
sessionKey,
233+
revision: 1,
234+
updatedAt: 1,
235+
steps: [{ step: "Recovered progress", status: "in_progress" }],
236+
},
237+
};
238+
});
239+
const context = {
240+
gateway: {
241+
snapshot: {
242+
phase: "connected",
243+
client: { request },
244+
hello: {
245+
features: { methods: ["progressCard.get"] },
246+
controlUiWidgetKinds: [
247+
{ pluginId: "session", kind: "session:progress", label: "Session progress" },
248+
],
249+
},
250+
},
251+
subscribe: () => () => undefined,
252+
subscribeEvents: () => () => undefined,
253+
},
254+
} as unknown as ApplicationContext;
255+
const widget: BoardWidget = {
256+
name: "protected-session-progress",
257+
tabId: "main",
258+
title: "Session progress",
259+
contentKind: "plugin",
260+
pluginKind: "session:progress",
261+
props: { sessionKey },
262+
sizeW: 6,
263+
sizeH: 4,
264+
position: 0,
265+
grantState: "none",
266+
revision: 1,
267+
};
268+
const provider = createApplicationContextProvider(context);
269+
const cell = document.createElement("openclaw-board-widget-cell");
270+
cell.widget = widget;
271+
cell.rect = { name: widget.name, x: 0, y: 0, w: 6, h: 4 };
272+
cell.sessionKey = "agent:main:dashboard";
273+
cell.callbacks = callbacks();
274+
provider.append(cell);
275+
document.body.append(provider);
276+
277+
await vi.waitFor(
278+
() => expect(cell.querySelector('[data-test-id="session-progress-error"]')).not.toBeNull(),
279+
CHUNK_LOAD_WAIT,
280+
);
281+
cell
282+
.querySelector<HTMLButtonElement>('[data-test-id="session-progress-error"] button')
283+
?.click();
284+
285+
await vi.waitFor(
286+
() =>
287+
expect(cell.querySelector("openclaw-session-progress-widget")?.textContent).toContain(
288+
"Recovered progress",
289+
),
290+
CHUNK_LOAD_WAIT,
291+
);
292+
expect(request).toHaveBeenCalledTimes(2);
293+
294+
cell.widget = { ...widget, props: { sessionKey: deniedSessionKey } };
295+
await vi.waitFor(
296+
() =>
297+
expect(
298+
cell.querySelector('[data-test-id="session-progress-error"]')?.textContent,
299+
).toContain("Select a session you can access or change sharing for this session."),
300+
CHUNK_LOAD_WAIT,
301+
);
302+
expect(cell.querySelector('[data-test-id="session-progress-error"] button')).toBeNull();
303+
expect(request).toHaveBeenCalledTimes(3);
304+
});
305+
127306
it("passes activity to a retained Workboard plugin element", async () => {
128307
const context = {
129308
gateway: {

0 commit comments

Comments
 (0)