Files
openclaw/apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatUserAccentInkTests.swift
Peter Steinberger 0155d95524 feat(ios): adopt gateway user accent in chat (#128599)
* feat(ios): adopt gateway user accent in chat

The iOS chat surface previously always used the hardcoded brand accent.
Read ui.prefs.accent ?? ui.seamColor (the Control UI user-accent
contract) from the existing config.get branding refresh and feed it to
the shared chat kit's userAccent seam, matching the macOS chat window.
Invalid values fall through; accent resets on gateway switch.

* fix(ios): contrast-aware accent ink and live config.changed refresh

Address ClawSweeper review findings: the shared chat kit now derives
user-text/send-glyph ink from the accent via the Control UI WCAG rule
(relative luminance > 0.179 -> black), fixing unreadable light accents
on iOS and macOS alike; the iOS server-event switch routes
config.changed through the guarded branding refresh so an accent
change reaches a connected app without reconnect.
2026-08-24 02:46:06 -07:00

28 lines
1.1 KiB
Swift

import SwiftUI
import Testing
@testable import OpenClawChatUI
struct ChatUserAccentInkTests {
@Test func lightAccentGetsBlackInk() {
// #fbbf24: the Control UI contract example of a light accent needing black ink.
let amber = Color(red: 0xFB / 255.0, green: 0xBF / 255.0, blue: 0x24 / 255.0)
#expect(OpenClawChatTheme.relativeLuminance(of: amber) > 0.179)
#expect(OpenClawChatTheme.userText(on: amber) == .black)
}
@Test func darkAccentKeepsWhiteInk() {
let crimson = Color(red: 0x8B / 255.0, green: 0x00 / 255.0, blue: 0x00 / 255.0)
#expect(OpenClawChatTheme.relativeLuminance(of: crimson) <= 0.179)
#expect(OpenClawChatTheme.userText(on: crimson) == .white)
}
@Test func missingAccentKeepsDefaultUserText() {
#expect(OpenClawChatTheme.userText(on: nil) == OpenClawChatTheme.userText)
}
@Test func luminanceMatchesWcagAnchors() {
#expect(abs(OpenClawChatTheme.relativeLuminance(of: .white) - 1.0) < 0.001)
#expect(abs(OpenClawChatTheme.relativeLuminance(of: .black) - 0.0) < 0.001)
}
}