Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
946 changes: 461 additions & 485 deletions apps/.i18n/native-source.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions apps/ios/Resources/Licenses/SwiftUI Siri Waveform.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Noah Chalifour

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
172 changes: 68 additions & 104 deletions apps/ios/Sources/Design/ChatProTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,23 @@ import SwiftUI

struct ChatProTab: View {
@Environment(NodeAppModel.self) private var appModel
@Environment(\.colorScheme) private var colorScheme
@State private var viewModel: OpenClawChatViewModel?
@State private var viewModelTransportModeID = ""
let headerLeadingAction: OpenClawSidebarHeaderAction?
let headerTitle: String?
let headerSubtitle: String?
let showsAgentBadge: Bool
let ownsNavigationStack: Bool
let openSettings: (() -> Void)?

init(
headerLeadingAction: OpenClawSidebarHeaderAction? = nil,
headerTitle: String? = nil,
headerSubtitle: String? = nil,
showsAgentBadge: Bool = true,
ownsNavigationStack: Bool = true,
openSettings: (() -> Void)? = nil)
{
self.headerLeadingAction = headerLeadingAction
self.headerTitle = headerTitle
self.headerSubtitle = headerSubtitle
self.showsAgentBadge = showsAgentBadge
self.ownsNavigationStack = ownsNavigationStack
self.openSettings = openSettings
Expand All @@ -37,6 +33,8 @@ struct ChatProTab: View {
self.content
}
} else {
// Phone and iPad hosts already provide a NavigationStack. Keep
// one native bar so embedded Chat never grows duplicate chrome.
self.content
}
}
Expand All @@ -62,88 +60,68 @@ struct ChatProTab: View {
}

