Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

feat(apps): add device appearance preferences

leepokai29b9739d148f
diff --git a/apps/Codync.xcodeproj/project.pbxproj b/apps/Codync.xcodeproj/project.pbxproj
index b278112f..5ddac675 100644
--- a/apps/Codync.xcodeproj/project.pbxproj
+++ b/apps/Codync.xcodeproj/project.pbxproj
@@ -12,6 +12,7 @@
0631979397E0D6822747E03A /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6E13F8EA6C7B0DA4D899FEE /* RootView.swift */; };
0C920E4962F182ADF75670C5 /* CodyncBot-tablet-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 120FD9DBA315A6DD543463D8 /* CodyncBot-tablet-Ink.ttf */; };
0D6E2869DC5A1BC7D6385444 /* CodyncOrb-Dot.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0C44BCF971511A5E94D073D5 /* CodyncOrb-Dot.ttf */; };
+ 16C24A622E33414C24B0C148 /* AppearanceSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0814BD0C30F01A163FBDF896 /* AppearanceSettings.swift */; };
17DD96A91B1EC2AE699F4A2F /* ViewingBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C0E04490F5C56FD070539E6 /* ViewingBadge.swift */; };
1855DC364C2F8E5B62878BD8 /* CodyncBot-teardrop-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 203A43D8DF8D3832F95FA837 /* CodyncBot-teardrop-Ink.ttf */; };
198096547EAA6C5FBB68558F /* CodyncBot-hex-Ink.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 89A0D530BEF30AF36F9DBEA8 /* CodyncBot-hex-Ink.ttf */; };
@@ -106,6 +107,7 @@
/* Begin PBXFileReference section */
0582B6169BFC36E4BCD51C0D /* BotListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BotListView.swift; sourceTree = "<group>"; };
+ 0814BD0C30F01A163FBDF896 /* AppearanceSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceSettings.swift; sourceTree = "<group>"; };
0829A4FCADAC108E8C2DB2F1 /* Widgets.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Widgets.entitlements; sourceTree = "<group>"; };
0A87B0091DAF0E4807D62017 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
0C44BCF971511A5E94D073D5 /* CodyncOrb-Dot.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "CodyncOrb-Dot.ttf"; sourceTree = "<group>"; };
@@ -286,6 +288,7 @@
B97102DEC6029268332DF901 /* AccessRequestView.swift */,
4EB282B31FBC94EE70D07638 /* AccountSwitcherView.swift */,
DD3DE9A4EEB369C4F75C9448 /* ActivityGalleryView.swift */,
+ 0814BD0C30F01A163FBDF896 /* AppearanceSettings.swift */,
0582B6169BFC36E4BCD51C0D /* BotListView.swift */,
6BC00039A6C2C0D3F39A5F67 /* ComputerStatus.swift */,
6FC76D28AB02DF1427D530ED /* LaunchSplash.swift */,
@@ -663,6 +666,7 @@
7E5F670CFFA0E4373F44DB41 /* AccountSession.swift in Sources */,
9BBB2FAEDBD35A83EAB02981 /* AccountSwitcherView.swift in Sources */,
00F78E3DAAF66E8E0933D091 /* ActivityGalleryView.swift in Sources */,
+ 16C24A622E33414C24B0C148 /* AppearanceSettings.swift in Sources */,
01A1F820EFEE49A8FCCFC3F3 /* BotListView.swift in Sources */,
7C20764DC05D499075BC5E8C /* CodyncApp.swift in Sources */,
2002C16E427B4E4E7279E1C4 /* ComputerStatus.swift in Sources */,
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppearancePreferences.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppearancePreferences.kt
new file mode 100644
index 00000000..99f6efdf
--- /dev/null
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppearancePreferences.kt
@@ -0,0 +1,34 @@
+package com.codync.android
+
+import android.content.Context
+import android.content.SharedPreferences
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.asStateFlow
+
+internal enum class Appearance(val value: String, val label: String) {
+ System("system", "System"), Light("light", "Light"), Dark("dark", "Dark");
+
+ fun isDark(system: Boolean): Boolean = when (this) {
+ System -> system
+ Light -> false
+ Dark -> true
+ }
+}
+
+/** Device-wide UI preference, independent of the active account and host. */
+internal object AppearancePreferences {
+ private var stored: SharedPreferences? = null
+ private val current = MutableStateFlow(Appearance.System)
+ val mode = current.asStateFlow()
+
+ fun initialize(context: Context) {
+ val preferences = context.getSharedPreferences("codync-appearance", Context.MODE_PRIVATE)
+ stored = preferences
+ current.value = Appearance.entries.firstOrNull { it.value == preferences.getString("mode", null) } ?: Appearance.System
+ }
+
+ fun select(value: Appearance) {
+ stored?.edit()?.putString("mode", value.value)?.apply()
+ current.value = value
+ }
+}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/AppearanceSettings.kt b/apps/android/app/src/main/kotlin/com/codync/android/AppearanceSettings.kt
new file mode 100644
index 00000000..4143b086
--- /dev/null
+++ b/apps/android/app/src/main/kotlin/com/codync/android/AppearanceSettings.kt
@@ -0,0 +1,20 @@
+package com.codync.android
+
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.lifecycle.compose.collectAsStateWithLifecycle
+import com.codync.android.design.CardSection
+import com.codync.android.design.ChoicePicker
+import com.codync.android.design.ValueRow
+
+@Composable
+internal fun AppearanceSettings() {
+ val mode by AppearancePreferences.mode.collectAsStateWithLifecycle()
+ CardSection("Appearance", "Only changes appearance on this device.") {
+ row {
+ ValueRow("Theme") {
+ ChoicePicker(mode, Appearance.entries.map { it to it.label }, AppearancePreferences::select, label = "Theme")
+ }
+ }
+ }
+}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/MainActivity.kt b/apps/android/app/src/main/kotlin/com/codync/android/MainActivity.kt
index edd8718b..f4ecb838 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/MainActivity.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/MainActivity.kt
@@ -5,6 +5,9 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.runtime.SideEffect
+import androidx.core.view.WindowCompat
import androidx.activity.viewModels
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
@@ -28,6 +31,7 @@ class MainActivity : ComponentActivity() {
private val store: AppStore by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ AppearancePreferences.initialize(applicationContext)
NativeAccounts.initialize(this)
Analytics.start(applicationContext)
// Clerk's session, not the UI's copy of it: right as sign-in and sign-out happen.
@@ -52,7 +56,16 @@ class MainActivity : ComponentActivity() {
DisposableEffect(images) { onDispose { AccountImages.close(images) } }
CompositionLocalProvider(LocalNetworkImages provides images) {
key(state.contextId, state.generation) {
- CodyncTheme { OverlayRoot { CodyncApp(state, store); LaunchLayer(state.loading) } }
+ val appearance by AppearancePreferences.mode.collectAsStateWithLifecycle()
+ val dark = appearance.isDark(isSystemInDarkTheme())
+ val darkBars = dark || state.screenRequest != null
+ SideEffect {
+ WindowCompat.getInsetsController(window, window.decorView).apply {
+ isAppearanceLightStatusBars = !darkBars
+ isAppearanceLightNavigationBars = !darkBars
+ }
+ }
+ CodyncTheme(dark = dark) { OverlayRoot { CodyncApp(state, store); LaunchLayer(state.loading) } }
}
}
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/SettingsView.kt b/apps/android/app/src/main/kotlin/com/codync/android/SettingsView.kt
index f5a969a3..5a89743e 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/SettingsView.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/SettingsView.kt
@@ -96,6 +96,7 @@ import kotlinx.serialization.json.put
}
}
}
+ AppearanceSettings()
if (state.actualConnection is LinkState.Ready) CardSection("Voice chat", "Android speech on this phone, or OpenAI and Gemini on your own API key, kept on the computer.") {
row {
Row(Modifier.fillMaxWidth().plainButton { voice = true }, verticalAlignment = Alignment.CenterVertically,
diff --git a/apps/android/design/src/main/kotlin/com/codync/android/design/CodyncTheme.kt b/apps/android/design/src/main/kotlin/com/codync/android/design/CodyncTheme.kt
index 889170d7..da82f303 100644
--- a/apps/android/design/src/main/kotlin/com/codync/android/design/CodyncTheme.kt
+++ b/apps/android/design/src/main/kotlin/com/codync/android/design/CodyncTheme.kt
@@ -13,11 +13,10 @@ import androidx.compose.ui.graphics.Color
/** Keep these pairs aligned with CodyncKit/Design/Theme.swift. */
val botMessageBackground: Color
- @Composable get() = if (isSystemInDarkTheme()) Color(0xFF15263E) else Color(0xFFEAF2FF)
+ @Composable get() = if (LocalDark.current) Color(0xFF15263E) else Color(0xFFEAF2FF)
@Composable
-fun CodyncTheme(content: @Composable () -> Unit) {
- val dark = isSystemInDarkTheme()
+fun CodyncTheme(dark: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
val colors = if (dark) darkColorScheme(
primary = Color.White,
onPrimary = Color.Black,
diff --git a/apps/desktop/src/main/appearance.ts b/apps/desktop/src/main/appearance.ts
new file mode 100644
index 00000000..59d02203
--- /dev/null
+++ b/apps/desktop/src/main/appearance.ts
@@ -0,0 +1,15 @@
+import { ipcMain, nativeTheme } from 'electron'
+import { appearance } from '../shared/appearance'
+import { prefs } from './host-controller'
+
+/** Electron applies this to every window's CSS, canvas media queries and native chrome. */
+export function registerAppearance() {
+ nativeTheme.themeSource = appearance(prefs.get('appearance'))
+ ipcMain.handle('app:appearance', () => nativeTheme.themeSource)
+ ipcMain.handle('app:setAppearance', (_event, value: unknown) => {
+ const selected = appearance(value)
+ prefs.set('appearance', selected)
+ nativeTheme.themeSource = selected
+ return selected
+ })
+}
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts
index 22c23868..055ae2a1 100644
--- a/apps/desktop/src/main/index.ts
+++ b/apps/desktop/src/main/index.ts
@@ -1,4 +1,5 @@
import { identity } from './environment'
+import { registerAppearance } from './appearance'
import { execFileSync } from 'node:child_process'
import { hostname } from 'node:os'
import { join } from 'node:path'
@@ -218,6 +219,7 @@ if (yieldsToInstall()) {
// A menu bar app: it keeps running with no window.
})
void app.whenReady().then(() => {
+ registerAppearance()
// Packaged builds take the icon from the bundle (resources/AppIcon.icon); a development run
// would otherwise show Electron's.
if (isMac && !app.isPackaged) app.dock?.setIcon(join(__dirname, '../../resources/icon.png'))
diff --git a/apps/desktop/src/preload/index.ts b/apps/desktop/src/preload/index.ts
index 48939706..3f65b225 100644
--- a/apps/desktop/src/preload/index.ts
+++ b/apps/desktop/src/preload/index.ts
@@ -114,6 +114,8 @@ const bridge: CodyncBridge = {
onCommand: (cb: (c: WindowCommand) => void) => listen('app:command', cb),
resetAllData: () => ipcRenderer.invoke('app:resetAllData'),
setLaunchAtLogin: (on) => ipcRenderer.invoke('app:setLaunchAtLogin', on),
+ appearance: () => ipcRenderer.invoke('app:appearance'),
+ setAppearance: (value) => ipcRenderer.invoke('app:setAppearance', value),
showInDock: () => ipcRenderer.invoke('app:showInDock'),
setShowInDock: (on) => ipcRenderer.invoke('app:setShowInDock', on),
launchAtLogin: () => ipcRenderer.invoke('app:launchAtLogin'),
diff --git a/apps/desktop/src/renderer/demo/bridge.ts b/apps/desktop/src/renderer/demo/bridge.ts
index 0dfc6d63..0c97badf 100644
--- a/apps/desktop/src/renderer/demo/bridge.ts
+++ b/apps/desktop/src/renderer/demo/bridge.ts
@@ -101,6 +101,8 @@ const bridge: CodyncBridge = {
onCommand: none,
resetAllData: async () => {},
setLaunchAtLogin: async () => false,
+ appearance: async () => 'system',
+ setAppearance: async (value) => value,
showInDock: async () => true,
setShowInDock: async () => true,
launchAtLogin: async () => false,
diff --git a/apps/desktop/src/renderer/views/settings/SettingsView.tsx b/apps/desktop/src/renderer/views/settings/SettingsView.tsx
index 32489f3e..1e1d9a6b 100644
--- a/apps/desktop/src/renderer/views/settings/SettingsView.tsx
+++ b/apps/desktop/src/renderer/views/settings/SettingsView.tsx
@@ -1,5 +1,6 @@
import { Fragment, useEffect, useState } from 'react'
import type { Screen } from '@shared/analytics'
+import { APPEARANCES, type Appearance } from '@shared/appearance'
import { islandLabel } from '@shared/island'
import { VOICE_SHORTCUTS, type VoiceShortcut } from '@shared/voice-shortcut'
import { Button, CardForm, CardSection, ChoicePicker, IconButton, ProgressBar, Switch, ValueRow } from '../../components/Controls'
@@ -112,6 +113,8 @@ function PageContent({ page }: { page: SettingsPage }) {
/** Account, window and app preferences. */
function GeneralSettings() {
const account = useAccount()
+ const [appearance, setAppearance] = useState<Appearance>('system')
+ useEffect(() => void window.codync.app.appearance().then(setAppearance), [])
const [textSize, setTextSize] = usePref(prefs.textSize)
const [usageIconStyle, setUsageIconStyle] = usePref(prefs.usageIconStyle)
const [compact, setCompact] = usePref(prefs.sidebarCompact)
@@ -154,6 +157,9 @@ function GeneralSettings() {
</div>
</CardSection>
<CardSection title="Appearance">
+ <ValueRow label="Theme">
+ <ChoicePicker selection={appearance} options={[...APPEARANCES]} onChange={(value) => void window.codync.app.setAppearance(value).then(setAppearance)} />
+ </ValueRow>
<ValueRow label="Text size">
<ChoicePicker
selection={textSize}
diff --git a/apps/desktop/src/shared/appearance.ts b/apps/desktop/src/shared/appearance.ts
new file mode 100644
index 00000000..bd732a64
--- /dev/null
+++ b/apps/desktop/src/shared/appearance.ts
@@ -0,0 +1,11 @@
+export const APPEARANCES = [
+ { id: 'system', label: 'System' },
+ { id: 'light', label: 'Light' },
+ { id: 'dark', label: 'Dark' },
+] as const
+
+export type Appearance = typeof APPEARANCES[number]['id']
+
+export function appearance(value: unknown): Appearance {
+ return value === 'light' || value === 'dark' ? value : 'system'
+}
diff --git a/apps/desktop/src/shared/ipc.ts b/apps/desktop/src/shared/ipc.ts
index 8d0bb30a..e9b17ef0 100644
--- a/apps/desktop/src/shared/ipc.ts
+++ b/apps/desktop/src/shared/ipc.ts
@@ -5,6 +5,7 @@ import type { ScreenAgentState } from './computer-access'
import type { IslandRect, IslandScreen, IslandSummary } from './island'
import type { VoiceKey, VoiceShortcut } from './voice-shortcut'
import type { ErrorReport } from './error-report'
+import type { Appearance } from './appearance'
// The bridge between the main process (host lifecycle, loopback HTTP, tray, windows)
// and the renderer (stores and UI). Exposed as `window.codync` by the preload script.
@@ -222,6 +223,8 @@ export interface CodyncBridge {
onCommand(cb: (command: WindowCommand) => void): () => void
resetAllData(): Promise<void>
setLaunchAtLogin(on: boolean): Promise<boolean>
+ appearance(): Promise<Appearance>
+ setAppearance(value: Appearance): Promise<Appearance>
showInDock(): Promise<boolean>
setShowInDock(on: boolean): Promise<boolean>
launchAtLogin(): Promise<boolean>
diff --git a/apps/ios/App/CodyncApp.swift b/apps/ios/App/CodyncApp.swift
index 91a9e937..49ea57f3 100644
--- a/apps/ios/App/CodyncApp.swift
+++ b/apps/ios/App/CodyncApp.swift
@@ -12,6 +12,7 @@ struct CodyncApp: App {
/// What the App Store has: greys out an update it doesn't have yet, reminds of newer ones.
@State private var updates = AppUpdates()
@Environment(\.scenePhase) private var scenePhase
+ @AppStorage(Appearance.storageKey) private var appearance = Appearance.system
@AppStorage("onboardingCompleted") private var onboardingCompleted = false
/// Cold launch with a computer to reach: the splash covers its connect and catch-up.
@State private var launching = !AppStore.shared.accounts.computers.isEmpty
@@ -34,6 +35,7 @@ struct CodyncApp: App {
})
.environment(updates)
.tint(Palette.accent)
+ .background(AppearanceWindow(appearance: appearance).frame(width: 0, height: 0))
// No scroll indicators anywhere in the app.
.scrollIndicators(.never)
.codyncSheet(isPresented: Binding(
diff --git a/apps/ios/Kit/Sources/CodyncKit/Design/Appearance.swift b/apps/ios/Kit/Sources/CodyncKit/Design/Appearance.swift
new file mode 100644
index 00000000..5597d6c0
--- /dev/null
+++ b/apps/ios/Kit/Sources/CodyncKit/Design/Appearance.swift
@@ -0,0 +1,14 @@
+/// A device preference; it does not change the host or another client's appearance.
+public enum Appearance: String, CaseIterable, Sendable {
+ case system, light, dark
+
+ public static let storageKey = "appearance"
+
+ public var label: String {
+ switch self {
+ case .system: "System"
+ case .light: "Light"
+ case .dark: "Dark"
+ }
+ }
+}
diff --git a/apps/ios/Views/AppearanceSettings.swift b/apps/ios/Views/AppearanceSettings.swift
new file mode 100644
index 00000000..abb8c6a9
--- /dev/null
+++ b/apps/ios/Views/AppearanceSettings.swift
@@ -0,0 +1,42 @@
+import CodyncKit
+import CodyncUI
+import SwiftUI
+import UIKit
+
+struct AppearanceSettings: View {
+ @AppStorage(Appearance.storageKey) private var appearance = Appearance.system
+
+ var body: some View {
+ CardSection("Appearance", footer: "Only changes appearance on this device.") {
+ ValueRow("Theme") {
+ ChoicePicker(selection: $appearance, options: Appearance.allCases.map { (id: $0, label: $0.label) })
+ }
+ }
+ }
+}
+
+/// Apply the device preference to the window so already-presented sheets update too.
+struct AppearanceWindow: UIViewRepresentable {
+ let appearance: Appearance
+
+ func makeUIView(context: Context) -> AppearanceView { AppearanceView() }
+
+ func updateUIView(_ view: AppearanceView, context: Context) {
+ view.style = switch appearance {
+ case .system: .unspecified
+ case .light: .light
+ case .dark: .dark
+ }
+ }
+
+ final class AppearanceView: UIView {
+ var style: UIUserInterfaceStyle = .unspecified {
+ didSet { window?.overrideUserInterfaceStyle = style }
+ }
+
+ override func didMoveToWindow() {
+ super.didMoveToWindow()
+ window?.overrideUserInterfaceStyle = style
+ }
+ }
+}
diff --git a/apps/ios/Views/SettingsView.swift b/apps/ios/Views/SettingsView.swift
index 123d4e85..c40f6b01 100644
--- a/apps/ios/Views/SettingsView.swift
+++ b/apps/ios/Views/SettingsView.swift
@@ -71,6 +71,8 @@ struct SettingsView: View {
}
}
+ AppearanceSettings()
+
CardSection("Notifications", footer: "Get a result summary, a request for input, or a failure notice. Notification previews follow your iOS settings.") {
Toggle("Push notifications", isOn: $notificationsEnabled)
.toggleStyle(.codync)
diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.md
index 228e12bf..256fb0a7 100644
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@ -6,6 +6,14 @@ any left). tools/asc-submit.py reads the released version's section;
a version without one gets a generic "Bug fixes and improvements" line. Delete old sections.
-->
+## 2.23.0
+
+### zh-Hant
+- 外觀可選擇跟隨系統、淺色或深色,並保留此裝置的偏好
+
+### en-US
+- Choose System, Light or Dark appearance and keep your preference on this device
+
## 2.22.2
### zh-Hant
diff --git a/docs/design/ui-conventions.md b/docs/design/ui-conventions.md
index 497fa292..952edf57 100644
--- a/docs/design/ui-conventions.md
+++ b/docs/design/ui-conventions.md
@@ -251,3 +251,19 @@ applies in expanded and compact sidebars. iOS retains native toolbar treatment;
terminal computer selection has no corresponding icon button.
Dialog scrims cover the entire presentation surface, including the iPhone status-bar and home-indicator safe areas, throughout opening and closing. The shared iPhone overlay fades a full-screen canvas without scaling its backdrop; root in-place dialogs also extend the canvas beyond container safe areas. Desktop dialogs keep their viewport-sized backdrop fixed and scale only the card. Terminal dialogs already dim the complete terminal buffer.
+
+## Appearance preference
+
+Desktop General → Appearance and phone settings → Appearance offer **System**,
+**Light** and **Dark**, defaulting to System. Save the choice on the device,
+independently of accounts and hosts, and apply it immediately and on relaunch.
+Desktop uses Electron's native theme source so native chrome, CSS and canvas
+artwork agree across all windows. iPhone sets the window's interface style so
+already-presented sheets update and System clears the override;
+Android supplies the selected theme and matching system-bar contrast. Remote
+screen viewing and explicitly dark previews keep their existing dark surfaces.
+
+The terminal's `Ctrl+K` actions offer the same three choices, saved in the local
+`tui-appearance` file. System retains the terminal's foreground/background and
+uses `COLORFGBG` for accent contrast. `CODYNC_THEME` supplies the initial choice
+when none is saved; `NO_COLOR` continues to disable color output.
diff --git a/docs/images/releases/2.23.0/android-dark.png b/docs/images/releases/2.23.0/android-dark.png
new file mode 100644
index 00000000..2fcc885e
Binary files /dev/null and b/docs/images/releases/2.23.0/android-dark.png differ
diff --git a/docs/images/releases/2.23.0/android-light.png b/docs/images/releases/2.23.0/android-light.png
new file mode 100644
index 00000000..54feb849
Binary files /dev/null and b/docs/images/releases/2.23.0/android-light.png differ
diff --git a/docs/images/releases/2.23.0/ios-dark.png b/docs/images/releases/2.23.0/ios-dark.png
new file mode 100644
index 00000000..071650cf
Binary files /dev/null and b/docs/images/releases/2.23.0/ios-dark.png differ
diff --git a/docs/images/releases/2.23.0/ios-light.png b/docs/images/releases/2.23.0/ios-light.png
new file mode 100644
index 00000000..6572acde
Binary files /dev/null and b/docs/images/releases/2.23.0/ios-light.png differ
diff --git a/docs/images/releases/2.23.0/linux-dark.png b/docs/images/releases/2.23.0/linux-dark.png
new file mode 100644
index 00000000..e445c165
Binary files /dev/null and b/docs/images/releases/2.23.0/linux-dark.png differ
diff --git a/docs/images/releases/2.23.0/linux-light.png b/docs/images/releases/2.23.0/linux-light.png
new file mode 100644
index 00000000..2e22a226
Binary files /dev/null and b/docs/images/releases/2.23.0/linux-light.png differ
diff --git a/docs/images/releases/2.23.0/macos-dark.png b/docs/images/releases/2.23.0/macos-dark.png
new file mode 100644
index 00000000..2882759c
Binary files /dev/null and b/docs/images/releases/2.23.0/macos-dark.png differ
diff --git a/docs/images/releases/2.23.0/macos-light.png b/docs/images/releases/2.23.0/macos-light.png
new file mode 100644
index 00000000..8d02c7f6
Binary files /dev/null and b/docs/images/releases/2.23.0/macos-light.png differ
diff --git a/docs/images/releases/2.23.0/windows-dark.png b/docs/images/releases/2.23.0/windows-dark.png
new file mode 100644
index 00000000..b2b6e54a
Binary files /dev/null and b/docs/images/releases/2.23.0/windows-dark.png differ
diff --git a/docs/images/releases/2.23.0/windows-light.png b/docs/images/releases/2.23.0/windows-light.png
new file mode 100644
index 00000000..ba22569d
Binary files /dev/null and b/docs/images/releases/2.23.0/windows-light.png differ
diff --git a/host/src/tui/app/overlay_keys.rs b/host/src/tui/app/overlay_keys.rs
index a04e00c4..308b074f 100644
--- a/host/src/tui/app/overlay_keys.rs
+++ b/host/src/tui/app/overlay_keys.rs
@@ -44,6 +44,10 @@ impl App {
Action::CheckUpdate => self.call("checkHostUpdate", json!({}), After::Update),
Action::Analytics => self.toggle_analytics(),
Action::AboutAnalytics => self.overlays.push(Overlay::Analytics(AnalyticsSheet::default())),
+ Action::Appearance(mode) => match super::super::appearance::select(mode) {
+ Ok(()) => self.flash(&format!("Appearance: {}", mode.name())),
+ Err(error) => self.flash(&format!("Couldn't save appearance: {error}")),
+ },
Action::Keys => self.overlays.push(Overlay::Help(Editor::default())),
}
}
diff --git a/host/src/tui/app/ui.rs b/host/src/tui/app/ui.rs
index 92a642ac..20200217 100644
--- a/host/src/tui/app/ui.rs
+++ b/host/src/tui/app/ui.rs
@@ -58,9 +58,10 @@ pub enum Action {
Analytics,
AboutAnalytics,
Keys,
+ Appearance(super::super::appearance::Appearance),
}
-pub const ACTIONS: [(&str, &str, Action); 12] = [
+pub const ACTIONS: [(&str, &str, Action); 15] = [
("New bot…", "n", Action::NewBot),
("New group chat…", "m", Action::NewGroup),
("Extensions: agents, connectors, skills…", "A", Action::Market),
@@ -72,6 +73,9 @@ pub const ACTIONS: [(&str, &str, Action); 12] = [
("Check for updates", "", Action::CheckUpdate),
("Share usage analytics", "", Action::Analytics),
("About usage analytics…", "", Action::AboutAnalytics),
+ ("Appearance: System", "", Action::Appearance(super::super::appearance::Appearance::System)),
+ ("Appearance: Light", "", Action::Appearance(super::super::appearance::Appearance::Light)),
+ ("Appearance: Dark", "", Action::Appearance(super::super::appearance::Appearance::Dark)),
("Keys", "?", Action::Keys),
];
diff --git a/host/src/tui/appearance.rs b/host/src/tui/appearance.rs
new file mode 100644
index 00000000..223b83b5
--- /dev/null
+++ b/host/src/tui/appearance.rs
@@ -0,0 +1,88 @@
+//! Appearance belongs to this terminal client, never the connected host.
+
+use anyhow::Result;
+use std::sync::LazyLock;
+use std::sync::atomic::{AtomicU8, Ordering};
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[repr(u8)]
+pub enum Appearance {
+ System,
+ Light,
+ Dark,
+}
+
+impl Appearance {
+ pub fn name(self) -> &'static str {
+ match self {
+ Self::System => "system",
+ Self::Light => "light",
+ Self::Dark => "dark",
+ }
+ }
+
+ fn parse(value: &str) -> Option<Self> {
+ match value.trim() {
+ "system" => Some(Self::System),
+ "light" => Some(Self::Light),
+ "dark" => Some(Self::Dark),
+ _ => None,
+ }
+ }
+}
+
+fn load() -> Appearance {
+ match std::fs::read_to_string(crate::service::data_dir().join("tui-appearance")) {
+ Ok(value) => Appearance::parse(&value).unwrap_or(Appearance::System),
+ Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
+ std::env::var("CODYNC_THEME").ok().and_then(|value| Appearance::parse(&value)).unwrap_or(Appearance::System)
+ }
+ Err(error) => {
+ tracing::warn!(%error, "couldn't read terminal appearance");
+ Appearance::System
+ }
+ }
+}
+
+static SELECTED: LazyLock<AtomicU8> = LazyLock::new(|| AtomicU8::new(load() as u8));
+
+pub fn current() -> Appearance {
+ match SELECTED.load(Ordering::Relaxed) {
+ 1 => Appearance::Light,
+ 2 => Appearance::Dark,
+ _ => Appearance::System,
+ }
+}
+
+pub fn select(mode: Appearance) -> Result<()> {
+ let path = crate::service::data_dir().join("tui-appearance");
+ std::fs::create_dir_all(crate::service::data_dir())?;
+ let temporary = path.with_extension(format!("{}.tmp", uuid::Uuid::new_v4()));
+ let result = std::fs::write(&temporary, mode.name()).and_then(|()| std::fs::rename(&temporary, &path));
+ if result.is_err() {
+ let _ = std::fs::remove_file(&temporary);
+ }
+ result?;
+ SELECTED.store(mode as u8, Ordering::Relaxed);
+ Ok(())
+}
+
+pub fn system_is_light() -> bool {
+ std::env::var("COLORFGBG")
+ .ok()
+ .and_then(|value| value.rsplit(';').next().and_then(|background| background.parse::<u8>().ok()))
+ .is_some_and(|background| background == 7 || background == 15)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn saved_choices_round_trip_and_unknown_values_are_rejected() {
+ for mode in [Appearance::System, Appearance::Light, Appearance::Dark] {
+ assert_eq!(Appearance::parse(mode.name()), Some(mode));
+ }
+ assert_eq!(Appearance::parse("unknown"), None);
+ }
+}
diff --git a/host/src/tui/mod.rs b/host/src/tui/mod.rs
index 791f0cb5..f143e04a 100644
--- a/host/src/tui/mod.rs
+++ b/host/src/tui/mod.rs
@@ -2,6 +2,7 @@
//! same HTTP + SSE API as the phone and desktop apps (locally: no pairing needed).
mod app;
+mod appearance;
mod connections;
mod drafts;
mod manage;
diff --git a/host/src/tui/view/mod.rs b/host/src/tui/view/mod.rs
index 1f38b1a7..01a4e4ca 100644
--- a/host/src/tui/view/mod.rs
+++ b/host/src/tui/view/mod.rs
@@ -62,6 +62,7 @@ pub fn draw(f: &mut Frame<'_>, app: &mut App) {
_ => Width::Huge,
};
let buf = f.buffer_mut();
+ buf.set_style(area, theme().text);
if area.width < 40 || area.height < 12 {
let c = app.counts();
put(buf, 0, 0, area.width, "Make the window bigger", theme().bold);
diff --git a/host/src/tui/view/style.rs b/host/src/tui/view/style.rs
index e31254d1..4a5f2bcb 100644
--- a/host/src/tui/view/style.rs
+++ b/host/src/tui/view/style.rs
@@ -34,79 +34,84 @@ pub(super) fn rgb(hex: u32) -> Color {
}
pub fn theme() -> &'static Theme {
- static T: LazyLock<Theme> = LazyLock::new(|| {
- let color = std::env::var_os("NO_COLOR").is_none_or(|v| v.is_empty());
- // COLORFGBG="15;0" is a dark background; "0;15" a light one. CODYNC_THEME wins.
- let light = match std::env::var("CODYNC_THEME").as_deref() {
- Ok("light") => true,
- Ok("dark") => false,
- _ => std::env::var("COLORFGBG")
- .ok()
- .and_then(|v| v.rsplit(';').next().and_then(|b| b.parse::<u8>().ok()))
- .is_some_and(|bg| bg == 7 || bg == 15),
- };
- let s = Style::default();
- if !color {
- let rev = s.add_modifier(Modifier::REVERSED);
- return Theme {
- color,
- text: s,
- bold: s.add_modifier(Modifier::BOLD),
- secondary: s,
- dim: s.add_modifier(Modifier::DIM),
- line: s.add_modifier(Modifier::DIM),
- amber: s.add_modifier(Modifier::BOLD),
- red: s.add_modifier(Modifier::BOLD),
- green: s,
- code: s.add_modifier(Modifier::BOLD),
- code_block: s,
- band: s,
- sel: rev,
- panel: s,
- btn: s,
- btn_primary: rev.add_modifier(Modifier::BOLD),
- added: s,
- removed: s.add_modifier(Modifier::DIM),
- on_color: Color::Reset,
- shade: Color::Reset,
- };
- }
- let (text, second, dim, line, band, sel, panel, btn, green, red, add_bg, rm_bg) = if light {
- (
- 0x141414, 0x5F5F5F, 0x767676, 0xD6D6D6, 0xEFEFEF, 0xE2E2E2, 0xF7F7F7, 0xE4E4E4, 0x2E7D32, 0xC23A2B,
- 0xE3F3E4, 0xF9E3E0,
- )
- } else {
- (
- 0xF2F2F2, 0x9A9A9A, 0x929292, 0x333333, 0x1C1C1C, 0x262626, 0x141414, 0x2A2A2A, 0x8FD18B, 0xF0A7A7,
- 0x14261A, 0x2A1616,
- )
- };
- let fg = |h| s.fg(rgb(h));
- Theme {
+ use super::super::appearance::{self, Appearance};
+ static LIGHT: LazyLock<Theme> = LazyLock::new(|| build_theme(true, true, true));
+ static DARK: LazyLock<Theme> = LazyLock::new(|| build_theme(false, true, true));
+ static SYSTEM_LIGHT: LazyLock<Theme> = LazyLock::new(|| build_theme(true, true, false));
+ static SYSTEM_DARK: LazyLock<Theme> = LazyLock::new(|| build_theme(false, true, false));
+ static MONO: LazyLock<Theme> = LazyLock::new(|| build_theme(false, false, false));
+ if std::env::var_os("NO_COLOR").is_some_and(|value| !value.is_empty()) {
+ return &MONO;
+ }
+ match appearance::current() {
+ Appearance::Light => &LIGHT,
+ Appearance::Dark => &DARK,
+ Appearance::System if appearance::system_is_light() => &SYSTEM_LIGHT,
+ Appearance::System => &SYSTEM_DARK,
+ }
+}
+
+fn build_theme(light: bool, color: bool, explicit: bool) -> Theme {
+ let s = if explicit { Style::default().bg(rgb(if light { 0xFFFFFF } else { 0x0A0A0A })) } else { Style::default() };
+ if !color {
+ let rev = s.add_modifier(Modifier::REVERSED);
+ return Theme {
color,
text: s,
bold: s.add_modifier(Modifier::BOLD),
- secondary: fg(second),
- dim: fg(dim),
- line: fg(line),
- amber: fg(if light { 0xB8700A } else { 0xF0A030 }),
- red: fg(red),
- green: fg(green),
- code: s.bg(rgb(band)),
- code_block: s.bg(rgb(band)),
- band: s.bg(rgb(band)),
- sel: s.bg(rgb(sel)),
- panel: s.bg(rgb(panel)),
- btn: s.bg(rgb(btn)),
- btn_primary: s.fg(rgb(if light { 0xFFFFFF } else { 0x0A0A0A })).bg(rgb(text)).add_modifier(Modifier::BOLD),
- added: s.fg(rgb(green)).bg(rgb(add_bg)),
- removed: s.fg(rgb(red)).bg(rgb(rm_bg)),
- on_color: rgb(0x0A0A0A),
- shade: rgb(if light { 0xB0B0B0 } else { 0x3A3A3A }),
- }
- });
- &T
+ secondary: s,
+ dim: s.add_modifier(Modifier::DIM),
+ line: s.add_modifier(Modifier::DIM),
+ amber: s.add_modifier(Modifier::BOLD),
+ red: s.add_modifier(Modifier::BOLD),
+ green: s,
+ code: s.add_modifier(Modifier::BOLD),
+ code_block: s,
+ band: s,
+ sel: rev,
+ panel: s,
+ btn: s,
+ btn_primary: rev.add_modifier(Modifier::BOLD),
+ added: s,
+ removed: s.add_modifier(Modifier::DIM),
+ on_color: Color::Reset,
+ shade: Color::Reset,
+ };
+ }
+ let (text, second, dim, line, band, sel, panel, btn, green, red, add_bg, rm_bg) = if light {
+ (
+ 0x141414, 0x5F5F5F, 0x767676, 0xD6D6D6, 0xEFEFEF, 0xE2E2E2, 0xF7F7F7, 0xE4E4E4, 0x2E7D32, 0xC23A2B,
+ 0xE3F3E4, 0xF9E3E0,
+ )
+ } else {
+ (
+ 0xF2F2F2, 0x9A9A9A, 0x929292, 0x333333, 0x1C1C1C, 0x262626, 0x141414, 0x2A2A2A, 0x8FD18B, 0xF0A7A7,
+ 0x14261A, 0x2A1616,
+ )
+ };
+ let fg = |h| s.fg(rgb(h));
+ Theme {
+ color,
+ text: if explicit { fg(text) } else { s },
+ bold: (if explicit { fg(text) } else { s }).add_modifier(Modifier::BOLD),
+ secondary: fg(second),
+ dim: fg(dim),
+ line: fg(line),
+ amber: fg(if light { 0xB8700A } else { 0xF0A030 }),
+ red: fg(red),
+ green: fg(green),
+ code: s.bg(rgb(band)),
+ code_block: s.bg(rgb(band)),
+ band: s.bg(rgb(band)),
+ sel: s.bg(rgb(sel)),
+ panel: s.bg(rgb(panel)),
+ btn: s.bg(rgb(btn)),
+ btn_primary: s.fg(rgb(if light { 0xFFFFFF } else { 0x0A0A0A })).bg(rgb(text)).add_modifier(Modifier::BOLD),
+ added: s.fg(rgb(green)).bg(rgb(add_bg)),
+ removed: s.fg(rgb(red)).bg(rgb(rm_bg)),
+ on_color: rgb(0x0A0A0A),
+ shade: rgb(if light { 0xB0B0B0 } else { 0x3A3A3A }),
+ }
}
pub fn bot_color(name: &str) -> Color {
@@ -188,3 +193,25 @@ pub(super) fn face_style(color: &str) -> Style {
let t = theme();
if t.color { Style::default().fg(bot_color(color)) } else { t.text }
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn explicit_appearance_sets_both_ink_and_ground_while_system_keeps_terminal_colors() {
+ let light = build_theme(true, true, true);
+ let dark = build_theme(false, true, true);
+ assert_eq!(light.text.fg, Some(rgb(0x141414)));
+ assert_eq!(light.text.bg, Some(rgb(0xFFFFFF)));
+ assert_eq!(dark.text.fg, Some(rgb(0xF2F2F2)));
+ assert_eq!(dark.text.bg, Some(rgb(0x0A0A0A)));
+ for light in [true, false] {
+ assert_eq!(build_theme(light, true, false).text, Style::default());
+ }
+ let mono = build_theme(false, false, false);
+ assert_eq!(mono.text, Style::default());
+ assert_eq!(mono.btn_primary.fg, None);
+ assert_eq!(mono.btn_primary.bg, None);
+ }
+}