Sessions with a parentID were filtered out of the sidebar, so a subagent's conversation was unreachable. They now render indented under the session that started them (robot marker, "子代理 ·" subtitle), the parent shows its worker count, and tapping one opens its full chat. Opening a parent also fetches its children with parentID=<id>, so older workers missing from the loaded page appear. A subagent's app bar gets a back arrow to its parent session. Builds now produce a universal APK plus per-ABI arm64/armv7/x86_64 splits; the packaging preference is kept in project memory. 0.4.9 (409).
129 lines
4.1 KiB
Dart
129 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:openchamber/api/models.dart';
|
|
import 'package:openchamber/screens/sessions_screen.dart';
|
|
import 'package:openchamber/state.dart';
|
|
|
|
void main() {
|
|
testWidgets('chat folders group under 聊天, not under session-xxxxx',
|
|
(tester) async {
|
|
final app = AppState();
|
|
app.chatRoots = const [r'C:\Users\me\.config\openchamber\chats'];
|
|
final now = DateTime.now().millisecondsSinceEpoch;
|
|
app.sessions = [
|
|
Session(
|
|
id: 'c1',
|
|
title: 'OpenCode 图像模型配置',
|
|
location: Location(
|
|
r'C:\Users\me\.config\openchamber\chats\2026-11-23\session-a'),
|
|
created: now,
|
|
updated: now,
|
|
),
|
|
Session(
|
|
id: 'c2',
|
|
title: 'LC_ALL 环境变量的设置来源',
|
|
location: Location(
|
|
r'C:\Users\me\.config\openchamber\chats\2026-11-22\session-b'),
|
|
created: now - 1000,
|
|
updated: now - 1000,
|
|
),
|
|
];
|
|
addTearDown(app.dispose);
|
|
|
|
await tester.pumpWidget(MaterialApp(
|
|
home: Scaffold(body: SessionListPane(app: app)),
|
|
));
|
|
await tester.pumpAndSettle();
|
|
|
|
// One chats group, labelled the same as the first-party sidebar.
|
|
expect(find.text('聊天'), findsOneWidget);
|
|
expect(find.byTooltip('新建聊天'), findsOneWidget);
|
|
expect(find.textContaining('session-'), findsNothing);
|
|
expect(find.text('OpenCode 图像模型配置'), findsOneWidget);
|
|
expect(find.text('LC_ALL 环境变量的设置来源'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('a subagent session shows nested under its parent and opens',
|
|
(tester) async {
|
|
final app = AppState();
|
|
final now = DateTime.now().millisecondsSinceEpoch;
|
|
app.sessions = [
|
|
Session(
|
|
id: 'parent',
|
|
title: '子代理输出 hello',
|
|
agent: 'build',
|
|
location: Location('/home/me/Sources/app'),
|
|
created: now,
|
|
updated: now,
|
|
),
|
|
Session(
|
|
id: 'child',
|
|
parentID: 'parent',
|
|
title: '输出 hello',
|
|
agent: 'general',
|
|
location: Location('/home/me/Sources/app'),
|
|
created: now - 500,
|
|
updated: now - 500,
|
|
),
|
|
];
|
|
addTearDown(app.dispose);
|
|
|
|
await tester.pumpWidget(MaterialApp(
|
|
home: Scaffold(body: SessionListPane(app: app)),
|
|
));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('子代理输出 hello'), findsOneWidget);
|
|
expect(find.text('输出 hello'), findsOneWidget);
|
|
expect(find.byIcon(Icons.smart_toy_outlined), findsOneWidget);
|
|
expect(find.textContaining('1 个子代理'), findsOneWidget);
|
|
|
|
await tester.tap(find.text('输出 hello'));
|
|
await tester.pump();
|
|
expect(app.chat?.session.id, 'child');
|
|
});
|
|
|
|
testWidgets('the project band matches a session row and keeps the keys in line',
|
|
(tester) async {
|
|
final app = AppState();
|
|
final now = DateTime.now().millisecondsSinceEpoch;
|
|
app.sessions = [
|
|
Session(
|
|
id: 's1',
|
|
title: '标签页拖拽与分屏',
|
|
agent: 'build',
|
|
location: Location(r'C:\msys64\home\Gary\Sources\pineapple-notepad'),
|
|
created: now,
|
|
updated: now,
|
|
),
|
|
];
|
|
addTearDown(app.dispose);
|
|
|
|
await tester.pumpWidget(MaterialApp(
|
|
home: Scaffold(body: SessionListPane(app: app)),
|
|
));
|
|
await tester.pumpAndSettle();
|
|
|
|
// A Windows path names the folder, not the whole path.
|
|
expect(find.text('pineapple-notepad'), findsOneWidget);
|
|
|
|
final header = find.ancestor(
|
|
of: find.text('pineapple-notepad'),
|
|
matching: find.byType(ListTile),
|
|
);
|
|
final row = find.ancestor(
|
|
of: find.text('标签页拖拽与分屏'),
|
|
matching: find.byType(ListTile),
|
|
);
|
|
final headerHeight = tester.getSize(header).height;
|
|
expect(tester.getSize(row).height, headerHeight);
|
|
// Compact, close to the old 56px project band.
|
|
expect(headerHeight, lessThanOrEqualTo(58));
|
|
|
|
// The project's + and the session's ⋮ share one vertical line.
|
|
final add = tester.getCenter(find.byTooltip('在此项目新会话'));
|
|
final menu = tester.getCenter(find.byIcon(Icons.more_vert));
|
|
expect(add.dx, closeTo(menu.dx, 0.5));
|
|
});
|
|
}
|