Record chat shell commands with fixture captures and a note

Show Expand only when output can overflow and drop the final newline from
the drawn output. The full-app probe lists shell runs with ?shell=1 so the
cards, Shell mode and Run command dialog can be captured in Chrome.
This commit is contained in:
2026-11-09 16:21:15 +00:00
parent a6f0f0a1cb
commit 5c3248a48d
7 changed files with 405 additions and 3 deletions
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'chat_shell_metrics.dart';
import 'chat_shell_run.dart';
import 'chat_shell_runs_controller.dart';
@@ -113,7 +114,7 @@ class _ChatShellCardActionsState extends State<ChatShellCardActions> {
? () => unawaited(controller.share(run.id))
: null,
),
if (run.output.isNotEmpty)
if (widget.expanded || chatShellOutputMayOverflow(run.output))
_button(
key: const Key('chat-shell-run-expand'),
label: widget.expanded
@@ -16,6 +16,17 @@ const double kChatShellOutputLineHeight = 1.35;
/// part, and Copy output still copies everything the server kept.
const int kChatShellRenderedOutputLimit = 64 * 1024;
/// Whether [output] may be taller than the collapsed area, so Expand is worth
/// offering. Counted in lines, with long lines counted as wrapping.
bool chatShellOutputMayOverflow(String output) {
var lines = 0;
for (final line in output.split('\n')) {
lines += 1 + line.length ~/ 80;
if (lines > kChatShellOutputCollapsedLines) return true;
}
return false;
}
/// The output area's maximum height for this window, text scale and font.
double chatShellOutputMaxHeight(
BuildContext context, {
@@ -51,6 +51,8 @@ class _ChatShellOutputViewState extends State<ChatShellOutputView> {
if (clipped) {
text = text.substring(text.length - kChatShellRenderedOutputLimit);
}
// The final newline ends the last line; it is not an empty line to draw.
if (text.endsWith('\n')) text = text.substring(0, text.length - 1);
final notes = [
if (run.truncated) 'Earlier output was dropped.',
if (clipped)