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
214 lines
7.2 KiB
Swift
214 lines
7.2 KiB
Swift
import AppKit
|
|
import SwiftUI
|
|
|
|
@MainActor
|
|
struct SessionsSettings: View {
|
|
private let isPreview: Bool
|
|
@State private var rows: [SessionRow]
|
|
@State private var errorMessage: String?
|
|
@State private var loading = false
|
|
@State private var hasLoaded = false
|
|
|
|
init(rows: [SessionRow]? = nil, isPreview: Bool = ProcessInfo.processInfo.isPreview) {
|
|
self._rows = State(initialValue: rows ?? [])
|
|
self.isPreview = isPreview
|
|
if isPreview {
|
|
self._hasLoaded = State(initialValue: true)
|
|
}
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 14) {
|
|
self.header
|
|
self.content
|
|
Spacer()
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
|
.settingsDetailContent()
|
|
.task {
|
|
guard !self.hasLoaded else { return }
|
|
guard !self.isPreview else { return }
|
|
self.hasLoaded = true
|
|
await self.refresh()
|
|
}
|
|
}
|
|
|
|
private var header: some View {
|
|
HStack(alignment: .top, spacing: 16) {
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
Text("Sessions")
|
|
.font(.title3.weight(.semibold))
|
|
Text("Peek at the stored conversation buckets the CLI reuses for context and rate limits.")
|
|
.font(.callout)
|
|
.foregroundStyle(.secondary)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
}
|
|
Spacer(minLength: 16)
|
|
SettingsRefreshButton(isLoading: self.loading) {
|
|
Task { await self.refresh() }
|
|
}
|
|
}
|
|
}
|
|
|
|
private var content: some View {
|
|
Group {
|
|
if self.rows.isEmpty, self.errorMessage == nil {
|
|
Text("No sessions yet. They appear after the first inbound message or heartbeat.")
|
|
.font(.footnote)
|
|
.foregroundStyle(.secondary)
|
|
.padding(.top, 6)
|
|
} else {
|
|
ScrollView(.vertical) {
|
|
LazyVStack(alignment: .leading, spacing: 0) {
|
|
ForEach(Array(self.rows.enumerated()), id: \.element.id) { index, row in
|
|
self.sessionRow(row)
|
|
.padding(.horizontal, 8)
|
|
.padding(.vertical, 8)
|
|
|
|
if index != self.rows.count - 1 {
|
|
Divider()
|
|
.padding(.leading, 8)
|
|
}
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
.overlay(alignment: .topLeading) {
|
|
if let errorMessage {
|
|
Text(errorMessage)
|
|
.font(.footnote)
|
|
.foregroundStyle(.red)
|
|
.padding(.leading, 8)
|
|
.padding(.top, 4)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private func sessionRow(_ row: SessionRow) -> some View {
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
HStack(alignment: .firstTextBaseline, spacing: 8) {
|
|
Text(row.label)
|
|
.font(.subheadline.bold())
|
|
.lineLimit(1)
|
|
.truncationMode(.middle)
|
|
Spacer()
|
|
Text(row.ageText)
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
|
|
HStack(spacing: 6) {
|
|
if row.kind != .direct {
|
|
SessionKindBadge(kind: row.kind)
|
|
}
|
|
if !row.flagLabels.isEmpty {
|
|
ForEach(row.flagLabels, id: \.self) { flag in
|
|
Badge(text: flag)
|
|
}
|
|
}
|
|
}
|
|
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
HStack(spacing: 8) {
|
|
Text("Context")
|
|
.font(.caption.weight(.semibold))
|
|
.foregroundStyle(.secondary)
|
|
Spacer()
|
|
Text(row.tokens.contextSummaryShort)
|
|
.font(.caption.monospacedDigit())
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
ContextUsageBar(
|
|
usedTokens: row.tokens.total,
|
|
contextTokens: row.tokens.contextTokens,
|
|
width: nil)
|
|
}
|
|
|
|
HStack(spacing: 10) {
|
|
if let model = row.model, !model.isEmpty {
|
|
self.label(icon: "cpu", text: model)
|
|
}
|
|
self.label(icon: "arrow.down.left", text: "\(row.tokens.input) in")
|
|
self.label(icon: "arrow.up.right", text: "\(row.tokens.output) out")
|
|
if let sessionId = row.sessionId, !sessionId.isEmpty {
|
|
HStack(spacing: 4) {
|
|
Image(systemName: "number").foregroundStyle(.secondary).font(.caption)
|
|
Text(sessionId)
|
|
.font(.footnote.monospaced())
|
|
.foregroundStyle(.secondary)
|
|
.lineLimit(1)
|
|
.truncationMode(.middle)
|
|
}
|
|
.help(sessionId)
|
|
}
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
|
|
private func label(icon: String, text: String) -> some View {
|
|
HStack(spacing: 4) {
|
|
Image(systemName: icon).foregroundStyle(.secondary).font(.caption)
|
|
Text(text)
|
|
}
|
|
.font(.footnote)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
|
|
private func refresh() async {
|
|
guard !self.loading else { return }
|
|
guard !self.isPreview else { return }
|
|
self.loading = true
|
|
self.errorMessage = nil
|
|
|
|
do {
|
|
let snapshot = try await SessionLoader.loadSnapshot()
|
|
self.rows = snapshot.rows
|
|
} catch {
|
|
self.rows = []
|
|
self.errorMessage = (error as? LocalizedError)?.errorDescription ?? error.localizedDescription
|
|
}
|
|
|
|
self.loading = false
|
|
}
|
|
}
|
|
|
|
private struct SessionKindBadge: View {
|
|
let kind: SessionKind
|
|
|
|
var body: some View {
|
|
Text(self.kind.label)
|
|
.font(.caption2.weight(.bold))
|
|
.padding(.horizontal, 7)
|
|
.padding(.vertical, 4)
|
|
.foregroundStyle(self.kind.tint)
|
|
.background(self.kind.tint.opacity(0.15))
|
|
.clipShape(Capsule())
|
|
}
|
|
}
|
|
|
|
private struct Badge: View {
|
|
let text: String
|
|
|
|
var body: some View {
|
|
Text(self.text)
|
|
.font(.caption2.weight(.semibold))
|
|
.padding(.horizontal, 6)
|
|
.padding(.vertical, 3)
|
|
.foregroundStyle(.secondary)
|
|
.background(Color.secondary.opacity(0.12))
|
|
.clipShape(Capsule())
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
struct SessionsSettings_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
SessionsSettings(rows: SessionRow.previewRows, isPreview: true)
|
|
.frame(width: SettingsTab.windowWidth, height: SettingsTab.windowHeight)
|
|
}
|
|
}
|
|
#endif
|