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
import 'dart:io';
import 'dart:ui' as ui;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/super_tabs/view.dart';
import 'box_render_preview_test.dart' show loadPreviewFonts;
import 'support/super_tab_fixture.dart';
/// Set to a folder to write the PR's screenshots there.
final shots = Platform.environment['SUPER_TAB_UNREAD_SHOTS'];
const _updates = [
'Reading the offline queue before the reconnect.',
'The reconnect keeps every queued edit in order.',
'Two devices editing at once settle on the newest edit.',
'Pushed the branch; the checks are running.',
];
/// The chat opened at its New messages line, read on past it (the bar leads
/// back), then through to the end (the bar goes).
void main() {
setUpAll(() async {
if (shots != null) await loadPreviewFonts();
});
for (final brightness in Brightness.values) {
testWidgets('screenshots for review (${brightness.name})', (tester) async {
final picture = GlobalKey();
final server = ConversationServer();
for (var i = 1; i <= 80; i++) {
server.append('${_updates[i % _updates.length]} ($i)');
server.messages.last['author'] = {
'kind': 'agent',
'id': 'lead-agent',
'name': 'Lead',
};
}
server.markReadElsewhere('lead', 30);
final c = server.controller();
addTearDown(c.dispose);
await c.refresh();
grid.AppTheme.brightness.value = brightness;
addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);
await tester.binding.setSurfaceSize(const Size(1200, 760));
addTearDown(() => tester.binding.setSurfaceSize(null));
await tester.pumpWidget(
MaterialApp(
theme: grid.buildAppTheme(brightness: brightness),
builder: (context, child) =>
RepaintBoundary(key: picture, child: child),
home: Scaffold(
body: SuperTabView(
controller: c,
onInvite: () {},
onAddAgent: (_) {},
onOpenTerminal: (_) {},
machineName: (_) => 'Mac Studio',
),
),
),
);
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('super-new-messages-line')), findsOne);
Future<void> shot(String name) async {
if (shots == null) return;
await tester.runAsync(() async {
final boundary =
picture.currentContext!.findRenderObject()!
as RenderRepaintBoundary;
final image = await boundary.toImage(pixelRatio: 1.5);
final bytes = await image.toByteData(format: ui.ImageByteFormat.png);
await Directory(shots!).create(recursive: true);
await File('$shots/unread-$name-${brightness.name}.png')
.writeAsBytes(bytes!.buffer.asUint8List());
image.dispose();
});
}
await shot('line');
final messages = find.byKey(
const PageStorageKey('super-messages-tab-lead'),
);
// On past the line in wheel steps, as a reader scrolls.
for (var step = 0; step < 6; step++) {
tester.binding.handlePointerEvent(
PointerScrollEvent(
position: tester.getCenter(messages),
scrollDelta: const Offset(0, 100),
),
);
await tester.pump();
}
await tester.pumpAndSettle();
// The line is above the screen now: the bar is the way back.
expect(find.byKey(const ValueKey('super-jump-unread')), findsOne);
await shot('read-on');
final list = tester.widget<ScrollView>(messages).controller!.position;
list.jumpTo(list.maxScrollExtent);
await tester.pumpAndSettle();
// Read through to the end: no bar, and the line stays above.
expect(find.byKey(const ValueKey('super-jump-unread')), findsNothing);
await shot('read-through');
// Reading to the end saves the read mark a moment later (controller.dart `_saveSoon`).
await tester.pump(const Duration(milliseconds: 300));
});
}
}