Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
246 lines
9.3 KiB
Swift
246 lines
9.3 KiB
Swift
import OpenClawChatUI
|
|
import OpenClawKit
|
|
import SwiftUI
|
|
|
|
struct IPadActivityScreen: View {
|
|
@Environment(NodeAppModel.self) private var appModel
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
@State private var sessions: [OpenClawChatSessionEntry] = []
|
|
@State private var isLoading = false
|
|
@State private var loadErrorText: String?
|
|
let headerLeadingAction: OpenClawSidebarHeaderAction?
|
|
let usesNativeNavigationChrome: Bool
|
|
let openChat: () -> Void
|
|
let openSettings: () -> Void
|
|
|
|
init(
|
|
headerLeadingAction: OpenClawSidebarHeaderAction? = nil,
|
|
usesNativeNavigationChrome: Bool = false,
|
|
openChat: @escaping () -> Void,
|
|
openSettings: @escaping () -> Void)
|
|
{
|
|
self.headerLeadingAction = headerLeadingAction
|
|
self.usesNativeNavigationChrome = usesNativeNavigationChrome
|
|
self.openChat = openChat
|
|
self.openSettings = openSettings
|
|
}
|
|
|
|
var body: some View {
|
|
IPadSidebarScreenChrome(
|
|
title: "Activity",
|
|
subtitle: "Live device and gateway activity.",
|
|
headerLeadingAction: self.headerLeadingAction,
|
|
usesNativeNavigationChrome: self.usesNativeNavigationChrome,
|
|
gatewayAction: self.openSettings)
|
|
{
|
|
ProMetricGrid(metrics: self.metrics)
|
|
self.activityFeed
|
|
}
|
|
.task(id: self.refreshID) {
|
|
await self.refreshSessions()
|
|
}
|
|
.refreshable {
|
|
await self.refreshSessions()
|
|
}
|
|
}
|
|
|
|
private var metrics: [ProMetric] {
|
|
[
|
|
ProMetric(
|
|
icon: self.gatewayConnected ? "checkmark.circle.fill" : "wifi.slash",
|
|
title: "Gateway",
|
|
value: self.gatewayStateText,
|
|
color: self.gatewayConnected ? OpenClawBrand.ok : .secondary),
|
|
ProMetric(
|
|
icon: "person.2.fill",
|
|
title: "Agents",
|
|
value: self.gatewayConnected ? "\(self.appModel.gatewayAgents.count)" : "offline",
|
|
color: OpenClawBrand.accentForeground),
|
|
ProMetric(
|
|
icon: "bubble.left.and.text.bubble.right",
|
|
title: "Sessions",
|
|
value: self.isLoading ? "..." : "\(self.sessionRows.count)",
|
|
color: OpenClawBrand.accentHotForeground),
|
|
]
|
|
}
|
|
|
|
private var activityFeed: some View {
|
|
ProCard(padding: 0, radius: OpenClawProMetric.cardRadius) {
|
|
VStack(spacing: 0) {
|
|
ProPanelHeader(
|
|
title: "Recent activity",
|
|
value: self.isLoading ? "Loading" : nil,
|
|
actionTitle: "Refresh",
|
|
action: {
|
|
Task { await self.refreshSessions() }
|
|
})
|
|
|
|
if let pendingExecApprovalPrompt = self.appModel.pendingExecApprovalPrompt {
|
|
ProStatusRow(
|
|
icon: "hand.raised.fill",
|
|
title: "Approval needed",
|
|
detail: pendingExecApprovalPrompt.commandPreview ?? pendingExecApprovalPrompt.commandText,
|
|
value: "pending",
|
|
color: OpenClawBrand.warn,
|
|
actionTitle: nil,
|
|
action: nil)
|
|
Divider().padding(.leading, 58)
|
|
}
|
|
|
|
ProStatusRow(
|
|
icon: self.gatewayConnected ? "network" : "wifi.slash",
|
|
title: "Gateway",
|
|
detail: self.gatewayDetailText,
|
|
value: self.gatewayStateText.lowercased(),
|
|
color: self.gatewayConnected ? OpenClawBrand.ok : .secondary,
|
|
actionTitle: self.gatewayConnected ? nil : "Settings",
|
|
action: self.gatewayConnected ? nil : self.openSettings)
|
|
|
|
Divider().padding(.leading, 58)
|
|
|
|
ProStatusRow(
|
|
icon: "square.and.arrow.down",
|
|
title: "Share intake",
|
|
detail: self.appModel.lastShareEventText,
|
|
value: "iPad",
|
|
color: OpenClawBrand.accentForeground,
|
|
actionTitle: nil,
|
|
action: nil)
|
|
|
|
if self.isLoading, self.sessions.isEmpty {
|
|
Divider().padding(.leading, 58)
|
|
ProStatusRow(
|
|
icon: "hourglass",
|
|
title: "Loading sessions",
|
|
detail: "Fetching recent activity from the gateway.",
|
|
value: "loading",
|
|
color: OpenClawBrand.accentForeground,
|
|
actionTitle: nil,
|
|
action: nil)
|
|
} else if let loadErrorText {
|
|
Divider().padding(.leading, 58)
|
|
ProStatusRow(
|
|
icon: "exclamationmark.triangle.fill",
|
|
title: "Sessions unavailable",
|
|
detail: loadErrorText,
|
|
value: "error",
|
|
color: OpenClawBrand.warn,
|
|
actionTitle: nil,
|
|
action: nil)
|
|
} else if self.sessionRows.isEmpty {
|
|
Divider().padding(.leading, 58)
|
|
ProStatusRow(
|
|
icon: "bubble.left.and.text.bubble.right",
|
|
title: self.sessionsAvailable ? "No recent sessions" : "Session activity offline",
|
|
detail: self.sessionsAvailable
|
|
? "Start a chat and it will appear here."
|
|
: "Connect to the gateway to load recent chat activity.",
|
|
value: self.sessionsAvailable ? "empty" : "offline",
|
|
color: .secondary,
|
|
actionTitle: self.sessionsAvailable ? "Chat" : nil,
|
|
action: self.sessionsAvailable ? self.openChat : nil)
|
|
} else {
|
|
ForEach(self.sessionRows) { row in
|
|
Divider().padding(.leading, 58)
|
|
ProStatusRow(
|
|
icon: row.icon,
|
|
title: row.title,
|
|
detail: row.detail,
|
|
value: row.state,
|
|
color: row.color,
|
|
actionTitle: "Open",
|
|
action: {
|
|
self.open(row)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.padding(.horizontal, OpenClawProMetric.pagePadding)
|
|
}
|
|
|
|
private var refreshID: String {
|
|
[
|
|
self.sessionsMode,
|
|
self.appModel.chatSessionKey,
|
|
self.scenePhase == .active ? "active" : "inactive",
|
|
].joined(separator: ":")
|
|
}
|
|
|
|
private var gatewayConnected: Bool {
|
|
GatewayStatusBuilder.build(appModel: self.appModel) == .connected
|
|
}
|
|
|
|
private var gatewayStateText: String {
|
|
guard !self.gatewayConnected else { return "Online" }
|
|
let status = self.appModel.gatewayDisplayStatusText.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
return status.isEmpty ? "Offline" : status
|
|
}
|
|
|
|
private var gatewayDetailText: String {
|
|
self.normalized(self.appModel.gatewayRemoteAddress)
|
|
?? self.normalized(self.appModel.gatewayServerName)
|
|
?? "No gateway connection"
|
|
}
|
|
|
|
private var sessionsAvailable: Bool {
|
|
self.appModel.isLocalChatFixtureEnabled || self.appModel.isOperatorGatewayConnected
|
|
}
|
|
|
|
private var sessionsMode: String {
|
|
self.appModel.chatTransportModeID
|
|
}
|
|
|
|
private var sessionRows: [CommandCenterTab.WorkItem] {
|
|
self.sessions
|
|
.filter { CommandCenterTab.isRecentChatSession(
|
|
$0.key,
|
|
defaultSessionKey: self.appModel.defaultChatSessionKey) }
|
|
.sorted { ($0.updatedAt ?? 0) > ($1.updatedAt ?? 0) }
|
|
.prefix(8)
|
|
.map {
|
|
CommandCenterTab.sessionWorkItem(
|
|
for: $0,
|
|
currentSessionKey: self.appModel.chatSessionKey)
|
|
}
|
|
}
|
|
|
|
private func refreshSessions() async {
|
|
guard self.scenePhase == .active else { return }
|
|
guard self.sessionsAvailable else {
|
|
self.sessions = []
|
|
self.loadErrorText = nil
|
|
return
|
|
}
|
|
|
|
self.isLoading = true
|
|
self.loadErrorText = nil
|
|
defer { self.isLoading = false }
|
|
|
|
do {
|
|
let transport = self.appModel.makeChatTransport()
|
|
let response = try await transport.listSessions(limit: CommandCenterTab.recentSessionsFetchLimit)
|
|
self.sessions = response.sessions
|
|
} catch {
|
|
self.sessions = []
|
|
self.loadErrorText = "Try again after the gateway reconnects."
|
|
}
|
|
}
|
|
|
|
private func open(_ item: CommandCenterTab.WorkItem) {
|
|
switch item.route {
|
|
case let .chat(sessionKey):
|
|
self.appModel.openChat(sessionKey: sessionKey)
|
|
self.openChat()
|
|
case .settings:
|
|
self.openSettings()
|
|
}
|
|
}
|
|
|
|
private func normalized(_ value: String?) -> String? {
|
|
guard let value else { return nil }
|
|
let trimmed = value.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
return trimmed.isEmpty ? nil : trimmed
|
|
}
|
|
}
|