Skip to content

Commit 3a5da4f

Browse files
authored
feat(ui): live agent activity subtitles on running sidebar sessions (#111221)
* feat(ui): live agent activity subtitles on running sidebar sessions * refactor(ui): lazy-load narration controller off the startup chunk, unexport test-only symbols * chore(ui): raise startup JS budget to 312 KiB for the lazy narration feature * test(ui): restore real timers after narration controller cases
1 parent 4efcea1 commit 3a5da4f

31 files changed

Lines changed: 2274 additions & 26 deletions

‎scripts/check-control-ui-performance.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ const KIB = 1024;
1212
export const CONTROL_UI_PERFORMANCE_BUDGETS = Object.freeze({
1313
startupJsRequests: 18,
1414
startupCssRequests: 1,
15-
startupJsGzipBytes: 310 * KIB,
15+
// 312 KiB accompanies the live-narration sidebar feature (2026-07): the
16+
// controller is a lazy chunk; only its thin element/pref wiring (~1.5 KiB)
17+
// stays in startup, which exhausted the previous ratchet's headroom.
18+
startupJsGzipBytes: 312 * KIB,
1619
// 45 KiB CSS ceilings maintainer-approved 2026-07 alongside the interleaved
1720
// sidebar zone styling; headroom over the ~36.5 KiB post-diet baseline.
1821
startupCssGzipBytes: 45 * KIB,

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const SESSION_PAGE_SIZE = 50;
3939
const TOTAL_MOCK_SESSIONS = 650;
4040
const TOTAL_TELEGRAM_SESSIONS = 180;
4141
const ATTENTION_FIXTURE_EXPIRES_AT = Date.parse("2099-01-01T00:00:00.000Z");
42+
const NARRATION_DEMO_SESSION_KEY = "agent:main:sidebar-narration-demo";
43+
const NARRATION_DEMO_RUN_ID = "mock-sidebar-narration-run";
4244

4345
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
4446
const uiRoot = path.join(repoRoot, "ui");
@@ -1031,6 +1033,11 @@ async function createChatPickerScenario(): Promise<ControlUiMockGatewayScenario>
10311033
sessionRow("agent:main:main", "Molty", baseTime - 1_000, {
10321034
childSessions: ["agent:main:lisbon-trip"],
10331035
}),
1036+
sessionRow(NARRATION_DEMO_SESSION_KEY, "Sidebar narration demo", baseTime - 15_000, {
1037+
hasActiveRun: true,
1038+
startedAt: baseTime - 45_000,
1039+
status: "running",
1040+
}),
10341041
sessionRow("agent:main:tax-research", "Tax filing research", baseTime - 60_000, {
10351042
hasActiveRun: true,
10361043
status: "running",
@@ -1510,6 +1517,31 @@ async function createChatPickerScenario(): Promise<ControlUiMockGatewayScenario>
15101517
},
15111518
},
15121519
models: modelProviders.models,
1520+
repeatingSessionEvents: {
1521+
intervalMs: 3_000,
1522+
events: [
1523+
{
1524+
event: "agent",
1525+
payload: {
1526+
// replace: the demo replays the same snapshot each cycle; without
1527+
// it the controller's cumulative-length dedupe drops the repeats.
1528+
data: { replace: true, text: "Rebasing onto main and rerunning the sidebar suite." },
1529+
runId: NARRATION_DEMO_RUN_ID,
1530+
sessionKey: NARRATION_DEMO_SESSION_KEY,
1531+
stream: "assistant",
1532+
},
1533+
},
1534+
{
1535+
event: "session.tool",
1536+
payload: {
1537+
data: { name: "exec" },
1538+
runId: NARRATION_DEMO_RUN_ID,
1539+
sessionKey: NARRATION_DEMO_SESSION_KEY,
1540+
stream: "tool",
1541+
},
1542+
},
1543+
],
1544+
},
15131545
sessionArchiveFiltering: true,
15141546
sessionKey: "agent:main:main",
15151547
};

‎src/config/types.openclaw.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ export type OpenClawConfig = {
217217
chatSendShortcut?: "enter" | "modifier-enter";
218218
/** Follow-up handling while a run is active; unset uses the server queue mode. */
219219
chatFollowUpMode?: "steer" | "queue";
220+
/** Show live agent activity beneath running Control UI sidebar sessions. */
221+
sidebarLiveActivity?: boolean;
220222
};
221223
};
222224
/** Secret providers, defaults, and ref-resolution settings. */

‎src/config/zod-schema.root-shape.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ export const OpenClawSchemaShape = {
301301
chatPersistCommentary: z.boolean().optional(),
302302
chatSendShortcut: z.union([z.literal("enter"), z.literal("modifier-enter")]).optional(),
303303
chatFollowUpMode: z.union([z.literal("steer"), z.literal("queue")]).optional(),
304+
sidebarLiveActivity: z.boolean().optional(),
304305
})
305306
.optional(),
306307
})

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ class OpenClawShell extends OpenClawLightDomElement {
14011401
.canPairDevice=${gatewaySnapshot.connected &&
14021402
hasOperatorAdminAccess(gatewaySnapshot.hello?.auth ?? null)}
14031403
.sidebarEntries=${navigationSnapshot.sidebarEntries}
1404+
.sidebarLiveActivity=${uiSettings.sidebarLiveActivity !== false}
14041405
.pinnedAgentIds=${navigationSnapshot.pinnedAgentIds}
14051406
.themeMode=${context.theme.mode}
14061407
.lobsterPetVisits=${uiSettings.lobsterPetVisits !== false}

‎ui/src/app/server-prefs.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe("server pref extraction", () => {
3535
locale: "de",
3636
chatShowThinking: false,
3737
chatSendShortcut: "modifier-enter",
38+
sidebarLiveActivity: false,
3839
sidebarEntries: ["route:usage", "session:agent:main:test", "route:usage", 7],
3940
bogus: true,
4041
}),
@@ -48,6 +49,7 @@ describe("server pref extraction", () => {
4849
locale: "de",
4950
chatShowThinking: false,
5051
chatSendShortcut: "modifier-enter",
52+
sidebarLiveActivity: false,
5153
sidebarEntries: ["route:usage", "session:agent:main:test"],
5254
});
5355
});
@@ -148,6 +150,14 @@ describe("changedServerUiPrefs", () => {
148150
).toBeNull();
149151
});
150152

