fix(app): bound the background-task output pane and row labels

Review 139 found the selected task's output page unbounded, overflowing a
phone-height conversation. The bar now keeps half the viewport and scrolls
its own body, the output pane is capped at twelve scaled lines, row labels
elide instead of overflowing, and a reply without a page reads as
unavailable rather than empty.
This commit is contained in:
2026-10-22 17:53:48 +01:00
parent 2cb4a0c555
commit a26bfe2b0c
5 changed files with 380 additions and 77 deletions
@@ -1,3 +1,5 @@
import 'dart:math' as math;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -5,6 +7,18 @@ import '../../../core/api_gateway.dart';
import '../domain/chat_shells.dart'; import '../domain/chat_shells.dart';
import '../ui/sessions/chat_adaptive.dart'; import '../ui/sessions/chat_adaptive.dart';
/// One bounded output page: the web's 220 px pane is twelve 18 px monospace
/// lines (`web/chat.css`), so the bound is read from the host's own output type
/// and the user's text scale rather than a fixed pixel row. A longer page
/// scrolls inside this box and never moves the transcript or composer.
const _outputVisibleLines = 12;
const _outputLineHeight = 1.5;
/// Even at a large text scale one pane keeps this share of the bar's own height
/// budget, so the bar's chrome and list keep room and the conversation below it
/// is never crowded out.
const _outputMaxBudgetShare = 0.45;
/// The selected background task's read-only detail and bounded output page. /// The selected background task's read-only detail and bounded output page.
/// ///
/// Every value is a recorded fact: the server's command, the shell identity, the /// Every value is a recorded fact: the server's command, the shell identity, the
@@ -16,11 +30,18 @@ class ChatBackgroundTaskDetail extends StatelessWidget {
super.key, super.key,
required this.shell, required this.shell,
required this.output, required this.output,
required this.heightBudget,
required this.onRefresh, required this.onRefresh,
}); });
final JsonMap shell; final JsonMap shell;
final ChatShellOutputSnapshot? output; final ChatShellOutputSnapshot? output;
/// The space the enclosing task bar has for its whole body. The output pane is
/// measured against this, not the window, so a list of rows, a narrow phone or
/// a large text scale cannot make the detail outgrow its own bar.
final double heightBudget;
final VoidCallback onRefresh; final VoidCallback onRefresh;
@override @override
@@ -73,6 +94,31 @@ class ChatBackgroundTaskDetail extends StatelessWidget {
return Text(text, style: style); return Text(text, style: style);
} }
/// The host's own monospace body for one output page. `height` is set so the
/// visible-line bound below is measured on the same line box that is drawn.
TextStyle _outputStyle(BuildContext context, bool cupertino) =>
(cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.bodySmall ?? const TextStyle())
.copyWith(
fontFamily: 'monospace',
height: _outputLineHeight,
// Cupertino's style is not inheriting; a selectable body needs a
// baseline from its own style.
textBaseline: TextBaseline.alphabetic,
);
/// The number of output lines the pane shows before it scrolls: up to twelve,
/// fewer when the user's text scale or the bar's remaining height would let
/// the pane crowd out the conversation.
int _outputVisibleLineCount(BuildContext context, TextStyle style) {
final scaledLine =
MediaQuery.textScalerOf(context).scale(style.fontSize ?? 12) *
_outputLineHeight;
final fit = (heightBudget * _outputMaxBudgetShare / scaledLine).floor();
return math.max(2, math.min(_outputVisibleLines, fit));
}
/// Selectable output in the host's own control. A Cupertino-only app has no /// Selectable output in the host's own control. A Cupertino-only app has no
/// `MaterialLocalizations`, which `SelectableText` asserts on, so one English /// `MaterialLocalizations`, which `SelectableText` asserts on, so one English
/// default scope is supplied for its context menu (the chat markdown view's /// default scope is supplied for its context menu (the chat markdown view's
@@ -81,20 +127,17 @@ class ChatBackgroundTaskDetail extends StatelessWidget {
BuildContext context, BuildContext context,
bool cupertino, bool cupertino,
String output, String output,
TextStyle style,
int maxLines,
) { ) {
final text = SelectableText( final text = SelectableText(
output, output,
key: const Key('chat-bg-task-output'), key: const Key('chat-bg-task-output'),
style: style: style,
(cupertino // A multiline selectable body scrolls itself: the host's text control
? CupertinoTheme.of(context).textTheme.textStyle // keeps the page selectable and gives it its own scrollbar/drag, so no
: Theme.of(context).textTheme.bodySmall) // nested scroller can steal the conversation's gestures.
?.copyWith( maxLines: maxLines,
fontFamily: 'monospace',
// Cupertino's style is not inheriting; a selectable body needs a
// baseline from its own style.
textBaseline: TextBaseline.alphabetic,
),
); );
if (!cupertino) return text; if (!cupertino) return text;
return Localizations( return Localizations(
@@ -136,7 +179,7 @@ class ChatBackgroundTaskDetail extends StatelessWidget {
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
'${output?.error ?? ''}', output?.error ?? '',
style: noteStyle?.copyWith( style: noteStyle?.copyWith(
color: cupertino color: cupertino
? CupertinoColors.systemRed.resolveFrom(context) ? CupertinoColors.systemRed.resolveFrom(context)
@@ -156,12 +199,19 @@ class ChatBackgroundTaskDetail extends StatelessWidget {
return Text(shellOutputEmptyNote, style: noteStyle); return Text(shellOutputEmptyNote, style: noteStyle);
case ChatShellOutputState.ready: case ChatShellOutputState.ready:
final page = output!.page!; final page = output!.page!;
final style = _outputStyle(context, cupertino);
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
spacing: 4, spacing: 4,
children: [ children: [
_label(context, cupertino, shellOutputLabel), _label(context, cupertino, shellOutputLabel),
_selectableOutput(context, cupertino, page.output), _selectableOutput(
context,
cupertino,
page.output,
style,
_outputVisibleLineCount(context, style),
),
if (page.truncated) Text(shellOutputBoundedNote, style: noteStyle), if (page.truncated) Text(shellOutputBoundedNote, style: noteStyle),
Align( Align(
alignment: AlignmentDirectional.centerStart, alignment: AlignmentDirectional.centerStart,
@@ -10,6 +10,12 @@ import '../domain/chat_shells.dart';
import '../ui/sessions/chat_adaptive.dart'; import '../ui/sessions/chat_adaptive.dart';
import 'chat_background_task_detail.dart'; import 'chat_background_task_detail.dart';
/// The bar is pinned above the transcript, so the whole surface keeps at most
/// this share of the window and scrolls inside itself. The transcript and the
/// composer therefore always keep most of the window, however many tasks are
/// listed and however large the selected page is.
const backgroundTaskViewportShare = 0.5;
/// The running background tasks a chat session owns (C11). /// The running background tasks a chat session owns (C11).
/// ///
/// The list is read from recorded facts only: the session's `chat_shells` /// The list is read from recorded facts only: the session's `chat_shells`
@@ -50,6 +56,7 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
ChatShellOutputSnapshot? _output; ChatShellOutputSnapshot? _output;
String? _listError; String? _listError;
int _generation = 0; int _generation = 0;
int _outputGeneration = 0;
bool _disposed = false; bool _disposed = false;
@override @override
@@ -154,6 +161,7 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
Future<void> _readOutput(String shellId) async { Future<void> _readOutput(String shellId) async {
if (_selectedId != shellId) return; if (_selectedId != shellId) return;
final token = ++_outputGeneration;
setState(() => _output = const ChatShellOutputSnapshot(loading: true)); setState(() => _output = const ChatShellOutputSnapshot(loading: true));
try { try {
final reply = await _repository.shellOutput( final reply = await _repository.shellOutput(
@@ -162,7 +170,9 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
cursor: 0, cursor: 0,
limit: chatShellOutputLimit, limit: chatShellOutputLimit,
); );
if (!mounted || _selectedId != shellId) return; if (!mounted || token != _outputGeneration || _selectedId != shellId) {
return;
}
final page = ChatShellOutputPage.fromReply(reply); final page = ChatShellOutputPage.fromReply(reply);
final reported = page.shell; final reported = page.shell;
setState(() { setState(() {
@@ -173,7 +183,9 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
_dropStaleSelection(); _dropStaleSelection();
}); });
} catch (error) { } catch (error) {
if (!mounted || _selectedId != shellId) return; if (!mounted || token != _outputGeneration || _selectedId != shellId) {
return;
}
setState( setState(
() => _output = ChatShellOutputSnapshot( () => _output = ChatShellOutputSnapshot(
error: describeErrorReason( error: describeErrorReason(
@@ -202,24 +214,40 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
final cupertino = final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino; chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final selectedShell = _selectedShell(running); final selectedShell = _selectedShell(running);
return Padding( // The bar is pinned above the transcript, so it keeps a bounded share of
// the window and scrolls its own body. Even three rows plus an open detail
// can then never push the transcript or the composer out of the viewport.
return ConstrainedBox(
key: const Key('chat-background-tasks'), key: const Key('chat-background-tasks'),
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 4), constraints: BoxConstraints(
child: Column( maxHeight:
crossAxisAlignment: CrossAxisAlignment.stretch, MediaQuery.sizeOf(context).height * backgroundTaskViewportShare,
spacing: 4, ),
children: [ child: LayoutBuilder(
_heading(context, cupertino, running.length, error == null), builder: (context, constraints) => SingleChildScrollView(
if (error != null) _listFailure(context, cupertino, error), key: const Key('chat-background-tasks-scroll'),
if (running.isNotEmpty) _taskList(context, cupertino, running), padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 4),
if (selectedShell != null) child: Column(
ChatBackgroundTaskDetail( crossAxisAlignment: CrossAxisAlignment.stretch,
key: const Key('chat-bg-task-detail'), spacing: 4,
shell: selectedShell, children: [
output: _output, _heading(context, cupertino, running.length, error == null),
onRefresh: () => unawaited(_readOutput(shellIdOf(selectedShell))), if (error != null) _listFailure(context, cupertino, error),
), if (running.isNotEmpty) _taskList(context, cupertino, running),
], if (selectedShell != null)
ChatBackgroundTaskDetail(
key: const Key('chat-bg-task-detail'),
shell: selectedShell,
output: _output,
// The detail derives its output pane from the space this bar
// actually has left instead of the whole window.
heightBudget: constraints.maxHeight,
onRefresh: () =>
unawaited(_readOutput(shellIdOf(selectedShell))),
),
],
),
),
), ),
); );
} }
@@ -249,15 +277,31 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
color: Theme.of(context).colorScheme.onSurfaceVariant, color: Theme.of(context).colorScheme.onSurfaceVariant,
); );
return Row( return Row(
spacing: 8,
children: [ children: [
Expanded( Expanded(
flex: 2,
child: Semantics( child: Semantics(
header: true, header: true,
child: Text(backgroundTasksTitle, style: titleStyle), child: Text(
backgroundTasksTitle,
// One compact line like the web's head: a large text scale elides
// rather than wrapping the heading into a tall stack.
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: titleStyle,
),
), ),
), ),
if (countKnown) if (countKnown)
Text(backgroundTasksRunningLabel(count), style: countStyle), Flexible(
child: Text(
backgroundTasksRunningLabel(count),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: countStyle,
),
),
], ],
); );
} }
@@ -314,6 +358,7 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
// More than the recorded visible-row cap: the list scrolls instead of // More than the recorded visible-row cap: the list scrolls instead of
// pushing the composer down. The bound is the host's own touch target. // pushing the composer down. The bound is the host's own touch target.
return ConstrainedBox( return ConstrainedBox(
key: const Key('chat-bg-task-list'),
constraints: const BoxConstraints( constraints: const BoxConstraints(
maxHeight: kMinInteractiveDimension * backgroundTaskVisibleRows, maxHeight: kMinInteractiveDimension * backgroundTaskVisibleRows,
), ),
@@ -336,7 +381,6 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
final style = CupertinoTheme.of(context).textTheme.textStyle; final style = CupertinoTheme.of(context).textTheme.textStyle;
return Semantics( return Semantics(
selected: selected, selected: selected,
button: true,
child: CupertinoButton( child: CupertinoButton(
key: key, key: key,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
@@ -345,8 +389,16 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
spacing: 8, spacing: 8,
children: [ children: [
Icon(CupertinoIcons.play_fill, color: primary), Icon(CupertinoIcons.play_fill, color: primary),
Text(shellRowLabel, style: style.copyWith(color: primary)), Flexible(
child: Text(
shellRowLabel,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: style.copyWith(color: primary),
),
),
Expanded( Expanded(
flex: 3,
child: Text( child: Text(
command, command,
maxLines: 1, maxLines: 1,
@@ -355,11 +407,15 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
), ),
), ),
if (selected) if (selected)
Text( Flexible(
shellDetailsLabel, child: Text(
style: CupertinoTheme.of( shellDetailsLabel,
context, maxLines: 1,
).textTheme.tabLabelTextStyle.copyWith(color: muted), overflow: TextOverflow.ellipsis,
style: CupertinoTheme.of(
context,
).textTheme.tabLabelTextStyle.copyWith(color: muted),
),
), ),
], ],
), ),
@@ -367,38 +423,57 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
); );
} }
final theme = Theme.of(context); final theme = Theme.of(context);
final fullCommand = '${shell['command'] ?? ''}'.trim();
final rowStyle = theme.textTheme.labelMedium;
return Semantics( return Semantics(
selected: selected, selected: selected,
child: ListTile( child: Tooltip(
key: key, // The row elides its command; the full recorded one stays reachable,
dense: true, // as the web row's `title` attribute does.
contentPadding: EdgeInsets.zero, message: fullCommand.isEmpty ? command : fullCommand,
leading: Icon(Icons.play_arrow, color: theme.colorScheme.tertiary), excludeFromSemantics: true,
title: Row( child: ListTile(
spacing: 8, key: key,
children: [ dense: true,
Text( contentPadding: EdgeInsets.zero,
shellRowLabel, leading: Icon(Icons.play_arrow, color: theme.colorScheme.tertiary),
style: theme.textTheme.labelMedium?.copyWith( title: Row(
color: theme.colorScheme.tertiary, spacing: 8,
), children: [
), // Every part of the row is flexible: at a large text scale or a
Expanded( // narrow phone the labels elide instead of overflowing the row.
child: Text( Flexible(
command, child: Text(
maxLines: 1, shellRowLabel,
overflow: TextOverflow.ellipsis, maxLines: 1,
style: theme.textTheme.labelMedium?.copyWith( overflow: TextOverflow.ellipsis,
color: theme.colorScheme.onSurfaceVariant, style: rowStyle?.copyWith(color: theme.colorScheme.tertiary),
), ),
), ),
), Expanded(
], flex: 3,
child: Text(
command,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: rowStyle?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
if (selected)
Flexible(
child: Text(
shellDetailsLabel,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: theme.textTheme.labelSmall,
),
),
],
),
onTap: () => _select(id),
), ),
trailing: selected
? Text(shellDetailsLabel, style: theme.textTheme.labelSmall)
: null,
onTap: () => _select(id),
), ),
); );
} }
@@ -134,9 +134,12 @@ class ChatShellOutputPage {
factory ChatShellOutputPage.fromReply(JsonMap reply) { factory ChatShellOutputPage.fromReply(JsonMap reply) {
final value = reply['chat_shell_output']; final value = reply['chat_shell_output'];
final page = value is Map // A reply without the page is not evidence of an empty shell. Report it as
? Map<String, dynamic>.from(value) // unavailable (as the web refuses it) instead of inventing "No output yet.".
: const <String, dynamic>{}; if (value is! Map) {
return const ChatShellOutputPage(unavailable: true);
}
final page = Map<String, dynamic>.from(value);
final shell = page['shell']; final shell = page['shell'];
return ChatShellOutputPage( return ChatShellOutputPage(
output: '${page['output'] ?? ''}', output: '${page['output'] ?? ''}',
@@ -76,6 +76,11 @@ JsonMap _running(String id, {String command = 'go test ./...'}) => {
JsonMap _snapshot(List<JsonMap> shells) => {'chat_shells': shells}; JsonMap _snapshot(List<JsonMap> shells) => {'chat_shells': shells};
/// A realistically long recorded page (200 shell lines, more than one screen).
List<String> _pageLines() => [
for (var index = 0; index < 200; index++) 'line $index',
];
Widget _host( Widget _host(
_TasksGateway gateway, { _TasksGateway gateway, {
bool cupertino = false, bool cupertino = false,
@@ -187,12 +192,10 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('4 running'), findsOneWidget); expect(find.text('4 running'), findsOneWidget);
expect(find.byKey(const Key('chat-bg-task-list')), findsOneWidget);
expect( expect(
find.descendant( tester.getRect(find.byKey(const Key('chat-bg-task-list'))).height,
of: find.byType(ChatBackgroundTasks), lessThanOrEqualTo(kMinInteractiveDimension * backgroundTaskVisibleRows),
matching: find.byType(SingleChildScrollView),
),
findsOneWidget,
); );
for (var index = 0; index < 4; index++) { for (var index = 0; index < 4; index++) {
expect( expect(
@@ -228,7 +231,7 @@ void main() {
'session_id': 's', 'session_id': 's',
'shell_id': 'sh1', 'shell_id': 'sh1',
'cursor': 0, 'cursor': 0,
'limit': 64 * 1024, 'limit': chatShellOutputLimit,
}, },
}, },
]); ]);
@@ -263,10 +266,16 @@ void main() {
await tester.pumpWidget(_host(gateway)); await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// A reply with no page at all is unavailable, not "No output yet.".
gateway.output = (_) async => const <String, dynamic>{};
await _tapTask(tester, 'sh1');
expect(find.text('Output unavailable for this task.'), findsOneWidget);
gateway.output = (_) async => { gateway.output = (_) async => {
'chat_shell_output': {'shell': _running('sh1')}, 'chat_shell_output': {'shell': _running('sh1')},
}; };
await _tapTask(tester, 'sh1'); await _tapTask(tester, 'sh1');
await _tapTask(tester, 'sh1');
expect(find.text('No output yet.'), findsOneWidget); expect(find.text('No output yet.'), findsOneWidget);
gateway.output = (_) async => { gateway.output = (_) async => {
@@ -395,6 +404,167 @@ void main() {
); );
}); });
testWidgets('a long output page scrolls inside a bounded pane', (
tester,
) async {
tester.view.physicalSize = const Size(400, 700);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final lines = [for (var index = 0; index < 200; index++) 'line $index'];
final gateway = _TasksGateway();
gateway.shells = () async => _snapshot([_running('sh1')]);
gateway.output = (_) async => {
'chat_shell_output': {
'shell': _running('sh1'),
'output': '${lines.join('\n')}\n',
},
};
addTearDown(gateway.close);
await tester.pumpWidget(_thread(gateway));
await tester.pumpAndSettle();
await _tapTask(tester, 'sh1');
// A real shell tail is bounded: the transcript and composer stay in the
// viewport instead of being pushed out by the whole page.
expect(tester.takeException(), isNull);
final outputFinder = find.byKey(const Key('chat-bg-task-output'));
final output = tester.getRect(outputFinder);
expect(output.height, lessThanOrEqualTo(210));
final detail = tester.getRect(find.byKey(const Key('chat-bg-task-detail')));
final composer = tester.getRect(
find.byKey(const ValueKey<String>('chat-composer-s')),
);
expect(detail.bottom, lessThanOrEqualTo(composer.top));
expect(composer.bottom, lessThanOrEqualTo(700));
// The page scrolls through the host's own text control to its last line.
expect(
tester.widget<SelectableText>(outputFinder).data,
contains('line 199'),
);
final scrollable = tester.state<ScrollableState>(
find.descendant(of: outputFinder, matching: find.byType(Scrollable)),
);
expect(scrollable.position.maxScrollExtent, greaterThan(0));
await tester.drag(outputFinder, const Offset(0, -300));
await tester.pumpAndSettle();
expect(scrollable.position.pixels, greaterThan(0));
});
testWidgets('three tasks and an open page fit a 320px phone', (tester) async {
tester.view.physicalSize = const Size(320, 568);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final gateway = _TasksGateway();
gateway.shells = () async =>
_snapshot([_running('sh1'), _running('sh2'), _running('sh3')]);
gateway.output = (_) async => {
'chat_shell_output': {
'shell': _running('sh1'),
'output': '${_pageLines().join('\n')}\n',
},
};
addTearDown(gateway.close);
await tester.pumpWidget(_thread(gateway));
await tester.pumpAndSettle();
await _tapTask(tester, 'sh1');
// Three rows plus the whole detail can no longer take the viewport: the bar
// keeps its share, scrolls its own body, and the composer stays reachable.
expect(tester.takeException(), isNull);
final bar = tester.getRect(find.byKey(const Key('chat-background-tasks')));
final composer = tester.getRect(
find.byKey(const ValueKey<String>('chat-composer-s')),
);
final transcript = tester.getRect(
find.byKey(const ValueKey<String>('chat-thread-s')),
);
expect(
bar.height,
lessThanOrEqualTo(568 * backgroundTaskViewportShare + 0.5),
);
expect(bar.bottom, lessThanOrEqualTo(composer.top));
expect(composer.bottom, lessThanOrEqualTo(568));
expect(transcript.height, greaterThan(0));
expect(
find.byKey(const Key('chat-background-tasks-scroll')),
findsOneWidget,
);
});
testWidgets('one open task at 2x text keeps the composer on screen', (
tester,
) async {
tester.view.physicalSize = const Size(320, 568);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = 2;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
final gateway = _TasksGateway();
gateway.shells = () async => _snapshot([_running('sh1')]);
gateway.output = (_) async => {
'chat_shell_output': {
'shell': _running('sh1'),
'output': '${_pageLines().join('\n')}\n',
},
};
addTearDown(gateway.close);
await tester.pumpWidget(_thread(gateway));
await tester.pumpAndSettle();
await _tapTask(tester, 'sh1');
expect(find.byKey(const Key('chat-bg-task-detail')), findsOneWidget);
// The row labels and the detail are laid out at twice the text size without
// overflowing, and the bar's bound still leaves the composer on screen.
expect(tester.takeException(), isNull);
final bar = tester.getRect(find.byKey(const Key('chat-background-tasks')));
final composer = tester.getRect(
find.byKey(const ValueKey<String>('chat-composer-s')),
);
expect(bar.bottom, lessThanOrEqualTo(composer.top));
expect(composer.bottom, lessThanOrEqualTo(568));
});
testWidgets('the Cupertino row elides its labels instead of overflowing', (
tester,
) async {
tester.view.physicalSize = const Size(320, 568);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = 2;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
final gateway = _TasksGateway();
gateway.shells = () async => _snapshot([
_running('sh1', command: 'go test ./... -run TestSomethingLongEnough'),
]);
gateway.output = (_) async => {
'chat_shell_output': {
'shell': _running('sh1'),
'output': 'native output',
},
};
addTearDown(gateway.close);
await tester.pumpWidget(_host(gateway, cupertino: true));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
await _tapTask(tester, 'sh1');
expect(tester.takeException(), isNull);
expect(find.text('Details'), findsOneWidget);
});
testWidgets('the conversation mounts the session task surface', ( testWidgets('the conversation mounts the session task surface', (
tester, tester,
) async { ) async {
@@ -116,11 +116,16 @@ void main() {
expect(chatShellOutputLimit, 64 * 1024); expect(chatShellOutputLimit, 64 * 1024);
}); });
test('an unknown reply parses as no page, never invented output', () { test('a reply without the page is unavailable, never invented output', () {
final page = ChatShellOutputPage.fromReply(const {}); final page = ChatShellOutputPage.fromReply(const {});
expect(page.output, ''); expect(page.output, '');
expect(page.shell, isNull); expect(page.shell, isNull);
expect(page.unavailable, isTrue);
expect(
ChatShellOutputSnapshot(page: page).state,
ChatShellOutputState.unavailable,
);
expect( expect(
const ChatShellOutputSnapshot(page: ChatShellOutputPage()).state, const ChatShellOutputSnapshot(page: ChatShellOutputPage()).state,
ChatShellOutputState.empty, ChatShellOutputState.empty,