Skip to content

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.

Remove duplicate agent switch from Companions viewer (#595)

Deebe191039f7e2
diff --git a/desktop/design/companion-home.png b/desktop/design/companion-home.png
index 9ec2b7fa7..13d66ccbf 100644
Binary files a/desktop/design/companion-home.png and b/desktop/design/companion-home.png differ
diff --git a/desktop/design/companions.md b/desktop/design/companions.md
index ea70185c0..bf810b95e 100644
--- a/desktop/design/companions.md
+++ b/desktop/design/companions.md
@@ -46,12 +46,11 @@ computer; this is not cross-machine memory sync.
![Pending memory review with source evidence and guarded approval, using synthetic fixture data](companion-memory-inbox.png)
-The header's **Powered by** menu chooses Codex or Claude Code for the collection.
-A new collection asks the person to choose; there is no Claude-first default or
-automatic fallback when usage runs out. Existing collections keep their agent.
-The choice stays visible across Story, Collection and Memories, and moves below
-the title in a narrow viewer. Selecting an uninstalled agent explains which one
-is missing and keeps the current choice.
+The agent and model controls live in the right conversation pane's header.
+The viewer header contains the Companions title and settings button, with no
+duplicate agent selector at any width. Existing collections keep their agent
+and do not switch automatically when usage runs out. Selecting an uninstalled
+agent explains which one is missing and keeps the current choice.
Opening the home starts or resumes the selected pair DSH through a UI-only local
socket request, without a prompt, pasted text or Enter key. The complete engine
diff --git a/desktop/lib/companions/companion_engine_picker.dart b/desktop/lib/companions/companion_engine_picker.dart
deleted file mode 100644
index b34ee7375..000000000
--- a/desktop/lib/companions/companion_engine_picker.dart
+++ /dev/null
@@ -1,13 +0,0 @@
-import 'package:flutter/material.dart';
-
-import '../widgets/harness_agent_picker.dart';
-
-/// The collection uses the same agent control as ordinary harness panes.
-class CompanionEnginePicker extends HarnessAgentPicker {
- const CompanionEnginePicker({
- super.key,
- required super.engine,
- required super.onSelected,
- super.busy,
- }) : super(triggerKey: const ValueKey('companion-engine-picker'));
-}
diff --git a/desktop/lib/companions/companion_home.dart b/desktop/lib/companions/companion_home.dart
index 1d756f8c7..174e25a24 100644
--- a/desktop/lib/companions/companion_home.dart
+++ b/desktop/lib/companions/companion_home.dart
@@ -18,7 +18,6 @@ import '../state/dial_status.dart';
import '../theme/app_theme.dart';
import '../widgets/daemon_illustration.dart';
import 'companion_dial.dart';
-import 'companion_engine_picker.dart';
import 'companion_story.dart';
import 'memory_review_text.dart';
import 'coding_memory_connection.dart';
@@ -37,8 +36,6 @@ class CompanionHome extends StatefulWidget {
required this.onHatch,
required this.onOpenControls,
this.onOpenConversation,
- this.onSelectEngine,
- this.openingTerminal = false,
this.terminalStatus,
this.dial,
this.onDeviceSettings,
@@ -49,8 +46,6 @@ class CompanionHome extends StatefulWidget {
final ValueChanged<ZooEgg> onHatch;
final ValueChanged<String> onOpenControls;
final VoidCallback? onOpenConversation;
- final ValueChanged<String>? onSelectEngine;
- final bool openingTerminal;
final String? terminalStatus;
final DialState? dial;
final void Function(String, Map<String, Object?>)? onDeviceSettings;
@@ -210,116 +205,93 @@ class _CompanionHomeState extends State<CompanionHome> {
return Material(
key: const ValueKey('companion-home'),
color: AppColors.background,
- child: LayoutBuilder(
- builder: (context, constraints) {
- final enginePicker = CompanionEnginePicker(
- engine: widget.brain.pairEngine,
- onSelected: widget.onSelectEngine,
- busy: widget.openingTerminal,
- );
- final viewer = Column(
- children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(28, 20, 18, 14),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Expanded(
- child: Text(
- 'Companions',
- style: ink(17)
- .copyWith(fontWeight: FontWeight.w600),
- ),
- ),
- if (constraints.maxWidth >= 500) enginePicker,
- IconButton(
- tooltip: 'Companion settings',
- key: const ValueKey('companion-settings'),
- onPressed: () => widget.onOpenControls('settings'),
- icon: Icon(
- AppIcons.slidersHorizontal,
- size: 20,
- color: AppColors.textSoft,
- ),
- ),
- ],
- ),
- if (constraints.maxWidth < 500) enginePicker,
- ],
+ child: Column(
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(28, 20, 18, 14),
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ 'Companions',
+ style: ink(17).copyWith(fontWeight: FontWeight.w600),
+ ),
),
- ),
- Padding(
- padding: const EdgeInsets.fromLTRB(20, 0, 20, 10),
- child: Row(
- children: [
- Expanded(
- child: Wrap(
- spacing: 4,
- runSpacing: 4,
- children: [
- for (final section in [
- 'Story',
- 'Collection',
- 'Memories',
- ])
- Semantics(
- selected: _section == section,
- child: _button(
- section,
- () => _selectSection(section),
- primary: _section == section,
- key: ValueKey('companion-nav-$section'),
- ),
- ),
- ],
- ),
- ),
- ],
+ IconButton(
+ tooltip: 'Companion settings',
+ key: const ValueKey('companion-settings'),
+ onPressed: () => widget.onOpenControls('settings'),
+ icon: Icon(
+ AppIcons.slidersHorizontal,
+ size: 20,
+ color: AppColors.textSoft,
+ ),
),
- ),
- if (widget.terminalStatus != null)
- Padding(
- padding: const EdgeInsets.fromLTRB(28, 0, 28, 10),
- child: Row(
+ ],
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 10),
+ child: Row(
+ children: [
+ Expanded(
+ child: Wrap(
+ spacing: 4,
+ runSpacing: 4,
children: [
- Expanded(
- child: Text(
- widget.terminalStatus!,
- style: ink(13, AppColors.textSoft),
+ for (final section in ['Story', 'Collection', 'Memories'])
+ Semantics(
+ selected: _section == section,
+ child: _button(
+ section,
+ () => _selectSection(section),
+ primary: _section == section,
+ key: ValueKey('companion-nav-$section'),
+ ),
),
- ),
- if (widget.onOpenConversation != null)
- _button('Open terminal', widget.onOpenConversation),
],
),
),
- Expanded(
- child: SingleChildScrollView(
- key: _memoryViewport,
- controller: _scroll,
- padding: const EdgeInsets.fromLTRB(28, 6, 28, 40),
- child: Align(
- alignment: Alignment.topCenter,
- child: ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 1100),
- child: switch (_section) {
- 'Collection' => _collection(),
- 'Memories' => _memories(),
- _ =>
- zoo.zoo.daemons.isEmpty && _previewSpecies == null
- ? _nest()
- : _story(),
- },
+ ],
+ ),
+ ),
+ if (widget.terminalStatus != null)
+ Padding(
+ padding: const EdgeInsets.fromLTRB(28, 0, 28, 10),
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ widget.terminalStatus!,
+ style: ink(13, AppColors.textSoft),
),
),
+ if (widget.onOpenConversation != null)
+ _button('Open terminal', widget.onOpenConversation),
+ ],
+ ),
+ ),
+ Expanded(
+ child: SingleChildScrollView(
+ key: _memoryViewport,
+ controller: _scroll,
+ padding: const EdgeInsets.fromLTRB(28, 6, 28, 40),
+ child: Align(
+ alignment: Alignment.topCenter,
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 1100),
+ child: switch (_section) {
+ 'Collection' => _collection(),
+ 'Memories' => _memories(),
+ _ => zoo.zoo.daemons.isEmpty && _previewSpecies == null
+ ? _nest()
+ : _story(),
+ },
),
),
- ],
- );
- return viewer;
- },
+ ),
+ ),
+ ],
),
);
}
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 8efb2bca8..a7790584c 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -4027,8 +4027,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
unawaited(_openCompanionTerminal(key));
}
- Future<void> _openCompanionTerminal(String key, {String? engine}) async {
- final result = await _brain.openConversation(engine: engine);
+ Future<void> _openCompanionTerminal(String key) async {
+ final result = await _brain.openConversation();
if (!mounted || _companionOpeningKey != key) return;
_companionOpeningKey = null;
if (key != '${_zoo.scope}:${_zoo.paired?.uid}' || !_creatureEnabled) return;
@@ -4083,26 +4083,6 @@ class _SwarmScreenState extends State<SwarmScreen> {
return result;
}
- void _selectCompanionEngine(String engine) {
- final uid = _zoo.paired?.uid;
- if (uid == null || _companionOpeningKey != null || _zoo.isPreview) return;
- if (_pairHarness case final pair?) {
- unawaited(
- app.changeAgent(pair.machineId, pair.agentId, engine).then((error) {
- if (mounted && error != null) _showPaneActionHint(error);
- }),
- );
- return;
- }
- final key = '${_zoo.scope}:$uid';
- setState(() {
- _companionAttemptedKey = key;
- _companionOpeningKey = key;
- _companionTerminalError = null;
- });
- unawaited(_openCompanionTerminal(key, engine: engine));
- }
-
Widget _companionViewer(BuildContext context) => CompanionHome(
key: ValueKey('companion-home:${_zoo.scope}'),
face: _face,
@@ -4112,10 +4092,6 @@ class _SwarmScreenState extends State<SwarmScreen> {
: app.openCodingMemoryConnection,
onHatch: _hatch,
onOpenControls: _openCompanionControls,
- onSelectEngine: _zoo.isPreview || !_brain.active || _zoo.paired == null
- ? null
- : _selectCompanionEngine,
- openingTerminal: _companionOpeningKey != null,
terminalStatus:
_companionTerminalError ??
(_companionOpeningKey != null
diff --git a/desktop/test/companion_engine_picker_test.dart b/desktop/test/companion_engine_picker_test.dart
deleted file mode 100644
index b88992133..000000000
--- a/desktop/test/companion_engine_picker_test.dart
+++ /dev/null
@@ -1,90 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter_test/flutter_test.dart';
-import 'package:harness/companions/companion_engine_picker.dart';
-import 'package:harness/shared/theme/app_theme.dart';
-import 'package:harness/shared/widgets/app_menu.dart';
-
-void main() {
- testWidgets('first choice, switching, dismissal and a pending launch', (
- tester,
- ) async {
- String? selected;
- var busy = false;
- late StateSetter update;
- await tester.pumpWidget(
- MaterialApp(
- theme: buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: StatefulBuilder(
- builder: (context, setState) {
- update = setState;
- return CompanionEnginePicker(
- engine: selected,
- busy: busy,
- onSelected: (engine) => setState(() => selected = engine),
- );
- },
- ),
- ),
- ),
- );
- final trigger = find.byKey(const ValueKey('companion-engine-picker'));
- expect(find.text('Choose agent'), findsOneWidget);
- await tester.tap(trigger);
- await tester.pumpAndSettle();
- await tester.tap(find.text('Codex'));
- await tester.pumpAndSettle();
- expect(selected, 'codex');
- expect(find.byType(AppMenuItem), findsNothing);
- await tester.tap(trigger);
- await tester.pumpAndSettle();
- expect(
- tester
- .widgetList<AppMenuItem>(find.byType(AppMenuItem))
- .where((row) => row.selected)
- .single
- .label,
- 'Codex',
- );
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await tester.pumpAndSettle();
- expect(selected, 'codex');
- expect(find.byType(AppMenuItem), findsNothing);
- await tester.tap(trigger);
- await tester.pumpAndSettle();
- await tester.tap(find.text('Claude Code'));
- await tester.pumpAndSettle();
- expect(selected, 'claude');
- update(() => busy = true);
- await tester.pumpAndSettle();
- expect(tester.widget<TextButton>(trigger).onPressed, isNull);
- expect(find.text('Opening…'), findsOneWidget);
- expect(tester.takeException(), isNull);
- });
-
- testWidgets('keyboard users can open, choose and dismiss the agent menu', (
- tester,
- ) async {
- String? chosen;
- await tester.pumpWidget(
- MaterialApp(
- home: Scaffold(
- body: CompanionEnginePicker(
- engine: null,
- onSelected: (engine) => chosen = engine,
- ),
- ),
- ),
- );
- await tester.sendKeyEvent(LogicalKeyboardKey.tab);
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pumpAndSettle();
- expect(find.byType(AppMenuItem), findsNWidgets(3));
- await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pumpAndSettle();
- expect(chosen, isNotNull);
- expect(find.byType(AppMenuItem), findsNothing);
- });
-}
diff --git a/desktop/test/companion_home_test.dart b/desktop/test/companion_home_test.dart
index 88b147c41..8d34e7fde 100644
--- a/desktop/test/companion_home_test.dart
+++ b/desktop/test/companion_home_test.dart
@@ -268,7 +268,6 @@ void main() {
: () => codingMemory,
onHatch: (_) {},
onOpenControls: (_) {},
- onSelectEngine: (_) {},
),
),
),