private var content: some View {
ZStack {
OpenClawProBackground()
VStack(spacing: 0) {
self.header
if let viewModel {
OpenClawChatView(
viewModel: viewModel,
drawsBackground: false,
showsSessionSwitcher: false,
userAccent: self.chatUserAccent,
assistantName: self.agentDisplayName,
assistantAvatarText: self.agentBadge,
assistantAvatarTint: OpenClawBrand.accent,
showsAssistantAvatars: false,
composerChrome: .clean,
isComposerEnabled: self.gatewayConnected,
messagePlaceholder: self.messagePlaceholder,
emptyAssistantIntro: "What would you like to work on?",
talkControl: self.talkControl)
.id(ObjectIdentifier(viewModel))
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
} else {
ProCard {
VStack(alignment: .leading, spacing: 8) {
Text("Chat is preparing")
.font(OpenClawType.headline)
Text("The operator session will attach when the gateway is ready.")
.font(OpenClawType.subhead)
.foregroundStyle(.secondary)
}
self.chatSurface
.background(Color(uiColor: .systemBackground))
.navigationTitle(self.headerDisplayTitle)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
if let headerLeadingAction {
ToolbarItem(placement: .topBarLeading) {
OpenClawSidebarRevealButton(action: headerLeadingAction)
}
.padding()
Spacer()
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.safeAreaPadding(.top, 8)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.navigationBarHidden(true)
}

private var header: some View {
OpenClawAdaptiveHeaderRow(
title: self.headerDisplayTitle,
subtitle: self.headerDisplaySubtitle,
titleFont: OpenClawType.headline,
subtitleFont: OpenClawType.caption,
subtitleLineLimit: 1)
{
HStack(spacing: 11) {
if let headerLeadingAction {
OpenClawSidebarHeaderLeadingSlot(action: headerLeadingAction)
if self.showsAgentBadge {
ToolbarItem(placement: .topBarLeading) {
self.headerIdentityBadge
}
}
ToolbarItem(placement: .topBarTrailing) {
self.connectionStatusButton
.accessibilityIdentifier("chat-gateway-status")
}
self.headerIdentityBadge
}
} accessory: {
self.connectionStatusButton
}
.padding(.horizontal, OpenClawProMetric.pagePadding)
.padding(.bottom, 4)
}

@ViewBuilder
private var headerIdentityBadge: some View {
if self.showsAgentBadge {
Text(self.agentBadge)
.font(OpenClawType.avatar(size: self.agentBadge.count > 2 ? 13 : 16))
.foregroundStyle(.white)
.minimumScaleFactor(0.6)
.lineLimit(1)
.frame(width: 38, height: 38)
.background(
Circle()
.fill(OpenClawBrand.accent.gradient))
.overlay(Circle().strokeBorder(.white.opacity(0.18), lineWidth: 1))
.shadow(color: OpenClawBrand.accent.opacity(0.14), radius: 5, y: 2)
private var chatSurface: some View {
if let viewModel {
OpenClawChatView(
viewModel: viewModel,
drawsBackground: false,
showsSessionSwitcher: false,
userAccent: self.chatUserAccent,
assistantName: self.agentDisplayName,
assistantAvatarText: self.agentBadge,
assistantAvatarTint: OpenClawBrand.accent,
showsAssistantAvatars: false,
composerChrome: .clean,
isComposerEnabled: self.gatewayConnected,
messagePlaceholder: self.messagePlaceholder,
talkControl: self.talkControl)
// iMessage-style grey bubbles for agent replies in the clean chrome.
.environment(\.openClawAssistantBubblesInCleanChrome, true)
.id(ObjectIdentifier(viewModel))
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
} else {
ProIconBadge(systemName: "bubble.left", color: OpenClawBrand.accent)
ContentUnavailableView(
"Preparing Chat",
systemImage: "bubble.left.and.bubble.right",
description: Text("The session attaches once the gateway is ready."))
}
}

/// Flat circular avatar for the nav bar — no gradient/shadow, per Apple bar-button sizing.
private var headerIdentityBadge: some View {
Text(self.agentBadge)
.font(OpenClawType.avatar(size: self.agentBadge.count > 2 ? 12 : 15))
.foregroundStyle(.white)
.minimumScaleFactor(0.6)
.lineLimit(1)
.frame(width: 30, height: 30)
.background(Circle().fill(OpenClawBrand.accent))
.accessibilityLabel(self.agentDisplayName)
}

private func syncChatViewModel() {
let sessionKey = self.appModel.chatSessionKey
let transportModeID = self.appModel.chatTransportModeID
Expand Down Expand Up @@ -200,37 +178,27 @@ struct ChatProTab: View {
private var connectionStatusButton: some View {
if let openSettings {
Button(action: openSettings) {
self.connectionStatusIcon
self.connectionPill
}
.buttonStyle(.plain)
.contentShape(Circle())
.accessibilityLabel(self.gatewayAccessibilityLabel)
.accessibilityHint("Opens Settings / Gateway")
.accessibilityIdentifier("chat-gateway-status")
} else {
self.connectionStatusIcon
self.connectionPill
.accessibilityLabel(self.gatewayAccessibilityLabel)
}
}

private var connectionStatusIcon: some View {
Image(systemName: self.gatewayStatusSymbol)
.font(OpenClawType.subheadSemiBold)
.foregroundStyle(self.gatewayPillColor)
.frame(width: 44, height: 44)
}

private var gatewayStatusSymbol: String {
switch self.gatewayDisplayState {
case .connected:
self.gatewayConnected ? "checkmark.circle.fill" : "exclamationmark.circle"
case .connecting:
"arrow.trianglehead.2.clockwise.rotate.90"
case .error:
"exclamationmark.triangle.fill"
case .disconnected:
"wifi.slash"
private var connectionPill: some View {
HStack(spacing: 5) {
ProStatusDot(color: self.gatewayPillColor)
Text(Self.gatewayPillTitle(state: self.gatewayDisplayState, isGatewayUsable: self.gatewayConnected))
.font(OpenClawType.subheadMedium)
.lineLimit(1)
}
.foregroundStyle(self.gatewayPillColor)
// Even breathing room inside the system glass capsule.
.padding(.horizontal, 6)
}

private var gatewayConnected: Bool {
Expand All @@ -253,7 +221,7 @@ struct ChatProTab: View {
case .connected:
self.gatewayConnected ? OpenClawBrand.ok : .secondary
case .connecting:
OpenClawBrand.accentForeground
OpenClawBrand.accent
case .error:
OpenClawBrand.warn
case .disconnected:
Expand Down Expand Up @@ -283,16 +251,12 @@ struct ChatProTab: View {
?? Self.defaultHeaderTitle(showsAgentBadge: self.showsAgentBadge, agentDisplayName: self.agentDisplayName)
}

private var headerDisplaySubtitle: String? {
self.normalized(self.headerSubtitle)
}

nonisolated static func defaultHeaderTitle(showsAgentBadge: Bool, agentDisplayName: String) -> String {
showsAgentBadge ? agentDisplayName : "Chat"
}

private var chatUserAccent: Color {
self.colorScheme == .light ? OpenClawBrand.info : OpenClawBrand.accent
OpenClawBrand.accent
}

private var activeAgent: AgentSummary? {
Expand All @@ -304,9 +268,9 @@ struct ChatProTab: View {
}

private var agentBadge: String {
if let identity = self.activeAgent?.identity,
if let identity = activeAgent?.identity,
let emoji = identity["emoji"]?.value as? String,
let normalizedEmoji = self.normalized(emoji)
let normalizedEmoji = normalized(emoji)
{
return normalizedEmoji
}
Expand Down
30 changes: 23 additions & 7 deletions apps/ios/Sources/Design/OpenClawBrand.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Observation
import SwiftUI

enum AppAppearancePreference: String, CaseIterable, Identifiable {
Expand Down Expand Up @@ -44,12 +45,29 @@ enum AppAppearancePreference: String, CaseIterable, Identifiable {
case .dark: .dark
}
}
}

var userInterfaceStyle: UIUserInterfaceStyle {
switch self {
case .system: .unspecified
case .light: .light
case .dark: .dark
@MainActor
@Observable
final class AppAppearanceModel {
private(set) var preference: AppAppearancePreference

init(userDefaults: UserDefaults = .standard) {
let storedPreference = userDefaults.string(forKey: AppAppearancePreference.storageKey)
.flatMap(AppAppearancePreference.init(rawValue:))
self.preference = AppAppearancePreference.launchArgumentPreference ?? storedPreference ?? .system
if AppAppearancePreference.launchArgumentPreference != nil {
userDefaults.set(self.preference.rawValue, forKey: AppAppearancePreference.storageKey)
}
}

func select(_ preference: AppAppearancePreference, userDefaults: UserDefaults = .standard) {
guard self.preference != preference else { return }
userDefaults.set(preference.rawValue, forKey: AppAppearancePreference.storageKey)
var transaction = Transaction()
transaction.disablesAnimations = true
withTransaction(transaction) {
self.preference = preference
}
}
}
Expand All @@ -65,7 +83,6 @@ enum OpenClawBrand {
static let uiTeal = adaptiveUIColor(light: (0, 196, 176), dark: (0, 196, 176))
static let uiVoid = adaptiveUIColor(light: (246, 247, 249), dark: (11, 12, 17))
static let uiObsidian = adaptiveUIColor(light: (255, 255, 255), dark: (19, 21, 28))
static let uiSlate = adaptiveUIColor(light: (242, 243, 247), dark: (28, 31, 43))
static let uiTextPrimary = adaptiveUIColor(light: (11, 12, 17), dark: (242, 239, 232))
static let uiTextSecondary = adaptiveUIColor(light: (90, 94, 110), dark: (168, 170, 191))
static let uiOK = adaptiveUIColor(light: (19, 122, 62), dark: (48, 209, 88))
Expand All @@ -81,7 +98,6 @@ enum OpenClawBrand {
static let teal = Color(uiColor: Self.uiTeal)
static let void = Color(uiColor: Self.uiVoid)
static let obsidian = Color(uiColor: Self.uiObsidian)
static let slate = Color(uiColor: Self.uiSlate)
static let textPrimary = Color(uiColor: Self.uiTextPrimary)
static let textSecondary = Color(uiColor: Self.uiTextSecondary)
static let danger = Color(uiColor: Self.uiDanger)
Expand Down
2 changes: 0 additions & 2 deletions apps/ios/Sources/Design/OpenClawProComponents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ enum OpenClawSpacing {
static let space3: CGFloat = 12
static let space4: CGFloat = 16
static let space6: CGFloat = 24
static let space8: CGFloat = 32
}

enum OpenClawRadius {
static let xs: CGFloat = 8
static let sm: CGFloat = 10
static let md: CGFloat = 12
static let lg: CGFloat = 16
static let xl: CGFloat = 20
}

struct OpenClawProBackground: View {
Expand Down
4 changes: 0 additions & 4 deletions apps/ios/Sources/Design/OpenClawTypography.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ enum OpenClawType {
scaledDisplay(weight: Display.opticalBold, size: 17, relativeTo: .headline)
}

static func display(size: CGFloat, weight: CGFloat, relativeTo textStyle: UIFont.TextStyle) -> Font {
self.scaledDisplay(weight: weight, size: size, relativeTo: textStyle)
}

// MARK: - Body — Inter

static var body: Font {
Expand Down
Loading
Loading