fix: match the background task bar to the activity strip

- draw the task bar in the activity strip's capsule (8px margins, 14px
  padding, 36px min height, stadium radius) so the two read as one stack
- drop the stop button from the bar: its padding pushed the clock off the
  right edge shared with the strip above; the row opens the sheet instead
- in the sheet, show only the clock while running, a stop button with a
  stop icon, and "已结束" once the command ends; no "运行中" label and no
  close x (the drag handle and the scrim already close it)
- say "读取输出…" while the first page loads instead of claiming the
  command has printed nothing
- rest the pet's feet on the status capsule's edge (4px top margin)
  instead of sinking 2px into it
This commit is contained in:
blumia committed 2026-11-24 23:19:47 +08:00
1 parent c4de5e84d8
commit 9564019a91
7 files changed
+142 -86

No files matched your search

+16 -1
View File
@@ -5,6 +5,21 @@
--- ---
## 0.4.15 后台任务条细节:外观一致、停止移到弹层、宠物站位(分支 `flutter`)
| 项 | 结果 |
| --- | --- |
| 外观一致 | 后台任务条改为与运行状态胶囊同一套形状:8 边距、14 水平内边距、36 最小高度、Stadium 圆角、相同的文字大小与基线,两条叠在一起时读作一组;多条任务在同一条胶囊里逐行排列 |
| 停止 | 按反馈去掉任务条上的「停止」按钮:它会把右侧对齐从计时挤开,与上方运行条的右端对不齐。现在点任意一行打开弹层,停止与复制都在弹层里(确认框「停止这个任务?」不变) |
| 弹层状态行 | 不再写「运行中」(弹层开着就是在跑,计时已经说明),也没有会让人误以为「点我刷新」的 `sync` 图标:左边只有计时;「停止」改成带方块停止图标的按钮;命令结束后才显示「已结束」 |
| 弹层关闭 | 去掉右侧的 x:拖动把手下滑和点遮罩都能关,x 是多余的 |
| 宠物 | 宠物站在最上方那条胶囊的边沿:有运行条或后台任务条时按它的 4px 上边距收脚,都不在时按输入框的 6px;之前会陷进胶囊顶边 2px |
| 测试 | `test/shell_jobs_test.dart`:任务条不再有「停止」、点行回调打开弹层、计时仍在;80 项全过 |
| 验证 | 模拟器:运行中 + 一条后台任务,两条胶囊等高同圆角;点任务行打开弹层:计时、带图标的「停止」与「复制」、实时输出与跟随,没有「运行中」字样与 x;首次读取时显示「读取输出…」转圈,不会误报「等待输出」;弹层内停止 → 确认 → shell 消失,弹层转为「已结束」并保留最后输出;从弹层头部下滑确实能关闭(x 去掉的前提);宠物在只有运行条、只有任务条、两者都有时都踩在胶囊上沿 |
| 版本 | **0.4.15(code 415)** |
---
## 0.4.14 后台任务:状态条、实时输出与停止(分支 `flutter`) ## 0.4.14 后台任务:状态条、实时输出与停止(分支 `flutter`)
| 项 | 结果 | | 项 | 结果 |
@@ -17,7 +32,7 @@
| 结束后 | 命令结束后,工具行与弹层不再轮询,改用会话里 synthetic `<background-result kind="shell" …>` 的最终输出(shell 被删除后仍能看);如果是用户在 App 里停的,显示「用户停止了这条命令。」而不是 Shell.NotFoundError | | 结束后 | 命令结束后,工具行与弹层不再轮询,改用会话里 synthetic `<background-result kind="shell" …>` 的最终输出(shell 被删除后仍能看);如果是用户在 App 里停的,显示「用户停止了这条命令。」而不是 Shell.NotFoundError |
| 刷新 | 打开会话立即刷新,之后 3 秒一次;会话消息变化时也刷新(新任务立刻出现);服务端无该接口时停止轮询 | | 刷新 | 打开会话立即刷新,之后 3 秒一次;会话消息变化时也刷新(新任务立刻出现);服务端无该接口时停止轮询 |
| 测试 | 新增 `test/shell_jobs_test.dart`:后台标记识别(前台命令不算)、转录/任务/外壳列表解析、输出页、完成说明与停止标记、计时格式、停止说明,以及状态条 1 条/2 条/多条折叠的布局;80 项全过 | | 测试 | 新增 `test/shell_jobs_test.dart`:后台标记识别(前台命令不算)、转录/任务/外壳列表解析、输出页、完成说明与停止标记、计时格式、停止说明,以及状态条 1 条/2 条/多条折叠的布局;80 项全过 |
| 验证 | 模拟器(真实任务):`sleep 900` 单条任务条 → 第二条命令变为「正在执行 2 条命令」+ 两条行;弹层实时输出(每秒 tick);弹层内「停止」→ 确认 → 任务与 shell 消失、模型收到 synthetic 停止说明;工具行「后台」标签 + 展开后的最终输出/「用户停止了这条命令。」 | | 验证 | 模拟器(真实任务):`sleep 900` 单条任务条 → 第二条命令变为「正在执行 2 条命令」+ 两条行;弹层实时输出(每秒 tick);弹层内「停止」→ 确认 → 任务与 shell 消失、模型收到 synthetic 停止说明;工具行「后台」标签 + 展开后的最终输出/「用户停止了这条命令。」。后台进程可用前台命令超时后「移到后台」的方式启动(`timeout` 5 秒、不加 background),这样不会像 `background: true` 那样在超时点被 SIGKILL,任务会一直跑到手动停止 |
| 版本 | **0.4.14(code 414)** | | 版本 | **0.4.14(code 414)** |
--- ---
+1 -1
View File
@@ -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 feature set as the earlier Asuka/Go and MyGo attempts, reimplemented in
Flutter to compare mobile UI maturity. Flutter to compare mobile UI maturity.
Status: 0.4.14 — servers (passwordless / password login, HTTP/HTTPS and Status: 0.4.15 — servers (passwordless / password login, HTTP/HTTPS and
SOCKS5/socks5h proxy, self-signed certificates and pinning, or a pairing link SOCKS5/socks5h proxy, self-signed certificates and pinning, or a pairing link
over the OpenChamber private relay with end-to-end encryption; the pairing 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 link is pasted or scanned with the camera), session list with search and live
+14 -5
View File
@@ -342,7 +342,11 @@ class _ChatScreenState extends State<ChatScreen> {
Positioned.fill(child: _messageList()), Positioned.fill(child: _messageList()),
// Over the messages, not in the column: the list keeps its // Over the messages, not in the column: the list keeps its
// full height and shows through around the pet. // full height and shows through around the pet.
Positioned.fill(child: PetLayer(state: _petState())), Positioned.fill(
child: PetLayer(
state: _petState(),
footOffset: _petFootOffset,
)),
], ],
), ),
), ),
@@ -1714,6 +1718,15 @@ class _ChatScreenState extends State<ChatScreen> {
); );
} }
/// Where the pet's feet rest: on the composer's capsule, or on the status
/// capsule when one is the last thing above the composer. That strip keeps
/// a 4px top margin of its own, so the feet stop on its edge instead of
/// sinking into it.
double get _petFootOffset {
final strip = chat.running || (_shells?.tasks.isNotEmpty ?? false);
return strip ? 4 : 6;
}
/// The mood the pet draws: the same activity the strip shows, then a failed /// The mood the pet draws: the same activity the strip shows, then a failed
/// last turn, then idle. /// last turn, then idle.
String _petState() { String _petState() {
@@ -1780,10 +1793,6 @@ class _ChatScreenState extends State<ChatScreen> {
tasks: tasks, tasks: tasks,
sessionId: chat.session.id, sessionId: chat.session.id,
onOpen: _openShellSheet, onOpen: _openShellSheet,
onStop: (task) async {
final ok = await confirmStopShell(context, task.command);
if (ok == true) await _stopShell(task);
},
); );
} }
+9 -3
View File
@@ -16,7 +16,12 @@ import '../pets/pet_pack.dart';
/// cap's while a turn runs). Dragging it sideways moves it along that edge. /// cap's while a turn runs). Dragging it sideways moves it along that edge.
class PetLayer extends StatefulWidget { class PetLayer extends StatefulWidget {
final String state; final String state;
const PetLayer({super.key, required this.state});
/// How far below the layer's bottom edge the feet stand: the composer's
/// top padding, or the status capsule's edge when one sits above it.
final double footOffset;
const PetLayer({super.key, required this.state, this.footOffset = 6});
@override @override
State<PetLayer> createState() => _PetLayerState(); State<PetLayer> createState() => _PetLayerState();
@@ -62,8 +67,9 @@ class _PetLayerState extends State<PetLayer> {
// little below the anchor, and the composer keeps a few px of top // little below the anchor, and the composer keeps a few px of top
// padding above its capsule, so step past both; that overflow is // padding above its capsule, so step past both; that overflow is
// fine, the layer does not clip. // fine, the layer does not clip.
final bottom = final bottom = -((pack.canvas.height - pack.anchor.dy) * scale +
-((pack.canvas.height - pack.anchor.dy) * scale + 6) + _lift; widget.footOffset) +
_lift;
return Stack( return Stack(
clipBehavior: Clip.none, clipBehavior: Clip.none,
+89 -67
View File
@@ -15,15 +15,15 @@ class ShellTaskBar extends StatefulWidget {
/// The chat's own session: a task from a child session is marked. /// The chat's own session: a task from a child session is marked.
final String sessionId; final String sessionId;
/// Tapping a row opens its output; the stop lives in that sheet.
final void Function(ShellTask task) onOpen; final void Function(ShellTask task) onOpen;
final void Function(ShellTask task) onStop;
const ShellTaskBar({ const ShellTaskBar({
super.key, super.key,
required this.tasks, required this.tasks,
required this.sessionId, required this.sessionId,
required this.onOpen, required this.onOpen,
required this.onStop,
}); });
@override @override
@@ -42,27 +42,35 @@ class _ShellTaskBarState extends State<ShellTaskBar> {
if (tasks.isEmpty) return const SizedBox.shrink(); if (tasks.isEmpty) return const SizedBox.shrink();
final theme = Theme.of(context); final theme = Theme.of(context);
final single = tasks.length == 1; final single = tasks.length == 1;
// The same capsule as the activity strip above it: one row of text in the
// same stadium, with the same margins, so the two read as one stack.
return Padding( return Padding(
padding: const EdgeInsets.fromLTRB(8, 2, 8, 6), padding: const EdgeInsets.fromLTRB(8, 4, 8, 4),
child: Material( child: Material(
color: theme.colorScheme.surfaceContainerHighest.withValues(alpha: 0.7), color: theme.colorScheme.surfaceContainerHighest.withValues(alpha: 0.7),
borderRadius: BorderRadius.circular(14), shape: const StadiumBorder(),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: Column( child: ConstrainedBox(
crossAxisAlignment: CrossAxisAlignment.stretch, constraints: const BoxConstraints(minHeight: 36),
children: [ child: Padding(
if (!single) _header(theme, tasks.length), padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6),
if (single || _open) child: Column(
for (final task in tasks) mainAxisSize: MainAxisSize.min,
_ShellTaskRow( crossAxisAlignment: CrossAxisAlignment.stretch,
key: ValueKey(task.id), children: [
task: task, if (!single) _header(theme, tasks.length),
subagent: task.sessionId.isNotEmpty && if (single || _open)
task.sessionId != widget.sessionId, for (final task in tasks)
onTap: () => widget.onOpen(task), _ShellTaskRow(
onStop: () => widget.onStop(task), key: ValueKey(task.id),
), task: task,
], subagent: task.sessionId.isNotEmpty &&
task.sessionId != widget.sessionId,
onTap: () => widget.onOpen(task),
),
],
),
),
), ),
), ),
); );
@@ -71,8 +79,8 @@ class _ShellTaskBarState extends State<ShellTaskBar> {
Widget _header(ThemeData theme, int count) { Widget _header(ThemeData theme, int count) {
return InkWell( return InkWell(
onTap: () => setState(() => _expanded = !_open), onTap: () => setState(() => _expanded = !_open),
child: Padding( child: SizedBox(
padding: const EdgeInsets.fromLTRB(12, 8, 8, 8), height: 24,
child: Row( child: Row(
children: [ children: [
Icon(Icons.terminal, size: 15, color: theme.hintColor), Icon(Icons.terminal, size: 15, color: theme.hintColor),
@@ -84,7 +92,8 @@ class _ShellTaskBarState extends State<ShellTaskBar> {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
color: theme.colorScheme.onSurfaceVariant, fontWeight: FontWeight.w600,
color: theme.colorScheme.onSurface,
), ),
), ),
), ),
@@ -101,14 +110,12 @@ class _ShellTaskRow extends StatelessWidget {
final ShellTask task; final ShellTask task;
final bool subagent; final bool subagent;
final VoidCallback onTap; final VoidCallback onTap;
final VoidCallback onStop;
const _ShellTaskRow({ const _ShellTaskRow({
super.key, super.key,
required this.task, required this.task,
required this.subagent, required this.subagent,
required this.onTap, required this.onTap,
required this.onStop,
}); });
@override @override
@@ -116,8 +123,8 @@ class _ShellTaskRow extends StatelessWidget {
final theme = Theme.of(context); final theme = Theme.of(context);
return InkWell( return InkWell(
onTap: onTap, onTap: onTap,
child: Padding( child: SizedBox(
padding: const EdgeInsets.fromLTRB(12, 2, 4, 2), height: 24,
child: Row( child: Row(
children: [ children: [
Icon(Icons.terminal, size: 15, color: theme.hintColor), Icon(Icons.terminal, size: 15, color: theme.hintColor),
@@ -128,26 +135,22 @@ class _ShellTaskRow extends StatelessWidget {
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: const TextStyle( style: const TextStyle(
fontSize: 12, fontFamily: 'monospace', height: 1.35), fontSize: 12.5, fontFamily: 'monospace', height: 1.3),
), ),
), ),
if (subagent) ...[ if (subagent) ...[
const SizedBox(width: 6), const SizedBox(width: 6),
Text('子代理', Text('子代理',
style: TextStyle(fontSize: 11, color: theme.hintColor)), style: TextStyle(
fontSize: 12,
color: theme.colorScheme.onSurfaceVariant,
)),
], ],
const SizedBox(width: 8), const SizedBox(width: 8),
// The clock ends on the capsule's inner edge, the same line the
// activity strip's clock ends on above it; stopping is a tap away
// in the sheet, so no button here to break that line.
ShellElapsed(startedAt: task.startedAt), ShellElapsed(startedAt: task.startedAt),
TextButton(
onPressed: onStop,
style: TextButton.styleFrom(
minimumSize: const Size(0, 34),
padding: const EdgeInsets.symmetric(horizontal: 10),
foregroundColor: theme.colorScheme.error,
textStyle: const TextStyle(fontSize: 12.5),
),
child: const Text('停止'),
),
], ],
), ),
), ),
@@ -324,8 +327,10 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
// The drag handle above and a tap on the scrim close the sheet;
// a close button would only repeat them.
Padding( Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 8, 0), padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@@ -340,11 +345,6 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
fontSize: 13, fontFamily: 'monospace', height: 1.4), fontSize: 13, fontFamily: 'monospace', height: 1.4),
), ),
), ),
IconButton(
icon: const Icon(Icons.close, size: 20),
tooltip: '关闭',
onPressed: () => Navigator.pop(context),
),
], ],
), ),
), ),
@@ -352,33 +352,30 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
padding: const EdgeInsets.fromLTRB(20, 0, 20, 8), padding: const EdgeInsets.fromLTRB(20, 0, 20, 8),
child: Row( child: Row(
children: [ children: [
Icon( // No "运行中" label: a live sheet is running by definition,
running ? Icons.sync : Icons.check_circle_outline, // and the clock says since when. Only the end is worth saying.
size: 15, if (running)
color: running ? theme.colorScheme.primary : theme.hintColor, ShellElapsed(
), startedAt: widget.task.startedAt, running: true)
const SizedBox(width: 6), else ...[
Text( Icon(Icons.check_circle_outline,
running ? '运行中' : '已结束', size: 15, color: theme.hintColor),
style: TextStyle( const SizedBox(width: 6),
fontSize: 12, Text('已结束',
color: running style:
? theme.colorScheme.primary TextStyle(fontSize: 12, color: theme.hintColor)),
: theme.hintColor), ],
),
const SizedBox(width: 10),
ShellElapsed(
startedAt: widget.task.startedAt, running: running),
const Spacer(), const Spacer(),
if (running) if (running)
TextButton( TextButton.icon(
onPressed: _stopping ? null : _stop, onPressed: _stopping ? null : _stop,
icon: const Icon(Icons.stop_rounded, size: 17),
label: Text(_stopping ? '停止中…' : '停止'),
style: TextButton.styleFrom( style: TextButton.styleFrom(
foregroundColor: theme.colorScheme.error, foregroundColor: theme.colorScheme.error,
minimumSize: const Size(0, 32), minimumSize: const Size(0, 32),
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
), ),
child: Text(_stopping ? '停止中…' : '停止'),
), ),
TextButton.icon( TextButton.icon(
onPressed: _text.isEmpty ? null : _copy, onPressed: _text.isEmpty ? null : _copy,
@@ -399,10 +396,29 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
Positioned.fill( Positioned.fill(
child: _text.isEmpty child: _text.isEmpty
? Center( ? Center(
child: Text( child: Column(
_feed.error ?? (running ? '等待输出…' : '没有输出'), mainAxisSize: MainAxisSize.min,
style: TextStyle( children: [
fontSize: 13, color: theme.hintColor), if (_feed.error == null && !_feed.loaded) ...[
const SizedBox(
width: 16,
height: 16,
child:
CircularProgressIndicator(strokeWidth: 1.8),
),
const SizedBox(height: 10),
],
Text(
_feed.error ??
(!_feed.loaded
? '读取输出…'
: running
? '等待输出…'
: '没有输出'),
style: TextStyle(
fontSize: 13, color: theme.hintColor),
),
],
), ),
) )
: Scrollbar( : Scrollbar(
@@ -636,6 +652,10 @@ class ShellOutputFeed {
final String directory; final String directory;
String text = ''; String text = '';
/// The first page has been read: before that, an empty [text] means the
/// read is still under way, not that the command has printed nothing.
bool loaded = false;
bool ended = false; bool ended = false;
String? error; String? error;
@@ -675,6 +695,7 @@ class ShellOutputFeed {
_cursor = page.cursor; _cursor = page.cursor;
} }
error = null; error = null;
loaded = true;
} else if (!ended) { } else if (!ended) {
final page = await client.shellOutput(task.id, final page = await client.shellOutput(task.id,
cursor: _cursor, directory: directory); cursor: _cursor, directory: directory);
@@ -701,6 +722,7 @@ class ShellOutputFeed {
} on ApiError catch (e) { } on ApiError catch (e) {
if (e.status == 404) { if (e.status == 404) {
ended = true; ended = true;
loaded = true;
error = null; error = null;
_timer?.cancel(); _timer?.cancel();
_timer = null; _timer = null;
+1 -1
View File
@@ -2,7 +2,7 @@ name: openchamber
description: "A lightweight OpenChamber client for phones." description: "A lightweight OpenChamber client for phones."
publish_to: 'none' publish_to: 'none'
version: 0.4.14+414 version: 0.4.15+415
environment: environment:
sdk: ^3.14.0 sdk: ^3.14.0
+12 -8
View File
@@ -250,7 +250,8 @@ void main() {
startedAt: DateTime.now().millisecondsSinceEpoch - 65000, startedAt: DateTime.now().millisecondsSinceEpoch - 65000,
); );
Future<void> pump(WidgetTester tester, List<ShellTask> tasks) async { Future<void> pump(WidgetTester tester, List<ShellTask> tasks,
{void Function(ShellTask)? onOpen}) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( home: Scaffold(
body: Column( body: Column(
@@ -258,8 +259,7 @@ void main() {
ShellTaskBar( ShellTaskBar(
tasks: tasks, tasks: tasks,
sessionId: 'ses_a', sessionId: 'ses_a',
onOpen: (_) {}, onOpen: onOpen ?? (_) {},
onStop: (_) {},
), ),
], ],
), ),
@@ -267,13 +267,17 @@ void main() {
)); ));
} }
testWidgets('one command is its own row, with stop and clock', testWidgets('one command is its own row, with its clock', (tester) async {
(tester) async { ShellTask? opened;
await pump(tester, [task('sh_1', command: 'pnpm dev')]); await pump(tester, [task('sh_1', command: 'pnpm dev')],
onOpen: (t) => opened = t);
expect(find.text('pnpm dev'), findsOneWidget); expect(find.text('pnpm dev'), findsOneWidget);
expect(find.text('停止'), findsOneWidget);
expect(find.text('1分05秒'), findsOneWidget); expect(find.text('1分05秒'), findsOneWidget);
expect(find.textContaining('正在执行'), findsNothing); expect(find.textContaining('正在执行'), findsNothing);
// Stopping is in the sheet the row opens, not a button on the bar.
expect(find.text('停止'), findsNothing);
await tester.tap(find.text('pnpm dev'));
expect(opened?.id, 'sh_1');
}); });
testWidgets('two commands share a count header and both show', testWidgets('two commands share a count header and both show',
@@ -286,7 +290,7 @@ void main() {
expect(find.text('pnpm dev'), findsOneWidget); expect(find.text('pnpm dev'), findsOneWidget);
expect(find.text('pnpm test'), findsOneWidget); expect(find.text('pnpm test'), findsOneWidget);
expect(find.text('子代理'), findsOneWidget); expect(find.text('子代理'), findsOneWidget);
expect(find.text('停止'), findsNWidgets(2)); expect(find.text('停止'), findsNothing);
}); });
testWidgets('a long list folds until asked', (tester) async { testWidgets('a long list folds until asked', (tester) async {