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.

Welcome page: keys work in the app, one more line under the tagline (#384)

Deebaa5d911fd31
diff --git a/desktop/lib/widgets/workspace_welcome.dart b/desktop/lib/widgets/workspace_welcome.dart
index 2ec809ba4..689a42662 100644
--- a/desktop/lib/widgets/workspace_welcome.dart
+++ b/desktop/lib/widgets/workspace_welcome.dart
@@ -1,3 +1,5 @@
+import 'dart:async';
+
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -44,6 +46,7 @@ class WorkspaceWelcome extends StatefulWidget {
class _WorkspaceWelcomeState extends State<WorkspaceWelcome> {
WelcomeSessions? _sessions;
int _cursor = 0;
+ final _focus = FocusNode(debugLabel: 'Welcome sessions');
ValueChanged<String> get onCommand => widget.onCommand;
@@ -56,9 +59,28 @@ class _WorkspaceWelcomeState extends State<WorkspaceWelcome> {
..addListener(_changed);
_sessions!.load();
app.addListener(_appChanged);
+ FocusManager.instance.addListener(_claimFocus);
+ WidgetsBinding.instance.addPostFrameCallback((_) => _claimFocus());
}
}
+ /// An empty tab gives its keys to the workspace around this page — on a new
+ /// tab, and again when Cmd-P or a dialog closes. Keys start at the focused
+ /// node and only go up, so that focus is taken here, where they are used.
+ /// Focus anywhere else (a field, a dialog, Cmd-P) is left alone, and the
+ /// app's shortcuts are read before any of this.
+ void _claimFocus() {
+ if (!mounted || _focus.hasPrimaryFocus || !_focus.canRequestFocus) return;
+ final primary = FocusManager.instance.primaryFocus;
+ if (primary != null && !_focus.ancestors.contains(primary)) return;
+ scheduleMicrotask(() {
+ final now = FocusManager.instance.primaryFocus;
+ if (mounted && (now == null || _focus.ancestors.contains(now))) {
+ _focus.requestFocus();
+ }
+ });
+ }
+
void _appChanged() => _sessions?.appChanged();
void _changed() {
@@ -67,6 +89,8 @@ class _WorkspaceWelcomeState extends State<WorkspaceWelcome> {
@override
void dispose() {
+ FocusManager.instance.removeListener(_claimFocus);
+ _focus.dispose();
if (_sessions != null) widget.app?.removeListener(_appChanged);
_sessions
?..removeListener(_changed)
@@ -194,7 +218,9 @@ class _WorkspaceWelcomeState extends State<WorkspaceWelcome> {
);
final footerInset = line + 52;
return Focus(
- autofocus: _sessions != null,
+ focusNode: _focus,
+ canRequestFocus: _sessions != null,
+ skipTraversal: true,
onKeyEvent: _key,
child: Material(
key: const ValueKey('workspace-welcome'),
@@ -231,7 +257,7 @@ class _WorkspaceWelcomeState extends State<WorkspaceWelcome> {
'Harness like a boss.',
key: const ValueKey('welcome-tagline'),
),
- SizedBox(height: line),
+ SizedBox(height: line * 2),
if (sessions == null)
_commands(
rows,
diff --git a/desktop/test/welcome_sessions_test.dart b/desktop/test/welcome_sessions_test.dart
index 00dd82086..a602f363e 100644
--- a/desktop/test/welcome_sessions_test.dart
+++ b/desktop/test/welcome_sessions_test.dart
@@ -2,11 +2,14 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/models.dart';
+import 'package:harness/state/new_harness.dart';
import 'package:harness/state/swarm_navigation.dart';
import 'package:harness/state/welcome_sessions.dart';
import 'package:harness/widgets/workspace_welcome.dart';
+import 'keymap_host_test.dart' show key;
import 'session_content_search_test.dart' show SearchConnection;
+import 'swarm_screen_test.dart' show mount;
import 'swarm_state_test.dart' show createApp;
final _now = DateTime(2026, 9, 27, 12);
@@ -173,6 +176,36 @@ void main() {
},
);
+ testWidgets(
+ 'in the workspace an empty tab keys the list, and gets it back after Cmd-P',
+ (tester) async {
+ newHarnessOpensInBox = true;
+ addTearDown(() => newHarnessOpensInBox = false);
+ final (connection: _, :sessions) = _setup();
+ final app = sessions.app;
+ await mount(tester, app);
+ await tester.pump(const Duration(milliseconds: 50));
+ String? focused() => FocusManager.instance.primaryFocus?.debugLabel;
+ expect(find.byKey(const ValueKey('welcome-sessions')), findsOneWidget);
+ expect(focused(), 'Welcome sessions');
+
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await tester.pump(const Duration(milliseconds: 100));
+ expect(focused(), isNot('Welcome sessions'));
+ await key(tester, LogicalKeyboardKey.escape);
+ await tester.pump(const Duration(milliseconds: 100));
+ expect(focused(), 'Welcome sessions');
+
+ // 1 Command palette (a1), 2 NFC chat, 3 Deploy latest firmware (a2).
+ await key(tester, LogicalKeyboardKey.arrowDown);
+ await key(tester, LogicalKeyboardKey.arrowDown);
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pump(const Duration(milliseconds: 100));
+ expect(app.panes.map((pane) => pane.agentId), ['a2']);
+ await tester.pumpWidget(const SizedBox());
+ },
+ );
+
testWidgets(
'without an app it is the welcome it was: no list, no keys taken',
(tester) async {