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:
1 parent
c4de5e84d8
commit
9564019a91
7 files changed
+142
-86
No files matched your search
@@ -342,7 +342,11 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
Positioned.fill(child: _messageList()),
|
||||
// Over the messages, not in the column: the list keeps its
|
||||
// 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
|
||||
/// last turn, then idle.
|
||||
String _petState() {
|
||||
@@ -1780,10 +1793,6 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
tasks: tasks,
|
||||
sessionId: chat.session.id,
|
||||
onOpen: _openShellSheet,
|
||||
onStop: (task) async {
|
||||
final ok = await confirmStopShell(context, task.command);
|
||||
if (ok == true) await _stopShell(task);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,12 @@ import '../pets/pet_pack.dart';
|
||||
/// cap's while a turn runs). Dragging it sideways moves it along that edge.
|
||||
class PetLayer extends StatefulWidget {
|
||||
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
|
||||
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
|
||||
// padding above its capsule, so step past both; that overflow is
|
||||
// fine, the layer does not clip.
|
||||
final bottom =
|
||||
-((pack.canvas.height - pack.anchor.dy) * scale + 6) + _lift;
|
||||
final bottom = -((pack.canvas.height - pack.anchor.dy) * scale +
|
||||
widget.footOffset) +
|
||||
_lift;
|
||||
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
|
||||
+89
-67
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user