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(desktop): give the terminal a colour scheme of its own
bubu-dudu5684650b809c
diff --git a/desktop/lib/core/startup.dart b/desktop/lib/core/startup.dartindex 277a25187..45c4ddbe8 100644--- a/desktop/lib/core/startup.dart+++ b/desktop/lib/core/startup.dart@@ -1,6 +1,7 @@import '../shared/theme/appearance_prefs_store.dart';import '../stats/harness_stats.dart';import '../terminal/terminal_font_store.dart';+import '../terminal/terminal_theme_store.dart';/// Every preference that has to be in place BEFORE the first frame.///@@ -16,6 +17,7 @@ import '../terminal/terminal_font_store.dart';/// The parameters exist for tests; the app passes nothing and gets the singletons the widgets read.Future<void> loadPersistedSettings({TerminalFontStore? terminalFont,+ TerminalThemeStore? terminalTheme,AppearancePrefsStore? appearance,HarnessStats? stats,}) async {@@ -24,6 +26,10 @@ Future<void> loadPersistedSettings({// preferences as one snapshot. Stats uses a separate file and can overlap.await Future.wait([(terminalFont ?? terminalFontStore).load(),+ // Beside the font, and for the same reason: loading the scheme after the+ // first frame paints every pane on the default ground and then snaps it to+ // the saved one, which reads as a flash of the wrong colour at every launch.+ (terminalTheme ?? terminalThemeStore).load(),// Every control box uses these values. A late load would move the whole// window's geometry after its first frame, as well as changing its palette.(appearance ?? appearancePrefsStore).load(),diff --git a/desktop/lib/settings/sections/terminal_section.dart b/desktop/lib/settings/sections/terminal_section.dartindex 3524c3fc8..479d188e1 100644--- a/desktop/lib/settings/sections/terminal_section.dart+++ b/desktop/lib/settings/sections/terminal_section.dart@@ -9,8 +9,10 @@ import '../../shared/widgets/app_select_field.dart';import '../../shared/widgets/section_scaffold.dart';import '../../shared/widgets/setting_row.dart';import '../../terminal/terminal_font_store.dart';+import '../../terminal/terminal_theme.dart';+import '../../terminal/terminal_theme_store.dart';-/// Settings ▸ Terminal: the face the agent's output is drawn in.+/// Settings ▸ Terminal: the colours and the face the agent's output is drawn in.////// Laid out in the app's own [SettingRow]s rather than in bare Material, for/// the same reason Appearance is: a preference reads as a preference here or it@@ -27,49 +29,104 @@ class TerminalSection extends StatelessWidget {return SectionScaffold(title: 'Terminal',subtitle:- "The font every terminal pane is drawn in, at its own size — the "- "app's UI scale never reaches it. ⌘+ and ⌘- resize without leaving "- "this screen.",+ "The colours and font every terminal pane is drawn in, at its own "+ "size — the app's UI scale never reaches it. ⌘+ and ⌘- resize "+ "without leaving this screen.",// A SingleChildScrollView, never a ListView — same reason as Appearance:// a lazy list keeps children across a rebuild and strands them on the// palette they first mounted with.child: SingleChildScrollView(child: ValueListenableBuilder<TerminalStyle>(valueListenable: terminalFontStore,- builder: (context, style, _) => Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- SettingRow(- title: 'Font',- detail:- 'Monospaced faces only — a proportional one misaligns '- 'every column an agent draws',- control: _FamilyField(family: terminalFontStore.family),- ),- const SizedBox(height: 10),- SettingRow(- title: 'Size',- detail:- '${TerminalFontStore.minSize.round()}–'- '${TerminalFontStore.maxSize.round()}pt. A change '- "re-derives the grid and resizes the agent's terminal",- control: _SizeStepper(size: style.fontSize),+ // Nested rather than merged into one builder: the two stores change+ // independently, and this is the pane that has to show both at once.+ builder: (context, style, _) =>+ ValueListenableBuilder<TerminalThemeChoice>(+ valueListenable: terminalThemeStore,+ builder: (context, scheme, _) =>+ _Controls(style: style, scheme: scheme),),- const SizedBox(height: 14),- _Preview(style: style),- const SizedBox(height: 12),- const _ResetRow(),- // Room under the last control so a scrolled-to-bottom pane does- // not end flush against the window edge.- const SizedBox(height: 8),- ],- ),),),);}}+class _Controls extends StatelessWidget {+ const _Controls({required this.style, required this.scheme});++ final TerminalStyle style;+ final TerminalThemeChoice scheme;++ @override+ Widget build(BuildContext context) {+ grid.AppTheme.watch(context);+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ // Colour first, then face, then size: the scheme is the change a+ // person notices from across the room, and it is the one that+ // makes the two rows under it look different while they choose.+ SettingRow(+ title: 'Colours',+ detail: scheme.detail,+ control: _SchemeField(scheme: scheme),+ ),+ const SizedBox(height: 10),+ SettingRow(+ title: 'Font',+ detail:+ 'Monospaced faces only — a proportional one misaligns '+ 'every column an agent draws',+ control: _FamilyField(family: terminalFontStore.family),+ ),+ const SizedBox(height: 10),+ SettingRow(+ title: 'Size',+ detail:+ '${TerminalFontStore.minSize.round()}–'+ '${TerminalFontStore.maxSize.round()}pt. A change '+ "re-derives the grid and resizes the agent's terminal",+ control: _SizeStepper(size: style.fontSize),+ ),+ const SizedBox(height: 14),+ _Preview(style: style, scheme: scheme),+ const SizedBox(height: 12),+ const _ResetRow(),+ // Room under the last control so a scrolled-to-bottom pane does+ // not end flush against the window edge.+ const SizedBox(height: 8),+ ],+ );+ }+}++/// The colour-scheme picker.+///+/// Same control as the face picker below it, for the same reason — see+/// [_FamilyField]. Unlike that one this list needs no per-platform guard:+/// colours resolve identically everywhere, so every value is always offered.+class _SchemeField extends StatelessWidget {+ const _SchemeField({required this.scheme});++ final TerminalThemeChoice scheme;++ @override+ Widget build(BuildContext context) {+ grid.AppTheme.watch(context);+ return AppSelectField<TerminalThemeChoice>(+ key: const Key('terminal-colour-scheme-dropdown'),+ width: SettingRow.controlWidth,+ value: scheme,+ options: [+ for (final choice in TerminalThemeChoice.values)+ SelectOption(value: choice, label: choice.label),+ ],+ onChanged: (choice) => unawaited(terminalThemeStore.set(choice)),+ );+ }+}+/// The face picker.////// [AppSelectField], not `DropdownButton` — see that widget's doc for why@@ -174,9 +231,10 @@ class _SizeStepper extends StatelessWidget {/// terminal's own ground ([grid.AppPalette.windowBg], recessed inside the/// card) so what you are judging is the thing itself.class _Preview extends StatelessWidget {- const _Preview({required this.style});+ const _Preview({required this.style, required this.scheme});final TerminalStyle style;+ final TerminalThemeChoice scheme;/// The cell the renderer would derive from this style.///@@ -229,7 +287,7 @@ class _Preview extends StatelessWidget {],),const SizedBox(height: 10),- _Screen(style: style),+ _Screen(style: style, scheme: scheme),],),);@@ -237,21 +295,29 @@ class _Preview extends StatelessWidget {}class _Screen extends StatelessWidget {- const _Screen({required this.style});+ const _Screen({required this.style, required this.scheme});final TerminalStyle style;+ final TerminalThemeChoice scheme;@overrideWidget build(BuildContext context) {grid.AppTheme.watch(context);- final base = style.toTextStyle(color: grid.AppPalette.textPrimary);- final dim = style.toTextStyle(color: grid.AppPalette.textSecondary);- final ok = style.toTextStyle(color: grid.AppPalette.online);+ // ⚠️ Drawn from the TERMINAL's resolved theme, not from the app's tokens.+ // This sample used to borrow `AppPalette` — fine while the terminal always+ // borrowed it too, and a lie the moment a scheme of its own could be+ // chosen: a user picking Tango would have been shown Harness's ground and+ // told that was the result. `terminalThemeFor` is the same call the real+ // pane makes, so what is judged here is what will be rendered.+ final theme = terminalThemeFor(grid.AppTheme.palette.value, scheme);+ final base = style.toTextStyle(color: theme.foreground);+ final dim = style.toTextStyle(color: theme.brightBlack);+ final ok = style.toTextStyle(color: theme.green);return Container(width: double.infinity,decoration: BoxDecoration(- color: grid.AppPalette.windowBg,+ color: theme.background,borderRadius: BorderRadius.circular(10),border: Border.all(color: grid.AppGlass.hair),),@@ -296,6 +362,13 @@ class _ResetRow extends StatelessWidget {@overrideWidget build(BuildContext context) {grid.AppTheme.watch(context);+ // ⚠️ Typography only — NOT the colour scheme, even though that row sits on+ // this screen too. The ⌘0 printed beside this button is the shortcut that+ // does the same thing, and ⌘0 in a terminal means "reset the zoom"+ // everywhere; making the button do more than the key it advertises is how+ // the two stop being the same control. The scheme needs no reset of its+ // own: its default is a named option the user can pick straight from the+ // list ('Match app appearance').final atDefault = terminalFontStore.isDefault;return Row(mainAxisAlignment: MainAxisAlignment.end,diff --git a/desktop/lib/terminal/terminal_theme.dart b/desktop/lib/terminal/terminal_theme.dartindex f8098be3d..d7d995ef8 100644--- a/desktop/lib/terminal/terminal_theme.dart+++ b/desktop/lib/terminal/terminal_theme.dart@@ -2,10 +2,27 @@ import 'package:flutter/material.dart';import 'package:xterm/xterm.dart';import '../shared/theme/color_palette.dart';+import 'terminal_theme_store.dart';++/// The colours a terminal pane draws itself in.+///+/// ⚠️ 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(+ 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.matchApp => _matchApp(palette),+};/// Cached per palette. Switching colors repaints the existing terminal view;/// it does not replace its controller, buffer, input connection or font.-TerminalTheme terminalThemeFor(HarnessPalette palette) => _palettes.putIfAbsent(+TerminalTheme _matchApp(HarnessPalette palette) => _palettes.putIfAbsent(palette,() => TerminalTheme(cursor: palette.accent,@@ -72,3 +89,46 @@ const darkTerminalTheme = TerminalTheme(searchHitBackgroundCurrent: Color(0xff31ff26),searchHitForeground: Color(0xff000000),);++/// The Tango palette, as GNOME Terminal ships it — what an agent looks like on+/// a stock Ubuntu desktop.+///+/// ⚠️ The sixteen ANSI slots below are Tango's, unmodified. The GROUND is not:+/// `#300A24` is Ubuntu's own aubergine, which it sets as a custom text colour+/// over this palette, and `#ffffff` the foreground that goes with it. Tango's+/// own dark is `#2e3436` and it is still here, as `black`, where a program+/// asking for colour 0 will find it. Swapping the ground for `black` would be+/// "more correct" and would stop looking like the thing people recognise.+///+/// `selection` is translucent for the reason [darkTerminalTheme] gives — it is+/// painted OVER the glyphs — at the same ~40% of this scheme's own brightBlue.+///+/// The three `searchHit*` colours are deliberately Harness's, shared with+/// [darkTerminalTheme]: find-in-terminal is this app's affordance, not+/// something the scheme has an opinion about, and a highlight that moved with+/// the palette would be a different colour to hunt for per scheme.+const tangoTerminalTheme = TerminalTheme(+ cursor: Color(0xffffffff),+ selection: Color(0x66729fcf),+ foreground: Color(0xffffffff),+ background: Color(0xff300a24),+ black: Color(0xff2e3436),+ red: Color(0xffcc0000),+ green: Color(0xff4e9a06),+ yellow: Color(0xffc4a000),+ blue: Color(0xff3465a4),+ magenta: Color(0xff75507b),+ cyan: Color(0xff06989a),+ white: Color(0xffd3d7cf),+ brightBlack: Color(0xff555753),+ brightRed: Color(0xffef2929),+ brightGreen: Color(0xff8ae234),+ brightYellow: Color(0xfffce94f),+ brightBlue: Color(0xff729fcf),+ brightMagenta: Color(0xffad7fa8),+ brightCyan: Color(0xff34e2e2),+ brightWhite: Color(0xffeeeeec),+ searchHitBackground: Color(0xffffff2b),+ searchHitBackgroundCurrent: Color(0xff31ff26),+ searchHitForeground: Color(0xff000000),+);diff --git a/desktop/lib/terminal/terminal_theme_store.dart b/desktop/lib/terminal/terminal_theme_store.dartnew file mode 100644index 000000000..58b590e0a--- /dev/null+++ b/desktop/lib/terminal/terminal_theme_store.dart@@ -0,0 +1,112 @@+import 'package:flutter/foundation.dart';++import '../core/harness_file_store.dart';+import '../core/local_key_value_store.dart';++/// A colour scheme the terminal is allowed to draw itself in.+///+/// Separate from [HarnessPalette] on purpose. The app's palette dresses the+/// window — sidebar, tabs, dialogs — and until this existed the terminal's+/// ground was simply borrowed from it, so the only way to sit an agent on a+/// different colour was to repaint the whole app. That is one value answering+/// two questions: "what colour is Harness" and "what colour is the screen a+/// remote program is drawing into". They are not the same question, and the+/// font settings beside this one already answer the second independently.+///+/// Deliberately a closed enum rather than free colour fields: sixteen ANSI+/// slots plus foreground, background, cursor and selection is a surface no+/// preferences pane can make legible, and a half-chosen ramp renders TUIs+/// unreadable in ways the user cannot attribute to what they changed. Adding a+/// 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`.+ matchApp(+ 'Match app appearance',+ 'Ground and cursor follow Settings ▸ Appearance',+ ),++ /// ⚠️ 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" would+ /// name a downstream of it and leave nothing to call the scheme itself when a+ /// second one arrives.+ ///+ /// The one thing here that is NOT Tango is the ground: `#300A24` is Ubuntu's+ /// own aubergine, set as a custom text colour over the Tango palette. Tango's+ /// own dark is `#2E3436` — kept below as `black`, where it belongs.+ tango('Tango', "GNOME Terminal's palette on Ubuntu's aubergine ground");++ const TerminalThemeChoice(this.label, this.detail);++ /// What the picker row says.+ final String label;++ /// The second line under it — what changes, in the user's terms.+ final String detail;++ /// What a fresh install opens with, and what a reset returns to.+ static const fallback = matchApp;+}++/// The user's chosen terminal colour scheme, remembered across launches.+///+/// A [ValueNotifier] singleton over [HarnessFileStore], loaded by+/// `loadPersistedSettings()` before the first frame — see that function's doc+/// for why a store that loads late is worse than one that never persisted.+///+/// Unlike [TerminalFontStore] the value here is the *choice*, not a resolved+/// theme: a resolved [TerminalTheme] depends on the app palette too (for+/// [TerminalThemeChoice.matchApp]), and caching that pairing belongs with the+/// colours in `terminal_theme.dart` rather than in the thing that remembers a+/// preference.+class TerminalThemeStore extends ValueNotifier<TerminalThemeChoice> {+ TerminalThemeStore({LocalKeyValueStore? storage})+ : _storage = storage ?? HarnessFileStore.shared,+ super(TerminalThemeChoice.fallback);++ static const _key = 'terminal_theme';++ final LocalKeyValueStore _storage;++ /// Read the saved choice, if there is one. Failure — or a scheme name from a+ /// build that had one this one does not — is silent and lands on the default.+ /// An unreadable state file is not a reason to refuse to start.+ /// `readMany`, not a plain `read`, for a single key: it is the batch path+ /// [TerminalFontStore] and [AppearancePrefsStore] take, so on a shared file+ /// store this preference arrives in the same snapshot as theirs rather than+ /// as a second pass over a file that may have been rewritten in between.+ Future<void> load() async {+ try {+ final saved = await _storage.readMany([_key]);+ value =+ TerminalThemeChoice.values+ .where((choice) => choice.name == saved[_key])+ .firstOrNull ??+ TerminalThemeChoice.fallback;+ } catch (_) {+ value = TerminalThemeChoice.fallback;+ }+ }++ Future<void> set(TerminalThemeChoice choice) async {+ if (choice == value) return;+ value = choice;+ try {+ await _storage.write(_key, choice.name);+ } catch (_) {+ // Kept in memory for this run; see load()'s doc.+ }+ }++ Future<void> reset() => set(TerminalThemeChoice.fallback);++ /// Whether the current pick *is* the default — so a Reset control can say it+ /// has nothing to do.+ bool get isDefault => value == TerminalThemeChoice.fallback;+}++/// The one instance the app reads. Lives here rather than beside `main()` for+/// the same reason [terminalFontStore] does: the terminal panel and the+/// Settings pane must not reach into the entrypoint for it.+final terminalThemeStore = TerminalThemeStore();diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dartindex 0fd3d57ba..ecb2cd162 100644--- a/desktop/lib/widgets/terminal_panel.dart+++ b/desktop/lib/widgets/terminal_panel.dart@@ -26,6 +26,7 @@ import '../terminal/remote_media_download.dart';import '../terminal/terminal_links.dart';import '../terminal/terminal_session.dart';import '../terminal/terminal_theme.dart';+import '../terminal/terminal_theme_store.dart';import '../terminal/terminal_viewport.dart';import '../shared/theme/app_theme.dart' as grid;import '../theme/app_theme.dart';@@ -168,6 +169,10 @@ class _TerminalPanelState extends State<TerminalPanel>widget.session.attachViewport(this);widget.session.addListener(_onSessionChanged);terminalFontStore.addListener(_onFontChanged);+ // Colours repaint the view in place — no relayout, no resize frame — but+ // they still need a rebuild to reach it, and this widget reads the store+ // directly rather than through a builder.+ terminalThemeStore.addListener(_onFontChanged);_afterTerminalMounted();}@@ -265,6 +270,7 @@ class _TerminalPanelState extends State<TerminalPanel>widget.session.removeListener(_onSessionChanged);widget.session.detachViewport(this);terminalFontStore.removeListener(_onFontChanged);+ terminalThemeStore.removeListener(_onFontChanged);_cancelDialInertia();_cursorBlinkTimer?.cancel();_focusNode.removeListener(_handleFocusChange);@@ -1117,7 +1123,10 @@ class _TerminalPanelState extends State<TerminalPanel>focusNode: _focusNode,autofocus: widget.focused && !showComposer,readOnly: widget.readOnly || !session.acceptsInput,- theme: terminalThemeFor(grid.AppTheme.palette.value),+ theme: terminalThemeFor(+ grid.AppTheme.palette.value,+ terminalThemeStore.value,+ ),padding: const EdgeInsets.all(10),textStyle: terminalFontStore.value,// ⚠️ The terminal is NOT app chrome, and the user said so:diff --git a/desktop/test/benchmarks/startup_benchmark.dart b/desktop/test/benchmarks/startup_benchmark.dartindex 0a4fe23ec..cbcb72d79 100644--- a/desktop/test/benchmarks/startup_benchmark.dart+++ b/desktop/test/benchmarks/startup_benchmark.dart@@ -16,6 +16,7 @@ import 'package:harness/shortcuts/keymap_commands.dart';import 'package:harness/shortcuts/keymap_store.dart';import 'package:harness/stats/harness_stats.dart';import 'package:harness/terminal/terminal_font_store.dart';+import 'package:harness/terminal/terminal_theme_store.dart';Map<String, num> distribution(List<int> times) {times.sort();@@ -60,6 +61,7 @@ void main() {for (var sample = -20; sample < 100; sample++) {final storage = HarnessFileStore(directory: preferences);final font = TerminalFontStore(storage: storage);+ final scheme = TerminalThemeStore(storage: storage);final appearance = AppearancePrefsStore(storage: storage);final stats = HarnessStats(store: statsStore);final keymapStore = KeymapStore(@@ -75,6 +77,7 @@ void main() {await Future.wait([loadPersistedSettings(terminalFont: font,+ terminalTheme: scheme,appearance: appearance,stats: stats,),@@ -97,6 +100,7 @@ void main() {keymapStore.dispose();stats.dispose();font.dispose();+ scheme.dispose();appearance.dispose();}}diff --git a/desktop/test/color_palette_test.dart b/desktop/test/color_palette_test.dartindex f000228bc..ab3ddfb40 100644--- a/desktop/test/color_palette_test.dart+++ b/desktop/test/color_palette_test.dart@@ -13,6 +13,7 @@ import 'package:harness/shared/theme/color_palette.dart';import 'package:harness/state/swarm_catalog.dart';import 'package:harness/terminal/terminal_binary.dart';import 'package:harness/terminal/terminal_theme.dart';+import 'package:harness/terminal/terminal_theme_store.dart';import 'package:xterm/xterm.dart';import 'swarm_screen_test.dart' show terminal;@@ -78,9 +79,23 @@ void main() {reason: palette.name,);}- expect(terminalThemeFor(palette), same(terminalThemeFor(palette)));- expect(terminalThemeFor(palette).background, palette.background);- expect(terminalThemeFor(palette).selection.a, lessThan(.5));+ const matchApp = TerminalThemeChoice.matchApp;+ expect(+ terminalThemeFor(palette, matchApp),+ same(terminalThemeFor(palette, matchApp)),+ );+ expect(+ terminalThemeFor(palette, matchApp).background,+ palette.background,+ );+ expect(terminalThemeFor(palette, matchApp).selection.a, lessThan(.5));+ // A scheme of its own ignores the palette entirely — that is what makes+ // it a scheme rather than a tint of the app's.+ expect(+ terminalThemeFor(palette, TerminalThemeChoice.tango).background,+ const Color(0xff300a24),+ reason: 'Tango does not follow ${palette.name}',+ );}});@@ -110,7 +125,9 @@ void main() {await tester.ensureVisible(find.byKey(const ValueKey('palette-forest')));expect(tester- .getSemantics(find.bySemanticsLabel('Forest palette. Quiet evergreen'))+ .getSemantics(+ find.bySemanticsLabel('Forest palette. Quiet evergreen'),+ ).getSemanticsData().hasAction(SemanticsAction.tap),isTrue,diff --git a/desktop/test/startup_test.dart b/desktop/test/startup_test.dartindex b1a22a4bd..5c0cdc716 100644--- a/desktop/test/startup_test.dart+++ b/desktop/test/startup_test.dart@@ -11,6 +11,7 @@ import 'package:harness/shared/theme/appearance_prefs_store.dart';import 'package:harness/shared/theme/color_palette.dart';import 'package:harness/stats/harness_stats.dart';import 'package:harness/terminal/terminal_font_store.dart';+import 'package:harness/terminal/terminal_theme_store.dart';import 'package:harness/terminal/terminal_typography.dart';class _GatedSettings extends Fake implements BatchLocalKeyValueStore {@@ -40,6 +41,7 @@ void main() {late HarnessFileStore storage;late FileSnapshotStore statsStorage;late TerminalFontStore font;+ late TerminalThemeStore scheme;late AppearancePrefsStore appearance;late HarnessStats stats;@@ -48,12 +50,14 @@ void main() {storage = HarnessFileStore(directory: Directory('${dir.path}/settings'));statsStorage = FileSnapshotStore('stats', directory: dir);font = TerminalFontStore(storage: storage);+ scheme = TerminalThemeStore(storage: storage);appearance = AppearancePrefsStore(storage: storage);stats = HarnessStats(store: statsStorage);});tearDown(() async {font.dispose();+ scheme.dispose();appearance.dispose();stats.dispose();await dir.delete(recursive: true);@@ -64,6 +68,7 @@ void main() {// Write through the real setters so the persisted formats are exercised.await font.setFamily(TerminalFontChoice.menlo);await font.setSize(17);+ await scheme.set(TerminalThemeChoice.tango);await appearance.setUiFamily('Helvetica Neue');await appearance.setUiSize(16);await appearance.setPalette(HarnessPalette.forest);@@ -78,21 +83,25 @@ void main() {final reopened = HarnessFileStore(directory: storage.directory);final nextFont = TerminalFontStore(storage: reopened);+ final nextScheme = TerminalThemeStore(storage: reopened);final nextAppearance = AppearancePrefsStore(storage: reopened);final nextStats = HarnessStats(store: FileSnapshotStore('stats', directory: dir),);addTearDown(nextFont.dispose);+ addTearDown(nextScheme.dispose);addTearDown(nextAppearance.dispose);addTearDown(nextStats.dispose);await loadPersistedSettings(terminalFont: nextFont,+ terminalTheme: nextScheme,appearance: nextAppearance,stats: nextStats,);expect(nextFont.family, TerminalFontChoice.menlo);expect(nextFont.size, 17);+ expect(nextScheme.value, TerminalThemeChoice.tango);expect(nextAppearance.value,const AppearancePrefs(@@ -110,11 +119,13 @@ void main() {test('a first launch restores defaults from empty isolated stores', () async {await loadPersistedSettings(terminalFont: font,+ terminalTheme: scheme,appearance: appearance,stats: stats,);expect(font.family, TerminalFontChoice.defaultForPlatform);expect(font.size, terminalFontSize);+ expect(scheme.value, TerminalThemeChoice.fallback);expect(appearance.value, const AppearancePrefs());expect(stats.summary.isEmpty, isTrue);expect(await storage.stateFile.exists(), isFalse);@@ -125,17 +136,21 @@ void main() {'independent loads overlap but readiness waits for every store',() async {final fontStorage = _GatedSettings();+ final schemeStorage = _GatedSettings();final appearanceStorage = _GatedSettings();final counters = _GatedSnapshot();final font = TerminalFontStore(storage: fontStorage);+ final scheme = TerminalThemeStore(storage: schemeStorage);final appearance = AppearancePrefsStore(storage: appearanceStorage);final stats = HarnessStats(store: counters);addTearDown(font.dispose);+ addTearDown(scheme.dispose);addTearDown(appearance.dispose);addTearDown(stats.dispose);var finished = false;final loading = loadPersistedSettings(terminalFont: font,+ terminalTheme: scheme,appearance: appearance,stats: stats,).then((_) => finished = true);@@ -143,6 +158,9 @@ void main() {expect(fontStorage.requests, [{'terminal_font_family', 'terminal_font_size'},]);+ expect(schemeStorage.requests, [+ {'terminal_theme'},+ ]);expect(appearanceStorage.requests, [{'app_ui_font_family', 'app_ui_font_size', 'app_color_palette'},]);@@ -165,6 +183,11 @@ void main() {await Future<void>.delayed(Duration.zero);expect(font.family, TerminalFontChoice.menlo);expect(font.size, 17);+ expect(finished, isFalse);++ schemeStorage.ready.complete({'terminal_theme': 'tango'});+ await Future<void>.delayed(Duration.zero);+ expect(scheme.value, TerminalThemeChoice.tango);expect(finished,isFalse,@@ -183,14 +206,17 @@ void main() {final broken = _GatedSettings();final counters = _GatedSnapshot();final font = TerminalFontStore(storage: broken);+ final scheme = TerminalThemeStore(storage: broken);final appearance = AppearancePrefsStore(storage: broken);final stats = HarnessStats(store: counters);addTearDown(font.dispose);+ addTearDown(scheme.dispose);addTearDown(appearance.dispose);addTearDown(stats.dispose);var finished = false;final loading = loadPersistedSettings(terminalFont: font,+ terminalTheme: scheme,appearance: appearance,stats: stats,).then((_) => finished = true);@@ -198,6 +224,7 @@ void main() {await Future<void>.delayed(Duration.zero);expect(finished, isFalse);expect(font.family, TerminalFontChoice.defaultForPlatform);+ expect(scheme.value, TerminalThemeChoice.fallback);expect(appearance.value, const AppearancePrefs());counters.ready.complete(jsonEncode({'version': 1, 'agentsSpawned': 5}));await loading;diff --git a/desktop/test/terminal_settings_section_test.dart b/desktop/test/terminal_settings_section_test.dartindex 9491b7b3d..5f049c28a 100644--- a/desktop/test/terminal_settings_section_test.dart+++ b/desktop/test/terminal_settings_section_test.dart@@ -9,7 +9,9 @@ import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness/settings/sections/terminal_section.dart';import 'package:harness/shared/theme/app_theme.dart';+import 'package:harness/shared/widgets/app_select_field.dart';import 'package:harness/terminal/terminal_font_store.dart';+import 'package:harness/terminal/terminal_theme_store.dart';/// The sample line inside the preview — the row of `m`s the renderer measures/// its cell with.@@ -50,12 +52,38 @@ void main() {await tester.pumpAndSettle();expect(tester.takeException(), isNull);+ expect(find.text('Colours'), findsOneWidget);expect(find.text('Font'), findsOneWidget);expect(find.text('Size'), findsOneWidget);expect(find.text('Preview'), findsOneWidget);expect(_sample, findsOneWidget);});+ testWidgets('every colour scheme is offered, and the default is on', (+ tester,+ ) async {+ tester.view.physicalSize = const Size(820 * 2, 700 * 2);+ tester.view.devicePixelRatio = 2;+ addTearDown(tester.view.reset);++ await tester.pumpWidget(_host());+ await tester.pumpAndSettle();++ // Unlike the font list, this one has no per-platform filter to get wrong:+ // colours resolve the same everywhere, so every value must be reachable.+ final field = tester.widget<AppSelectField<TerminalThemeChoice>>(+ find.byKey(const Key('terminal-colour-scheme-dropdown')),+ );+ expect(+ field.options.map((option) => option.value),+ TerminalThemeChoice.values,+ );+ expect(field.value, terminalThemeStore.value);+ // The store is the real singleton — see this file's header. Read only.+ expect(terminalThemeStore.value, TerminalThemeChoice.fallback);+ expect(find.text('Match app appearance'), findsWidgets);+ });+testWidgets('the preview refuses the app-wide text scale', (tester) async {// The fifth seam named in `appearance_section.dart`, and the one nothing// guarded: the preview exists to show the size the TERMINAL will render