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): terminal header names the folder alone

bubu-dudu2eb07bdbea78
diff --git a/mobile/lib/phone/terminal_header.dart b/mobile/lib/phone/terminal_header.dart
index 5f5d65d82..777d4f9ec 100644
--- a/mobile/lib/phone/terminal_header.dart
+++ b/mobile/lib/phone/terminal_header.dart
@@ -13,7 +13,7 @@ import 'status_pill.dart';
///
/// ```
/// [mark●] agent-3 ⋯
-/// ~/…/autonomous-harness ⑂ main
+/// autonomous-harness ⑂ main
/// ```
///
/// ⚠️ **The connection state is the dot on the engine mark, not a word.** It
@@ -205,38 +205,26 @@ class _Identity extends StatelessWidget {
);
}
-/// A folder as the header names it: its own name, with everything above it
-/// folded into `…` — `~/…/autonomous-harness`.
+/// A folder as the header names it: its own name and nothing above it —
+/// `autonomous-harness`.
///
-/// Home is written `~` the way a shell prompt writes it, so a folder directly in
-/// home keeps its whole path (`~/notes`) and home itself is `~`. A folder
-/// outside home keeps its root: `/…/srv`.
+/// Home itself is written `~` the way a shell prompt writes it, and the root
+/// `/`: those have no name of their own to show.
///
/// ⚠️ The parents are the part every agent somebody owns has in common — the
-/// folder's own name is what tells two of them apart, so it is the one thing
-/// never cut here.
+/// folder's own name is what tells two of them apart, so it is all that is kept.
String projectPathLabel(String cwd) {
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;
-
- if (homeDepth > 0) {
- final below = parts.length - homeDepth;
- if (below <= 0) return '~';
- if (below == 1) return '~/${parts.last}';
- return '~/…/${parts.last}';
- }
- // Outside home: a Windows drive keeps its letter, anything else its root.
- final lead = RegExp(r'^[A-Za-z]:$').hasMatch(parts.first) ? parts.first : '';
- if (parts.length == 1) return '$lead/${parts.last}';
- if (lead.isNotEmpty && parts.length == 2) return '$lead/${parts.last}';
- return '$lead/…/${parts.last}';
+ // Home: `/Users/<name>` on a Mac, `/home/<name>` on Linux, `/root`, `~`.
+ final isHome =
+ (path.startsWith('/') &&
+ parts.length == 2 &&
+ (parts[0] == 'Users' || parts[0] == 'home')) ||
+ (path.startsWith('/') && parts.length == 1 && parts[0] == 'root') ||
+ (path.startsWith('~') && parts.length == 1);
+ if (isHome) return '~';
+ return parts.last;
}
diff --git a/mobile/test/terminal_header_test.dart b/mobile/test/terminal_header_test.dart
index 319baca0c..3e068c281 100644
--- a/mobile/test/terminal_header_test.dart
+++ b/mobile/test/terminal_header_test.dart
@@ -8,19 +8,21 @@ import 'package:harness_mobile/phone/terminal_header.dart';
/// The terminal's top bar: *agent* over *folder ⑂ branch*, with the
/// connection state as a dot on the engine mark.
void main() {
- group('the folder is named by its own name, parents folded', () {
+ group('the folder is named by its own name alone', () {
for (final (cwd, label) in [
(
'/Users/dudu/Bitcoin_builder/Grid/autonomous-harness',
- '~/…/autonomous-harness',
+ 'autonomous-harness',
),
- ('/home/tony/work/harness', '~/…/harness'),
- ('/Users/dudu/notes', '~/notes'),
+ ('/home/tony/work/harness', 'harness'),
+ ('/Users/dudu/notes', 'notes'),
('/Users/dudu', '~'),
- ('/root/app', '~/app'),
- ('/srv', '/srv'),
- ('/opt/tools/grid', '/…/grid'),
- (r'C:\Users\tony\code\harness', 'C:/…/harness'),
+ ('/root', '~'),
+ ('~', '~'),
+ ('/root/app', 'app'),
+ ('/srv', 'srv'),
+ ('/opt/tools/grid', 'grid'),
+ (r'C:\Users\tony\code\harness', 'harness'),
('/', '/'),
]) {
test('$cwd → $label', () => expect(projectPathLabel(cwd), label));
@@ -50,7 +52,7 @@ void main() {
);
expect(find.text('agent-3'), findsOneWidget);
- expect(find.text('~/…/autonomous-harness'), findsOneWidget);
+ expect(find.text('autonomous-harness'), findsOneWidget);
expect(find.text('feat/mobile-ios-android'), findsOneWidget);
// No word for the state — the dot says it, and its tooltip.
expect(find.text('Live'), findsNothing);