Skip to content

Commit 3aaf13c

Browse files
authored
feat(ui): show activity cards for online people (#130664)
* feat(ui): show activity cards for online people Record live person timing independently of heartbeat freshness and expose keyboard- and touch-accessible cards with visible session links. Preserve continuous online intervals across overlapping tabs without adding persistent activity history. Closes #130649 * build(protocol): refresh generated presence timing fields * fix(gateway): scope presence snapshots to read-access operators Apply one recipient projection to hello, system-presence, and events. Keep person timing and time-zone details behind read access, and filter watched references with the canonical session-list policy without leaking hidden counts. Preserve idle-person metadata for readers and prevent non-reader activity-driven frames. * fix(plugins): preserve Gateway capability load context Carry the owning registry's metadata generation, workspace, install records, and built-artifact preference through capability discovery. Preserve standalone source loading and existing speech eligibility while avoiding synchronous source transforms on cold Talk catalog requests. Fixes #130777 * test: align integrated presence and capability coverage Keep the recipient matrix in its timing-aware owner, close the suite-owned Gateway for shutdown proof, and spy on the canonical install-record reader. Remove the retired private carrier's assertion allowance. * fix(gateway): broadcast presence when clients connect Publish completed connection rows through the canonical scoped broadcaster so established readers see first connections and reconnects without waiting for profile edits or activity. Preserve shared online intervals and reset them only after the final socket closes. * fix(ci): align presence fixtures and sidebar type ownership Reuse the canonical sidebar host type to remove the type-only lazy-runtime cycle. Assert omitted scopes through hello auth and denied presence reads, and supply presence version callbacks in the shared WebSocket context fixture. Retain startup admission and drain assertions without changing deadlines. * fix(ui): retain latest scroll commands until their destination Do not treat the virtualizer's idle debounce or a decreasing offset as reader takeover. Settle at the actual DOM end within one pixel, retaining the separate eight-pixel UI-follow policy and explicit input cancellation. Cover retargeted idle delivery and near-end precision with the real dependency, synchronize pointer baseline capture, and type the existing composer snapshot as its textarea contract. Fixes #130892
1 parent 5090935 commit 3aaf13c

68 files changed

Lines changed: 3564 additions & 644 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,8 @@ public struct PresenceEntry: Codable, Sendable {
15301530
public let tags: [String]?
15311531
public let text: String?
15321532
public let ts: Int
1533+
public let onlinesince: Int?
1534+
public let lastactivityat: Int?
15331535
public let deviceid: String?
15341536
public let roles: [String]?
15351537
public let scopes: [String]?
@@ -1551,6 +1553,8 @@ public struct PresenceEntry: Codable, Sendable {
15511553
tags: [String]? = nil,
15521554
text: String? = nil,
15531555
ts: Int,
1556+
onlinesince: Int? = nil,
1557+
lastactivityat: Int? = nil,
15541558
deviceid: String? = nil,
15551559
roles: [String]? = nil,
15561560
scopes: [String]? = nil,
@@ -1571,6 +1575,8 @@ public struct PresenceEntry: Codable, Sendable {
15711575
self.tags = tags
15721576
self.text = text
15731577
self.ts = ts
1578+
self.onlinesince = onlinesince
1579+
self.lastactivityat = lastactivityat
15741580
self.deviceid = deviceid
15751581
self.roles = roles
15761582
self.scopes = scopes
@@ -1593,6 +1599,8 @@ public struct PresenceEntry: Codable, Sendable {
15931599
case tags
15941600
case text
15951601
case ts
1602+
case onlinesince = "onlineSince"
1603+
case lastactivityat = "lastActivityAt"
15961604
case deviceid = "deviceId"
15971605
case roles
15981606
case scopes

‎config/assertion-safety-baseline.txt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,6 @@ src/agents/prepared-model-catalog.ts 1
19601960
src/agents/prepared-model-catalog.worker.ts 1
19611961
src/agents/prepared-model-runtime.configured.ts 2
19621962
src/agents/prepared-model-runtime.facts.ts 1
1963-
src/agents/prepared-model-runtime.plugin-context.ts 2
19641963
src/agents/prepared-model-runtime.ts 1
19651964
src/agents/provider-attribution.ts 14
19661965
src/agents/provider-auth-aliases.ts 2
@@ -3033,7 +3032,7 @@ src/gateway/server.auth.control-ui.mobile-bootstrap.suite.ts 7
30333032
src/gateway/server.auth.control-ui.owner-bootstrap.suite.ts 5
30343033
src/gateway/server.auth.control-ui.pairing.suite.ts 6
30353034
src/gateway/server.auth.control-ui.trusted-proxy.suite.ts 5
3036-
src/gateway/server.auth.default-token.suite.ts 11
3035+
src/gateway/server.auth.default-token.suite.ts 10
30373036
src/gateway/server.auth.modes.suite.ts 1
30383037
src/gateway/server/hooks-request-handler.ts 4
30393038
src/gateway/server/http-listen.ts 1

‎docs/concepts/multi-user.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ When several people watch the same session, the transcript also shows a live typ
6060

6161
When the loaded session list contains fewer than two distinct owner identities and no session has recorded outside participants, OpenClaw hides all ownership and owner-filter chrome. A single-user gateway therefore looks unchanged.
6262

63+
## People cards
64+
65+
Hover or focus a person in the sidebar's **Online** section to open their information card. The details button also opens the card on touch devices. Selecting the person's name or **View activity** opens their Activity page.
66+
67+
The card shows how long the person has been continuously connected, their reported app/device context and time zone, and their last observed activity during that online period. Opening a different session, typing, and sending a new message count as activity; connection heartbeats and agent responses do not. **Not observed yet** means no qualifying activity has been recorded, not that the person is inactive. These timing facts are ephemeral and reset after the person's final connection closes or the Gateway restarts.
68+
69+
People presence is shared with operators who have read access (`operator.read`, also implied by `operator.write` or `operator.admin`). Those readers may see other people's online and activity timing and reported time zone whether or not the person is watching a session. Node and pairing-only connections receive neither the presence inventory nor its activity-driven events. This does not change cross-reader IP visibility or provide isolation for all Gateway metadata; see [Who can see presence](/concepts/presence#who-can-see-presence).
70+
71+
**Viewing now** and **Recent sessions** link only to sessions available in your loaded session list. Recent sessions reflect reliable ownership or creation attribution, not a complete history of the person's contributions. Session update times describe the session, not when that person last acted. Connection descriptions and time zones are client-reported hints, not verified physical locations.
72+
73+
The Gateway also filters watched-session references for each recipient using `sessions.list` visibility rules, across connect snapshots, presence RPC responses, and events. Hidden or missing references are omitted without counts or placeholders; opening someone's card never borrows that person's session access.
74+
6375
## Agent-spawned sessions
6476

6577
Sessions an agent creates with `sessions_spawn` (`visible: true`) are attributed to the requesting agent: the creator and initial owner is the agent itself, and the sidebar shows the agent's configured identity name and avatar rather than an internal session key.

‎docs/concepts/presence.md‎

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,38 @@ Presence entries are structured objects with fields like:
3333
- `lastInputSeconds`: seconds since last user input, if known
3434
- `reason`: free-form client-supplied string; the Gateway itself only emits `self`, `connect`, and `disconnect`
3535
- `deviceId`, `roles`, `scopes`: device identity and role/scope hints from the connect handshake
36-
- `ts`: last update timestamp (ms since epoch)
36+
- `ts`: last presence update timestamp (ms since epoch), including heartbeat updates; not a user-activity timestamp
37+
- `onlineSince`: start of an authenticated person's current continuous online period, shared across overlapping connections
38+
- `lastActivityAt`: latest observed accepted interaction during that online period; absent until activity is observed
3739
- `watchedSessions`: session keys the client explicitly declares it is viewing, filtered for the recipient
3840

39-
### Watched session references
40-
41-
Hello snapshots, `system-presence`, and `presence` events include only watched
42-
session references that the recipient can see under the current session-list
43-
visibility rules. Drafts, incognito sessions, and operator role restrictions
44-
follow those same rules. Missing or deleted sessions are omitted, including for
45-
admins. Keys retain their agent scope, including agent-qualified `global` and
46-
`unknown` references.
47-
48-
Session references require an operator connection with read access
49-
(`operator.read`, `operator.write`, or `operator.admin`). Nodes, pairing-only
50-
clients, and non-admin clients awaiting authenticated profile verification still
51-
receive the non-session presence roster in hello snapshots and events, without
52-
watched references. An established admin grant does not depend on profile
53-
verification. `system-presence` itself requires operator read access.
54-
55-
Filtering preserves the connection and person metadata and the presence timestamp.
56-
When no references are visible, `watchedSessions` is omitted, just as when the
57-
client declares no watches; there are no hidden-session counts or markers.
41+
## Who can see presence
42+
43+
The presence roster is shared with operators who have `operator.read` access;
44+
`operator.write` and `operator.admin` also grant read access. Readers can see other
45+
people's online and activity timing and reported `timeZone`, including people who
46+
are not watching a session. Node connections, pairing-only operators, and other
47+
connections without read access receive an empty presence roster in the connect
48+
snapshot and no `presence` events. The `system-presence` RPC requires the same
49+
operator read access.
50+
51+
Watched-session references are filtered separately for each recipient using the
52+
same visibility rules as `sessions.list`. Hidden or missing sessions are omitted
53+
entirely, without counts or placeholders. This filtering applies to connect
54+
snapshots, `system-presence` responses, and presence events; the person being
55+
viewed does not grant the recipient access to their sessions.
56+
57+
Drafts, incognito sessions, and operator role restrictions follow those list
58+
rules. Missing or deleted references are omitted even for admins. Keys retain
59+
their agent scope, including agent-qualified `global` and `unknown` references.
60+
Non-admin readers awaiting authenticated profile verification receive person
61+
metadata but no watched references; established admin grants retain admin list
62+
visibility. When no references are visible, `watchedSessions` is omitted.
5863
Message subscriptions alone do not declare viewer presence.
5964

60-
These are coordination features within a shared agent, not isolation between
61-
mutually untrusted users. Everyone operating an agent shares that agent's
62-
capabilities. See [Multi-user trust boundary](/concepts/multi-user#trust-boundary).
65+
This policy does not change which IP addresses are shared between readers and
66+
does not isolate all Gateway metadata. Use separate Gateway trust boundaries
67+
when readers must not see each other's presence or other shared metadata.
6368

6469
## Producers (where presence comes from)
6570

@@ -111,6 +116,10 @@ by parsed host or other beacon metadata. A stable `instanceId` helps consumers
111116
associate rows with the same client; it does not merge separate user WebSocket
112117
connections. Ephemeral control-plane clients are excluded from tracking entirely.
113118

119+
The Control UI groups connection rows by authenticated identity when displaying
120+
people. The [people card](/concepts/multi-user#people-cards) keeps online duration
121+
and observed activity separate from each entry's heartbeat freshness.
122+
114123
## TTL and bounded size
115124

116125
Presence is intentionally ephemeral:

‎packages/gateway-protocol/src/schema/snapshot.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ describe("SnapshotSchema", () => {
1919
SnapshotSchema,
2020
snapshotWithPresence({
2121
ts: 1,
22+
onlineSince: 0,
23+
lastActivityAt: 1,
2224
user: { id: "[email protected]", email: "[email protected]" },
2325
}),
2426
),
@@ -29,6 +31,14 @@ describe("SnapshotSchema", () => {
2931
expect(Value.Check(SnapshotSchema, snapshotWithPresence({ ts: 1 }))).toBe(true);
3032
});
3133

34+
it.each(["onlineSince", "lastActivityAt"])("rejects non-millisecond %s values", (field) => {
35+
for (const value of [-1, 1.5, "1000", null]) {
36+
expect(Value.Check(SnapshotSchema, snapshotWithPresence({ ts: 1, [field]: value }))).toBe(
37+
false,
38+
);
39+
}
40+
});
41+
3242
it("accepts optional watched session keys", () => {
3343
expect(
3444
Value.Check(

‎packages/gateway-protocol/src/schema/snapshot.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,25 @@ export const PresenceEntrySchema = closedObject({
2626
reason: Type.Optional(NonEmptyString),
2727
tags: Type.Optional(Type.Array(NonEmptyString)),
2828
text: Type.Optional(Type.String()),
29+
/** Heartbeat freshness, not online duration or user activity. */
2930
ts: Type.Integer({ minimum: 0 }),
31+
/** Server timestamps for the person's continuous online interval and last accepted activity. */
32+
onlineSince: Type.Optional(Type.Integer({ minimum: 0 })),
33+
lastActivityAt: Type.Optional(Type.Integer({ minimum: 0 })),
3034
deviceId: Type.Optional(NonEmptyString),
3135
roles: Type.Optional(Type.Array(NonEmptyString)),
3236
scopes: Type.Optional(Type.Array(NonEmptyString)),
3337
instanceId: Type.Optional(NonEmptyString),
3438
user: Type.Optional(
3539
closedObject({
36-
/** Opaque identity key: authenticated email today, durable profile id later. Clients group presence by this. */
40+
/** Canonical profile id when resolved, otherwise authenticated identity. Clients group presence by this. */
3741
id: NonEmptyString,
3842
email: Type.Optional(NonEmptyString),
3943
name: Type.Optional(NonEmptyString),
4044
avatarUrl: Type.Optional(NonEmptyString),
4145
}),
4246
),
43-
/** Session keys this connection is actively subscribed to (watching). Sorted lexicographically for deterministic snapshots. */
47+
/** Sessions this connection declares it is viewing, independent of transport subscriptions. Sorted lexicographically. */
4448
watchedSessions: Type.Optional(Type.Array(NonEmptyString)),
4549
});
4650

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,8 @@ async function createChatPickerScenario(
16981698
]
16991699
: [];
17001700
const workboardMocks = buildWorkboardMocks(baseTime);
1701-
const activitySessions = buildActivitySessionRows(Date.now());
1701+
const activityTime = Date.now();
1702+
const activitySessions = buildActivitySessionRows(activityTime);
17021703
const sessions = [
17031704
...activitySessions,
17041705
...(fixture === "workboard"
@@ -2059,8 +2060,38 @@ async function createChatPickerScenario(
20592060
name: selfProfile.displayName ?? undefined,
20602061
email: selfProfile.emails[0],
20612062
},
2062-
{ id: "presence-colin", name: "Colin", email: "[email protected]" },
2063-
{ id: "presence-patricia", email: "[email protected]" },
2063+
{
2064+
id: "presence-colin",
2065+
name: "Colin",
2066+
2067+
onlineSince: activityTime - 47 * 60_000,
2068+
lastActivityAt: activityTime - 2 * 60_000,
2069+
deviceFamily: "Mac",
2070+
platform: "macOS",
2071+
timeZone: "America/Los_Angeles",
2072+
watchedSessions: ["agent:activity:design-review", "agent:main:main"],
2073+
},
2074+
{
2075+
id: "presence-colin",
2076+
name: "Colin",
2077+
2078+
onlineSince: activityTime - 47 * 60_000,
2079+
lastActivityAt: activityTime - 2 * 60_000,
2080+
deviceFamily: "Mac",
2081+
platform: "macOS",
2082+
timeZone: "America/Los_Angeles",
2083+
watchedSessions: ["agent:activity:design-review"],
2084+
},
2085+
{
2086+
id: "presence-patricia",
2087+
2088+
onlineSince: activityTime - 12 * 60_000,
2089+
lastActivityAt: activityTime - 30_000,
2090+
deviceFamily: "iPhone",
2091+
platform: "iOS",
2092+
timeZone: "Europe/Stockholm",
2093+
watchedSessions: ["agent:activity:support-handoff"],
2094+
},
20642095
],
20652096
methodResponses: {
20662097
...buildBackgroundTasksMock(baseTime),

‎src/agents/openclaw-plugin-tools.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
getPluginRuntimeGatewayRequestScope,
1616
withPluginRuntimeRegistryScope,
1717
} from "../plugins/runtime/gateway-request-scope.js";
18+
import { getPluginRuntimeLoadContext } from "../plugins/runtime/load-context.js";
1819
import type { OpenClawPluginToolDelivery } from "../plugins/tool-types.js";
1920
import { resolvePluginTools } from "../plugins/tools.js";
2021
import type { OpenClawPluginToolContext } from "../plugins/types.js";
@@ -31,7 +32,6 @@ import {
3132
resolveOpenClawPluginToolInputs,
3233
type OpenClawPluginToolOptions,
3334
} from "./openclaw-tools.plugin-context.js";
34-
import { getPreparedPluginRuntimeLoadContext } from "./prepared-model-runtime.plugin-context.js";
3535
import type { PreparedModelRuntimeSnapshot } from "./prepared-model-runtime.types.js";
3636
import { resolveAgentRuntimeToolConfig } from "./tool-runtime-config.js";
3737
import type { AnyAgentTool } from "./tools/common.js";
@@ -307,7 +307,7 @@ export function resolveOpenClawPluginToolsForOptions(params: {
307307
...(preparedModelRuntime
308308
? {
309309
preparedRuntime: {
310-
loadContext: getPreparedPluginRuntimeLoadContext(preparedModelRuntime.pluginRegistry),
310+
loadContext: getPluginRuntimeLoadContext(preparedModelRuntime.pluginRegistry),
311311
metadataSnapshot: preparedModelRuntime.metadataSnapshot,
312312
registry: preparedModelRuntime.pluginRegistry,
313313
},

‎src/agents/openclaw-tools.browser-plugin.integration.test.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ import { loadWebMediaRaw } from "../media/web-media.js";
1919
import { createEmptyPluginRegistry } from "../plugins/registry-empty.js";
2020
import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../plugins/runtime.js";
2121
import { withPluginRuntimeRegistryScope } from "../plugins/runtime/gateway-request-scope.js";
22+
import { getPluginRuntimeLoadContext } from "../plugins/runtime/load-context.js";
2223
import { activateSecretsRuntimeSnapshot, clearSecretsRuntimeSnapshot } from "../secrets/runtime.js";
2324
import { createOutboundTestPlugin, createTestRegistry } from "../test-utils/channel-plugins.js";
2425
import { getRuntimeAuthProfileStoreCredentialsRevision } from "./auth-profiles/runtime-snapshots.js";
2526
import { resolveOpenClawPluginToolsForOptions } from "./openclaw-plugin-tools.js";
2627
import { createOpenClawTools } from "./openclaw-tools.js";
27-
import {
28-
getPreparedPluginRuntimeLoadContext,
29-
prepareOwnedPluginLoadContext,
30-
} from "./prepared-model-runtime.plugin-context.js";
28+
import { prepareOwnedPluginLoadContext } from "./prepared-model-runtime.plugin-context.js";
3129
import { jsonResult } from "./tools/common.js";
3230

3331
const hoisted = vi.hoisted(() => ({
@@ -491,7 +489,7 @@ describe("createOpenClawTools browser plugin integration", () => {
491489
metadataSnapshot,
492490
),
493491
).toBe(metadataSnapshot);
494-
const loadContext = getPreparedPluginRuntimeLoadContext(pluginRegistry);
492+
const loadContext = getPluginRuntimeLoadContext(pluginRegistry);
495493
if (!loadContext) {
496494
throw new Error("expected prepared plugin load context");
497495
}

‎src/agents/prepared-model-runtime.inbound-registry.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import { createDeferred } from "../../test/helpers/promise.js";
1010
import { retainLegacyDefaultAgentId } from "../config/legacy.default-agent-owner.js";
1111
import { createEmptyPluginRegistry } from "../plugins/registry-empty.js";
1212
import { getPluginRuntimeGenerationRegistry } from "../plugins/runtime/generation-scope.js";
13+
import { getPluginRuntimeLoadContext } from "../plugins/runtime/load-context.js";
1314
import {
1415
acquireAgentRunPreparedModelRuntime,
1516
getPreparedModelRuntimeSnapshot,
1617
loadPublishedGatewayReplyDispatchRuntime,
1718
registerPreparedModelRuntimePublicationListener,
1819
refreshPreparedModelRuntimeSnapshots,
1920
} from "./prepared-model-runtime.js";
20-
import { getPreparedPluginRuntimeLoadContext } from "./prepared-model-runtime.plugin-context.js";
2121

2222
const mocks = getPreparedModelRuntimeMocks();
2323

@@ -197,7 +197,7 @@ describe("prepared reply dispatch runtime", () => {
197197
pluginGeneration: configuredRuntimeBefore.pluginGeneration,
198198
});
199199
const dynamicSelectedBefore = dynamicLease.snapshot.pluginRegistry;
200-
expect(getPreparedPluginRuntimeLoadContext(dynamicSelectedBefore)).toMatchObject({
200+
expect(getPluginRuntimeLoadContext(dynamicSelectedBefore)).toMatchObject({
201201
preferBuiltPluginArtifacts: true,
202202
});
203203
dynamicLease.release();

0 commit comments

Comments
 (0)