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.

A pane in a tab says who started it, after its name (#1221)

Dee9b8e012869e3
diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dart
index de41365a1..200bd66fb 100644
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@ -2887,146 +2887,199 @@ class _TerminalHeader extends StatelessWidget {
if (leadingStatus || showIdentityMark)
SizedBox(width: leadingStatus ? 6 : 10),
Expanded(
- child: Row(
- children: [
- // Four parts to an Agent Messages mark's one while it
- // shows; alone, the title has all the room.
- Flexible(
- flex: 4,
- child: Tooltip(
- message: identityDetail,
- waitDuration: const Duration(milliseconds: 500),
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onDoubleTap: () => unawaited(
- showAgentRenameDialog(
- context,
- notifier,
- session.machineId,
- session.agentId,
- session.agentName,
+ child: LayoutBuilder(
+ builder: (context, inner) {
+ // Who started it, after the name, where the details row
+ // that says it in a wide header is not drawn: a pane in
+ // a tab has a compact header, and there it said so only
+ // in the name's tooltip (a clean VM, #1217). Never more
+ // than its share of the row, and never so much that the
+ // name, the marks and the status beside it go short;
+ // left out only where a few words would not fit at all.
+ final gap = workspaceBarCellSizeOf(context).width;
+ final chipRoom = status != null && !leadingStatus
+ ? (narrow ? 36.0 : constraints.maxWidth * .22) + 8
+ : starting != null
+ ? statusWidth + 8
+ : 0.0;
+ final startedRoom =
+ math.min(
+ inner.maxWidth * .45,
+ inner.maxWidth -
+ activityWidth -
+ chipRoom -
+ 64 * math.max(1, scale),
+ ) -
+ gap;
+ final showStartedBy =
+ startedBy != null &&
+ (compact || narrow) &&
+ startedRoom >= 72 * math.max(1, scale);
+ return Row(
+ children: [
+ // Four parts to an Agent Messages mark's one while it
+ // shows; alone, the title has all the room.
+ Flexible(
+ flex: 4,
+ child: Tooltip(
+ message: identityDetail,
+ waitDuration: const Duration(milliseconds: 500),
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onDoubleTap: () => unawaited(
+ showAgentRenameDialog(
+ context,
+ notifier,
+ session.machineId,
+ session.agentId,
+ session.agentName,
+ ),
+ ),
+ child: Text(
+ session.agentName,
+ key: const ValueKey('terminal-pane-title'),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: titleStyle,
+ ),
),
),
- child: Text(
- session.agentName,
- key: const ValueKey('terminal-pane-title'),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: titleStyle,
- ),
),
- ),
- ),
- HarnessActivityMark(
- app: notifier,
- machineId: session.machineId,
- agentId: session.agentId,
- ),
- PaneMessageMarkView(
- controller: notifier.agentMessages,
- machineId: session.machineId,
- agentId: session.agentId,
- style: titleStyle,
- ),
- if ((status != null && !leadingStatus) ||
- starting != null ||
- !compact)
- const SizedBox(width: 8),
- if (status != null && narrow && !leadingStatus)
- statusButton()
- else if (status != null && !leadingStatus)
- ConstrainedBox(
- constraints: BoxConstraints(
- maxWidth: math.max(
- 0,
- math.min(
- constraints.maxWidth * .22,
- constraints.maxWidth - actionsWidth - 110,
+ HarnessActivityMark(
+ app: notifier,
+ machineId: session.machineId,
+ agentId: session.agentId,
+ ),
+ if (showStartedBy)
+ Padding(
+ padding: EdgeInsets.only(left: gap),
+ child: ConstrainedBox(
+ constraints: BoxConstraints(
+ maxWidth: startedRoom,
+ ),
+ child: Text(
+ 'started by $startedBy',
+ key: const ValueKey('pane-started-by'),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: titleStyle.copyWith(
+ color:
+ (titleStyle.color ??
+ grid.AppPalette.textPrimary)
+ .withValues(alpha: .55),
+ ),
+ ),
),
),
+ PaneMessageMarkView(
+ controller: notifier.agentMessages,
+ machineId: session.machineId,
+ agentId: session.agentId,
+ style: titleStyle,
),
- child: Align(
- alignment: Alignment.centerLeft,
- child: Tooltip(
- message: status.detail,
- child: TextButton(
- onPressed: statusAction,
- style: TextButton.styleFrom(
- foregroundColor: color,
- disabledForegroundColor: AppColors.textSoft,
- minimumSize: Size.zero,
- tapTargetSize:
- MaterialTapTargetSize.shrinkWrap,
- padding: const EdgeInsets.symmetric(
- horizontal: 6,
- vertical: 4,
+ if ((status != null && !leadingStatus) ||
+ starting != null ||
+ !compact)
+ const SizedBox(width: 8),
+ if (status != null && narrow && !leadingStatus)
+ statusButton()
+ else if (status != null && !leadingStatus)
+ ConstrainedBox(
+ constraints: BoxConstraints(
+ maxWidth: math.max(
+ 0,
+ math.min(
+ constraints.maxWidth * .22,
+ constraints.maxWidth - actionsWidth - 110,
),
),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(status.icon, size: 14),
- const SizedBox(width: 6),
- Flexible(
- child: Text(
- // The chip names the STATE; what
- // pressing it does is in the tooltip
- // and in `actionLabel`. "Link
- // required" that can be pressed reads
- // better than a bare verb where every
- // neighbour is a status.
- status.label,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: grid.AppType.monoLabel(
- fontWeight: FontWeight.w400,
- ),
+ ),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Tooltip(
+ message: status.detail,
+ child: TextButton(
+ onPressed: statusAction,
+ style: TextButton.styleFrom(
+ foregroundColor: color,
+ disabledForegroundColor:
+ AppColors.textSoft,
+ minimumSize: Size.zero,
+ tapTargetSize:
+ MaterialTapTargetSize.shrinkWrap,
+ padding: const EdgeInsets.symmetric(
+ horizontal: 6,
+ vertical: 4,
),
),
- ],
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(status.icon, size: 14),
+ const SizedBox(width: 6),
+ Flexible(
+ child: Text(
+ // The chip names the STATE; what
+ // pressing it does is in the tooltip
+ // and in `actionLabel`. "Link
+ // required" that can be pressed reads
+ // better than a bare verb where every
+ // neighbour is a status.
+ status.label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: grid.AppType.monoLabel(
+ fontWeight: FontWeight.w400,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
),
),
- ),
- ),
- )
- else if (status == null && starting != null && narrow)
- PaneStartingChip(phase: starting, narrow: true)
- else if (status == null && starting != null)
- // Never wider than the room this row is sure to have: the name's
- // share (at most 45%) or what the actions and the PR badge leave —
- // less [_headerFurniture]. Its words shorten rather than push the
- // row past the header's edge.
- ConstrainedBox(
- constraints: BoxConstraints(
- maxWidth: math.max(
- 0,
- math.min(
- constraints.maxWidth * .45 - _headerFurniture,
- constraints.maxWidth -
- actionsWidth -
- badgeWidth -
- _headerFurniture,
+ )
+ else if (status == null && starting != null && narrow)
+ PaneStartingChip(phase: starting, narrow: true)
+ else if (status == null && starting != null)
+ // Never wider than the room this row is sure to have: the name's
+ // share (at most 45%) or what the actions and the PR badge leave —
+ // less [_headerFurniture]. Its words shorten rather than push the
+ // row past the header's edge.
+ ConstrainedBox(
+ constraints: BoxConstraints(
+ maxWidth: math.max(
+ 0,
+ math.min(
+ constraints.maxWidth * .45 -
+ _headerFurniture,
+ constraints.maxWidth -
+ actionsWidth -
+ badgeWidth -
+ _headerFurniture,
+ ),
+ ),
),
- ),
- ),
- child: PaneStartingChip(phase: starting),
- )
- else if (!compact)
- Padding(
- padding: const EdgeInsets.all(4),
- child: Tooltip(
- message: 'Terminal connected',
- child: Container(
- width: 8,
- height: 8,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: color,
+ child: PaneStartingChip(phase: starting),
+ )
+ else if (!compact)
+ Padding(
+ padding: const EdgeInsets.all(4),
+ child: Tooltip(
+ message: 'Terminal connected',
+ child: Container(
+ width: 8,
+ height: 8,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: color,
+ ),
+ ),
),
),
- ),
- ),
- ],
+ ],
+ );
+ },
),
),
const SizedBox(width: 8),
diff --git a/desktop/test/started_child_pane_test.dart b/desktop/test/started_child_pane_test.dart
index 0bb21f9be..a7e27b06a 100644
--- a/desktop/test/started_child_pane_test.dart
+++ b/desktop/test/started_child_pane_test.dart
@@ -4,6 +4,7 @@
// person sees it"). Only one first seen live: never on a restore, never again
// after the person closed it, never a stopped one.
import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart' show RenderParagraph;
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/models.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
@@ -123,56 +124,62 @@ void main() {
expect(app.activeSwarm, same(second));
});
- test('a list read after pushes filled it still counts as the window\'s first', () async {
- final machine = _Machine();
- final app = createApp(connectionForTest: (_) => machine, connected: true);
- addTearDown(app.dispose);
- await app.addAgentToSwarm('m', 'a0');
- // The first load failed; pushes alone made the list, and the safety-net
- // read finds nothing to change.
- final lead = _agent('a0', name: 'lead', createdAt: DateTime.now());
- machine.listed = [lead];
- app.stateOf('m')!.agents = [];
- await _push(app, lead);
- await app.syncAgentsIfChangedForTest('m');
- expect(app.stateOf('m')!.agents, hasLength(1));
- await _push(app, _agent('kid', parent: 'a0'));
- expect(_agents(app.activeSwarm), ['a0', 'kid']);
- });
+ test(
+ 'a list read after pushes filled it still counts as the window\'s first',
+ () async {
+ final machine = _Machine();
+ final app = createApp(connectionForTest: (_) => machine, connected: true);
+ addTearDown(app.dispose);
+ await app.addAgentToSwarm('m', 'a0');
+ // The first load failed; pushes alone made the list, and the safety-net
+ // read finds nothing to change.
+ final lead = _agent('a0', name: 'lead', createdAt: DateTime.now());
+ machine.listed = [lead];
+ app.stateOf('m')!.agents = [];
+ await _push(app, lead);
+ await app.syncAgentsIfChangedForTest('m');
+ expect(app.stateOf('m')!.agents, hasLength(1));
+ await _push(app, _agent('kid', parent: 'a0'));
+ expect(_agents(app.activeSwarm), ['a0', 'kid']);
+ },
+ );
- test('a list that brings it first places it too, once the window has read one', () async {
- final machine = _Machine();
- final app = createApp(connectionForTest: (_) => machine, connected: true);
- addTearDown(app.dispose);
- await app.reloadMachineData('m');
- await app.addAgentToSwarm('m', 'a0');
- machine.listed = [...machine.listed, _agent('kid', parent: 'a0')];
- await app.reloadMachineData('m');
- expect(_agents(app.activeSwarm), ['a0', 'kid']);
- });
+ test(
+ 'a list that brings it first places it too, once the window has read one',
+ () async {
+ final machine = _Machine();
+ final app = createApp(connectionForTest: (_) => machine, connected: true);
+ addTearDown(app.dispose);
+ await app.reloadMachineData('m');
+ await app.addAgentToSwarm('m', 'a0');
+ machine.listed = [...machine.listed, _agent('kid', parent: 'a0')];
+ await app.reloadMachineData('m');
+ expect(_agents(app.activeSwarm), ['a0', 'kid']);
+ },
+ );
- test('not on restore: what the first list brings stays where it was', () async {
- final storage = MemoryStore();
- await PaneLayoutStore(storage: storage).saveSwarms([
- Swarm(id: 'work', name: 'Work')
- ..panes.add(TerminalPane(id: 1, machineId: 'm', agentId: 'a0')),
- ], 'work');
- final machine = _Machine()
- ..listed = [_agent('a0', name: 'lead'), _agent('kid', parent: 'a0')];
- final app = createApp(
- store: storage,
- connectionForTest: (_) => machine,
- );
- addTearDown(app.dispose);
- await app.restorePaneLayoutForTest();
- // A push before the window has read the list is the restore too.
- await _push(app, _agent('early', parent: 'a0'));
- await app.reloadMachineData('m');
- await _push(app, _agent('kid', parent: 'a0'));
- await _push(app, _agent('early', parent: 'a0'));
- expect(_agents(app.activeSwarm), ['a0']);
- expect(app.stateOf('m')!.agents.map((a) => a.id), contains('kid'));
- });
+ test(
+ 'not on restore: what the first list brings stays where it was',
+ () async {
+ final storage = MemoryStore();
+ await PaneLayoutStore(storage: storage).saveSwarms([
+ Swarm(id: 'work', name: 'Work')
+ ..panes.add(TerminalPane(id: 1, machineId: 'm', agentId: 'a0')),
+ ], 'work');
+ final machine = _Machine()
+ ..listed = [_agent('a0', name: 'lead'), _agent('kid', parent: 'a0')];
+ final app = createApp(store: storage, connectionForTest: (_) => machine);
+ addTearDown(app.dispose);
+ await app.restorePaneLayoutForTest();
+ // A push before the window has read the list is the restore too.
+ await _push(app, _agent('early', parent: 'a0'));
+ await app.reloadMachineData('m');
+ await _push(app, _agent('kid', parent: 'a0'));
+ await _push(app, _agent('early', parent: 'a0'));
+ expect(_agents(app.activeSwarm), ['a0']);
+ expect(app.stateOf('m')!.agents.map((a) => a.id), contains('kid'));
+ },
+ );
test('not again after the person closes it', () async {
final machine = _Machine();
@@ -345,4 +352,117 @@ void main() {
session.dispose();
});
}
+
+ // A pane in a tab draws the compact header (`pane_grid.dart`), which has no
+ // details row: there "started by" was only in the name's tooltip (a clean
+ // VM, #1217), where the owner's mockup has it in the pane.
+ Future<AppNotifier> compactPane(
+ WidgetTester tester, {
+ required double width,
+ String parent = 'lead',
+ Brightness brightness = Brightness.dark,
+ }) async {
+ tester.view.physicalSize = const Size(1400, 600);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ final app = createApp(connected: true);
+ addTearDown(app.dispose);
+ app.stateOf('m')!.agents = [
+ Agent(id: 'a0', name: parent, engine: 'codex', terminalAvailable: true),
+ const Agent(
+ id: 'kid',
+ name: 'helper',
+ engine: 'claude',
+ terminalAvailable: true,
+ parentAgentId: 'a0',
+ ),
+ ];
+ final session = TerminalSession(
+ machineId: 'm',
+ agentId: 'kid',
+ agentName: 'helper',
+ engineId: 'claude',
+ send: (_, _) async => true,
+ sendBinary: (_) async => true,
+ )..status = TerminalSessionStatus.controlling;
+ addTearDown(session.dispose);
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: brightness),
+ home: Scaffold(
+ body: Align(
+ alignment: Alignment.topLeft,
+ child: SizedBox(
+ width: width,
+ height: 400,
+ child: TerminalPanel(
+ notifier: app,
+ session: session,
+ focused: false,
+ compactHeader: true,
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pump();
+ return app;
+ }
+
+ final startedBy = find.byKey(const ValueKey('pane-started-by'));
+ final title = find.byKey(const ValueKey('terminal-pane-title'));
+
+ for (final brightness in Brightness.values) {
+ testWidgets('a pane in a tab says who started it after its name, muted '
+ '(${brightness.name})', (tester) async {
+ await compactPane(tester, width: 700, brightness: brightness);
+ expect(find.text('started by lead'), findsOneWidget);
+ expect(startedBy, findsOneWidget);
+ expect(
+ tester.getRect(startedBy).left,
+ greaterThan(tester.getRect(title).right),
+ );
+ // The name is whole beside it.
+ final name = tester.renderObject<RenderParagraph>(title);
+ expect(name.didExceedMaxLines, isFalse);
+ final words = tester.widget<Text>(startedBy);
+ final ink = tester.widget<Text>(title).style!.color!;
+ expect(words.style!.color!.a, lessThan(ink.a));
+ expect(tester.takeException(), isNull);
+ });
+ }
+
+ testWidgets('a long starter name is shortened, the pane name is not', (
+ tester,
+ ) async {
+ await compactPane(
+ tester,
+ width: 520,
+ parent: 'get a second opinion from claude code on the indentation',
+ );
+ expect(startedBy, findsOneWidget);
+ expect(
+ tester.renderObject<RenderParagraph>(startedBy).didExceedMaxLines,
+ isTrue,
+ );
+ expect(
+ tester.renderObject<RenderParagraph>(title).didExceedMaxLines,
+ isFalse,
+ );
+ expect(tester.getRect(startedBy).width, lessThanOrEqualTo(520 * .45));
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('a pane too narrow for it keeps it in the name\'s tooltip only', (
+ tester,
+ ) async {
+ await compactPane(tester, width: 260);
+ expect(startedBy, findsNothing);
+ final tip = tester.widget<Tooltip>(
+ find.ancestor(of: title, matching: find.byType(Tooltip)).first,
+ );
+ expect(tip.message, contains('Started by lead'));
+ expect(tester.takeException(), isNull);
+ });
}