The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
feat(mobile): light mode, and Dark/Light terminal schemes (#248)
bubu-dudu10070f4fb5ed
diff --git a/mobile/lib/app_shell.dart b/mobile/lib/app_shell.dartindex 82753003b..648623a90 100644--- a/mobile/lib/app_shell.dart+++ b/mobile/lib/app_shell.dart@@ -1,4 +1,5 @@import 'package:flutter/material.dart';+import 'package:flutter/services.dart';import 'package:flutter_riverpod/flutter_riverpod.dart';import 'analytics/analytics_lifecycle.dart';@@ -130,9 +131,9 @@ class HarnessApp extends StatelessWidget {),// The design system's own `buildAppTheme` — see the note where a second,// hand-written `ThemeData` used to shadow it, in `lib/theme/app_theme.dart`.- // Harness Desktop is dark-only: one theme, no `darkTheme`/`themeMode` to- // resolve between.- theme: grid.buildAppTheme(brightness: Brightness.dark),+ // One theme, no `darkTheme`/`themeMode` to resolve between: the chosen+ // palette says whether it is light or dark.+ theme: grid.buildAppTheme(brightness: prefs.palette.brightness),// The UI size reaches every `Text` as a text SCALE rather than as hundreds// of edited call sites. `withClampedTextScaling` with both bounds equal IS// the way to force a factor — MediaQuery has no "set the scale"@@ -175,9 +176,13 @@ class HarnessApp extends StatelessWidget {/// mounted with. [grid.BrightnessScope] marks the ones that called/// `AppTheme.watch` dirty directly, across that boundary.///-/// Pinned to [Brightness.dark] rather than read from `Theme.of(context)`:-/// Harness Desktop is dark-only, and there is no other theme for `Theme.of`-/// to ever resolve to here.+/// Set from the palette rather than read from `Theme.of(context)`: the palette+/// is where light or dark is chosen, and [HarnessApp] builds the theme from the+/// same value, so the two cannot disagree.+///+/// The status and navigation bar icons follow it too. Nothing else sets them —+/// the phone draws no `AppBar` — so without this they kept the OS's own style+/// and went dark-on-dark or light-on-light with the app.class _GridTokenScope extends StatelessWidget {const _GridTokenScope({required this.child});@@ -185,11 +190,32 @@ class _GridTokenScope extends StatelessWidget {@overrideWidget build(BuildContext context) {- grid.AppTheme.brightness.value = Brightness.dark;- return grid.BrightnessScope(child: child);+ final brightness = grid.AppTheme.palette.value.brightness;+ grid.AppTheme.brightness.value = brightness;+ return AnnotatedRegion<SystemUiOverlayStyle>(+ value: systemBarsFor(brightness),+ child: grid.BrightnessScope(child: child),+ );}}+/// The system bars' style for an app of [brightness]: icons that contrast with it, over the+/// transparent bars `main.dart` draws edge to edge under. The colours are restated because an+/// [AnnotatedRegion]'s style replaces the one set at launch.+SystemUiOverlayStyle systemBarsFor(Brightness brightness) {+ // The icons are the opposite of the app; iOS's `statusBarBrightness` names the GROUND instead.+ final icons = brightness == Brightness.dark+ ? Brightness.light+ : Brightness.dark;+ return SystemUiOverlayStyle(+ statusBarColor: const Color(0x00000000),+ systemNavigationBarColor: const Color(0x00000000),+ statusBarIconBrightness: icons,+ systemNavigationBarIconBrightness: icons,+ statusBarBrightness: brightness,+ );+}+/// Which screen the app's state calls for.////// ⚠️ **What a desktop window also had here, and why it is gone.** The macOS application menudiff --git a/mobile/lib/demo/main_sample.dart b/mobile/lib/demo/main_sample.dartindex 63ede6c7e..77af0d52a 100644--- a/mobile/lib/demo/main_sample.dart+++ b/mobile/lib/demo/main_sample.dart@@ -1,5 +1,7 @@import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:harness_mobile/app_shell.dart' show systemBarsFor;import 'package:harness_mobile/core/startup.dart';import 'package:harness_mobile/shared/theme/app_theme.dart' as grid;import 'package:harness_mobile/shared/theme/appearance_prefs_store.dart';@@ -34,13 +36,16 @@ class SampleApp extends StatelessWidget {uiScale: prefs.uiSize / grid.AppFont.uiSizeDefault,codeSize: grid.AppFont.codeSize,);- grid.AppTheme.brightness.value = Brightness.dark;+ final brightness = prefs.palette.brightness;+ grid.AppTheme.brightness.value = brightness;return MaterialApp(title: 'Harness sample',debugShowCheckedModeBanner: false,- theme: grid.buildAppTheme(brightness: Brightness.dark),- builder: (context, child) =>- grid.BrightnessScope(child: child ?? const SizedBox.shrink()),+ theme: grid.buildAppTheme(brightness: brightness),+ builder: (context, child) => AnnotatedRegion<SystemUiOverlayStyle>(+ value: systemBarsFor(brightness),+ child: grid.BrightnessScope(child: child ?? const SizedBox.shrink()),+ ),home: const _Launcher(),);},diff --git a/mobile/lib/phone/settings_page.dart b/mobile/lib/phone/settings_page.dartindex cb32d0ff1..eada6baa8 100644--- a/mobile/lib/phone/settings_page.dart+++ b/mobile/lib/phone/settings_page.dart@@ -47,10 +47,11 @@ import 'voice_language_store.dart';////// What a phone shows that the desktop splits across panes:///-/// - **Appearance** carries the six [HarnessPalette] choices the desktop keeps in its own-/// Customize pane. They are not decoration here: the phone's tab bar, cards and terminal ground-/// are all drawn from the chosen palette, and until now the phone shipped whichever one the-/// desktop had last written to `~/.harness`.+/// - **Appearance** carries the [HarnessPalette] choices the desktop keeps in its own Customize+/// pane — six dark, two light. They are not decoration here: the phone's tab bar, cards and+/// terminal ground are all drawn from the chosen palette, a light one is how the phone goes+/// light, and until now the phone shipped whichever one the desktop had last written to+/// `~/.harness`./// - **Terminal** carries the colour scheme beside the face and the size, because on a phone all/// three answer the same question — what the pane looks like at arm's length./// - **Voice** carries the language the mic is transcribed in. A section of one row, and it earns@@ -546,19 +547,30 @@ class _TerminalThemeRow extends StatelessWidget {);}-/// The app's palette — the six [HarnessPalette] choices the desktop lays out as swatch cards.+/// The app's palette — the [HarnessPalette] choices the desktop lays out as swatch cards.////// A sheet of names rather than a grid of previews, and the difference is the screen: the desktop's/// cards each draw a miniature workspace, which needs the width of a settings pane to be legible at-/// all. Shrunk to a phone's column they would be six indistinguishable dark rectangles. The app+/// all. Shrunk to a phone's column they would be eight indistinguishable rectangles. The app/// repaints on the tap anyway — [AppearancePrefsStore.setPalette] moves the notifier before it/// writes — so the preview IS the app behind the sheet, at full size, which no swatch can beat.+///+/// Under Dark and Light captions, because a light palette is the whole of light mode: there is no+/// other switch, and a person looking for one scans for the word.class _PaletteRow extends StatelessWidget {@overrideWidget build(BuildContext context) => ValueListenableBuilder<AppearancePrefs>(valueListenable: appearancePrefsStore,builder: (context, prefs, _) {AppTheme.watch(context);+ PhoneSheetAction choice(HarnessPalette palette) => PhoneSheetAction(+ icon: palette == prefs.palette+ ? LucideIcons.check300+ : LucideIcons.swatchBook300,+ label: palette.label,+ value: palette.description,+ onTap: () => unawaited(appearancePrefsStore.setPalette(palette)),+ );return SettingsRow(// "App colors", beside the terminal's own "Colors": both read Graphite by default, and// two rows with one value looked like the same setting twice.@@ -567,15 +579,17 @@ class _PaletteRow extends StatelessWidget {onTap: () => showPhoneSheet(context,title: 'App colors',- actions: [- for (final palette in HarnessPalette.values)- PhoneSheetAction(- icon: palette == prefs.palette- ? LucideIcons.check300- : LucideIcons.swatchBook300,- label: palette.label,- onTap: () =>- unawaited(appearancePrefsStore.setPalette(palette)),+ sections: [+ for (final (caption, dark) in const [+ ('Dark', true),+ ('Light', false),+ ])+ PhoneSheetSection(+ caption: caption,+ actions: [+ for (final palette in HarnessPalette.values)+ if (palette.isDark == dark) choice(palette),+ ],),],),diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex 2513c3f8b..d2b933bd6 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -2792,7 +2792,7 @@ class _AttachingState extends State<_Attaching> with TickerProviderStateMixin {final lineHeight = fontSize * style.height;// Resolved exactly as [TerminalPanel] resolves it for the view underneath,// so the skeleton's ground and the terminal's are the same colour.- final ground = terminalThemeFor(+ final ground = terminalScreenThemeFor(AppTheme.palette.value,terminalThemeStore.value,).background;diff --git a/mobile/lib/phone/tty.dart b/mobile/lib/phone/tty.dartindex c8d3fd72b..46eda4f89 100644--- a/mobile/lib/phone/tty.dart+++ b/mobile/lib/phone/tty.dart@@ -43,18 +43,27 @@ class Tty {/// Rules, marks and the gutter — brightBlack, as a terminal draws its own furniture.Color get dim => theme.brightBlack;+ /// Whether the ground is light — a light palette, or the Light scheme.+ bool get isLight => theme.background.computeLuminance() > .5;+/// Secondary TEXT in the chrome: labels, details, hints. brightBlack on the ground is 3.1:1, too/// faint to read at a glance on a phone; this is the agent's own faint text, about 4.9:1.+ /// Dark ink needs more of itself on a light ground: 52% there is 3.3:1, 70% is 5.7:1 on Mist and+ /// still 4.5:1 on a [selected] row.Color get faint => Color.alphaBlend(- theme.foreground.withValues(alpha: 0.52),+ theme.foreground.withValues(alpha: isLight ? 0.70 : 0.52),theme.background,);/// Hints stay readable on raised form fields, as well as on the terminal ground.Color get placeholder => Color.alphaBlend(- theme.foreground.withValues(alpha: 0.60),+ theme.foreground.withValues(alpha: isLight ? 0.75 : 0.60),theme.background,);++ /// Ink on a solid ANSI fill — a green button, a red mic. The dark ramp's fills are bright and+ /// take [dark] (black, or the scheme's white on red); the light ramp's are deep, and take white.+ Color onFill(Color dark) => isLight ? Colors.white : dark;Color get green => theme.green;Color get yellow => theme.yellow;Color get red => theme.red;diff --git a/mobile/lib/phone/tty_controls.dart b/mobile/lib/phone/tty_controls.dartindex 844cb9bc3..6855b3039 100644--- a/mobile/lib/phone/tty_controls.dart+++ b/mobile/lib/phone/tty_controls.dart@@ -73,7 +73,9 @@ class _TtyPrimaryButtonState extends State<TtyPrimaryButton> {: _down? Color.alphaBlend(Colors.black.withValues(alpha: 0.18), tty.green): tty.green;- final ink = !enabled && !widget.busy ? tty.faint : tty.theme.black;+ final ink = !enabled && !widget.busy+ ? tty.faint+ : tty.onFill(tty.theme.black);return Semantics(button: true,enabled: enabled,@@ -525,7 +527,7 @@ class TtyFieldMic extends StatelessWidget {child: Icon(live ? LucideIcons.arrowUp300 : LucideIcons.mic300,size: 18,- color: live ? tty.theme.brightWhite : tty.text,+ color: live ? tty.onFill(tty.theme.brightWhite) : tty.text,),),),diff --git a/mobile/lib/phone/voice_mic_face.dart b/mobile/lib/phone/voice_mic_face.dartindex 314a21c7f..f9c79e2c6 100644--- a/mobile/lib/phone/voice_mic_face.dart+++ b/mobile/lib/phone/voice_mic_face.dart@@ -162,7 +162,9 @@ class VoiceMicCore extends StatelessWidget {duration: const Duration(milliseconds: 200),opacity: _spins(face) ? 1 : 0,child: _BusyArc(- color: fill == _Fill.accent ? tty.theme.brightWhite : tty.text,+ color: fill == _Fill.accent+ ? tty.onFill(tty.theme.brightWhite)+ : tty.text,spin: motion && _spins(face),),),@@ -195,8 +197,8 @@ class VoiceMicCore extends StatelessWidget {}Color _inkFor(_Fill fill, Tty tty) => switch (fill) {- _Fill.accent => tty.theme.black,- _Fill.warn => tty.theme.black,+ _Fill.accent => tty.onFill(tty.theme.black),+ _Fill.warn => tty.onFill(tty.theme.black),_Fill.glass => face == VoiceMicFace.off ? tty.dim : tty.text,};@@ -615,8 +617,14 @@ class _HeldBadge extends StatelessWidget {shape: BoxShape.circle,color: AppPalette.warn,// A ring the terminal's own near-black, so the dot reads as sitting- // ON the rim rather than as a stain on the fill.- border: Border.all(color: const Color(0xFF141414), width: 2),+ // ON the rim rather than as a stain on the fill — its ground, on a+ // light one.+ border: Border.all(+ color: Tty.of(context).isLight+ ? Tty.of(context).ground+ : const Color(0xFF141414),+ width: 2,+ ),),),);diff --git a/mobile/lib/shared/theme/app_theme.dart b/mobile/lib/shared/theme/app_theme.dartindex 717912e70..6072769ca 100644--- a/mobile/lib/shared/theme/app_theme.dart+++ b/mobile/lib/shared/theme/app_theme.dart@@ -5,8 +5,9 @@ import 'package:flutter/material.dart';import 'color_palette.dart';/// The app's live brightness — the single source of truth the color tokens below-/// resolve against. Harness Desktop is dark-only: `_GridTokenScope` (in-/// `main.dart`) pins this to [Brightness.dark] once, at the top of the tree.+/// resolve against. The palette decides it: `_GridTokenScope` (in+/// `app_shell.dart`) sets this from [palette]'s own brightness, so a light+/// palette ([HarnessPalette.paper], [HarnessPalette.mist]) is a light app.////// Every `AppPalette`/`AppSurface`/`AppGlass`/`AppCard` member is a getter that/// switches on this, so a call site like `color: AppPalette.windowBg` follows the@@ -202,20 +203,20 @@ abstract final class AppPalette {// (#141414) is now *darker* than the page it sits on. Depth in dark is// therefore carried by the rim and the shadow, not by the fill — §2's stack// still holds, it just has less room to say it in.- static Color get windowBg =>- AppTheme.pick(const Color(0xFFFFFFFF), AppTheme.palette.value.background);+ //+ // These four come from the palette in both themes: a light palette carries+ // its own light surfaces (color_palette.dart), and it is the palette that+ // decides the brightness in the first place.+ static Color get windowBg => AppTheme.palette.value.background;// sidebar column — a barely-there cool grey (Codex keeps the rail almost white,// set apart by a hairline, not a tone) / charcoal panel in dark.- static Color get panelBg =>- AppTheme.pick(const Color(0xFFF9F9F8), AppTheme.palette.value.panel);+ static Color get panelBg => AppTheme.palette.value.panel;// input fills, quiet cards- static Color get cardBg =>- AppTheme.pick(const Color(0xFFF3F3F2), AppTheme.palette.value.card);+ static Color get cardBg => AppTheme.palette.value.card;- static Color get cardBgHover =>- AppTheme.pick(const Color(0xFFECECEA), AppTheme.palette.value.hover);+ static Color get cardBgHover => AppTheme.palette.value.hover;// A hairline separator. Light: a faint cool black; dark: a faint white — a// black divider would vanish on charcoal.@@ -273,8 +274,7 @@ abstract final class AppPalette {/// row, still plainly the same indigo. [accent] can't simply take this value:/// it is the fill under white text in ~100 places, and lightening it there/// would drop that text to ~3.1:1 — fixing the icon by breaking the buttons.- static Color get accentOnSurface =>- AppTheme.pick(const Color(0xFF2F5BEA), AppTheme.palette.value.accent);+ static Color get accentOnSurface => AppTheme.palette.value.accent;// avatar fill (white text on it); a touch brighter in dark for contrast.static Color get accentMuted =>@@ -337,25 +337,32 @@ abstract final class AppPalette {static Color get accentHover =>AppTheme.pick(const Color(0xFF2850D8), const Color(0xFF4166F2));+ // These three are drawn as TEXT as often as dots (status labels, ledger+ // rows), so their light values clear 4.5:1 on the deepest light-palette+ // ground they meet — Paper's search #E2E2DF / Mist's #DCE4EE — not only on+ // white: teal 4.90, online 5.02, warn 4.93 there (6.4–6.5 on white).+// "Owner" badge — a teal that stays legible on either surface.static Color get teal =>- AppTheme.pick(const Color(0xFF0F766E), const Color(0xFF2DD4BF));+ AppTheme.pick(const Color(0xFF0D6B63), const Color(0xFF2DD4BF));// green "connected" dotstatic Color get online =>- AppTheme.pick(const Color(0xFF15803D), const Color(0xFF3FB950));+ AppTheme.pick(const Color(0xFF146C34), const Color(0xFF3FB950));// expiring soonstatic Color get warn =>- AppTheme.pick(const Color(0xFFB45309), const Color(0xFFFFB020));+ AppTheme.pick(const Color(0xFF9A4708), const Color(0xFFFFB020));- // grey dot+ // grey dot — a state mark, so ≥3:1 in light (3.14 on Paper's search ground).static Color get offline =>- AppTheme.pick(const Color(0xFFA3A29C), const Color(0xFF6E6E6E));+ AppTheme.pick(const Color(0xFF7F7E78), const Color(0xFF6E6E6E));// Grid brand lightning gold — the live/active ⚡ mark, matching the tray bolt.+ // Light is a deeper gold than the tray's: #C98A00 was 2.27–2.95:1 on the+ // light grounds, this is 3.93 at worst.static Color get brandBolt =>- AppTheme.pick(const Color(0xFFC98A00), const Color(0xFFE0A93B));+ AppTheme.pick(const Color(0xFF946500), const Color(0xFFE0A93B));static Color get textPrimary =>AppTheme.pick(const Color(0xFF1A1A18), const Color(0xFFF5F5F5));@@ -363,8 +370,13 @@ abstract final class AppPalette {static Color get textSecondary =>AppTheme.pick(const Color(0xFF62615B), const Color(0xFFA8A8A2));+ /// Meta text and hints. Light is #7A7973, not the #8E8D86 it was: that one+ /// was tuned for a white page and fell to 2.57:1 on Paper's search ground+ /// (#E2E2DF) and 2.60 on Mist's (#DCE4EE). This holds 3.36 / 3.40 there and+ /// 3.49 / 3.51 on the two workspaces, and stays 1.42:1 apart from+ /// [textSecondary] so the three steps still read as three.static Color get textFaint =>- AppTheme.pick(const Color(0xFF8E8D86), const Color(0xFF6E6E68));+ AppTheme.pick(const Color(0xFF7A7973), const Color(0xFF6E6E68));/// The page a document is drawn on, and the ink on it.///@@ -434,9 +446,9 @@ abstract final class AppPalette {/// [buildAppTheme] needs the values *before* the global brightness is the one/// being built for — see the note at its `scrollbarTheme`. The getters below read/// these same four, so there is one set of numbers rather than two that can drift.-const Color _scrollThumbLight = Color(0xFF8C8C8C);+const Color _scrollThumbLight = Color(0xFF787878);const Color _scrollThumbDark = Color(0xFF686868);-const Color _scrollThumbHoverLight = Color(0xFF6E6E6E);+const Color _scrollThumbHoverLight = Color(0xFF5E5E5E);const Color _scrollThumbHoverDark = Color(0xFF8A8A8A);/// Surface tokens for the app's chrome — the sidebar's rows, the composer card,@@ -504,6 +516,9 @@ abstract final class AppSurface {/// barely dents a white one, so reaching 3:1 needs 0.40 in dark and 0.50 in/// light. These are those two values resolved — 3.55:1 dark, 3.36:1 light —/// stated as colours so a list on the panel measures the same as one on the page.+ /// Light was since deepened (#8C8C8C → #787878) for the light palettes'+ /// tinted grounds: the old thumb fell to 2.69:1 on Paper's workspace; this+ /// one holds 3.53 there and 3.55 on Mist's.static Color get scrollThumb =>AppTheme.pick(_scrollThumbLight, _scrollThumbDark);@@ -918,20 +933,22 @@ ThemeData buildAppTheme({Brightness brightness = Brightness.light}) {outlineVariant: const Color(0x14FFFFFF),error: const Color(0xFFF2544B),)- : const ColorScheme.light(+ : ColorScheme.light(primary: AppPalette.accent,onPrimary: Colors.white,secondary: AppPalette.accent,- // Pure white — matches AppPalette.windowBg so the chat pane (which- // paints scheme.surface) reads as clean white, letting the composer's- // rim and shadow stand out instead of blending into an off-white wash.- surface: Color(0xFFFFFFFF),- onSurface: Color(0xFF1A1A18),- onSurfaceVariant: Color(0xFF62615B),- surfaceContainerHighest: Color(0xFFF3F3F2),- outline: Color(0x0F000000),- outlineVariant: Color(0x0F000000),- error: Color(0xFFB3261E),+ // The light palette's own ground — matches AppPalette.windowBg, as+ // the dark scheme's does.+ surface: AppTheme.palette.value.background,+ onSurface: AppTheme.palette.value.foreground,+ onSurfaceVariant: const Color(0xFF62615B),+ // The field fill. Not the card, which is pure white on both light+ // palettes: a white field in a white dialog has no edge at all. The+ // panel tone is the step the old light theme's #F3F3F2 was.+ surfaceContainerHighest: AppTheme.palette.value.panel,+ outline: const Color(0x0F000000),+ outlineVariant: const Color(0x0F000000),+ error: const Color(0xFFB3261E),);// The chrome fills used by menus, dialogs and toasts. A getter-backed token@@ -945,9 +962,7 @@ ThemeData buildAppTheme({Brightness brightness = Brightness.light}) {// both were `#1E1E1E`, which is [AppCard.base] — a content card's colour, one// step *below* the block it was supposed to be.final panelFill = isDark ? AppMenu.fillDark : AppMenu.fillLight;- final dialogFill = isDark- ? AppTheme.palette.value.card- : const Color(0xFFFFFFFF);+ final dialogFill = AppTheme.palette.value.card;final textTheme = _appTextTheme(scheme.onSurface, scheme.onSurfaceVariant);return ThemeData(@@ -1085,7 +1100,9 @@ ThemeData buildAppTheme({Brightness brightness = Brightness.light}) {trackColor: WidgetStateProperty.resolveWith((s) => s.contains(WidgetState.selected)? AppPalette.accent- : (isDark ? const Color(0xFF3A3A3A) : const Color(0xFFA3A29C)),+ // Light's off track is a UI mark (3:1): #A3A29C was 2.56 on a+ // white dialog; #858480 is 3.74 there, 3.37 on the panel.+ : (isDark ? const Color(0xFF3A3A3A) : const Color(0xFF858480)),),trackOutlineColor: WidgetStateProperty.all(Colors.transparent),),@@ -1102,8 +1119,10 @@ ThemeData buildAppTheme({Brightness brightness = Brightness.light}) {// same as the button beside it. (The typed text is set on the field via// [kFieldTextStyle]; `InputDecorationTheme` has no `style` of its own, so// a field's own text can't be themed globally here.)+ // 75% in light: at 70% the hint sat at 2.999:1 on Mist's panel-toned+ // fill; this is 3.29 (Mist) / 3.29 (Paper). Dark keeps 70% (3.99:1).hintStyle: _fieldTextStyle(- scheme.onSurfaceVariant.withValues(alpha: 0.7),+ scheme.onSurfaceVariant.withValues(alpha: isDark ? 0.7 : 0.75),),// Material builds a field for a phone: its default padding, plus the 48px// touch target it gives a prefixIcon, rendered this 48 tall next to a 32pxdiff --git a/mobile/lib/shared/theme/color_palette.dart b/mobile/lib/shared/theme/color_palette.dartindex 2a1bcf10b..b766cf8b4 100644--- a/mobile/lib/shared/theme/color_palette.dart+++ b/mobile/lib/shared/theme/color_palette.dart@@ -1,7 +1,13 @@+import 'dart:ui' show Brightness;+import 'package:flutter/painting.dart';/// Coordinated workspace colors. These feed the existing design-system tokens,/// native tabs/search, and terminal defaults; they do not change agent state.+///+/// A palette carries its own [brightness]: choosing a light one is how the app+/// goes light. There is no separate light/dark switch to disagree with it —+/// `_GridTokenScope` (app_shell.dart) reads it from here.enum HarnessPalette {graphite('Graphite',@@ -74,11 +80,45 @@ enum HarnessPalette {tabBar: Color(0xff2b221d),search: Color(0xff3c3129),accent: Color(0xffe6c39e),+ ),+ // The light palettes mirror the dark ones' layering: the workspace gutter and+ // tab bar sit a step darker than the terminal ground, cards a step lighter.+ // Their accents are deep rather than pale, since an accent is drawn as text,+ // a cursor and a focus ring on the ground.+ paper(+ 'Paper',+ 'Neutral light',+ brightness: Brightness.light,+ foreground: Color(0xff1f1f1d),+ background: Color(0xfffafaf9),+ panel: Color(0xfff3f3f1),+ card: Color(0xffffffff),+ hover: Color(0xffebebe8),+ workspace: Color(0xffe6e6e3),+ tabBar: Color(0xffeeeeec),+ search: Color(0xffe2e2df),+ accent: Color(0xff3d5a8a),+ ),+ mist(+ 'Mist',+ 'Cool light',+ brightness: Brightness.light,+ foreground: Color(0xff1b2330),+ background: Color(0xfff7f9fc),+ panel: Color(0xffeef2f7),+ card: Color(0xffffffff),+ hover: Color(0xffe3e9f1),+ workspace: Color(0xffe1e7f0),+ tabBar: Color(0xffe9eef5),+ search: Color(0xffdce4ee),+ accent: Color(0xff2f5bb8),);const HarnessPalette(this.label,this.description, {+ this.brightness = Brightness.dark,+ this.foreground = const Color(0xfff5f5f5),required this.background,required this.panel,required this.card,@@ -90,8 +130,10 @@ enum HarnessPalette {});final String label, description;+ final Brightness brightness;+ final Color foreground;final Color background, panel, card, hover, workspace, tabBar, search, accent;- Color get foreground => const Color(0xfff5f5f5);+ bool get isDark => brightness == Brightness.dark;static HarnessPalette fromId(String? id) =>values.where((palette) => palette.name == id).firstOrNull ?? graphite;@@ -101,5 +143,7 @@ enum HarnessPalette {'workspace': workspace.toARGB32(),'search': search.toARGB32(),'accent': accent.toARGB32(),+ 'foreground': foreground.toARGB32(),+ 'dark': isDark ? 1 : 0,};}diff --git a/mobile/lib/terminal/terminal_theme.dart b/mobile/lib/terminal/terminal_theme.dartindex d7d995ef8..2c52fbf25 100644--- a/mobile/lib/terminal/terminal_theme.dart+++ b/mobile/lib/terminal/terminal_theme.dart@@ -4,62 +4,126 @@ import 'package:xterm/xterm.dart';import '../shared/theme/color_palette.dart';import 'terminal_theme_store.dart';-/// The colours a terminal pane draws itself in.+/// The colours a terminal pane's SCREEN draws itself in — the scheme the person+/// chose, exactly. Only what paints the terminal itself reads this (the+/// `TerminalView`, and the skeleton laid where it is about to be).////// ⚠️ Returns a CACHED (or `const`) instance, never a fresh one. The vendored/// renderer short-circuits on identity before repainting, so a new/// [TerminalTheme] built per rebuild reads as "the colours changed" every/// frame — the same trap [TerminalFontStore] documents for [TerminalStyle].-TerminalTheme terminalThemeFor(+TerminalTheme terminalScreenThemeFor(HarnessPalette palette,TerminalThemeChoice choice,) => switch (choice) {// A whole scheme of its own: the app palette is not consulted at all, which// is the entire point of offering it.TerminalThemeChoice.tango => tangoTerminalTheme,+ TerminalThemeChoice.dark => darkTerminalTheme,+ TerminalThemeChoice.light => lightTerminalTheme,TerminalThemeChoice.matchApp => _matchApp(palette),};+/// The terminal-styled CHROME's colours — every [Tty] screen, sheet and+/// picker — which are drawn on the app palette's grounds or on a ground they+/// take from this same theme.+///+/// The chosen scheme while it agrees with the palette about light and dark;+/// the palette's own match-app theme when it does not. Tango and Dark are dark+/// schemes: under a light palette their white ink would land on the app's+/// light grounds at about 1:1 — every header and picker unreadable — and Light+/// under a dark palette is the same trap the other way round. The terminal+/// screen itself still wears the chosen scheme ([terminalScreenThemeFor]).+///+/// Cached, like [terminalScreenThemeFor]: both return the same instances.+TerminalTheme terminalThemeFor(+ HarnessPalette palette,+ TerminalThemeChoice choice,+) {+ final screen = terminalScreenThemeFor(palette, choice);+ final screenDark = screen.background.computeLuminance() <= .5;+ return screenDark == palette.isDark ? screen : _matchApp(palette);+}+/// Cached per palette. Switching colors repaints the existing terminal view;/// it does not replace its controller, buffer, input connection or font.-TerminalTheme _matchApp(HarnessPalette palette) => _palettes.putIfAbsent(- palette,- () => TerminalTheme(- cursor: palette.accent,- selection: palette.accent.withValues(alpha: 0.3),- foreground: palette.foreground,- background: palette.background,- black: darkTerminalTheme.black,- red: darkTerminalTheme.red,- green: darkTerminalTheme.green,- yellow: darkTerminalTheme.yellow,- blue: darkTerminalTheme.blue,- magenta: darkTerminalTheme.magenta,- cyan: darkTerminalTheme.cyan,- white: darkTerminalTheme.white,- brightBlack: darkTerminalTheme.brightBlack,- brightRed: darkTerminalTheme.brightRed,- brightGreen: darkTerminalTheme.brightGreen,- brightYellow: darkTerminalTheme.brightYellow,- brightBlue: darkTerminalTheme.brightBlue,- brightMagenta: darkTerminalTheme.brightMagenta,- brightCyan: darkTerminalTheme.brightCyan,- brightWhite: darkTerminalTheme.brightWhite,- searchHitBackground: darkTerminalTheme.searchHitBackground,- searchHitBackgroundCurrent: darkTerminalTheme.searchHitBackgroundCurrent,- searchHitForeground: darkTerminalTheme.searchHitForeground,- ),-);+///+/// The ANSI ramp follows the palette's brightness: the dark ramp's pale yellow+/// and white are unreadable on a light ground, and the light ramp's deep ones+/// vanish on a dark one.+TerminalTheme _matchApp(HarnessPalette palette) =>+ _palettes.putIfAbsent(palette, () {+ final ramp = palette.isDark ? darkTerminalTheme : lightTerminalTheme;+ return TerminalTheme(+ cursor: palette.accent,+ selection: palette.accent.withValues(alpha: 0.3),+ foreground: palette.foreground,+ background: palette.background,+ black: ramp.black,+ red: ramp.red,+ green: ramp.green,+ yellow: ramp.yellow,+ blue: ramp.blue,+ magenta: ramp.magenta,+ cyan: ramp.cyan,+ white: ramp.white,+ brightBlack: ramp.brightBlack,+ brightRed: ramp.brightRed,+ brightGreen: ramp.brightGreen,+ brightYellow: ramp.brightYellow,+ brightBlue: ramp.brightBlue,+ brightMagenta: ramp.brightMagenta,+ brightCyan: ramp.brightCyan,+ brightWhite: ramp.brightWhite,+ searchHitBackground: ramp.searchHitBackground,+ searchHitBackgroundCurrent: ramp.searchHitBackgroundCurrent,+ searchHitForeground: ramp.searchHitForeground,+ );+ });final _palettes = <HarnessPalette, TerminalTheme>{};+/// The ANSI ramp a light palette's terminal uses: GitHub Light's, with the five+/// slots it leaves under text contrast on a near-white ground darkened (same+/// hue) until every one of the sixteen reads at ≥4.6:1 on both light palettes'+/// grounds — white, brightBlue, brightMagenta, brightCyan and brightWhite, the+/// last of which was 2.9:1. Any of them can be a line of an agent's output.+/// Ground and ink come from the palette; [_matchApp] takes only the ramp and+/// search colours.+const lightTerminalTheme = TerminalTheme(+ cursor: Color(0xff0969da),+ selection: Color(0x4d0969da),+ foreground: Color(0xff1f2328),+ background: Color(0xffffffff),+ black: Color(0xff24292f),+ red: Color(0xffcf222e),+ green: Color(0xff116329),+ yellow: Color(0xff4d2d00),+ blue: Color(0xff0969da),+ magenta: Color(0xff8250df),+ cyan: Color(0xff1b7c83),+ white: Color(0xff5c6570),+ brightBlack: Color(0xff57606a),+ brightRed: Color(0xffa40e26),+ brightGreen: Color(0xff1a7f37),+ brightYellow: Color(0xff633c01),+ brightBlue: Color(0xff006ce3),+ brightMagenta: Color(0xff8749f7),+ brightCyan: Color(0xff297a8e),+ brightWhite: Color(0xff69737d),+ searchHitBackground: Color(0xffffff2b),+ searchHitBackgroundCurrent: Color(0xff31ff26),+ searchHitForeground: Color(0xff000000),+);+/// Harness owns the terminal's *default* appearance.////// Terminal streams provide ANSI attributes, not the source application's/// complete colour scheme. The default foreground, background, and ANSI ramp-/// must therefore follow Harness's own (dark-only) appearance. Explicit ANSI-/// and true-colour cells remain untouched by xterm, so a TUI keeps the colours-/// it deliberately emits.+/// must therefore follow Harness's own appearance — this ramp for a dark+/// palette, [lightTerminalTheme]'s for a light one. Explicit ANSI and+/// true-colour cells remain untouched by xterm, so a TUI keeps the colours it+/// deliberately emits.const darkTerminalTheme = TerminalTheme(cursor: Color(0xffaeafad),// Translucent, not opaque: this is painted over the glyphs after they're drawn (seediff --git a/mobile/lib/terminal/terminal_theme_store.dart b/mobile/lib/terminal/terminal_theme_store.dartindex 12d4dc4e6..8bb678543 100644--- a/mobile/lib/terminal/terminal_theme_store.dart+++ b/mobile/lib/terminal/terminal_theme_store.dart@@ -20,12 +20,21 @@ import '../core/local_key_value_store.dart';/// scheme later is one value here and one `const` in `terminal_theme.dart`.enum TerminalThemeChoice {/// Today's behaviour, and still the default: ground and cursor follow the- /// palette chosen in Settings ▸ Appearance, ANSI ramp from `darkTerminalTheme`.+ /// palette chosen in Settings ▸ Appearance, and the ANSI ramp its brightness+ /// (`darkTerminalTheme`'s or `lightTerminalTheme`'s).matchApp('Same as the app','Ground and cursor follow Settings ▸ Appearance',),+ /// Harness's own dark screen whatever the app wears — a light app with a+ /// dark terminal, the way many people keep an editor.+ dark('Dark', 'A dark screen, whatever the app colors'),++ /// Harness's own light screen whatever the app wears — the reverse, for+ /// reading output on white inside a dark app.+ light('Light', 'A light screen, whatever the app colors'),+/// ⚠️ Named for the PALETTE, not for the distribution that popularised it./// These sixteen colours are the Tango Desktop Project's, which GNOME/// Terminal ships as its built-in `Tango` scheme. Calling it "Ubuntu" woulddiff --git a/mobile/lib/widgets/engine_identity.dart b/mobile/lib/widgets/engine_identity.dartindex 595fde858..1d12118e4 100644--- a/mobile/lib/widgets/engine_identity.dart+++ b/mobile/lib/widgets/engine_identity.dart@@ -2,6 +2,7 @@ import 'dart:math' as math;import 'package:flutter/material.dart';+import '../shared/theme/app_theme.dart' as grid;import '../theme/app_theme.dart';class EngineIdentity {@@ -140,6 +141,7 @@ class EngineMark extends StatelessWidget {@overrideWidget build(BuildContext context) {+ final dark = grid.AppTheme.watch(context) == Brightness.dark;final identity = engineIdentity(engine, displayName: displayName);final mark = identity.asset != null? Image.asset(@@ -159,14 +161,41 @@ class EngineMark extends StatelessWidget {? CustomPaint(key: const ValueKey('engine-icon-claude'),size: Size.square(size),- painter: _ClaudeMarkPainter(identity.color),+ // The brand clay is 2.5:1 on a light workspace; there the same+ // hue a step deeper (3.1:1+), so the mark still reads as a shape.+ painter: _ClaudeMarkPainter(+ dark ? identity.color : const Color(0xffc2633f),+ ),): _InitialMark(key: ValueKey('engine-fallback-${identity.id}'),identity: identity,size: size,);- return Opacity(opacity: enabled ? 1 : 0.45, child: mark);+ // These vendor assets use near-white ink with no ground of their own. They+ // sit bare on a dark palette as they always have; on a light one they get+ // the desktop's dark tile, or their shapes are white on white.+ final needsDarkTile =+ !dark &&+ const {'cursor', 'opencode', 'grok', 'copilot'}.contains(identity.id);+ return Opacity(+ opacity: enabled ? 1 : 0.45,+ child: needsDarkTile+ ? SizedBox.square(+ dimension: size,+ child: DecoratedBox(+ decoration: BoxDecoration(+ color: const Color(0xff29322f),+ borderRadius: BorderRadius.circular(size * .2),+ ),+ child: Padding(+ padding: EdgeInsets.all(size * .08),+ child: mark,+ ),+ ),+ )+ : mark,+ );}}diff --git a/mobile/lib/widgets/rename_agent_dialog.dart b/mobile/lib/widgets/rename_agent_dialog.dartindex 83a7ae972..f80996287 100644--- a/mobile/lib/widgets/rename_agent_dialog.dart+++ b/mobile/lib/widgets/rename_agent_dialog.dart@@ -396,9 +396,15 @@ class _RenameAgentDialogState extends State<_RenameAgentDialog> {disabledBackground: _busy? accent: accent.withValues(alpha: 0.22),+ // Disabled, white at 40% vanishes into the pale wash a light card+ // makes of the accent (1.1:1); there the label takes the accent+ // itself — 4.0:1, the wash alone saying it is off. Dark: 3.5:1.disabledForeground: _busy? Colors.white- : Colors.white.withValues(alpha: 0.4),+ : grid.AppTheme.pick(+ accent,+ Colors.white.withValues(alpha: 0.4),+ ),),onPressed: _canSave ? () => unawaited(_submit()) : null,child: _busydiff --git a/mobile/lib/widgets/terminal_panel.dart b/mobile/lib/widgets/terminal_panel.dartindex e03e9ece2..3e7fab43d 100644--- a/mobile/lib/widgets/terminal_panel.dart+++ b/mobile/lib/widgets/terminal_panel.dart@@ -1129,7 +1129,7 @@ class _TerminalPanelState extends State<TerminalPanel>// (cb47ba35 → TestFlight build 11), which is why// test/terminal_panel_backspace_test.dart pins it.deleteDetection: true,- theme: terminalThemeFor(+ theme: terminalScreenThemeFor(grid.AppTheme.palette.value,terminalThemeStore.value,),diff --git a/mobile/test/theme/app_theme_test.dart b/mobile/test/theme/app_theme_test.dartindex 8440fe696..3668f09cb 100644--- a/mobile/test/theme/app_theme_test.dart+++ b/mobile/test/theme/app_theme_test.dart@@ -28,7 +28,7 @@ void main() {expect(AppColors.accent, grid.AppPalette.accentOnSurface);expect(AppColors.success, grid.AppPalette.online);expect(AppColors.warning, grid.AppPalette.warn);- // Dark-only on the phone: the error ink tuned for a dark card.+ // Graphite, the default palette, is dark: the error ink tuned for a dark card.expect(grid.AppTheme.isDark, isTrue);expect(AppColors.danger, const Color(0xFFF2544B));});diff --git a/mobile/test/theme/light_palette_test.dart b/mobile/test/theme/light_palette_test.dartnew file mode 100644index 000000000..091f00d3a--- /dev/null+++ b/mobile/test/theme/light_palette_test.dart@@ -0,0 +1,121 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/app_shell.dart' show systemBarsFor;+import 'package:harness_mobile/shared/theme/app_theme.dart' as grid;+import 'package:harness_mobile/shared/theme/color_palette.dart';+import 'package:harness_mobile/terminal/terminal_theme.dart';+import 'package:harness_mobile/terminal/terminal_theme_store.dart';++/// Light mode, as the desktop ships it (#453): a light palette is the whole+/// switch, and the terminal's chrome never borrows a scheme that disagrees+/// with the palette about light and dark.+void main() {+ tearDown(() {+ grid.AppTheme.palette.value = HarnessPalette.graphite;+ grid.AppTheme.brightness.value = Brightness.dark;+ });++ double contrast(Color a, Color b) {+ final (x, y) = (a.computeLuminance(), b.computeLuminance());+ return (x > y ? x + .05 : y + .05) / (x > y ? y + .05 : x + .05);+ }++ test('Tango keeps the screen; the chrome keeps the palette', () {+ for (final palette in HarnessPalette.values) {+ expect(+ terminalScreenThemeFor(palette, TerminalThemeChoice.tango).background,+ const Color(0xff300a24),+ reason: 'Tango does not follow ${palette.name}',+ );+ // A dark scheme's white ink on a light palette's grounds would be ~1:1.+ expect(+ terminalThemeFor(palette, TerminalThemeChoice.tango),+ same(+ palette.isDark+ ? tangoTerminalTheme+ : terminalThemeFor(palette, TerminalThemeChoice.matchApp),+ ),+ reason: palette.name,+ );+ }+ });++ test('Dark and Light screens hold; the chrome stays readable', () {+ for (final palette in HarnessPalette.values) {+ expect(+ terminalScreenThemeFor(palette, TerminalThemeChoice.dark),+ same(darkTerminalTheme),+ );+ expect(+ terminalScreenThemeFor(palette, TerminalThemeChoice.light),+ same(lightTerminalTheme),+ );+ final agrees = palette.isDark+ ? TerminalThemeChoice.dark+ : TerminalThemeChoice.light;+ final disagrees = palette.isDark+ ? TerminalThemeChoice.light+ : TerminalThemeChoice.dark;+ expect(+ terminalThemeFor(palette, agrees),+ same(terminalScreenThemeFor(palette, agrees)),+ reason: palette.name,+ );+ expect(+ terminalThemeFor(palette, disagrees),+ same(terminalThemeFor(palette, TerminalThemeChoice.matchApp)),+ reason: palette.name,+ );+ }+ });++ test('a light palette is light everywhere it is read', () {+ for (final palette in [HarnessPalette.paper, HarnessPalette.mist]) {+ expect(palette.isDark, isFalse, reason: palette.name);+ expect(palette.nativeColors['dark'], 0, reason: palette.name);+ expect(+ systemBarsFor(palette.brightness).statusBarIconBrightness,+ Brightness.dark,+ reason: palette.name,+ );+ final terminal = terminalThemeFor(palette, TerminalThemeChoice.matchApp);+ expect(terminal.foreground, palette.foreground);+ // The light ramp, not the dark one's pale yellow and white.+ expect(terminal.yellow, lightTerminalTheme.yellow);+ expect(terminal.white, lightTerminalTheme.white);++ // Every ANSI slot is somebody's output text on this ground.+ for (final slot in [+ terminal.black, terminal.red, terminal.green, terminal.yellow,+ terminal.blue, terminal.magenta, terminal.cyan, terminal.white,+ terminal.brightBlack, terminal.brightRed, terminal.brightGreen,+ terminal.brightYellow, terminal.brightBlue, terminal.brightMagenta,+ terminal.brightCyan, terminal.brightWhite,+ ]) {+ expect(+ contrast(slot, palette.background),+ greaterThanOrEqualTo(4.5),+ reason: '${palette.name} $slot',+ );+ }++ grid.AppTheme.palette.value = palette;+ grid.AppTheme.brightness.value = palette.brightness;+ expect(grid.AppPalette.windowBg, palette.background);+ expect(grid.AppPalette.textPrimary.computeLuminance(), lessThan(.1));+ }+ grid.AppTheme.brightness.value = Brightness.dark;+ expect(HarnessPalette.graphite.nativeColors['dark'], 1);+ expect(+ systemBarsFor(HarnessPalette.graphite.brightness).statusBarIconBrightness,+ Brightness.light,+ );+ expect(+ terminalThemeFor(+ HarnessPalette.graphite,+ TerminalThemeChoice.matchApp,+ ).yellow,+ darkTerminalTheme.yellow,+ );+ });+}