@@ -11,6 +11,7 @@ import {
1111 type ApplicationGatewaySnapshot ,
1212} from "../../app/context.ts" ;
1313import { hasOperatorAdminAccess , hasOperatorPairingAccess } from "../../app/operator-access.ts" ;
14+ import { readPresenceEntries } from "../../app/user-profile.ts" ;
1415import { showConfirmDialog , type ConfirmDialogOptions } from "../../components/confirm-dialog.ts" ;
1516import { showSecretRevealDialog } from "../../components/secret-reveal-dialog.ts" ;
1617import { renderDocsLink } from "../../components/settings-ui.ts" ;
@@ -62,12 +63,6 @@ type InventoryRemovalPrompt =
6263 | { kind : "entry" ; entry : InventoryRemovalRequest }
6364 | { kind : "stale" ; entries : InventoryRemovalRequest [ ] } ;
6465
65- function readPresence ( value : unknown ) : PresenceEntry [ ] | null {
66- const presence =
67- value && typeof value === "object" ? ( value as { presence ?: unknown } ) . presence : null ;
68- return Array . isArray ( presence ) ? ( presence as PresenceEntry [ ] ) : null ;
69- }
70-
7166function presenceConnectivitySignature ( entries : PresenceEntry [ ] ) : string {
7267 const states = new Map < string , "connected" | "offline" > ( ) ;
7368 for ( const entry of entries ) {
@@ -154,7 +149,7 @@ class DevicesPage extends OpenClawLightDomElement {
154149 if ( this . gateway . gateway !== gateway || this . context . gateway !== gateway ) {
155150 return ;
156151 }
157- const presence = event . event === "presence" ? readPresence ( event . payload ) : null ;
152+ const presence = event . event === "presence" ? readPresenceEntries ( event . payload ) : null ;
158153 if ( presence ) {
159154 const connectivityChanged =
160155 presenceConnectivitySignature ( presence ) !==
@@ -226,7 +221,7 @@ class DevicesPage extends OpenClawLightDomElement {
226221 snapshot . client &&
227222 ( change . identityChanged || change . connectionChanged )
228223 ) {
229- const initialPresence = readPresence ( snapshot . hello ?. snapshot ) ;
224+ const initialPresence = readPresenceEntries ( snapshot . hello ?. snapshot ) ;
230225 this . presence = initialPresence ?? [ ] ;
231226 void this . loadPresence ( ) ;
232227 }
@@ -250,7 +245,7 @@ class DevicesPage extends OpenClawLightDomElement {
250245 const snapshot = this . context . gateway . snapshot ;
251246 if ( ! this . gateway . isRouteDataCurrent ( data ) ) {
252247 this . resetServerState ( snapshot ) ;
253- this . presence = readPresence ( snapshot . hello ?. snapshot ) ?? [ ] ;
248+ this . presence = readPresenceEntries ( snapshot . hello ?. snapshot ) ?? [ ] ;
254249 void this . loadPresence ( ) ;
255250 this . ensureInitialData ( ) ;
256251 return ;
@@ -261,7 +256,7 @@ class DevicesPage extends OpenClawLightDomElement {
261256 connected : snapshot . phase === "connected" ,
262257 requestGeneration : this . gateway . epoch ,
263258 } ;
264- const initialPresence = readPresence ( snapshot . hello ?. snapshot ) ;
259+ const initialPresence = readPresenceEntries ( snapshot . hello ?. snapshot ) ;
265260 if ( initialPresence ) {
266261 this . presence = initialPresence ;
267262 }
0 commit comments