feat: browse subagent sessions nested under their parent
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).
This commit is contained in:
1 parent
79221e57d7
commit
cebf09048e
9 files changed
+170
-19
No files matched your search
@@ -5,6 +5,18 @@
|
||||
|
||||
---
|
||||
|
||||
## 0.4.9 浏览子代理会话(分支 `flutter`)
|
||||
|
||||
| 项 | 结果 |
|
||||
| --- | --- |
|
||||
| 侧栏嵌套 | 子代理会话(`parentID` 指向父会话)不再被过滤掉:父行下面缩进显示一个子代理行(robot 图标,副标题以「子代理 ·」开头),父行的副标题显示「N 个子代理」;父会话在置顶区也带出它的子代理。子代理行可以点开查看完整会话内容,⋮ 菜单与普通会话一致 |
|
||||
| 按需加载 | 打开父会话时并行请求 `GET /api/session?parentID=<id>`(每个父会话一次),把不在当前分页里的旧子代理补进列表;断开连接时清空缓存 |
|
||||
| 父会话返回 | 子代理会话的 AppBar 左侧改为返回箭头(tooltip「返回父会话」),标题前有 robot 标记;点击回到父会话。侧栏点父行也能回去 |
|
||||
| 测试 | `test/sidebar_rows_test.dart` 新增:父子会话同时显示、缩进/robot 图标、「1 个子代理」副标题、点击子行打开该会话;46 项全过 |
|
||||
| 版本 | **0.4.9(code 409)** |
|
||||
|
||||
---
|
||||
|
||||
## 0.4.8 项目图标与聊天图标(分支 `flutter`)
|
||||
|
||||
| 项 | 结果 |
|
||||
|
||||
@@ -5,7 +5,7 @@ Android first. This branch (`flutter`) is a framework evaluation: the same
|
||||
feature set as the earlier Asuka/Go and MyGo attempts, reimplemented in
|
||||
Flutter to compare mobile UI maturity.
|
||||
|
||||
Status: 0.4.8 — servers (passwordless / password login, HTTP/HTTPS and
|
||||
Status: 0.4.9 — servers (passwordless / password login, HTTP/HTTPS and
|
||||
SOCKS5/socks5h proxy, self-signed certificates and pinning, or a pairing link
|
||||
over the OpenChamber private relay with end-to-end encryption; the pairing
|
||||
link is pasted or scanned with the camera), session list with search and live
|
||||
@@ -22,7 +22,9 @@ remembers them per connection and directory: reopening after an app restart
|
||||
attaches to the shells the server still holds instead of starting new ones. The panel is a tab row with its own
|
||||
close button, and each tab has its own header row. Starting a session opens a
|
||||
draft that only creates the session on the first send; the session list is
|
||||
grouped by project with date captions, pins, archive and swipe actions; the
|
||||
grouped by project with date captions, pins, archive and swipe actions;
|
||||
subagent sessions nest under the session that started them and open like any
|
||||
other chat; the
|
||||
server's managed chat folders are one 聊天 group, and a new session can target
|
||||
聊天 instead of a project. Project rows use the icon and colour chosen in
|
||||
OpenChamber (including an uploaded/auto icon image), and the chat group has a
|
||||
|
||||
@@ -95,6 +95,7 @@ class Client {
|
||||
String? search,
|
||||
String? directory,
|
||||
bool? archived,
|
||||
String? parentID,
|
||||
}) async {
|
||||
final query = <String, String>{
|
||||
'limit': '$limit',
|
||||
@@ -103,6 +104,7 @@ class Client {
|
||||
if (search != null && search.isNotEmpty) 'search': search,
|
||||
if (directory != null && directory.isNotEmpty) 'directory': directory,
|
||||
if (archived != null) 'archived': '$archived',
|
||||
if (parentID != null && parentID.isNotEmpty) 'parentID': parentID,
|
||||
};
|
||||
final r = await _json('GET', '/api/session', query: query, directory: directory);
|
||||
final data = (r['data'] as List? ?? [])
|
||||
|
||||
@@ -135,19 +135,50 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// The session that started this one, when it is a subagent.
|
||||
Session? get _parentSession {
|
||||
final parentID = widget.session.parentID;
|
||||
if (parentID == null || parentID.isEmpty) return null;
|
||||
for (final session in widget.app.sessions) {
|
||||
if (session.id == parentID) return session;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final parent = _parentSession;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: widget.onOpenSessions == null
|
||||
? null
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.menu),
|
||||
tooltip: '会话',
|
||||
onPressed: widget.onOpenSessions,
|
||||
),
|
||||
title: Text(_title(), maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
// A subagent opened from its parent's row goes back there; its own
|
||||
// sessions menu would lose that way back on a phone.
|
||||
leading: parent != null
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
tooltip: '返回父会话',
|
||||
onPressed: () => widget.app.openChat(parent),
|
||||
)
|
||||
: widget.onOpenSessions == null
|
||||
? null
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.menu),
|
||||
tooltip: '会话',
|
||||
onPressed: widget.onOpenSessions,
|
||||
),
|
||||
title: Row(
|
||||
children: [
|
||||
if (widget.session.isChild) ...[
|
||||
Icon(Icons.smart_toy_outlined,
|
||||
size: 16, color: theme.hintColor),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
Expanded(
|
||||
child: Text(_title(),
|
||||
maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.view_sidebar_outlined),
|
||||
|
||||
@@ -289,7 +289,7 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
if (!collapsed)
|
||||
for (final entry in _dated(group.sessions)) ...[
|
||||
_caption(entry.key),
|
||||
for (final session in entry.value) _row(session),
|
||||
for (final session in entry.value) ..._rowsWithChildren(session),
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -449,7 +449,7 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
),
|
||||
),
|
||||
if (!collapsed)
|
||||
for (final session in pinned) _row(session),
|
||||
for (final session in pinned) ..._rowsWithChildren(session),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -489,7 +489,24 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
.any((s) => s.parentID == session.id && _app.active.contains(s.id));
|
||||
}
|
||||
|
||||
Widget _row(Session session, {bool archived = false}) {
|
||||
/// The session's worker sessions (subagents). The API lists them among the
|
||||
/// sessions, so they are drawn nested right below their parent.
|
||||
List<Session> _childrenOf(Session parent, {bool archived = false}) {
|
||||
final source = archived ? _app.archivedSessions : _app.sessions;
|
||||
return [
|
||||
for (final session in source)
|
||||
if (session.parentID == parent.id) session,
|
||||
]..sort((a, b) => a.created.compareTo(b.created));
|
||||
}
|
||||
|
||||
List<Widget> _rowsWithChildren(Session session, {bool archived = false}) => [
|
||||
_row(session, archived: archived),
|
||||
for (final child in _childrenOf(session, archived: archived))
|
||||
_row(child, archived: archived, child: true),
|
||||
];
|
||||
|
||||
Widget _row(Session session,
|
||||
{bool archived = false, bool child = false}) {
|
||||
final theme = Theme.of(context);
|
||||
final scheme = theme.colorScheme;
|
||||
final running = _isActive(session);
|
||||
@@ -531,6 +548,10 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
minTileHeight: 56,
|
||||
selected: selected,
|
||||
selectedTileColor: scheme.primary.withValues(alpha: 0.10),
|
||||
leading: child
|
||||
? Icon(Icons.smart_toy_outlined,
|
||||
size: 16, color: scheme.onSurfaceVariant)
|
||||
: null,
|
||||
title: Text(
|
||||
session.title.isEmpty ? '(无标题会话)' : session.title,
|
||||
maxLines: 1,
|
||||
@@ -540,8 +561,10 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
fontWeight: selected ? FontWeight.w600 : FontWeight.w400,
|
||||
),
|
||||
),
|
||||
subtitle: Text(_subtitle(session),
|
||||
maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
subtitle: Text(
|
||||
child ? '子代理 · ${_subtitle(session)}' : _subtitle(session),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -659,7 +682,7 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
),
|
||||
if (_showArchived)
|
||||
for (final session in app.archivedSessions)
|
||||
_row(session, archived: true),
|
||||
_row(session, archived: true, child: session.isChild),
|
||||
if (_showArchived &&
|
||||
app.archivedLoaded &&
|
||||
app.archivedSessions.isEmpty)
|
||||
@@ -684,6 +707,8 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
String _subtitle(Session s) {
|
||||
final parts = <String>[];
|
||||
if (s.agent.isNotEmpty) parts.add(s.agent);
|
||||
final children = _childrenOf(s).length;
|
||||
if (children > 0) parts.add('$children 个子代理');
|
||||
if (s.model != null) parts.add(_app.modelName(s.model));
|
||||
if (s.updated > 0) {
|
||||
final t = DateTime.fromMillisecondsSinceEpoch(s.updated);
|
||||
|
||||
+40
-1
@@ -133,6 +133,10 @@ class AppState extends ChangeNotifier {
|
||||
String? _sessionsNext;
|
||||
bool loadingMoreSessions = false;
|
||||
|
||||
/// Parents whose subagent sessions were already fetched.
|
||||
final Set<String> _childrenLoaded = {};
|
||||
final Set<String> _childrenLoading = {};
|
||||
|
||||
/// Terminal workspaces by directory: each holds that directory's tabs and
|
||||
/// keeps their shells alive while sessions/tabs are switched.
|
||||
final Map<String, TerminalWorkspace> terminals = {};
|
||||
@@ -465,6 +469,8 @@ class AppState extends ChangeNotifier {
|
||||
projects = [];
|
||||
chatsRoot = null;
|
||||
chatRoots = [];
|
||||
_childrenLoaded.clear();
|
||||
_childrenLoading.clear();
|
||||
_projectIcons.clear();
|
||||
archivedSessions = [];
|
||||
archivedLoaded = false;
|
||||
@@ -1196,12 +1202,45 @@ class AppState extends ChangeNotifier {
|
||||
Future<void> openChat(Session s) async {
|
||||
draftOpen = false;
|
||||
chat = ChatState(this, s);
|
||||
// The shell shows the new session at once; its messages follow.
|
||||
// The shell shows the new session at once; its messages follow. Fetching
|
||||
// the session's subagents in parallel fills the nested rows under it.
|
||||
notifyListeners();
|
||||
unawaited(loadChildren(s));
|
||||
await chat!.load();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Fetches a parent's worker sessions once. The global list usually carries
|
||||
/// them, but an older parent's children can fall outside the loaded page.
|
||||
Future<void> loadChildren(Session parent) async {
|
||||
final cl = client;
|
||||
if (cl == null || parent.isChild) return;
|
||||
if (_childrenLoaded.contains(parent.id) ||
|
||||
_childrenLoading.contains(parent.id)) {
|
||||
return;
|
||||
}
|
||||
_childrenLoading.add(parent.id);
|
||||
try {
|
||||
final page = await cl.listSessions(
|
||||
parentID: parent.id, limit: 50, directory: parent.directory);
|
||||
if (client != cl) return;
|
||||
final known = sessions.map((s) => s.id).toSet();
|
||||
var added = false;
|
||||
for (final child in page.data) {
|
||||
if (known.add(child.id)) {
|
||||
sessions.add(child);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
_childrenLoaded.add(parent.id);
|
||||
if (added) notifyListeners();
|
||||
} catch (_) {
|
||||
// Retried the next time the session is opened.
|
||||
} finally {
|
||||
_childrenLoading.remove(parent.id);
|
||||
}
|
||||
}
|
||||
|
||||
void closeChat() {
|
||||
chat = null;
|
||||
notifyListeners();
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/// The app version sent to the server in pairing and relay handshakes.
|
||||
const appVersion = '0.4.8';
|
||||
const appVersion = '0.4.9';
|
||||
+1
-1
@@ -2,7 +2,7 @@ name: openchamber
|
||||
description: "A lightweight OpenChamber client for phones."
|
||||
publish_to: 'none'
|
||||
|
||||
version: 0.4.8+408
|
||||
version: 0.4.9+409
|
||||
|
||||
environment:
|
||||
sdk: ^3.14.0
|
||||
|
||||
@@ -43,6 +43,46 @@ void main() {
|
||||
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();
|
||||
|
||||
Reference in new issue
Block a user