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.

feat(mobile): ⋯ sheet shows the agent's folder path and branch

bubu-dudu108a139ae9dc
diff --git a/mobile/lib/phone/phone_sheet.dart b/mobile/lib/phone/phone_sheet.dart
index 2b780a30b..8e01b6c95 100644
--- a/mobile/lib/phone/phone_sheet.dart
+++ b/mobile/lib/phone/phone_sheet.dart
@@ -68,6 +68,8 @@ class PhoneSheetSection {
/// for. One sheet rather than a menu per page: the actions differ, the shape does not.
///
/// [sections] draws captioned groups after [actions]; an empty section is left out.
+///
+/// [titleDetail] is drawn under [titleParts] — the folder and branch, on an agent's sheet.
Future<void> showPhoneSheet(
BuildContext context, {
required String title,
@@ -75,6 +77,7 @@ Future<void> showPhoneSheet(
List<PhoneSheetSection> sections = const [],
PhoneSheetAction? titleAction,
List<String>? titleParts,
+ Widget? titleDetail,
}) => showModalBottomSheet<void>(
context: context,
useRootNavigator: true,
@@ -100,7 +103,17 @@ Future<void> showPhoneSheet(
fontSize: 13,
),
)
- : _TitleParts(parts: titleParts),
+ : Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _TitleParts(parts: titleParts),
+ if (titleDetail != null) ...[
+ const SizedBox(height: 3),
+ titleDetail,
+ ],
+ ],
+ ),
),
// [titleAction]: an icon on the title line — for something that is not about the
// subject of the sheet (Settings, on an agent's sheet), so it does not take a row
diff --git a/mobile/lib/phone/terminal_header.dart b/mobile/lib/phone/terminal_header.dart
index 777d4f9ec..17ca8ab53 100644
--- a/mobile/lib/phone/terminal_header.dart
+++ b/mobile/lib/phone/terminal_header.dart
@@ -1,3 +1,5 @@
+import 'dart:math' as math;
+
import 'package:flutter/material.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
@@ -205,6 +207,89 @@ class _Identity extends StatelessWidget {
);
}
+/// Where an agent works, as the `⋯` sheet shows it under the names: the folder
+/// with its parent — `~/…/autonomous-harness/mobile` — then the branch.
+///
+/// The header has room for the folder's own name alone; the sheet is where the
+/// rest of the path is read.
+class AgentPlaceLine extends StatelessWidget {
+ const AgentPlaceLine({super.key, required this.project});
+
+ final AgentProject project;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final branch = project.branchLabel;
+ final style = TextStyle(color: AppPalette.textSecondary, fontSize: 13);
+ return Wrap(
+ crossAxisAlignment: WrapCrossAlignment.center,
+ spacing: 8,
+ runSpacing: 2,
+ children: [
+ Text(projectPathTrail(project.cwd), style: style),
+ if (branch != null)
+ Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(
+ LucideIcons.gitBranch300,
+ size: 13,
+ color: AppPalette.textFaint,
+ ),
+ const SizedBox(width: 3),
+ Flexible(
+ child: Text(
+ branch,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ ),
+ ),
+ ],
+ ),
+ ],
+ );
+ }
+}
+
+/// A folder with its parent, everything above them folded into `…` —
+/// `~/…/autonomous-harness/mobile`.
+///
+/// Home is written `~` the way a shell prompt writes it; a path short enough to
+/// need no fold is kept whole (`~/notes`, `/srv/app`).
+String projectPathTrail(String cwd) {
+ const kept = 2;
+ final path = cwd.replaceAll('\\', '/');
+ final parts = path.split('/').where((part) => part.isNotEmpty).toList();
+ if (parts.isEmpty) return path.isEmpty ? '~' : '/';
+
+ // `/Users/<name>/…` on a Mac, `/home/<name>/…` on Linux, `/root` for root.
+ var homeDepth = 0;
+ if (path.startsWith('/') && parts.length >= 2) {
+ if (parts[0] == 'Users' || parts[0] == 'home') homeDepth = 2;
+ }
+ if (path.startsWith('/') && parts[0] == 'root') homeDepth = 1;
+ if (path.startsWith('~')) homeDepth = 1;
+
+ final String lead;
+ final List<String> below;
+ if (homeDepth > 0) {
+ lead = '~';
+ below = parts.sublist(math.min(homeDepth, parts.length));
+ } else {
+ // A Windows drive keeps its letter, anything else its root.
+ final drive = RegExp(r'^[A-Za-z]:$').hasMatch(parts.first);
+ lead = drive ? parts.first : '';
+ below = drive ? parts.sublist(1) : parts;
+ }
+ if (below.isEmpty) return lead.isEmpty ? '/' : lead;
+ final tail = below.length <= kept
+ ? below
+ : ['…', ...below.sublist(below.length - kept)];
+ return '$lead/${tail.join('/')}';
+}
+
/// A folder as the header names it: its own name and nothing above it —
/// `autonomous-harness`.
///
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index aaa2b9dc9..13c4c8199 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
+import 'package:harness_mobile/core/models.dart' show AgentProject;
import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/shared/widgets/app_icon_button.dart';
import 'package:harness_mobile/state/app_state.dart';
@@ -769,6 +770,7 @@ class _TerminalPageState extends State<TerminalPage>
machineName:
machine?.machine.displayName ?? '',
agentName: agent.name,
+ project: agent.project,
),
),
],
@@ -829,12 +831,18 @@ class _TerminalPageState extends State<TerminalPage>
});
}
- void _showActions({required String machineName, required String agentName}) {
+ void _showActions({
+ required String machineName,
+ required String agentName,
+ AgentProject? project,
+ }) {
showPhoneSheet(
context,
title: '$agentName · $machineName',
- // Two lines — the agent, then its machine — shown in full.
+ // Two lines — the agent, then its machine — shown in full, then where it works: the folder
+ // with its parent and the branch, which the header has no room for.
titleParts: [agentName, machineName],
+ titleDetail: project == null ? null : AgentPlaceLine(project: project),
// Two groups: what acts on THIS agent, and the two screens the app itself has. Machines is a
// door like Settings rather than a list of its own — the list belongs on the page behind it,
// where it has room for every machine and does not push the rest of this sheet down.
diff --git a/mobile/test/terminal_header_test.dart b/mobile/test/terminal_header_test.dart
index 3e068c281..02250cf74 100644
--- a/mobile/test/terminal_header_test.dart
+++ b/mobile/test/terminal_header_test.dart
@@ -29,6 +29,25 @@ void main() {
}
});
+ group('the sheet names the folder with its parent, the rest folded', () {
+ for (final (cwd, label) in [
+ (
+ '/Users/dudu/Bitcoin_builder/Grid/autonomous-harness/mobile',
+ '~/…/autonomous-harness/mobile',
+ ),
+ ('/home/tony/work/harness', '~/work/harness'),
+ ('/Users/dudu/notes', '~/notes'),
+ ('/Users/dudu', '~'),
+ ('/root/a/b/c', '~/…/b/c'),
+ ('/srv/app', '/srv/app'),
+ ('/opt/tools/grid', '/…/tools/grid'),
+ (r'C:\Users\tony\code\harness', 'C:/…/code/harness'),
+ ('/', '/'),
+ ]) {
+ test('$cwd → $label', () => expect(projectPathTrail(cwd), label));
+ }
+ });
+
testWidgets('two lines, and the state on the mark', (tester) async {
final agent = Agent.fromJson({
'id': 'a',