Skip to content

Commit 1f0a3ec

Browse files
authored
feat(ui): session observer HUD, sidebar subtitles, and settings (#112260)
* feat(ui): session observer HUD, subtitle integration, and settings * test(ui): observer demo fixtures for the mock control-ui harness * fix(ui): satisfy lint and deadcode gates for observer surfaces * test(ui): adopt renamed pull-request summary api after rebase * fix(ui): clean rebase artifacts in observer test files
1 parent 73d2b27 commit 1f0a3ec

35 files changed

Lines changed: 1928 additions & 16 deletions

‎apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,7 @@ public struct SystemInfoResult: Codable, Sendable {
18881888
public let disktotalbytes: Int?
18891889
public let diskavailablebytes: Int?
18901890
public let diskpath: String?
1891+
public let defaultagentutilitymodel: AnyCodable?
18911892

18921893
public init(
18931894
machinename: String,
@@ -1909,7 +1910,8 @@ public struct SystemInfoResult: Codable, Sendable {
19091910
memoryfreebytes: Int,
19101911
disktotalbytes: Int? = nil,
19111912
diskavailablebytes: Int? = nil,
1912-
diskpath: String? = nil)
1913+
diskpath: String? = nil,
1914+
defaultagentutilitymodel: AnyCodable? = nil)
19131915
{
19141916
self.machinename = machinename
19151917
self.hostname = hostname
@@ -1931,6 +1933,7 @@ public struct SystemInfoResult: Codable, Sendable {
19311933
self.disktotalbytes = disktotalbytes
19321934
self.diskavailablebytes = diskavailablebytes
19331935
self.diskpath = diskpath
1936+
self.defaultagentutilitymodel = defaultagentutilitymodel
19341937
}
19351938

19361939
private enum CodingKeys: String, CodingKey {
@@ -1954,6 +1957,7 @@ public struct SystemInfoResult: Codable, Sendable {
19541957
case disktotalbytes = "diskTotalBytes"
19551958
case diskavailablebytes = "diskAvailableBytes"
19561959
case diskpath = "diskPath"
1960+
case defaultagentutilitymodel = "defaultAgentUtilityModel"
19571961
}
19581962
}
19591963

‎docs/web/control-ui.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ The Control UI is a small **Vite + Lit** single-page app served by the Gateway:
1414

1515
It speaks **directly to the Gateway WebSocket** on the same port.
1616

17-
While you watch a running session, the Gateway can use that agent's utility model to produce a compact status digest for session status surfaces. The latest digest stays with the session after the run becomes idle. Session observation is enabled by default; set `gateway.controlUi.sessionObserver: false` to disable it gateway-wide, or set `agents.defaults.utilityModel: ""` to disable utility-model tasks for agents that do not override that setting.
17+
While you watch a running session, the Gateway can use that agent's utility model to produce a compact status digest. Chat shows it as a one-line status pill that expands into a card with the assessment, plan progress, pull requests, and elapsed time. The card can expand once when a run becomes stuck or needs input; the `/btw` side chat takes priority over the expanded card.
18+
19+
After the first digest arrives, it owns that run's sidebar subtitle instead of heuristic live activity. A final done or failed digest remains visible while the session is unread, then the row returns to its normal work subtitle.
20+
21+
Session observation is enabled by default. In **Settings > Appearance > Sidebar**, you can turn it off gateway-wide, inspect the resolved small model and its provenance, or choose automatic routing, disable utility tasks, or select an explicit `agents.defaults.utilityModel`. The equivalent config controls are `gateway.controlUi.sessionObserver: false` and `agents.defaults.utilityModel: ""`.
1822

1923
## Quick open (local)
2024

‎packages/gateway-protocol/src/schema/system-info.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ import { closedObject } from "./closed-object.js";
66
/** Empty request payload for Gateway host system information. */
77
export const SystemInfoParamsSchema = closedObject({});
88

9+
const UtilityModelStatusSchema = Type.Union([
10+
closedObject({ status: Type.Literal("auto"), model: Type.String({ minLength: 1 }) }),
11+
closedObject({ status: Type.Literal("configured"), model: Type.String({ minLength: 1 }) }),
12+
closedObject({ status: Type.Literal("disabled") }),
13+
closedObject({ status: Type.Literal("unavailable") }),
14+
]);
15+
916
/** Gateway host identity and resource snapshot. */
1017
export const SystemInfoResultSchema = closedObject({
1118
machineName: Type.String(),
@@ -29,6 +36,8 @@ export const SystemInfoResultSchema = closedObject({
2936
diskTotalBytes: Type.Optional(Type.Integer()),
3037
diskAvailableBytes: Type.Optional(Type.Integer()),
3138
diskPath: Type.Optional(Type.String()),
39+
/** Resolved utility model for the configured default agent. */
40+
defaultAgentUtilityModel: Type.Optional(UtilityModelStatusSchema),
3241
});
3342

3443
// Wire types derive directly from local schema consts so public d.ts graphs never

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const TOTAL_TELEGRAM_SESSIONS = 180;
4242
const ATTENTION_FIXTURE_EXPIRES_AT = Date.parse("2099-01-01T00:00:00.000Z");
4343
const NARRATION_DEMO_SESSION_KEY = "agent:main:sidebar-narration-demo";
4444
const NARRATION_DEMO_RUN_ID = "mock-sidebar-narration-run";
45+
const OBSERVER_DEMO_SESSION_KEY = "agent:main:session-observer-demo";
46+
const OBSERVER_DEMO_RUN_ID = "mock-session-observer-run";
4547

4648
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
4749
const uiRoot = path.join(repoRoot, "ui");
@@ -1063,6 +1065,19 @@ async function createChatPickerScenario(): Promise<ControlUiMockGatewayScenario>
10631065
sessionRow("agent:main:main", "Molty", baseTime - 1_000, {
10641066
childSessions: ["agent:main:lisbon-trip"],
10651067
}),
1068+
sessionRow(OBSERVER_DEMO_SESSION_KEY, "Session observer demo", baseTime - 3_000, {
1069+
activeRunIds: [OBSERVER_DEMO_RUN_ID],
1070+
hasActiveRun: true,
1071+
observerDigest: {
1072+
headline: "Third run of the same vitest file - two assertions still failing",
1073+
health: "grinding",
1074+
revision: 1,
1075+
runId: OBSERVER_DEMO_RUN_ID,
1076+
updatedAt: baseTime - 2_000,
1077+
},
1078+
startedAt: baseTime - 4_000,
1079+
status: "running",
1080+
}),
10661081
sessionRow(NARRATION_DEMO_SESSION_KEY, "Sidebar narration demo", baseTime - 15_000, {
10671082
hasActiveRun: true,
10681083
startedAt: baseTime - 45_000,
@@ -1085,6 +1100,15 @@ async function createChatPickerScenario(): Promise<ControlUiMockGatewayScenario>
10851100
}),
10861101
sessionRow("agent:main:work-openclaw", "OpenClaw work checkout", baseTime - 85_000, {
10871102
execCwd: "/Users/peter/Work/openclaw",
1103+
lastReadAt: baseTime - 120_000,
1104+
observerDigest: {
1105+
headline: "Done: fixed the flaky retry-window test",
1106+
health: "done",
1107+
revision: 1,
1108+
runId: "mock-idle-final-run",
1109+
updatedAt: baseTime - 40_000,
1110+
},
1111+
unread: true,
10881112
}),
10891113
mainChildRow,
10901114
sessionRow("agent:main:home-server", "Home server migration", baseTime - 240_000, {
@@ -1195,6 +1219,10 @@ async function createChatPickerScenario(): Promise<ControlUiMockGatewayScenario>
11951219
cpuCount: 16,
11961220
memoryTotalBytes: 68_719_476_736,
11971221
memoryFreeBytes: 34_359_738_368,
1222+
defaultAgentUtilityModel: {
1223+
status: "auto",
1224+
model: "anthropic/claude-haiku-4-5",
1225+
},
11981226
},
11991227
"fs.listDir": {
12001228
cases: [
@@ -1676,6 +1704,39 @@ async function createChatPickerScenario(): Promise<ControlUiMockGatewayScenario>
16761704
repeatingSessionEvents: {
16771705
intervalMs: 3_000,
16781706
events: [
1707+
{
1708+
event: "session.observer",
1709+
payload: {
1710+
headline: "Reading the failing test",
1711+
health: "on-track",
1712+
revision: 2,
1713+
runId: OBSERVER_DEMO_RUN_ID,
1714+
sessionKey: OBSERVER_DEMO_SESSION_KEY,
1715+
updatedAt: baseTime + 1_000,
1716+
},
1717+
},
1718+
{
1719+
event: "session.observer",
1720+
payload: {
1721+
headline: "Third run of the same vitest file - two assertions still failing",
1722+
health: "grinding",
1723+
revision: 3,
1724+
runId: OBSERVER_DEMO_RUN_ID,
1725+
sessionKey: OBSERVER_DEMO_SESSION_KEY,
1726+
updatedAt: baseTime + 4_000,
1727+
},
1728+
},
1729+
{
1730+
event: "session.observer",
1731+
payload: {
1732+
headline: "Same failure five runs in a row - it may be circling",
1733+
health: "stuck",
1734+
revision: 4,
1735+
runId: OBSERVER_DEMO_RUN_ID,
1736+
sessionKey: OBSERVER_DEMO_SESSION_KEY,
1737+
updatedAt: baseTime + 7_000,
1738+
},
1739+
},
16791740
{
16801741
event: "agent",
16811742
payload: {

‎src/gateway/server-methods/system-info.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ describe("system.info", () => {
5252
expect(payload.memoryTotalBytes).toBeGreaterThan(0);
5353
expect(payload.processInstanceId).toBe(getGatewayProcessInstanceId());
5454
expect(payload.uptimeMs).toBeGreaterThanOrEqual(0);
55+
expect(payload.defaultAgentUtilityModel).toEqual({ status: "unavailable" });
5556
});
5657
});

‎src/gateway/server-methods/system.ts‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ import {
1616
SYSTEM_PRESENCE_CLEAR_LAST_INPUT_TAG,
1717
validateSystemEventParams,
1818
} from "../../../packages/gateway-protocol/src/schema.js";
19-
import { listAgentIds } from "../../agents/agent-scope.js";
19+
import { listAgentIds, resolveDefaultAgentId } from "../../agents/agent-scope.js";
20+
import {
21+
readUtilityModelSetting,
22+
resolveUtilityModelRefForAgent,
23+
} from "../../agents/utility-model.js";
2024
import { resolveGatewayPort, resolveStateDir } from "../../config/paths.js";
2125
import { resolveMainSessionKeyFromConfig } from "../../config/sessions.js";
2226
import { resolveAdvertisedLanHost } from "../../infra/advertised-lan-host.js";
@@ -55,8 +59,20 @@ async function collectSystemInfo(context: GatewayRequestContext): Promise<System
5559
const loadAverage: [number, number, number] = [oneMinute, fiveMinutes, fifteenMinutes];
5660
const stateDir = resolveStateDir();
5761
const disk = tryReadDiskSpace(stateDir);
58-
const port = resolveGatewayPort(context.getRuntimeConfig());
62+
const config = context.getRuntimeConfig();
63+
const port = resolveGatewayPort(config);
5964
const lanAddress = (await resolveCachedAdvertisedLanHost()) ?? undefined;
65+
const defaultAgentId = resolveDefaultAgentId(config);
66+
const utilitySetting = readUtilityModelSetting(config, defaultAgentId);
67+
const utilityModel = resolveUtilityModelRefForAgent({ cfg: config, agentId: defaultAgentId });
68+
const defaultAgentUtilityModel =
69+
utilitySetting.kind === "disabled"
70+
? ({ status: "disabled" } as const)
71+
: utilitySetting.kind === "explicit"
72+
? ({ status: "configured", model: utilitySetting.modelRef } as const)
73+
: utilityModel
74+
? ({ status: "auto", model: utilityModel } as const)
75+
: ({ status: "unavailable" } as const);
6076

6177
return {
6278
machineName: await getMachineDisplayName(),
@@ -83,6 +99,7 @@ async function collectSystemInfo(context: GatewayRequestContext): Promise<System
8399
diskPath: stateDir,
84100
}
85101
: {}),
102+
defaultAgentUtilityModel,
86103
};
87104
}
88105

‎src/gateway/session-utils.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ describe("gateway session utils", () => {
264264
});
265265

266266
expect(row.observerDigest).toEqual({
267+
runId: observerDigest.runId,
267268
headline: observerDigest.headline,
268269
health: observerDigest.health,
269270
updatedAt: observerDigest.updatedAt,

‎src/gateway/session-utils.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,6 +2238,7 @@ export function buildGatewaySessionRow(params: {
22382238
agentStatus,
22392239
observerDigest: observerDigest
22402240
? {
2241+
runId: observerDigest.runId,
22412242
headline: observerDigest.headline,
22422243
health: observerDigest.health,
22432244
updatedAt: observerDigest.updatedAt,

‎src/gateway/session-utils.types.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ export type GatewaySessionRow = {
8282
unread?: boolean;
8383
lastReadAt?: number;
8484
agentStatus?: SessionEntry["agentStatus"];
85-
observerDigest?: Pick<SessionObserverDigest, "headline" | "health" | "updatedAt" | "revision">;
85+
observerDigest?: Pick<
86+
SessionObserverDigest,
87+
"runId" | "headline" | "health" | "updatedAt" | "revision"
88+
>;
8689
/** Last real user/channel interaction; background work does not advance it. */
8790
lastInteractionAt?: number;
8891
lastActivityAt?: number;

‎ui/src/api/types.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export type UpdateAvailable = import("../../../src/infra/update-startup.js").UpdateAvailable;
22
import type { FastMode } from "@openclaw/normalization-core/string-coerce";
3+
import type { SessionObserverDigest } from "../../../packages/gateway-protocol/src/schema/sessions.js";
34
import type { SessionAgentStatus } from "../../../packages/gateway-protocol/src/session-icon.js";
45
import type { SessionGoal } from "../../../src/config/sessions/types.js";
56
import type { CronJobBase } from "../../../src/cron/types-shared.js";
@@ -510,6 +511,10 @@ export type GatewaySessionRow = {
510511
unread?: boolean;
511512
lastReadAt?: number;
512513
agentStatus?: SessionAgentStatus;
514+
observerDigest?: Pick<
515+
SessionObserverDigest,
516+
"runId" | "headline" | "health" | "updatedAt" | "revision"
517+
>;
513518
lastActivityAt?: number;
514519
archived?: boolean;
515520
archivedAt?: number;

0 commit comments

Comments
 (0)