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

+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.
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) onStop;
const ShellTaskBar({
super.key,
required this.tasks,
required this.sessionId,
required this.onOpen,
required this.onStop,
});
@override
@@ -42,27 +42,35 @@ class _ShellTaskBarState extends State<ShellTaskBar> {
if (tasks.isEmpty) return const SizedBox.shrink();
final theme = Theme.of(context);
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(
padding: const EdgeInsets.fromLTRB(8, 2, 8, 6),
padding: const EdgeInsets.fromLTRB(8, 4, 8, 4),
child: Material(
color: theme.colorScheme.surfaceContainerHighest.withValues(alpha: 0.7),
borderRadius: BorderRadius.circular(14),
shape: const StadiumBorder(),
clipBehavior: Clip.antiAlias,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (!single) _header(theme, tasks.length),
if (single || _open)
for (final task in tasks)
_ShellTaskRow(
key: ValueKey(task.id),
task: task,
subagent: task.sessionId.isNotEmpty &&
task.sessionId != widget.sessionId,
onTap: () => widget.onOpen(task),
onStop: () => widget.onStop(task),
),
],
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: 36),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (!single) _header(theme, tasks.length),
if (single || _open)
for (final task in tasks)
_ShellTaskRow(
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) {
return InkWell(
onTap: () => setState(() => _expanded = !_open),
child: Padding(
padding: const EdgeInsets.fromLTRB(12, 8, 8, 8),
child: SizedBox(
height: 24,
child: Row(
children: [
Icon(Icons.terminal, size: 15, color: theme.hintColor),
@@ -84,7 +92,8 @@ class _ShellTaskBarState extends State<ShellTaskBar> {
overflow: TextOverflow.ellipsis,
style: TextStyle(
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 bool subagent;
final VoidCallback onTap;
final VoidCallback onStop;
const _ShellTaskRow({
super.key,
required this.task,
required this.subagent,
required this.onTap,
required this.onStop,
});
@override
@@ -116,8 +123,8 @@ class _ShellTaskRow extends StatelessWidget {
final theme = Theme.of(context);
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.fromLTRB(12, 2, 4, 2),
child: SizedBox(
height: 24,
child: Row(
children: [
Icon(Icons.terminal, size: 15, color: theme.hintColor),
@@ -128,26 +135,22 @@ class _ShellTaskRow extends StatelessWidget {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 12, fontFamily: 'monospace', height: 1.35),
fontSize: 12.5, fontFamily: 'monospace', height: 1.3),
),
),
if (subagent) ...[
const SizedBox(width: 6),
Text('子代理',
style: TextStyle(fontSize: 11, color: theme.hintColor)),
style: TextStyle(
fontSize: 12,
color: theme.colorScheme.onSurfaceVariant,
)),
],
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),
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(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// The drag handle above and a tap on the scrim close the sheet;
// a close button would only repeat them.
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 8, 0),
padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -340,11 +345,6 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
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),
child: Row(
children: [
Icon(
running ? Icons.sync : Icons.check_circle_outline,
size: 15,
color: running ? theme.colorScheme.primary : theme.hintColor,
),
const SizedBox(width: 6),
Text(
running ? '运行中' : '已结束',
style: TextStyle(
fontSize: 12,
color: running
? theme.colorScheme.primary
: theme.hintColor),
),
const SizedBox(width: 10),
ShellElapsed(
startedAt: widget.task.startedAt, running: running),
// No "运行中" label: a live sheet is running by definition,
// and the clock says since when. Only the end is worth saying.
if (running)
ShellElapsed(
startedAt: widget.task.startedAt, running: true)
else ...[
Icon(Icons.check_circle_outline,
size: 15, color: theme.hintColor),
const SizedBox(width: 6),
Text('已结束',
style:
TextStyle(fontSize: 12, color: theme.hintColor)),
],
const Spacer(),
if (running)
TextButton(
TextButton.icon(
onPressed: _stopping ? null : _stop,
icon: const Icon(Icons.stop_rounded, size: 17),
label: Text(_stopping ? '停止中…' : '停止'),
style: TextButton.styleFrom(
foregroundColor: theme.colorScheme.error,
minimumSize: const Size(0, 32),
padding: const EdgeInsets.symmetric(horizontal: 10),
),
child: Text(_stopping ? '停止中…' : '停止'),
),
TextButton.icon(
onPressed: _text.isEmpty ? null : _copy,
@@ -399,10 +396,29 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
Positioned.fill(
child: _text.isEmpty
? Center(
child: Text(
_feed.error ?? (running ? '等待输出…' : '没有输出'),
style: TextStyle(
fontSize: 13, color: theme.hintColor),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
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(
@@ -636,6 +652,10 @@ class ShellOutputFeed {
final String directory;
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;
String? error;
@@ -675,6 +695,7 @@ class ShellOutputFeed {
_cursor = page.cursor;
}
error = null;
loaded = true;
} else if (!ended) {
final page = await client.shellOutput(task.id,
cursor: _cursor, directory: directory);
@@ -701,6 +722,7 @@ class ShellOutputFeed {
} on ApiError catch (e) {
if (e.status == 404) {
ended = true;
loaded = true;
error = null;
_timer?.cancel();
_timer = null;