Skip to content

Commit 5fe8cde

Browse files
authored
feat(ui): show active agent in dashboard header
Show the active agent name in the Control UI dashboard breadcrumb without adding the current session key/name. Verification: - pnpm test ui/src/ui/app-render.helpers.node.test.ts - node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json ui/src/ui/components/dashboard-header.ts ui/src/ui/app-render.helpers.ts ui/src/ui/app-render.ts ui/src/ui/app-render.helpers.node.test.ts - git diff --check - Testbox pnpm check:changed
1 parent 3c97125 commit 5fe8cde

6 files changed

Lines changed: 99 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Docs: https://docs.openclaw.ai
1111

1212
### Changes
1313

14+
- Control UI/header: show the active agent name in dashboard breadcrumbs without adding the current session key, keeping non-chat views oriented without crowding the topbar.
1415
- Gateway/startup: keep model-catalog test helpers, run-session lookup code, QR pairing helpers, and TypeBox memory-tool schema construction out of hot startup import paths, reducing default gateway benchmark plugin-load and memory pressure.
1516
- Control UI/performance: record browser long animation frame or long task entries in the debug event log when supported, making slow dashboard renders easier to attribute from the UI.
1617
- Channels/streaming: add unified `streaming.mode: "progress"` drafts with auto single-word status labels and shared progress configuration across Discord, Telegram, Matrix, Slack, and Microsoft Teams.

‎ui/src/styles/layout.css‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@
196196
color: var(--muted);
197197
}
198198

199+
.topnav-shell .dashboard-header__breadcrumb-segment {
200+
display: inline-flex;
201+
align-items: center;
202+
gap: 8px;
203+
min-width: 0;
204+
}
205+
199206
.topnav-shell .dashboard-header__breadcrumb-link {
200207
display: inline-flex;
201208
align-items: center;
@@ -221,6 +228,21 @@
221228
text-overflow: ellipsis;
222229
}
223230

231+
.topnav-shell .dashboard-header__breadcrumb-context {
232+
max-width: 18ch;
233+
overflow: hidden;
234+
color: var(--muted);
235+
font-weight: 550;
236+
text-overflow: ellipsis;
237+
white-space: nowrap;
238+
}
239+
240+
@media (max-width: 720px) {
241+
.topnav-shell .dashboard-header__breadcrumb-context {
242+
max-width: 10ch;
243+
}
244+
}
245+
224246
.topbar-status {
225247
display: flex;
226248
align-items: center;

‎ui/src/ui/app-render.helpers.node.test.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
isCronSessionKey,
4040
parseSessionKey,
4141
resolveAssistantAttachmentAuthToken,
42+
resolveDashboardHeaderContext,
4243
resolveSessionOptionGroups,
4344
resolveSessionDisplayName,
4445
switchChatSession,
@@ -452,6 +453,50 @@ describe("resolveSessionDisplayName", () => {
452453
});
453454
});
454455

