mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-14 10:46:05 +00:00
chore(apps): remove dead native code
This commit is contained in:
@@ -4076,7 +4076,6 @@ private final class AudioTapDiagnostics: @unchecked Sendable {
|
||||
private var lastLoggedAt = Date.distantPast
|
||||
private var lastLevelEmitAt = Date.distantPast
|
||||
private var maxRmsWindow: Float = 0
|
||||
private var lastRms: Float = 0
|
||||
|
||||
init(label: String, onLevel: (@Sendable (Float) -> Void)? = nil) {
|
||||
self.label = label
|
||||
@@ -4107,7 +4106,6 @@ private final class AudioTapDiagnostics: @unchecked Sendable {
|
||||
|
||||
let resolvedRms = Float(TalkAudioLevel.rms(buffer: buffer))
|
||||
self.lock.lock()
|
||||
self.lastRms = resolvedRms
|
||||
if resolvedRms > self.maxRmsWindow { self.maxRmsWindow = resolvedRms }
|
||||
let maxRms = self.maxRmsWindow
|
||||
if shouldLog { self.maxRmsWindow = 0 }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import AppKit
|
||||
import Foundation
|
||||
import OpenClawIPC
|
||||
import OpenClawKit
|
||||
import WebKit
|
||||
|
||||
|
||||
@@ -36,9 +36,6 @@ let remoteCliPathKey = "openclaw.remoteCliPath"
|
||||
let canvasEnabledKey = "openclaw.canvasEnabled"
|
||||
let cameraEnabledKey = "openclaw.cameraEnabled"
|
||||
let computerControlEnabledKey = "openclaw.computerControlEnabled"
|
||||
let systemRunPolicyKey = "openclaw.systemRunPolicy"
|
||||
let systemRunAllowlistKey = "openclaw.systemRunAllowlist"
|
||||
let systemRunEnabledKey = "openclaw.systemRunEnabled"
|
||||
let locationModeKey = "openclaw.locationMode"
|
||||
let locationPreciseKey = "openclaw.locationPreciseEnabled"
|
||||
let peekabooBridgeEnabledKey = "openclaw.peekabooBridgeEnabled"
|
||||
|
||||
@@ -149,10 +149,6 @@ final class DeepLinkHandler {
|
||||
self.expectedKey()
|
||||
}
|
||||
|
||||
static func currentCanvasKey() -> String {
|
||||
self.canvasUnattendedKey
|
||||
}
|
||||
|
||||
private static func expectedKey() -> String {
|
||||
let defaults = UserDefaults.standard
|
||||
if let key = defaults.string(forKey: deepLinkKeyKey), !key.isEmpty {
|
||||
|
||||
@@ -12,9 +12,4 @@ enum LaunchdManager {
|
||||
let userTarget = "gui/\(getuid())/\(launchdLabel)"
|
||||
self.runLaunchctl(["kickstart", "-k", userTarget])
|
||||
}
|
||||
|
||||
static func stopOpenClaw() {
|
||||
let userTarget = "gui/\(getuid())/\(launchdLabel)"
|
||||
self.runLaunchctl(["stop", userTarget])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ final class MenuSessionsInjector: NSObject, NSMenuDelegate {
|
||||
private var cacheUpdatedAt: Date?
|
||||
private let refreshIntervalSeconds: TimeInterval = 12
|
||||
private var cachedUsageSummary: GatewayUsageSummary?
|
||||
private var cachedUsageErrorText: String?
|
||||
private var usageCacheUpdatedAt: Date?
|
||||
private let usageRefreshIntervalSeconds: TimeInterval = 30
|
||||
private var cachedCostSummary: GatewayCostUsageSummary?
|
||||
@@ -777,7 +776,6 @@ extension MenuSessionsInjector {
|
||||
self.cachedUsageSummary = try await UsageLoader.loadSummary()
|
||||
} catch {
|
||||
self.cachedUsageSummary = nil
|
||||
self.cachedUsageErrorText = nil
|
||||
}
|
||||
self.usageCacheUpdatedAt = Date()
|
||||
}
|
||||
@@ -1283,9 +1281,8 @@ extension MenuSessionsInjector {
|
||||
self.cacheUpdatedAt = Date()
|
||||
}
|
||||
|
||||
func setTestingUsageSummary(_ summary: GatewayUsageSummary?, errorText: String? = nil) {
|
||||
func setTestingUsageSummary(_ summary: GatewayUsageSummary?) {
|
||||
self.cachedUsageSummary = summary
|
||||
self.cachedUsageErrorText = errorText
|
||||
self.usageCacheUpdatedAt = Date()
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,6 @@ actor RemoteTunnelManager {
|
||||
private var lastRestartAt: Date?
|
||||
private let restartBackoffSeconds: TimeInterval = 2.0
|
||||
|
||||
func controlTunnelPortIfRunning() async -> UInt16? {
|
||||
await self.controlTunnelRouteIfRunning()?.localPort
|
||||
}
|
||||
|
||||
func controlTunnelRouteIfRunning() async -> Route? {
|
||||
guard let configuration = try? RemotePortTunnel.configuration(
|
||||
remotePort: GatewayEnvironment.gatewayPort())
|
||||
|
||||
@@ -10,7 +10,6 @@ final class TalkOverlayController {
|
||||
static let overlaySize: CGFloat = 440
|
||||
static let orbSize: CGFloat = 96
|
||||
static let orbPadding: CGFloat = 12
|
||||
static let orbHitSlop: CGFloat = 10
|
||||
|
||||
private let logger = Logger(subsystem: "ai.openclaw", category: "talk.overlay")
|
||||
|
||||
@@ -73,15 +72,6 @@ final class TalkOverlayController {
|
||||
self.model.level = max(0, min(1, level))
|
||||
}
|
||||
|
||||
func currentWindowOrigin() -> CGPoint? {
|
||||
self.window?.frame.origin
|
||||
}
|
||||
|
||||
func setWindowOrigin(_ origin: CGPoint) {
|
||||
guard let window else { return }
|
||||
window.setFrameOrigin(origin)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func ensureWindow() {
|
||||
|
||||
@@ -114,18 +114,6 @@ enum CostUsageFormatting {
|
||||
if value >= 0.01 { return String(format: "$%.2f", value) }
|
||||
return String(format: "$%.4f", value)
|
||||
}
|
||||
|
||||
static func formatTokenCount(_ value: Int?) -> String? {
|
||||
guard let value else { return nil }
|
||||
let safe = max(0, value)
|
||||
if safe >= 1_000_000 { return String(format: "%.1fm", Double(safe) / 1_000_000.0) }
|
||||
if safe >= 1000 {
|
||||
return safe >= 10000
|
||||
? String(format: "%.0fk", Double(safe) / 1000.0)
|
||||
: String(format: "%.1fk", Double(safe) / 1000.0)
|
||||
}
|
||||
return String(safe)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
|
||||
@@ -11,7 +11,6 @@ struct GatewayUsageProvider: Codable {
|
||||
let displayName: String
|
||||
let windows: [GatewayUsageWindow]
|
||||
let plan: String?
|
||||
let error: String?
|
||||
}
|
||||
|
||||
struct GatewayUsageSummary: Codable {
|
||||
@@ -27,12 +26,6 @@ struct UsageRow: Identifiable {
|
||||
let windowLabel: String?
|
||||
let usedPercent: Double?
|
||||
let resetAt: Date?
|
||||
let error: String?
|
||||
|
||||
var hasError: Bool {
|
||||
if let error, !error.isEmpty { return true }
|
||||
return false
|
||||
}
|
||||
|
||||
var titleText: String {
|
||||
if let plan, !plan.isEmpty { return "\(self.displayName) (\(plan))" }
|
||||
@@ -85,8 +78,7 @@ extension GatewayUsageSummary {
|
||||
plan: provider.plan,
|
||||
windowLabel: window.label,
|
||||
usedPercent: window.usedPercent,
|
||||
resetAt: window.resetAt.map { Date(timeIntervalSince1970: $0 / 1000) },
|
||||
error: nil)
|
||||
resetAt: window.resetAt.map { Date(timeIntervalSince1970: $0 / 1000) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
private struct ViewWidthPreferenceKey: PreferenceKey {
|
||||
static let defaultValue: CGFloat = 0
|
||||
|
||||
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
|
||||
value = max(value, nextValue())
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
func onWidthChange(_ onChange: @escaping (CGFloat) -> Void) -> some View {
|
||||
self.background(
|
||||
GeometryReader { proxy in
|
||||
Color.clear.preference(key: ViewWidthPreferenceKey.self, value: proxy.size.width)
|
||||
})
|
||||
.onPreferenceChange(ViewWidthPreferenceKey.self, perform: onChange)
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
enum ViewMetricsTesting {
|
||||
static func reduceWidth(current: CGFloat, next: CGFloat) -> CGFloat {
|
||||
var value = current
|
||||
ViewWidthPreferenceKey.reduce(value: &value, nextValue: { next })
|
||||
return value
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -138,12 +138,6 @@ enum VoiceWakeForwarder {
|
||||
return .failure(.rpcFailed(message))
|
||||
}
|
||||
|
||||
static func checkConnection() async -> Result<Void, VoiceWakeForwardError> {
|
||||
let status = await GatewayConnection.shared.status()
|
||||
if status.ok { return .success(()) }
|
||||
return .failure(.rpcFailed(status.error ?? "agent rpc unreachable"))
|
||||
}
|
||||
|
||||
private static func loadSessionRouteEntry(sessionKey: String) async -> SessionRouteEntry? {
|
||||
do {
|
||||
let data = try await GatewayConnection.shared.request(
|
||||
|
||||
@@ -36,11 +36,6 @@ struct LowCoverageHelperTests {
|
||||
#expect(color == nil)
|
||||
}
|
||||
|
||||
@Test func `view metrics reduce width`() {
|
||||
let value = ViewMetricsTesting.reduceWidth(current: 120, next: 180)
|
||||
#expect(value == 180)
|
||||
}
|
||||
|
||||
@Test func `shell executor handles empty command`() async {
|
||||
let result = await ShellExecutor.runDetailed(command: [], cwd: nil, env: nil, timeout: nil)
|
||||
#expect(result.success == false)
|
||||
|
||||
@@ -94,16 +94,14 @@ struct MenuSessionsInjectorTests {
|
||||
provider: "anthropic",
|
||||
displayName: "Claude",
|
||||
windows: [GatewayUsageWindow(label: "5h", usedPercent: 12, resetAt: nil)],
|
||||
plan: "Pro",
|
||||
error: nil),
|
||||
plan: "Pro"),
|
||||
GatewayUsageProvider(
|
||||
provider: "openai",
|
||||
displayName: "Codex",
|
||||
windows: [GatewayUsageWindow(label: "day", usedPercent: 3, resetAt: nil)],
|
||||
plan: nil,
|
||||
error: nil),
|
||||
plan: nil),
|
||||
])
|
||||
injector.setTestingUsageSummary(usage, errorText: nil)
|
||||
injector.setTestingUsageSummary(usage)
|
||||
|
||||
let menu = NSMenu()
|
||||
menu.addItem(NSMenuItem(title: "Header", action: nil, keyEquivalent: ""))
|
||||
|
||||
@@ -30,14 +30,6 @@ enum ChatLinkPreviewResult: Equatable {
|
||||
|
||||
struct ChatLinkPreviewThumbnail: @unchecked Sendable {
|
||||
let image: CGImage
|
||||
|
||||
var pixelWidth: Int {
|
||||
self.image.width
|
||||
}
|
||||
|
||||
var pixelHeight: Int {
|
||||
self.image.height
|
||||
}
|
||||
}
|
||||
|
||||
enum ChatLinkPreviewImageResult: @unchecked Sendable {
|
||||
@@ -352,7 +344,6 @@ extension [UInt8] {
|
||||
}
|
||||
|
||||
func chatLinkPreviewRedirectURL(
|
||||
response: HTTPURLResponse,
|
||||
request: URLRequest,
|
||||
redirectCount: Int,
|
||||
hostPolicy: (URL) -> Bool = chatLinkPreviewAllowsHost) -> URL?
|
||||
@@ -568,13 +559,12 @@ private final class ChatLinkPreviewSessionDelegate: NSObject, URLSessionDataDele
|
||||
func urlSession(
|
||||
_: URLSession,
|
||||
task _: URLSessionTask,
|
||||
willPerformHTTPRedirection response: HTTPURLResponse,
|
||||
willPerformHTTPRedirection _: HTTPURLResponse,
|
||||
newRequest request: URLRequest,
|
||||
completionHandler: @escaping @Sendable (URLRequest?) -> Void)
|
||||
{
|
||||
let nextURL = self.lock.withLock {
|
||||
let url = chatLinkPreviewRedirectURL(
|
||||
response: response,
|
||||
request: request,
|
||||
redirectCount: self.redirectCount,
|
||||
hostPolicy: self.hostPolicy)
|
||||
|
||||
@@ -141,7 +141,7 @@ struct ChatMarkdownTableView: View {
|
||||
GridRow {
|
||||
ForEach(self.table.header.indices, id: \.self) { column in
|
||||
// One cell per column carries the GFM alignment.
|
||||
self.cell(self.table.header[column], column: column, isHeader: true)
|
||||
self.cell(self.table.header[column], isHeader: true)
|
||||
.gridColumnAlignment(self.columnAlignment(column))
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ struct ChatMarkdownTableView: View {
|
||||
ForEach(self.table.rows.indices, id: \.self) { rowIndex in
|
||||
GridRow {
|
||||
ForEach(self.table.rows[rowIndex].indices, id: \.self) { column in
|
||||
self.cell(self.table.rows[rowIndex][column], column: column, isHeader: false)
|
||||
self.cell(self.table.rows[rowIndex][column], isHeader: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ struct ChatMarkdownTableView: View {
|
||||
.strokeBorder(Color.white.opacity(0.08), lineWidth: 1)))
|
||||
}
|
||||
|
||||
private func cell(_ text: String, column: Int, isHeader: Bool) -> some View {
|
||||
private func cell(_ text: String, isHeader: Bool) -> some View {
|
||||
Text(self.inlineMarkdown(text))
|
||||
.font(isHeader ? OpenClawChatTypography.footnoteSemiBold : OpenClawChatTypography.footnote)
|
||||
.foregroundStyle(OpenClawChatTheme.assistantText)
|
||||
|
||||
@@ -21,7 +21,6 @@ enum OpenClawChatTheme {
|
||||
static let lightCanvasMiddle = UIColor(red: 250 / 255.0, green: 251 / 255.0, blue: 252 / 255.0, alpha: 1)
|
||||
static let lightCanvasBottom = UIColor.white
|
||||
static let lightAccent = UIColor(red: 220 / 255.0, green: 38 / 255.0, blue: 38 / 255.0, alpha: 1)
|
||||
static let lightAccentHot = UIColor(red: 239 / 255.0, green: 68 / 255.0, blue: 68 / 255.0, alpha: 1)
|
||||
static let darkCanvasTop = UIColor(red: 12 / 255.0, green: 13 / 255.0, blue: 15 / 255.0, alpha: 1)
|
||||
static let darkCanvasMiddle = UIColor(red: 7 / 255.0, green: 8 / 255.0, blue: 10 / 255.0, alpha: 1)
|
||||
static let darkCanvasBottom = UIColor(red: 4 / 255.0, green: 5 / 255.0, blue: 6 / 255.0, alpha: 1)
|
||||
@@ -29,7 +28,6 @@ enum OpenClawChatTheme {
|
||||
static let darkPanelRaised = UIColor(red: 17 / 255.0, green: 18 / 255.0, blue: 21 / 255.0, alpha: 1)
|
||||
static let darkComposer = UIColor(red: 24 / 255.0, green: 25 / 255.0, blue: 28 / 255.0, alpha: 1)
|
||||
static let darkAccent = UIColor(red: 198 / 255.0, green: 49 / 255.0, blue: 42 / 255.0, alpha: 1)
|
||||
static let darkAccentHot = UIColor(red: 239 / 255.0, green: 62 / 255.0, blue: 82 / 255.0, alpha: 1)
|
||||
}
|
||||
|
||||
private static func adaptiveColor(
|
||||
@@ -66,14 +64,6 @@ enum OpenClawChatTheme {
|
||||
dynamicProvider: resolvedOnboardingAssistantBubbleColor(for:))
|
||||
#endif
|
||||
|
||||
static var surface: Color {
|
||||
#if os(macOS)
|
||||
Color(nsColor: .windowBackgroundColor)
|
||||
#else
|
||||
Color(uiColor: .systemBackground)
|
||||
#endif
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var background: some View {
|
||||
#if os(macOS)
|
||||
@@ -101,14 +91,6 @@ enum OpenClawChatTheme {
|
||||
#endif
|
||||
}
|
||||
|
||||
static var card: Color {
|
||||
#if os(macOS)
|
||||
Color(nsColor: .textBackgroundColor)
|
||||
#else
|
||||
self.adaptiveColor(light: .secondarySystemBackground, dark: IOSPalette.darkPanel)
|
||||
#endif
|
||||
}
|
||||
|
||||
static var subtleCard: AnyShapeStyle {
|
||||
#if os(macOS)
|
||||
AnyShapeStyle(.ultraThinMaterial)
|
||||
|
||||
@@ -7,14 +7,6 @@ import AppKit
|
||||
enum OpenClawChatTypography {
|
||||
static let bodySize: CGFloat = 17
|
||||
|
||||
static var title3: Font {
|
||||
display(size: 22, weight: .bold, relativeTo: .title2)
|
||||
}
|
||||
|
||||
static var title3SemiBold: Font {
|
||||
display(size: 22, weight: .semibold, relativeTo: .title2)
|
||||
}
|
||||
|
||||
static var headline: Font {
|
||||
display(size: 17, weight: .semibold, relativeTo: .headline)
|
||||
}
|
||||
|
||||
@@ -57,11 +57,6 @@ extension OpenClawChatViewModel {
|
||||
self.sessions[index].thinkingLevel = thinkingLevel
|
||||
}
|
||||
|
||||
/// `agent-command.ts` throws for explicit unsupported levels, so hidden controls must send `off`.
|
||||
var effectiveThinkingLevelForSend: String {
|
||||
self.effectiveThinkingLevelForSend(self.preferredThinkingLevel)
|
||||
}
|
||||
|
||||
func effectiveThinkingLevelForSend(
|
||||
_ storedLevel: String,
|
||||
sessionKey: String? = nil,
|
||||
|
||||
@@ -181,8 +181,6 @@ struct OpenClawMascotPose: Equatable {
|
||||
var effect: OpenClawMascotEffect = .none
|
||||
var effectPhase: CGFloat = 0
|
||||
|
||||
static let still = OpenClawMascotPose()
|
||||
|
||||
/// Motionless expression per mood for Reduce Motion users.
|
||||
static func staticPose(for mood: OpenClawMascotMood) -> OpenClawMascotPose {
|
||||
var pose = OpenClawMascotPose()
|
||||
|
||||
@@ -124,40 +124,24 @@ struct ChatLinkPreviewHostPolicyTests {
|
||||
|
||||
struct ChatLinkPreviewFetcherDecisionTests {
|
||||
@Test func `redirect decision enforces hop limit and host policy`() throws {
|
||||
let originalURL = try #require(URL(string: "https://example.com/start"))
|
||||
let response = try #require(HTTPURLResponse(
|
||||
url: originalURL,
|
||||
statusCode: 302,
|
||||
httpVersion: nil,
|
||||
headerFields: ["Location": "https://example.org/next"]))
|
||||
let publicRequest = try URLRequest(url: #require(URL(string: "https://example.org/next")))
|
||||
let privateRequest = try URLRequest(url: #require(URL(string: "http://127.0.0.1/next")))
|
||||
|
||||
#expect(chatLinkPreviewRedirectURL(
|
||||
response: response,
|
||||
request: publicRequest,
|
||||
redirectCount: 2) == publicRequest.url)
|
||||
#expect(chatLinkPreviewRedirectURL(
|
||||
response: response,
|
||||
request: publicRequest,
|
||||
redirectCount: 3) == nil)
|
||||
#expect(chatLinkPreviewRedirectURL(
|
||||
response: response,
|
||||
request: privateRequest,
|
||||
redirectCount: 0) == nil)
|
||||
}
|
||||
|
||||
@Test func `image redirects use the same hop and host rules`() throws {
|
||||
let originalURL = try #require(URL(string: "https://images.example/start"))
|
||||
let response = try #require(HTTPURLResponse(
|
||||
url: originalURL,
|
||||
statusCode: 302,
|
||||
httpVersion: nil,
|
||||
headerFields: ["Location": "http://127.0.0.1/private.png"]))
|
||||
let privateRequest = try URLRequest(url: #require(URL(string: "http://127.0.0.1/private.png")))
|
||||
|
||||
#expect(chatLinkPreviewRedirectURL(
|
||||
response: response,
|
||||
request: privateRequest,
|
||||
redirectCount: 0) == nil)
|
||||
}
|
||||
@@ -253,8 +237,8 @@ struct ChatLinkPreviewNetworkTests {
|
||||
let data = try makeChatLinkPreviewPNG(width: 1200, height: 800)
|
||||
let thumbnail = try #require(chatDecodeLinkPreviewThumbnail(data, mimeType: "image/png"))
|
||||
|
||||
#expect(max(thumbnail.pixelWidth, thumbnail.pixelHeight) == chatLinkPreviewImageMaxPixelSize)
|
||||
#expect(min(thumbnail.pixelWidth, thumbnail.pixelHeight) <= chatLinkPreviewImageMaxPixelSize)
|
||||
#expect(max(thumbnail.image.width, thumbnail.image.height) == chatLinkPreviewImageMaxPixelSize)
|
||||
#expect(min(thumbnail.image.width, thumbnail.image.height) <= chatLinkPreviewImageMaxPixelSize)
|
||||
}
|
||||
|
||||
@Test func `source pixel limit rejects oversized dimensions before decode`() throws {
|
||||
|
||||
@@ -157,7 +157,7 @@ struct OpenClawMascotAnimatorTests {
|
||||
#expect(celebrating.leftClawDegrees > 0)
|
||||
#expect(celebrating.mouthCurve > 0)
|
||||
let idle = OpenClawMascotPose.staticPose(for: .idle)
|
||||
#expect(idle == .still)
|
||||
#expect(idle == OpenClawMascotPose())
|
||||
}
|
||||
|
||||
@Test func `clamp channels bounds every channel`() {
|
||||
|
||||
Reference in New Issue
Block a user