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): show the background behind running harnesses
reinSPQRf047dfa1bdc2
diff --git a/CONTEXT.md b/CONTEXT.mdindex 1ab4e12c1..44ce13d32 100644--- a/CONTEXT.md+++ b/CONTEXT.md@@ -7,7 +7,7 @@ Harness runs and supervises coding agents across desktop, mobile, CLI and device### Appearance**Background**:-The image or fill shown on an empty welcome or new-tab page; never shown behind agents or terminals.+The image or fill shown on an empty welcome or new-tab page and, when **Behind harnesses** is on, behind the panes of a running harness tab._Avoid_: Wallpaper, start background**Built-in background**:@@ -25,3 +25,11 @@ _Avoid_: Overlay, opacity, brightness**Fit**:How a custom background is sized to the page: fill, fit, center or tile._Avoid_: Scale mode, crop++**Behind harnesses**:+The choice to also show a non-Blank background behind a running harness tab's panes, seen through them. Off by default.+_Avoid_: Running-tab background, transparent terminals++**Pane opacity**:+How solid a harness tab's panes are while **Behind harnesses** is on; lower lets more of the background through.+_Avoid_: Transparency, terminal opacity, Dim (which darkens the background itself)diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 430bd5057..29886dcac 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -6254,9 +6254,16 @@ class _SwarmScreenState extends State<SwarmScreen> {child: Stack(fit: StackFit.expand,children: [- if (app.panes.isEmpty &&- !newHarnessOpensInBox &&- !app.activeSwarm.isNewTabPage)+ if (app.panes.isEmpty+ ? !newHarnessOpensInBox &&+ !app.activeSwarm.isNewTabPage+ // Behind harnesses: seen through the panes and+ // their gutters, on harness tabs only.+ : appearancePrefsStore+ .value+ .showsBehindHarnesses &&+ !app.activeSwarm.isUtility &&+ !app.activeSwarm.isOrchestrator)const RepaintBoundary(key: ValueKey('harness-start-background'),child: SwarmWallpaper(),@@ -6287,93 +6294,98 @@ class _SwarmScreenState extends State<SwarmScreen> {child: Stack(children: [Positioned.fill(- child: PaneGrid(- notifier: app,- swarmMode: true,- soloFocused: _compact(context),- empty:- app.panes.isEmpty &&- !app.activeSwarm.isUtility &&- !app- .activeSwarm- .isOrchestrator- ? newHarnessOpensInBox ||- app- .activeSwarm- .isNewTabPage- ? _startGuide()- : HarnessStartPage(- key: ValueKey(- 'harness-start:${app.activeSwarmId}',- ),- focusNode:- _startSearchFocus,- createSearch: () =>- SwarmSearchController(- app,- _navigation- .recent,- projects:- _projects,- commands:- _searchCommands,- recentCommands: () =>- _navigation- .recentCommands,- // The first box a new- // person meets is the same- // box: its placeholder- // promises `?` and a way- // to create, so it has them.- modes:- _searchModes,- adding: true,- offersCreate:- true,- placement:- HarnessPlacement- .currentTab,- catalog:- _searchCatalog,- ),- onNewTab: _newTab,- onNewPane: () =>- unawaited(- _addAgent(- query: '',- ),- ),- onCommands:- _showSearchCommands,- onQuickStart:- _learning.offer- ? _startQuickStart- : null,- onPractice:- _practiceKeyboard,- onNew: () => _newAgent(- placement:- HarnessPlacement- .currentTab,- ),- onNewWithTask: (task) =>- _newAgent(- task: task,- placement:- HarnessPlacement- .currentTab,- ),- onStore: _openStore,- onResourceSearch:- (query) =>- _openSearch(- adding: true,- query: query,+ child: PaneOpacity(+ opacity: appearancePrefsStore+ .value+ .effectivePaneOpacity,+ child: PaneGrid(+ notifier: app,+ swarmMode: true,+ soloFocused: _compact(context),+ empty:+ app.panes.isEmpty &&+ !app+ .activeSwarm+ .isUtility &&+ !app+ .activeSwarm+ .isOrchestrator+ ? newHarnessOpensInBox ||+ app+ .activeSwarm+ .isNewTabPage+ ? _startGuide()+ : HarnessStartPage(+ key: ValueKey(+ 'harness-start:${app.activeSwarmId}',+ ),+ focusNode:+ _startSearchFocus,+ createSearch: () => SwarmSearchController(+ app,+ _navigation.recent,+ projects: _projects,+ commands:+ _searchCommands,+ recentCommands: () =>+ _navigation+ .recentCommands,+ // The first box a new+ // person meets is the same+ // box: its placeholder+ // promises `?` and a way+ // to create, so it has them.+ modes: _searchModes,+ adding: true,+ offersCreate: true,+ placement:+ HarnessPlacement+ .currentTab,+ catalog:+ _searchCatalog,+ ),+ onNewTab: _newTab,+ onNewPane: () =>+ unawaited(+ _addAgent(+ query: '',),- onChoose:- _chooseStartSearch,- )- : null,+ ),+ onCommands:+ _showSearchCommands,+ onQuickStart:+ _learning.offer+ ? _startQuickStart+ : null,+ onPractice:+ _practiceKeyboard,+ onNew: () => _newAgent(+ placement:+ HarnessPlacement+ .currentTab,+ ),+ onNewWithTask:+ (+ task,+ ) => _newAgent(+ task: task,+ placement:+ HarnessPlacement+ .currentTab,+ ),+ onStore: _openStore,+ onResourceSearch:+ (+ query,+ ) => _openSearch(+ adding: true,+ query: query,+ ),+ onChoose:+ _chooseStartSearch,+ )+ : null,+ ),),),],diff --git a/desktop/lib/settings/appearance/wallpaper_section.dart b/desktop/lib/settings/appearance/wallpaper_section.dartindex 42e01df37..688b56bbe 100644--- a/desktop/lib/settings/appearance/wallpaper_section.dart+++ b/desktop/lib/settings/appearance/wallpaper_section.dart@@ -34,7 +34,7 @@ class WallpaperSection extends StatelessWidget {),const SizedBox(height: 8),Text(- 'A little curiosity for your new swarms.',+ 'Shown on new tabs, and behind your harnesses if you like.',style: grid.AppType.body(color: grid.AppPalette.textSecondary),),const SizedBox(height: 16),@@ -84,6 +84,11 @@ class WallpaperSection extends StatelessWidget {const SizedBox(height: 20),_CustomControls(prefs: prefs, custom: value.custom),],+ // Blank has nothing to show through; the choice is kept for later.+ if (value.background != HarnessBackground.plain) ...[+ const SizedBox(height: 20),+ _BehindHarnessesControls(prefs: prefs, value: value),+ ],],),);@@ -392,3 +397,61 @@ class _CustomControls extends StatelessWidget {);}}++/// Behind harnesses, and how solid the panes stay while it shows through them.+class _BehindHarnessesControls extends StatelessWidget {+ const _BehindHarnessesControls({required this.prefs, required this.value});+ final AppearancePrefsStore prefs;+ final AppearancePrefs value;++ @override+ Widget build(BuildContext context) {+ final label = grid.AppType.label(color: grid.AppPalette.textPrimary);+ final percent = '${(value.paneOpacity * 100).round()}%';+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ SwitchListTile(+ key: const ValueKey('background-behind-harnesses'),+ contentPadding: EdgeInsets.zero,+ value: value.behindHarnesses,+ onChanged: (on) => prefs.setBehindHarnesses(on: on),+ title: Text('Behind harnesses', style: label),+ subtitle: Text(+ 'Show it through the panes of running tabs.',+ style: grid.AppType.label(color: grid.AppPalette.textSecondary),+ ),+ ),+ if (value.behindHarnesses) ...[+ const SizedBox(height: 8),+ Text('Pane opacity', style: label),+ Row(+ children: [+ Expanded(+ child: Slider(+ key: const ValueKey('background-pane-opacity'),+ value: value.paneOpacity,+ min: AppearancePrefs.paneOpacityMin,+ divisions: 20,+ label: percent,+ onChanged: (opacity) =>+ prefs.setBehindHarnesses(opacity: opacity),+ ),+ ),+ SizedBox(+ width: 44,+ child: Text(+ percent,+ textAlign: TextAlign.end,+ style: grid.AppType.label(+ color: grid.AppPalette.textSecondary,+ ),+ ),+ ),+ ],+ ),+ ],+ ],+ );+ }+}diff --git a/desktop/lib/shared/theme/appearance_prefs_store.dart b/desktop/lib/shared/theme/appearance_prefs_store.dartindex b79e4b92f..e4f7018a7 100644--- a/desktop/lib/shared/theme/appearance_prefs_store.dart+++ b/desktop/lib/shared/theme/appearance_prefs_store.dart@@ -22,6 +22,8 @@ class AppearancePrefs {this.palette = HarnessPalette.graphite,this.background = HarnessBackground.plain,this.custom = const CustomBackground(),+ this.behindHarnesses = false,+ this.paneOpacity = paneOpacityDefault,this.prompt = const PromptPrefs(),});@@ -33,6 +35,24 @@ class AppearancePrefs {/// click.final CustomBackground custom;+ /// Also paint the background behind a running harness tab's panes. Kept+ /// while Blank is selected, so choosing an image again brings it back.+ final bool behindHarnesses;++ /// How solid the panes are while [behindHarnesses] shows through them.+ final double paneOpacity;+ static const double paneOpacityDefault = 0.5;+ static const double paneOpacityMin = 0;++ /// Whether a running harness tab paints the background at all: Blank has+ /// nothing to show through.+ bool get showsBehindHarnesses =>+ behindHarnesses && background != HarnessBackground.plain;++ /// The opacity panes paint their own fill at; 1 unless the background is+ /// showing behind them.+ double get effectivePaneOpacity => showsBehindHarnesses ? paneOpacity : 1;+/// Legacy fields, retained for settings compatibility with older builds.final String? uiFamily;final double uiSize;@@ -50,6 +70,8 @@ class AppearancePrefs {HarnessPalette? palette,HarnessBackground? background,CustomBackground? custom,+ bool? behindHarnesses,+ double? paneOpacity,PromptPrefs? prompt,bool clearUiFamily = false,}) => AppearancePrefs(@@ -58,6 +80,8 @@ class AppearancePrefs {palette: palette ?? this.palette,background: background ?? this.background,custom: custom ?? this.custom,+ behindHarnesses: behindHarnesses ?? this.behindHarnesses,+ paneOpacity: paneOpacity ?? this.paneOpacity,prompt: prompt ?? this.prompt,);@@ -69,11 +93,21 @@ class AppearancePrefs {other.palette == palette &&other.background == background &&other.custom == custom &&+ other.behindHarnesses == behindHarnesses &&+ other.paneOpacity == paneOpacity &&other.prompt == prompt;@override- int get hashCode =>- Object.hash(uiFamily, uiSize, palette, background, custom, prompt);+ int get hashCode => Object.hash(+ uiFamily,+ uiSize,+ palette,+ background,+ custom,+ behindHarnesses,+ paneOpacity,+ prompt,+ );}/// The user's appearance choices, remembered across launches.@@ -95,11 +129,13 @@ class AppearancePrefsStore extends ValueNotifier<AppearancePrefs> {static const _paletteKey = 'app_color_palette';static const _backgroundKey = 'harness_start_background';static const _customKey = 'harness_custom_background';+ static const _behindKey = 'harness_background_behind_harnesses';static const _promptKey = 'workspace_prompt_v1';Future<void>? _promptSave;Future<void>? _paletteSave;Future<void>? _backgroundSave;Future<void>? _customSave;+ Future<void>? _behindSave;final LocalKeyValueStore _storage;final Directory? _backgroundsDirectory;@@ -129,8 +165,10 @@ class AppearancePrefsStore extends ValueNotifier<AppearancePrefs> {_paletteKey,_backgroundKey,_customKey,+ _behindKey,_promptKey,]);+ final (behind, opacity) = _behindFrom(saved[_behindKey]);final custom = _customFrom(saved[_customKey]);final background = HarnessBackground.fromId(saved[_backgroundKey]);value = AppearancePrefs(@@ -143,6 +181,8 @@ class AppearancePrefsStore extends ValueNotifier<AppearancePrefs> {? HarnessBackground.plain: background,custom: custom,+ behindHarnesses: behind,+ paneOpacity: opacity,prompt: _promptFrom(saved[_promptKey]),);} catch (_) {@@ -250,6 +290,55 @@ class AppearancePrefsStore extends ValueNotifier<AppearancePrefs> {}}+ /// Behind harnesses and pane opacity. Opacity changes are clamped to+ /// [AppearancePrefs.paneOpacityMin]…1 rather than rejected.+ Future<void> setBehindHarnesses({bool? on, double? opacity}) {+ final next = value.copyWith(+ behindHarnesses: on,+ paneOpacity: opacity == null ? null : _clampOpacity(opacity),+ );+ if (next == value) return _behindSave ?? Future.value();+ value = next;+ return _behindSave ??= _saveBehind();+ }++ Future<void> _saveBehind() async {+ try {+ while (true) {+ final on = value.behindHarnesses, opacity = value.paneOpacity;+ await _storage.write(+ _behindKey,+ jsonEncode({'on': on, 'opacity': opacity}),+ );+ if (value.behindHarnesses == on && value.paneOpacity == opacity) break;+ }+ } catch (_) {+ // Keep the choice for this run if storage is unavailable.+ } finally {+ _behindSave = null;+ }+ }++ static (bool, double) _behindFrom(String? raw) {+ try {+ final json = raw == null ? null : jsonDecode(raw);+ if (json is! Map) return (false, AppearancePrefs.paneOpacityDefault);+ final on = json['on'], opacity = json['opacity'];+ return (+ on == true,+ opacity is num+ ? _clampOpacity(opacity.toDouble())+ : AppearancePrefs.paneOpacityDefault,+ );+ } catch (_) {+ return (false, AppearancePrefs.paneOpacityDefault);+ }+ }++ static double _clampOpacity(double opacity) => opacity.isFinite+ ? opacity.clamp(AppearancePrefs.paneOpacityMin, 1.0)+ : AppearancePrefs.paneOpacityDefault;+static CustomBackground _customFrom(String? raw) {try {return CustomBackground.fromJson(raw == null ? null : jsonDecode(raw));@@ -324,6 +413,7 @@ class AppearancePrefsStore extends ValueNotifier<AppearancePrefs> {await _paletteSave;await _backgroundSave;await _customSave;+ await _behindSave;await _promptSave;try {await _storage.delete(_familyKey);@@ -331,6 +421,7 @@ class AppearancePrefsStore extends ValueNotifier<AppearancePrefs> {await _storage.delete(_paletteKey);await _storage.delete(_backgroundKey);await _storage.delete(_customKey);+ await _storage.delete(_behindKey);await _storage.delete(_promptKey);} catch (_) {// See above.diff --git a/desktop/lib/widgets/box_chrome.dart b/desktop/lib/widgets/box_chrome.dartindex 89b022173..c5eda78c0 100644--- a/desktop/lib/widgets/box_chrome.dart+++ b/desktop/lib/widgets/box_chrome.dart@@ -16,6 +16,27 @@ BorderSide terminalPaneBorder({bool focused = false}) => BorderSide(/// One gutter around the workspace, between panes, and beside command docks.const double kWorkspaceInset = 9.5;+/// How solid the workspace's panes paint their own fill: below 1 while the+/// background shows through them (Behind harnesses). Only fills turn+/// translucent — text, colored cells, banners and the composer stay solid.+class PaneOpacity extends InheritedWidget {+ const PaneOpacity({super.key, required this.opacity, required super.child});+ final double opacity;++ /// 1 outside a workspace that set one.+ static double of(BuildContext context) =>+ context.dependOnInheritedWidgetOfExactType<PaneOpacity>()?.opacity ?? 1;++ /// [color] at the pane opacity.+ static Color fill(BuildContext context, Color color) {+ final opacity = of(context);+ return opacity >= 1 ? color : color.withValues(alpha: color.a * opacity);+ }++ @override+ bool updateShouldNotify(PaneOpacity old) => old.opacity != opacity;+}+/// The selected tab joins the workspace with the same small radius used at/// its top corners. The bottom curves turn outward, like a browser tab.class TerminalTabBorder extends ShapeBorder {diff --git a/desktop/lib/widgets/pane_grid.dart b/desktop/lib/widgets/pane_grid.dartindex 5697cb340..94b293187 100644--- a/desktop/lib/widgets/pane_grid.dart+++ b/desktop/lib/widgets/pane_grid.dart@@ -1217,7 +1217,12 @@ class _PaneCell extends StatelessWidget {// shows a seam between the header strip and the terminal under it.// What changes to make the gaps visible is the field BEHIND the grid// (see _GridField), which is the part the gaps actually show.- color: grid.AppPalette.windowBg,+ //+ // Behind harnesses: a terminal paints its own translucent fills, so+ // the frame adds none (two would stack); a status pane has only this.+ color: PaneOpacity.of(context) < 1 && pane.session != null+ ? null+ : PaneOpacity.fill(context, grid.AppPalette.windowBg),borderRadius: BorderRadius.circular(_paneRadius),// The rim is always drawn — it is what gives an unfocused card its// edge, now that no shared line does. It only CHANGES COLOUR ondiff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dartindex 76e495aac..68981323d 100644--- a/desktop/lib/widgets/terminal_panel.dart+++ b/desktop/lib/widgets/terminal_panel.dart@@ -20,6 +20,7 @@ import '../state/app_state.dart';import '../state/model_start_watch.dart';import 'agent_drag.dart';+import 'box_chrome.dart';import 'rename_agent_dialog.dart';import 'terminal_composer.dart';import '../shortcuts/app_keymap.dart';@@ -2103,89 +2104,97 @@ class _TerminalPanelState extends State<TerminalPanel>final machineState = widget.notifier.stateOf(session.machineId);final remote = machineState != null && !machineState.isLocalMachine;final showComposer = _showsComposer;+ // Behind harnesses: each part paints its own fill at this opacity (the+ // header, the screen) or solid (the composer), over nothing — a fill+ // underneath them all would stack with theirs.+ final paneOpacity = PaneOpacity.of(context);+ final chromeFill = PaneOpacity.fill(context, grid.AppPalette.windowBg);return KeymapRegion(contextKind: KeymapContext.terminal,composing: () =>_focusNode.hasFocus &&_terminalViewKey.currentState?.isComposing == true,child: ColoredBox(- color: grid.AppPalette.windowBg,+ color: paneOpacity < 1 ? Colors.transparent : grid.AppPalette.windowBg,child: Column(children: [if (widget.showHeader)- Stack(- children: [- Visibility(- visible: _find == null,- maintainSize: true,- maintainAnimation: true,- maintainState: true,- child: _buildHeader(context),- ),- // Attach the focused pane's input before Find is requested.- // Hidden/unfocused panes need no dormant editor or index.- if (_find != null || (widget.visible && widget.focused))- Positioned.fill(- child: Offstage(- offstage: _find == null,- child: LayoutBuilder(- builder: (context, constraints) => Row(- children: [- if (constraints.maxWidth > 520)- Expanded(+ ColoredBox(+ color: chromeFill,+ child: Stack(+ children: [+ Visibility(+ visible: _find == null,+ maintainSize: true,+ maintainAnimation: true,+ maintainState: true,+ child: _buildHeader(context),+ ),+ // Attach the focused pane's input before Find is requested.+ // Hidden/unfocused panes need no dormant editor or index.+ if (_find != null || (widget.visible && widget.focused))+ Positioned.fill(+ child: Offstage(+ offstage: _find == null,+ child: LayoutBuilder(+ builder: (context, constraints) => Row(+ children: [+ if (constraints.maxWidth > 520)+ Expanded(+ child: Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: _stripPadding,+ ),+ child: Text(+ session.agentName,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ // The header's own ink, which this+ // line stands in for while Find is open.+ style: grid.AppType.monoLabel(+ color: terminalThemeFor(+ grid.AppTheme.palette.value,+ terminalThemeStore.value,+ ).foreground.withValues(alpha: .70),+ fontWeight: FontWeight.w400,+ ),+ ),+ ),+ )+ else+ const Spacer(),+ SizedBox(+ width: math.min(constraints.maxWidth, 380),+child: Padding(padding: const EdgeInsets.symmetric(- horizontal: _stripPadding,+ horizontal: 6,+ vertical: 4,),- child: Text(- session.agentName,- maxLines: 1,- overflow: TextOverflow.ellipsis,- // The header's own ink, which this- // line stands in for while Find is open.- style: grid.AppType.monoLabel(- color: terminalThemeFor(- grid.AppTheme.palette.value,- terminalThemeStore.value,- ).foreground.withValues(alpha: .70),- fontWeight: FontWeight.w400,- ),+ child: TerminalFindBar(+ key: _findBarKey,+ search: _find,+ initialQuery: _lastFindQuery,+ initialCaseSensitive:+ _lastFindCaseSensitive,+ readOnly:+ widget.readOnly ||+ !session.acceptsInput,+ onQuery: _queryFind,+ onStep: _stepFind,+ onClose: _closeFind,+ onFocus: () =>+ widget.onRendererFocus?.call(),),),- )- else- const Spacer(),- SizedBox(- width: math.min(constraints.maxWidth, 380),-- child: Padding(- padding: const EdgeInsets.symmetric(- horizontal: 6,- vertical: 4,- ),- child: TerminalFindBar(- key: _findBarKey,- search: _find,- initialQuery: _lastFindQuery,- initialCaseSensitive:- _lastFindCaseSensitive,- readOnly:- widget.readOnly ||- !session.acceptsInput,- onQuery: _queryFind,- onStep: _stepFind,- onClose: _closeFind,- onFocus: () =>- widget.onRendererFocus?.call(),- ),),- ),- ],+ ],+ ),),),),- ),- ],+ ],+ ),),// Goes with the row above it: the phone draws its own rule under@@ -2245,6 +2254,7 @@ class _TerminalPanelState extends State<TerminalPanel>terminalThemeStore.value,),padding: const EdgeInsets.all(10),+ backgroundOpacity: paneOpacity,textStyle: terminalFontStore.value,// The chosen point size already sizes each terminal cell.// Applying the OS text scale again would change rows/cols@@ -2358,16 +2368,23 @@ class _TerminalPanelState extends State<TerminalPanel>if (!widget.compactHeader &&remote &&widget.onToggleComposer != null)- ComposerGrip(- expanded: widget.composerVisible,- onPressed: widget.onToggleComposer!,+ ColoredBox(+ color: chromeFill,+ child: ComposerGrip(+ expanded: widget.composerVisible,+ onPressed: widget.onToggleComposer!,+ ),),+ // Solid whatever the pane opacity: this is where you type.if (showComposer)- TerminalComposer(- tabId: widget.paneLocation?.$1,- session: session,- focusNode: _composerFocus,- inputEnabled: !widget.readOnly,+ ColoredBox(+ color: grid.AppPalette.windowBg,+ child: TerminalComposer(+ tabId: widget.paneLocation?.$1,+ session: session,+ focusNode: _composerFocus,+ inputEnabled: !widget.readOnly,+ ),),],),diff --git a/desktop/test/background_behind_harnesses_test.dart b/desktop/test/background_behind_harnesses_test.dartnew file mode 100644index 000000000..e815b2a2e--- /dev/null+++ b/desktop/test/background_behind_harnesses_test.dart@@ -0,0 +1,144 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/core/local_key_value_store.dart';+import 'package:harness/settings/appearance/wallpaper_section.dart';+import 'package:harness/shared/theme/appearance_prefs_store.dart';+import 'package:harness/shared/theme/harness_background.dart';+import 'package:harness/widgets/box_chrome.dart';++class _Storage implements LocalKeyValueStore {+ final values = <String, String>{};+ @override+ Future<String?> read(String key) async => values[key];+ @override+ Future<void> write(String key, String value) async => values[key] = value;+ @override+ Future<void> delete(String key) async => values.remove(key);+}++const _key = 'harness_background_behind_harnesses';++HarnessBackground get _artwork => HarnessBackground.gallery.firstWhere(+ (background) => background != HarnessBackground.plain,+);++void main() {+ group('prefs', () {+ test('off by default, at 50%', () {+ const prefs = AppearancePrefs();+ expect(prefs.behindHarnesses, isFalse);+ expect(prefs.paneOpacity, 0.5);+ expect(prefs.effectivePaneOpacity, 1);+ });++ test('round-trips through storage', () async {+ final storage = _Storage();+ final store = AppearancePrefsStore(storage: storage);+ await store.setBehindHarnesses(on: true, opacity: 0.6);++ final reloaded = AppearancePrefsStore(storage: storage);+ await reloaded.load();+ expect(reloaded.value.behindHarnesses, isTrue);+ expect(reloaded.value.paneOpacity, 0.6);+ });++ test('opacity is clamped, and garbage lands on the defaults', () async {+ final storage = _Storage();+ final store = AppearancePrefsStore(storage: storage);+ await store.setBehindHarnesses(opacity: -1);+ expect(store.value.paneOpacity, AppearancePrefs.paneOpacityMin);+ await store.setBehindHarnesses(opacity: 7);+ expect(store.value.paneOpacity, 1);++ storage.values[_key] = '{"on": "yes", "opacity": "NaN"}';+ await store.load();+ expect(store.value.behindHarnesses, isFalse);+ expect(store.value.paneOpacity, AppearancePrefs.paneOpacityDefault);++ storage.values[_key] = 'not json';+ await store.load();+ expect(store.value.behindHarnesses, isFalse);+ });++ test('Blank shows nothing behind harnesses, but keeps the choice', () async {+ final store = AppearancePrefsStore(storage: _Storage());+ await store.setBehindHarnesses(on: true, opacity: 0.7);+ expect(store.value.showsBehindHarnesses, isFalse);+ expect(store.value.effectivePaneOpacity, 1);++ await store.setBackground(_artwork);+ expect(store.value.showsBehindHarnesses, isTrue);+ expect(store.value.effectivePaneOpacity, 0.7);++ await store.setBackground(HarnessBackground.plain);+ expect(store.value.behindHarnesses, isTrue);+ expect(store.value.effectivePaneOpacity, 1);+ });++ test('reset forgets it', () async {+ final storage = _Storage();+ final store = AppearancePrefsStore(storage: storage);+ await store.setBehindHarnesses(on: true);+ await store.reset();+ expect(store.value.behindHarnesses, isFalse);+ expect(storage.values.containsKey(_key), isFalse);+ });+ });++ testWidgets('the switch shows for artwork and reveals pane opacity', (+ tester,+ ) async {+ final store = AppearancePrefsStore(storage: _Storage());+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SingleChildScrollView(child: WallpaperSection(store: store)),+ ),+ ),+ );+ final toggle = find.byKey(const ValueKey('background-behind-harnesses'));+ final slider = find.byKey(const ValueKey('background-pane-opacity'));+ expect(toggle, findsNothing, reason: 'Blank has nothing to show');++ await store.setBackground(_artwork);+ await tester.pumpAndSettle();+ expect(toggle, findsOneWidget);+ expect(slider, findsNothing);++ await tester.ensureVisible(toggle);+ await tester.tap(toggle);+ await tester.pumpAndSettle();+ expect(store.value.behindHarnesses, isTrue);+ expect(slider, findsOneWidget);+ expect(find.text('50%'), findsOneWidget);+ });++ testWidgets('PaneOpacity scales fills, and is solid outside a workspace', (+ tester,+ ) async {+ late Color inside, outside;+ await tester.pumpWidget(+ Column(+ children: [+ Builder(+ builder: (context) {+ outside = PaneOpacity.fill(context, const Color(0xff202020));+ return const SizedBox();+ },+ ),+ PaneOpacity(+ opacity: 0.5,+ child: Builder(+ builder: (context) {+ inside = PaneOpacity.fill(context, const Color(0xff202020));+ return const SizedBox();+ },+ ),+ ),+ ],+ ),+ );+ expect(outside.a, 1);+ expect(inside.a, closeTo(0.5, 0.01));+ });+}diff --git a/desktop/third_party/xterm/lib/src/terminal_view.dart b/desktop/third_party/xterm/lib/src/terminal_view.dartindex c54a09747..c76a4c582 100644--- a/desktop/third_party/xterm/lib/src/terminal_view.dart+++ b/desktop/third_party/xterm/lib/src/terminal_view.dart@@ -284,6 +284,7 @@ class TerminalViewState extends State<TerminalView> {textStyle: widget.textStyle,textScaler: widget.textScaler ?? MediaQuery.textScalerOf(context),theme: widget.theme,+ fillsBackground: widget.backgroundOpacity >= 1,focusNode: _focusNode,cursorType: widget.cursorType,alwaysShowCursor: widget.alwaysShowCursor,@@ -703,6 +704,7 @@ class _TerminalView extends LeafRenderObjectWidget {required this.textStyle,required this.textScaler,required this.theme,+ this.fillsBackground = true,required this.focusNode,required this.cursorType,required this.alwaysShowCursor,@@ -733,6 +735,9 @@ class _TerminalView extends LeafRenderObjectWidget {final TerminalTheme theme;+ /// See [RenderTerminal.fillsBackground].+ final bool fillsBackground;+final FocusNode focusNode;final TerminalCursorType cursorType;@@ -760,6 +765,7 @@ class _TerminalView extends LeafRenderObjectWidget {textStyle: textStyle,textScaler: textScaler,theme: theme,+ fillsBackground: fillsBackground,focusNode: focusNode,cursorType: cursorType,alwaysShowCursor: alwaysShowCursor,@@ -784,6 +790,7 @@ class _TerminalView extends LeafRenderObjectWidget {..textStyle = textStyle..textScaler = textScaler..theme = theme+ ..fillsBackground = fillsBackground..focusNode = focusNode..cursorType = cursorType..alwaysShowCursor = alwaysShowCursordiff --git a/desktop/third_party/xterm/lib/src/ui/render.dart b/desktop/third_party/xterm/lib/src/ui/render.dartindex f9033a613..037c98c01 100644--- a/desktop/third_party/xterm/lib/src/ui/render.dart+++ b/desktop/third_party/xterm/lib/src/ui/render.dart@@ -32,6 +32,7 @@ class RenderTerminal extends RenderBox with RelayoutWhenSystemFontsChangeMixin {required TerminalStyle textStyle,required TextScaler textScaler,required TerminalTheme theme,+ bool fillsBackground = true,required FocusNode focusNode,required TerminalCursorType cursorType,required bool alwaysShowCursor,@@ -52,6 +53,7 @@ class RenderTerminal extends RenderBox with RelayoutWhenSystemFontsChangeMixin {_onEditableRect = onEditableRect,_composingText = composingText,_composingBacktrackCells = composingBacktrackCells,+ _fillsBackground = fillsBackground,_painter = TerminalPainter(theme: theme,textStyle: textStyle,@@ -164,6 +166,18 @@ class RenderTerminal extends RenderBox with RelayoutWhenSystemFontsChangeMixin {markNeedsPaint();}+ /// Whether each frame opens with a solid fill in the theme's background.+ /// False while [TerminalView.backgroundOpacity] is below 1: the view's own+ /// translucent fill sits underneath, and a solid one here would hide what+ /// shows through it. This render object is a repaint boundary, so its layer+ /// is re-recorded from empty on every paint either way.+ bool _fillsBackground;+ set fillsBackground(bool value) {+ if (value == _fillsBackground) return;+ _fillsBackground = value;+ markNeedsPaint();+ }+set devicePixelRatio(double value) {if (value == _painter.devicePixelRatio) return;_painter.devicePixelRatio = value;@@ -568,10 +582,12 @@ class RenderTerminal extends RenderBox with RelayoutWhenSystemFontsChangeMixin {final paintBounds = offset & size;canvas.save();canvas.clipRect(paintBounds);- canvas.drawRect(- paintBounds,- Paint()..color = _painter.theme.background,- );+ if (_fillsBackground) {+ canvas.drawRect(+ paintBounds,+ Paint()..color = _painter.theme.background,+ );+ }final lines = _terminal.buffer.lines;final charHeight = _painter.cellSize.height;