456+
describe("resolveDashboardHeaderContext", () => {
457+
it("uses the active agent identity name", () => {
458+
expect(
459+
resolveDashboardHeaderContext({
460+
sessionKey: "agent:deep-chat:imessage:sample-thread",
461+
agentsList: {
462+
defaultId: "deep-chat",
463+
mainKey: "main",
464+
scope: "user",
465+
agents: [{ id: "deep-chat", identity: { name: "Deep Chat" } }],
466+
},
467+
} as unknown as AppViewState),
468+
).toEqual({ agentLabel: "Deep Chat" });
469+
});
470+
471+
it("falls back to the configured agent name", () => {
472+
expect(
473+
resolveDashboardHeaderContext({
474+
sessionKey: "agent:beta:main",
475+
agentsList: {
476+
defaultId: "beta",
477+
mainKey: "main",
478+
scope: "user",
479+
agents: [{ id: "beta", name: "Coding" }],
480+
},
481+
} as unknown as AppViewState),
482+
).toEqual({ agentLabel: "Coding" });
483+
});
484+
485+
it("falls back to the agent id", () => {
486+
expect(
487+
resolveDashboardHeaderContext({
488+
sessionKey: "agent:beta:subagent:maintainer-v2",
489+
agentsList: {
490+
defaultId: "main",
491+
mainKey: "main",
492+
scope: "user",
493+
agents: [],
494+
},
495+
} as unknown as AppViewState),
496+
).toEqual({ agentLabel: "beta" });
497+
});
498+
});
499+
455500
describe("isCronSessionKey", () => {
456501
it("returns true for cron: prefixed keys", () => {
457502
expect(isCronSessionKey("cron:abc-123")).toBe(true);

‎ui/src/ui/app-render.helpers.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { createSessionAndRefresh, loadSessions } from "./controllers/sessions.ts
1818
import { icons } from "./icons.ts";
1919
import { iconForTab, pathForTab, titleForTab, type Tab } from "./navigation.ts";
2020
import { parseAgentSessionKey, resolveAgentIdFromSessionKey } from "./session-key.ts";
21-
import { normalizeOptionalString } from "./string-coerce.ts";
21+
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "./string-coerce.ts";
2222
import type { ThemeMode } from "./theme.ts";
2323
import type { SessionsListResult } from "./types.ts";
2424
import type { ChatQueueItem } from "./ui-types.ts";
@@ -52,6 +52,20 @@ export function resolveAssistantAttachmentAuthToken(
5252
return resolveControlUiAuthToken(state);
5353
}
5454

55+
export function resolveDashboardHeaderContext(
56+
state: Pick<AppViewState, "agentsList" | "sessionKey">,
57+
): { agentLabel: string } {
58+
const agentId = resolveAgentIdFromSessionKey(state.sessionKey);
59+
const agent = state.agentsList?.agents.find(
60+
(entry) => normalizeLowercaseStringOrEmpty(entry.id) === agentId,
61+
);
62+
const agentLabel =
63+
normalizeOptionalString(agent?.identity?.name) ??
64+
normalizeOptionalString(agent?.name) ??
65+
agentId;
66+
return { agentLabel };
67+
}
68+
5569
function resolveSidebarChatSessionKey(state: AppViewState): string {
5670
const snapshot = state.hello?.snapshot as
5771
| { sessionDefaults?: SessionDefaultsSnapshot }

‎ui/src/ui/app-render.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
renderChatSessionSelect,
1212
renderTab,
1313
resolveAssistantAttachmentAuthToken,
14+
resolveDashboardHeaderContext,
1415
renderSidebarConnectionStatus,
1516
renderTopbarThemeModeToggle,
1617
createChatSession,
@@ -645,6 +646,7 @@ export function renderApp(state: AppViewState) {
645646
const chatFocus = isChat && (state.settings.chatFocusMode || state.onboarding);
646647
const navDrawerOpen = state.navDrawerOpen && !chatFocus && !state.onboarding;
647648
const navCollapsed = state.settings.navCollapsed && !navDrawerOpen;
649+
const dashboardHeaderContext = resolveDashboardHeaderContext(state);
648650
const showThinking = state.onboarding ? false : state.settings.chatShowThinking;
649651
const showToolCalls = state.onboarding ? true : state.settings.chatShowToolCalls;
650652
const localAssistantAvatarOverride =
@@ -1362,6 +1364,7 @@ export function renderApp(state: AppViewState) {
13621364
<dashboard-header
13631365
.tab=${state.tab}
13641366
.basePath=${state.basePath}
1367+
.agentLabel=${dashboardHeaderContext.agentLabel}
13651368
@navigate=${(event: CustomEvent<Tab>) => {
13661369
state.setTab(event.detail);
13671370
}}

‎ui/src/ui/components/dashboard-header.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LitElement, html } from "lit";
1+
import { LitElement, html, nothing } from "lit";
22
import { property } from "lit/decorators.js";
33
import { pathForTab, titleForTab, type Tab } from "../navigation.js";
44

@@ -9,6 +9,7 @@ export class DashboardHeader extends LitElement {
99

1010
@property() tab: Tab = "overview";
1111
@property() basePath = "";
12+
@property() agentLabel = "";
1213

1314
private readonly handleOverviewClick = (event: MouseEvent) => {
1415
if (
@@ -29,6 +30,7 @@ export class DashboardHeader extends LitElement {
2930

3031
override render() {
3132
const label = titleForTab(this.tab);
33+
const agentLabel = this.agentLabel.trim();
3234

3335
return html`
3436
<div class="dashboard-header">
@@ -40,6 +42,16 @@ export class DashboardHeader extends LitElement {
4042
>
4143
OpenClaw
4244
</a>
45+
${agentLabel
46+
? html`
47+
<span class="dashboard-header__breadcrumb-segment">
48+
<span class="dashboard-header__breadcrumb-sep">›</span>
49+
<span class="dashboard-header__breadcrumb-context" title=${agentLabel}>
50+
${agentLabel}
51+
</span>
52+
</span>
53+
`
54+
: nothing}
4355
<span class="dashboard-header__breadcrumb-sep">›</span>
4456
<span class="dashboard-header__breadcrumb-current">${label}</span>
4557
</div>

0 commit comments

Comments
 (0)