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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Desktop: the sign-in picture says "this computer", and Settings says a nameless account's email once (#1202)
Dee8cdde29480bd
diff --git a/desktop/lib/settings/sections/account_section.dart b/desktop/lib/settings/sections/account_section.dartindex f08a01fbf..71373c632 100644--- a/desktop/lib/settings/sections/account_section.dart+++ b/desktop/lib/settings/sections/account_section.dart@@ -61,8 +61,11 @@ class AccountSection extends StatelessWidget {: 'Your Harness sign-in on this computer.',child: SingleChildScrollView(child: SettingRow(- title:- profile?.displayName ?? (local ? 'Local session' : 'Signed in'),+ // An account with no name is called by its email, and the email is+ // the line under it: signing up by email showed the address twice.+ title: profile != null && profile.displayName != profile.email+ ? profile.displayName+ : (local && profile == null ? 'Local session' : 'Signed in'),detail:profile?.email ??(local ? 'Loopback backend' : 'Profile unavailable'),diff --git a/desktop/lib/widgets/login_fleet_map.dart b/desktop/lib/widgets/login_fleet_map.dartindex 22102b22d..c7598c740 100644--- a/desktop/lib/widgets/login_fleet_map.dart+++ b/desktop/lib/widgets/login_fleet_map.dart@@ -2,7 +2,7 @@ import 'dart:math' as math;import 'dart:ui' as ui;import 'package:flutter/material.dart';-import 'package:flutter/foundation.dart' show kIsWeb;+import 'package:flutter/foundation.dart' show kIsWeb, visibleForTesting;import '../shared/theme/app_theme.dart' as grid;@@ -155,6 +155,25 @@ class _Pin {/// would replace that with a solid — a 6% white well painted as pure white.Color _fade(Color color, double k) => color.withValues(alpha: color.a * k);+/// The line over the window's panes: where "here" is, and how many machines+/// are linked to it.+///+/// One name for a Mac and a Linux computer, so the map is one picture for both.+/// The count is left off where the line would not fit. Labels keep their point+/// size while the drawing scales, so the desktop's sign-in sheet has no room+/// for it ("this Mac · 4 linked" ran into the window's right edge there); the+/// browser's wide page does.+@visibleForTesting+String loginFleetHereLabel({+ required bool web,+ required double room,+ required double Function(String label) measure,+}) {+ final here = web ? 'this browser' : '● this computer';+ final counted = '$here · 4 linked';+ return measure(counted) <= room ? counted : here;+}+/// The drawing, in its own 512×190 space; the canvas is scaled to fit so every/// number here is the one from the mockup rather than a fraction to re-derive.class _MapPainter extends CustomPainter {@@ -342,7 +361,12 @@ class _MapPainter extends CustomPainter {);_text(canvas,- kIsWeb ? 'this browser · 4 linked' : '● this Mac · 4 linked',+ loginFleetHereLabel(+ web: kIsWeb,+ // As wide as the panes under it.+ room: _panes[1].right - _panes[0].left,+ measure: _measure,+ ),Offset(_window.left + 7, _window.top + 6),color: _fade(palette.ink2, landed),diff --git a/desktop/test/login_fleet_map_test.dart b/desktop/test/login_fleet_map_test.dartnew file mode 100644index 000000000..e83b12fe6--- /dev/null+++ b/desktop/test/login_fleet_map_test.dart@@ -0,0 +1,96 @@+import 'dart:ui' as ui;++import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/widgets/login_fleet_map.dart';++import 'support/real_fonts.dart';++/// The mockup's numbers (`_MapPainter`, a 512×190 drawing): the window's line+/// starts 7 in from the window's left edge, above panes that end at 317.+const _lineLeft = 197.0;+const _panesTop = 66.0;+const _panesRight = 317.0;++/// The sign-in card is 520 wide and pads its picture by 24 a side.+const _sheetMapWidth = 472.0;++void main() {+ // Ahem's square glyphs make every line here too wide to mean anything.+ setUpAll(loadRealFonts);++ testWidgets('in the sign-in sheet the window\'s line stays in the window', (+ tester,+ ) async {+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ home: grid.BrightnessScope(+ child: const Center(+ child: SizedBox(width: _sheetMapWidth, child: LoginFleetMap()),+ ),+ ),+ ),+ );+ await tester.pump(const Duration(seconds: 3));++ final picture = find.descendant(+ of: find.byType(LoginFleetMap),+ matching: find.byType(CustomPaint),+ );+ final canvas = TestRecordingCanvas();+ tester+ .widget<CustomPaint>(picture)+ .painter!+ .paint(canvas, tester.getSize(picture));+ final lines = [+ for (final call in canvas.invocations)+ if (call.invocation.memberName == #drawParagraph)+ (+ call.invocation.positionalArguments[0] as ui.Paragraph,+ call.invocation.positionalArguments[1] as Offset,+ ),+ ];+ final (line, at) = lines.singleWhere(+ (drawn) => drawn.$2.dx == _lineLeft && drawn.$2.dy < _panesTop,+ );+ // "this Mac · 4 linked" ended past the window's right edge here.+ expect(at.dx + line.longestLine, lessThanOrEqualTo(_panesRight));+ // And it is the short line that was drawn, in the picture's own measure:+ // labels keep their point size while the drawing scales.+ double drawn(String label) => (TextPainter(+ text: TextSpan(text: label, style: grid.AppType.caption(height: 1.2)),+ textDirection: TextDirection.ltr,+ textScaler: const TextScaler.linear(512 / _sheetMapWidth),+ )..layout()).width;+ expect(line.longestLine, closeTo(drawn('● this computer'), 0.5));+ expect(+ drawn('● this computer · 4 linked'),+ greaterThan(_panesRight - _lineLeft),+ reason: 'the count has no room in the sheet',+ );+ });++ test('the window is this computer on a Mac and on Linux alike', () {+ double wide(String label) => label.length * 6.0;+ final roomy = loginFleetHereLabel(web: false, room: 400, measure: wide);+ final tight = loginFleetHereLabel(web: false, room: 100, measure: wide);++ // One picture for both: "this Mac" stood on Linux too.+ expect(roomy, '● this computer · 4 linked');+ expect('$roomy $tight', isNot(contains('Mac')));+ // The count goes where it would run out of the window.+ expect(tight, '● this computer');+ expect(wide(tight), lessThanOrEqualTo(100));+ // A browser is not one of the person's computers.+ expect(+ loginFleetHereLabel(web: true, room: 400, measure: wide),+ 'this browser · 4 linked',+ );+ expect(+ loginFleetHereLabel(web: true, room: 100, measure: wide),+ 'this browser',+ );+ });+}diff --git a/desktop/test/workspace_account_test.dart b/desktop/test/workspace_account_test.dartindex d2a4f6344..b8f7cc040 100644--- a/desktop/test/workspace_account_test.dart+++ b/desktop/test/workspace_account_test.dart@@ -8,6 +8,7 @@ import 'package:harness/screens/login_screen.dart';import 'package:harness/settings/settings_screen.dart';import 'package:harness/settings/settings_section.dart';import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/shared/widgets/setting_row.dart';import 'package:harness/state/app_state.dart';import 'package:harness/widgets/account_menu.dart';import 'package:harness/widgets/workspace_account_button.dart';@@ -261,6 +262,48 @@ void main() {}});+ testWidgets('Settings says who is signed in, and an email only once', (+ tester,+ ) async {+ for (final (name, lines) in [+ ('Dee Example', ['Dee Example', '[email protected]']),+ // Signed up by email: the account is called by its address, which is+ // the line under the title already.+ (null, ['Signed in', '[email protected]']),+ ]) {+ final app = createApp()+ ..currentUser = CurrentUserProfile(+ name: name,+ email: '[email protected]',+ );+ await mount(tester, app);+ await tester.tap(_avatar);+ await tester.pump();+ await tester.pump();+ await tester.tap(find.byKey(const ValueKey('account-menu-settings')));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));++ Finder said(String text) => find.descendant(+ of: find.byType(SettingsScreen),+ matching: find.text(text),+ );+ for (final line in lines) {+ expect(said(line), findsOneWidget, reason: '$name: $line');+ }+ // Both are the same raised row: one with no second line is drawn bare.+ expect(+ tester.widget<SettingRow>(find.byType(SettingRow)).detail,+ '[email protected]',+ );+ Navigator.of(tester.element(find.byType(SettingsScreen))).pop();+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 400));+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ }+ });+testWidgets('the native tab row is told which of the two to draw', (tester,) async {