feat: fold subagent trees and open them from Agent Task rows
Subagent sessions now render as a collapsed tree in the sidebar: parents with workers get an expand/collapse chevron, expanded child rows sit behind a guide line, and the parent keeps its worker count. The parent of the open subagent expands once so its child is visible. Subagent tool rows in the parent chat (subagent or task) are labeled 子代理, show the description and open the child session on tap; a child outside the loaded page is fetched by id first. Subagent chats are read-only by default with the first-party notice; allowPromptingSubagentSessions permits ordinary subagents, while a Lead's operator-child worker stays read-only until takeover. 0.4.10 (410).
This commit is contained in:
1 parent
cebf09048e
commit
9cbd97d532
10 files changed
+271
-23
No files matched your search
@@ -74,9 +74,15 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('子代理输出 hello'), findsOneWidget);
|
||||
// Tree rows start collapsed; the parent alone shows the count.
|
||||
expect(find.text('输出 hello'), findsNothing);
|
||||
expect(find.byTooltip('展开子代理'), findsOneWidget);
|
||||
expect(find.textContaining('1 个子代理'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byTooltip('展开子代理'));
|
||||
await tester.pump();
|
||||
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();
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:openchamber/api/models.dart';
|
||||
import 'package:openchamber/state.dart';
|
||||
|
||||
void main() {
|
||||
test('subagent chats are read-only unless the server allows prompting them',
|
||||
() {
|
||||
final app = AppState();
|
||||
addTearDown(app.dispose);
|
||||
final child = Session(id: 'child', title: '输出 hello', parentID: 'parent');
|
||||
|
||||
expect(app.promptReadOnlyFor(child), isTrue);
|
||||
app.allowPromptingSubagentSessions = true;
|
||||
expect(app.promptReadOnlyFor(child), isFalse);
|
||||
|
||||
// A lead's operator worker stays read-only until taken over, whatever the
|
||||
// subagent setting says.
|
||||
final worker = Session(
|
||||
id: 'worker',
|
||||
title: 'worker',
|
||||
metadata: {
|
||||
'openchamber': {'kind': 'operator-child', 'parentID': 'lead'},
|
||||
},
|
||||
);
|
||||
expect(app.promptReadOnlyFor(worker), isTrue);
|
||||
|
||||
final root = Session(id: 'root', title: 'root');
|
||||
expect(app.promptReadOnlyFor(root), isFalse);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user