153+
it("syncs the live sidebar activity preference", () => {
154+
const previous = loadSettings();
155+
expect(previous.sidebarLiveActivity).toBe(true);
156+
expect(changedServerUiPrefs(previous, { ...previous, sidebarLiveActivity: false })).toEqual({
157+
sidebarLiveActivity: false,
158+
});
159+
});
160+
151161
it("syncs chat behavior prefs and pushes clearable resets as null", () => {
152162
const previous = loadSettings();
153163
const withOverrides = {

‎ui/src/app/server-prefs.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ const SYNCED_PREFS = {
100100
extract: (value) => normalizeSidebarEntries(value) ?? undefined,
101101
local: (settings) => settings.sidebarEntries,
102102
}),
103+
sidebarLiveActivity: prefSpec<boolean>({
104+
extract: (value) => (typeof value === "boolean" ? value : undefined),
105+
local: (settings) => settings.sidebarLiveActivity !== false,
106+
}),
103107
} as const;
104108

105109
type SyncedPrefKey = keyof typeof SYNCED_PREFS;

‎ui/src/app/settings.node.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,27 @@ describe("loadSettings default gateway URL derivation", () => {
597597
expect(loadSettings().catalogOpenTarget).toBe("viewer");
598598
});
599599

600+
it("defaults live sidebar activity on and persists only an explicit opt-out", () => {
601+
setTestLocation({
602+
protocol: "https:",
603+
host: "gateway.example:8443",
604+
pathname: "/",
605+
});
606+
607+
const gwUrl = expectedGatewayUrl("");
608+
const scopedKey = `openclaw.control.settings.v1:${gwUrl}`;
609+
expect(loadSettings().sidebarLiveActivity).toBe(true);
610+
611+
saveSettings({ ...loadSettings(), sidebarLiveActivity: false });
612+
expect(JSON.parse(localStorage.getItem(scopedKey) ?? "{}").sidebarLiveActivity).toBe(false);
613+
expect(loadSettings().sidebarLiveActivity).toBe(false);
614+
615+
saveSettings({ ...loadSettings(), sidebarLiveActivity: true });
616+
expect(JSON.parse(localStorage.getItem(scopedKey) ?? "{}")).not.toHaveProperty(
617+
"sidebarLiveActivity",
618+
);
619+
});
620+
600621
it("persists only a normalized realtime Talk microphone id", () => {
601622
setTestLocation({
602623
protocol: "https:",

‎ui/src/app/settings.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export type UiSettings = {
125125
navCollapsed: boolean; // Collapsible sidebar state
126126
navWidth: number; // Sidebar width when expanded (240–400px)
127127
sidebarEntries: string[]; // Ordered routes and pinned sessions below Home
128+
sidebarLiveActivity?: boolean; // Latest activity under running sidebar sessions (default true)
128129
pinnedAgentIds?: string[]; // Agents surfaced first in the agent-chip quick switcher
129130
textScale?: TextScaleStop; // Browser-local text scale percentage
130131
customTheme?: ImportedCustomTheme;
@@ -357,6 +358,7 @@ export function loadSettings(): UiSettings {
357358
navCollapsed: false,
358359
navWidth: NAV_WIDTH_DEFAULT,
359360
sidebarEntries: [...DEFAULT_SIDEBAR_ENTRIES],
361+
sidebarLiveActivity: true,
360362
pinnedAgentIds: [],
361363
textScale: 100,
362364
composerHoldToRecord: true,
@@ -454,6 +456,10 @@ export function loadSettings(): UiSettings {
454456
normalizeSidebarEntries(parsedRecord.sidebarEntries) ??
455457
migratedSidebarEntries ??
456458
defaults.sidebarEntries,
459+
sidebarLiveActivity:
460+
typeof parsed.sidebarLiveActivity === "boolean"
461+
? parsed.sidebarLiveActivity
462+
: defaults.sidebarLiveActivity,
457463
pinnedAgentIds: normalizePinnedAgentIds(parsed.pinnedAgentIds),
458464
textScale: normalizeTextScale(parsed.textScale, defaults.textScale),
459465
customTheme: customTheme ?? undefined,
@@ -592,6 +598,7 @@ function persistSettings(next: UiSettings, options: { selectGateway?: boolean }
592598
navCollapsed: next.navCollapsed,
593599
navWidth: next.navWidth,
594600
sidebarEntries: next.sidebarEntries,
601+
...(next.sidebarLiveActivity === false ? { sidebarLiveActivity: false } : {}),
595602
// Empty pin list is the default; only real pins persist.
596603
...(next.pinnedAgentIds && next.pinnedAgentIds.length > 0
597604
? { pinnedAgentIds: next.pinnedAgentIds }

‎ui/src/components/app-sidebar-base.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export abstract class AppSidebarBase extends OpenClawLightDomContentsElement {
2525
@property({ attribute: false }) canPairDevice = false;
2626
@property({ attribute: false }) sessionKey = "";
2727
@property({ attribute: false }) sidebarEntries: readonly string[] = DEFAULT_SIDEBAR_ENTRIES;
28+
@property({ attribute: false }) sidebarLiveActivity = true;
2829
/** Agents surfaced first in the chip quick switcher when many exist. */
2930
@property({ attribute: false }) pinnedAgentIds: readonly string[] = [];
3031
@property({ attribute: false }) themeMode: ThemeMode = "system";

0 commit comments

Comments
 (0)