Merge branch 'worktree-agent-af0cf2f1be0c96f0d' into integrate/chat-chrome

This commit is contained in:
2026-10-31 03:15:04 +00:00
20 changed files with 960 additions and 379 deletions
@@ -7,7 +7,8 @@ import '../ui/sessions/chat_adaptive.dart';
import 'chat_background_tasks_controller.dart';
import 'chat_background_tasks_panel.dart';
/// Compact live task count, mounted above Send. Details live only in its modal.
/// Compact live task count: a quiet control inside the composer beside Send,
/// shown only while tasks run. Details live only in its modal.
class ChatBackgroundTasks extends StatefulWidget {
const ChatBackgroundTasks({
super.key,
@@ -109,43 +110,63 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
listenable: controller,
builder: (context, _) {
final count = controller.running.length;
final label = controller.error != null
final failed = controller.error != null;
// Nothing to show without running tasks: never a "0 tasks" caption. A
// list that cannot be read stays reachable so its refusal is reported.
if (count == 0 && !failed) return const SizedBox.shrink();
final label = failed
? 'Tasks'
: controller.loading && count == 0
? 'Tasks…'
: '$count ${count == 1 ? 'task' : 'tasks'}';
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final button = cupertino
? CupertinoButton(
key: const Key('chat-background-tasks-button'),
sizeStyle: CupertinoButtonSize.small,
padding: EdgeInsets.zero,
onPressed: _open,
child: Text(
final Widget button;
if (cupertino) {
final color = CupertinoColors.secondaryLabel.resolveFrom(context);
button = CupertinoButton(
key: const Key('chat-background-tasks-button'),
sizeStyle: CupertinoButtonSize.small,
padding: const EdgeInsets.symmetric(horizontal: 6),
onPressed: _open,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(CupertinoIcons.square_stack_3d_up, size: 16, color: color),
const SizedBox(width: 4),
Text(
label,
style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle
.copyWith(color: CupertinoTheme.of(context).primaryColor),
style: CupertinoTheme.of(
context,
).textTheme.tabLabelTextStyle.copyWith(color: color),
),
)
: TextButton(
key: const Key('chat-background-tasks-button'),
onPressed: _open,
child: Text(
label,
style: Theme.of(context).textTheme.labelSmall?.copyWith(
color: Theme.of(context).colorScheme.primary,
),
),
);
return Semantics(
button: true,
excludeSemantics: true,
onTap: _open,
label: controller.error != null
? 'Background tasks unavailable'
: 'Background tasks, $label',
child: button,
],
),
);
} else {
final theme = Theme.of(context);
button = TextButton.icon(
key: const Key('chat-background-tasks-button'),
style: TextButton.styleFrom(
foregroundColor: theme.colorScheme.onSurfaceVariant,
padding: const EdgeInsets.symmetric(horizontal: 8),
visualDensity: VisualDensity.compact,
),
onPressed: _open,
icon: const Icon(Icons.layers_outlined, size: 16),
label: Text(label, style: theme.textTheme.labelSmall),
);
}
return Padding(
// Level with the field's single line, beside Send.
padding: const EdgeInsetsDirectional.only(end: 4, bottom: 4),
child: Semantics(
button: true,
excludeSemantics: true,
onTap: _open,
label: failed
? 'Background tasks unavailable'
: 'Background tasks, $label',
child: button,
),
);
},
);
@@ -0,0 +1,25 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// The conversation bar's model and mode controls read as the bar's other
/// actions do: neutral, not tinted like a primary call to action.
///
/// Material: a [TextButton] style in the role the bar's icon buttons use
/// (`onSurfaceVariant`).
ButtonStyle chatBarTextButtonStyle(BuildContext context) =>
TextButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
);
/// Cupertino: [content] (a [CupertinoButton]'s child) in the label colour
/// instead of the button's tint.
Widget chatBarCupertinoContent(BuildContext context, Widget content) {
final color = CupertinoColors.label.resolveFrom(context);
return IconTheme.merge(
data: IconThemeData(color: color),
child: DefaultTextStyle.merge(
style: TextStyle(color: color),
child: content,
),
);
}
@@ -21,6 +21,8 @@ import 'chat_command_actions.dart';
import 'chat_command_palette.dart';
import 'chat_composer_controller.dart';
import '../ui/transcript/chat_attachment_frame.dart';
import '../../../ui/adaptive/glass_pill.dart';
import 'chat_reading_width.dart';
/// The composer's placeholder when the chat names no working directory.
const String chatComposerPlaceholder = 'Message the agent';
@@ -612,87 +614,119 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
final selected = commands.isEmpty
? 0
: _selectedCommand % commands.length;
// Everything the next message carries (attachments, its notices) sits
// inside the glass with the field, as one floating composer; only the
// command palette, a separate menu, floats above it.
final extras = <Widget>[
if (!_attachments.isEmpty) _attachmentStrip(context, cupertino),
if (_uploading)
_notice(
context,
cupertino,
key: const Key('chat-composer-uploading'),
text: _attachments.attachments.length == 1
? 'Uploading 1 file…'
: 'Uploading ${_attachments.attachments.length} files…',
),
if (_attachmentError != null)
_notice(
context,
cupertino,
key: const Key('chat-composer-attachment-error'),
text: _attachmentError!,
failed: true,
),
if (_commandNotice != null) _commandReport(context, cupertino),
if (composer.queued)
_notice(
context,
cupertino,
key: const Key('chat-composer-queued'),
text: chatQueuedNotice,
),
if (error != null)
_notice(
context,
cupertino,
key: const Key('chat-composer-error'),
text: error,
failed: true,
),
];
return SafeArea(
top: false,
child: Padding(
key: const Key('chat-composer'),
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (commands.isNotEmpty)
Padding(
padding: const EdgeInsetsDirectional.only(bottom: 8),
child: ChatCommandPalette(
commands: commands,
selectedIndex: selected,
onSelected: _completeCommand,
),
),
if (!_attachments.isEmpty) _attachmentStrip(context, cupertino),
if (_uploading)
_notice(
context,
cupertino,
key: const Key('chat-composer-uploading'),
text: _attachments.attachments.length == 1
? 'Uploading 1 file…'
: 'Uploading ${_attachments.attachments.length} files…',
),
if (_attachmentError != null)
_notice(
context,
cupertino,
key: const Key('chat-composer-attachment-error'),
text: _attachmentError!,
failed: true,
),
if (_commandNotice != null) _commandReport(context, cupertino),
if (composer.queued)
_notice(
context,
cupertino,
key: const Key('chat-composer-queued'),
text: chatQueuedNotice,
),
if (error != null)
_notice(
context,
cupertino,
key: const Key('chat-composer-error'),
text: error,
failed: true,
),
if (widget.backgroundTasks != null)
Align(
alignment: AlignmentDirectional.centerEnd,
child: widget.backgroundTasks!,
),
_pill(
context,
cupertino,
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
_attach(context, cupertino),
Expanded(
child: Focus(
canRequestFocus: false,
includeSemantics: false,
onKeyEvent: _onKey,
child: _field(cupertino),
// The composer floats over the transcript in the conversation's
// centred reading column; the space beside it passes taps through.
child: Align(
heightFactor: 1,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: kChatReadingWidth),
child: Padding(
key: const Key('chat-composer'),
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 12),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (commands.isNotEmpty)
Padding(
padding: const EdgeInsetsDirectional.only(bottom: 8),
child: ChatCommandPalette(
commands: commands,
selectedIndex: selected,
onSelected: _completeCommand,
),
),
if (widget.running) ...[
_primary(context, cupertino, stop: true),
const SizedBox(width: 4),
],
_primary(context, cupertino),
],
),
_pill(
context,
cupertino,
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (extras.isNotEmpty)
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(
12,
8,
12,
0,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: extras,
),
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
_attach(context, cupertino),
Expanded(
child: Focus(
canRequestFocus: false,
includeSemantics: false,
onKeyEvent: _onKey,
child: _field(cupertino),
),
),
// Shown only while tasks run (or their list
// cannot be read); a quiet control, not a
// caption.
?widget.backgroundTasks,
if (widget.running) ...[
_primary(context, cupertino, stop: true),
const SizedBox(width: 4),
],
_primary(context, cupertino),
],
),
],
),
),
],
),
],
),
),
),
);
@@ -700,22 +734,17 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
);
}
/// The field and its controls in one rounded filled surface, in the host's
/// own fill role, so the composer reads as a single input rather than a row
/// of separate controls.
Widget _pill(BuildContext context, bool cupertino, Widget child) {
final fill = cupertino
? CupertinoColors.systemGrey6.resolveFrom(context)
: Theme.of(context).colorScheme.surfaceContainerHigh;
return DecoratedBox(
key: const Key('chat-composer-pill'),
decoration: BoxDecoration(
color: fill,
borderRadius: const BorderRadius.all(Radius.circular(28)),
),
child: Padding(padding: const EdgeInsets.all(4), child: child),
);
}
/// The field and its controls in one frosted-glass surface floating over
/// the transcript, so the composer reads as a single input rather than a
/// row of separate controls, and the conversation shows through it.
Widget _pill(BuildContext context, bool cupertino, Widget child) => GlassPill(
key: const Key('chat-composer-pill'),
cupertino: cupertino,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(28)),
),
child: Padding(padding: const EdgeInsets.all(4), child: child),
);
/// The attach control: a host button that opens the picker, disabled when the
/// host has no picker or one prompt is already awaiting its reply.
@@ -5,6 +5,7 @@ import '../../../core/api_gateway.dart';
import '../../../core/error_reason.dart';
import '../data/chat_repository.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'chat_bar_control_style.dart';
/// The conversation bar's permission-mode control.
///
@@ -118,14 +119,19 @@ class _ChatModeControlState extends State<ChatModeControl> {
key: key,
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: _open,
child: content,
child: chatBarCupertinoContent(context, content),
),
),
);
}
return Tooltip(
message: 'Change mode (currently $label)',
child: TextButton(key: key, onPressed: _open, child: content),
child: TextButton(
key: key,
style: chatBarTextButtonStyle(context),
onPressed: _open,
child: content,
),
);
}
}
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'chat_bar_control_style.dart';
import 'chat_model_chooser.dart';
import 'chat_models.dart';
@@ -135,14 +136,19 @@ class _ChatModelControlState extends State<ChatModelControl> {
key: key,
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: _open,
child: content,
child: chatBarCupertinoContent(context, content),
),
),
);
}
return Tooltip(
message: 'Change model (currently $label)',
child: TextButton(key: key, onPressed: _open, child: content),
child: TextButton(
key: key,
style: chatBarTextButtonStyle(context),
onPressed: _open,
child: content,
),
);
}
}
@@ -0,0 +1,10 @@
import 'dart:math' as math;
/// The widest the conversation's reading column grows: transcript rows and
/// the floating composer share it, centred, so a wide window keeps a
/// comfortable line length instead of stretching messages edge to edge.
const double kChatReadingWidth = 760;
/// The space on each side of the centred reading column in [width].
double chatReadingInset(double width) =>
math.max(0, (width - kChatReadingWidth) / 2);
@@ -28,7 +28,9 @@ import 'chat_models.dart';
import 'chat_row_keys.dart';
import 'chat_scroll.dart';
import 'chat_thread_controller.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/segmented_bar_overlay.dart';
import 'chat_reading_width.dart';
import 'chat_thread_header.dart';
import 'chat_transcript_cache.dart';
import 'chat_permission_card_model.dart';
@@ -717,124 +719,147 @@ class _ChatThreadViewState extends State<ChatThreadView> {
// Under the app shell the conversation takes over the app's bar (title,
// Back, model, information) instead of drawing a second bar below it.
final inShellBar = ShellBar.available(context);
final column = Column(
children: [
Expanded(
// The conversation's own bar floats over its transcript, which
// scrolls behind it.
child: SegmentedBarOverlay(
bar: _header(context, inShellBar),
child: NotificationListener<ScrollMetricsNotification>(
onNotification: _onScrollMetrics,
child: NotificationListener<ScrollNotification>(
onNotification: _onScrollNotification,
child: Stack(
// The transcript fills the page; the conversation's bar floats over its
// top and the frosted composer over its bottom, and history scrolls
// behind both.
final column = FloatingBarOverlay(
bar: ChatComposerBar(
key: ValueKey<String>('chat-composer-${widget.sessionId}'),
composer: _composer,
running: _controller.running,
commands: _commandActions(),
picker: widget.attachmentPicker,
images: _images,
placeholder: chatComposerPlaceholderFor(
'${widget.session?['directory'] ?? ''}',
),
backgroundTasks: ChatBackgroundTasks(
key: ValueKey('chat-background-tasks-${widget.sessionId}'),
gateway: widget.gateway,
sessionId: widget.sessionId,
syncToken: widget.syncToken,
),
),
child: SegmentedBarOverlay(
bar: _header(context, inShellBar),
child: NotificationListener<ScrollMetricsNotification>(
onNotification: _onScrollMetrics,
child: NotificationListener<ScrollNotification>(
onNotification: _onScrollNotification,
child: LayoutBuilder(
builder: (context, constraints) {
// Rows keep to the centred reading column on a wide
// window; the margins beside it still scroll the list.
final side = chatReadingInset(constraints.maxWidth);
final media = MediaQuery.paddingOf(context);
return Stack(
children: [
Builder(
// At rest the first item starts below the floating bar.
builder: (context) => ListView(
key: ValueKey<String>(
'chat-thread-${widget.sessionId}',
),
controller: _scroll,
padding: EdgeInsets.only(
top: MediaQuery.paddingOf(context).top + 8,
bottom: 8,
),
children: [
if (initialLoad)
Padding(
key: const Key('chat-thread-loading'),
padding: const EdgeInsets.all(16),
child: Center(
child: cupertino
? const CupertinoActivityIndicator()
: const CircularProgressIndicator(),
),
),
if (_controller.hasMore)
Padding(
key: const Key('chat-load-older'),
padding: const EdgeInsets.symmetric(
horizontal: 16,
),
child: Align(
alignment: AlignmentDirectional.centerStart,
child: cupertino
? CupertinoButton(
padding: EdgeInsets.zero,
onPressed: _controller.loading
? null
: _controller.loadOlder,
child: const Text('Load older'),
)
: TextButton(
onPressed: _controller.loading
? null
: _controller.loadOlder,
child: const Text('Load older'),
),
),
),
if (historyNotice != null)
_ChatNoticeLine(
key: const Key('chat-history-error'),
notice: historyNotice,
onDismiss: _dismiss,
onRetry: _controller.load,
),
if (liveNotice != null)
_ChatNoticeLine(
key: const Key('chat-live-error'),
notice: liveNotice,
onDismiss: _dismiss,
onRetry: _controller.resync,
),
if (_controller.loaded &&
allRows.isEmpty &&
allNotices.isEmpty &&
_commandNotices.isEmpty &&
_controller.error == null)
const Padding(
key: Key('chat-thread-empty'),
padding: EdgeInsets.all(16),
child: Text('No messages in this chat yet.'),
),
for (var index = 0; index < rows.length; index++)
Padding(
key: ValueKey<String>(keys[index]),
padding: const EdgeInsets.symmetric(
horizontal: 16,
),
child: _transcriptRow(
rows[index],
onDismissCompaction:
compactionNotice != null &&
chatNoticeActivityCondition(
rows[index],
) ==
compactionNotice.condition
? () => _dismiss(compactionNotice)
: null,
),
),
// The conversation's own command lines sit after the
// turns, as on the web; they are never bubbles.
for (final notice in _commandNotices)
_ChatNoticeLine(
key: ValueKey<String>(
'chat-command-notice-${notice.condition}',
),
notice: notice,
onDismiss: _dismiss,
),
],
// At rest the first item starts below the floating bar
// and the last one ends above the floating composer.
ListView(
key: ValueKey<String>(
'chat-thread-${widget.sessionId}',
),
controller: _scroll,
padding: EdgeInsets.fromLTRB(
side,
media.top + 8,
side,
media.bottom + 8,
),
children: [
if (initialLoad)
Padding(
key: const Key('chat-thread-loading'),
padding: const EdgeInsets.all(16),
child: Center(
child: cupertino
? const CupertinoActivityIndicator()
: const CircularProgressIndicator(),
),
),
if (_controller.hasMore)
Padding(
key: const Key('chat-load-older'),
padding: const EdgeInsets.symmetric(
horizontal: 16,
),
child: Align(
alignment: AlignmentDirectional.centerStart,
child: cupertino
? CupertinoButton(
padding: EdgeInsets.zero,
onPressed: _controller.loading
? null
: _controller.loadOlder,
child: const Text('Load older'),
)
: TextButton(
onPressed: _controller.loading
? null
: _controller.loadOlder,
child: const Text('Load older'),
),
),
),
if (historyNotice != null)
_ChatNoticeLine(
key: const Key('chat-history-error'),
notice: historyNotice,
onDismiss: _dismiss,
onRetry: _controller.load,
),
if (liveNotice != null)
_ChatNoticeLine(
key: const Key('chat-live-error'),
notice: liveNotice,
onDismiss: _dismiss,
onRetry: _controller.resync,
),
if (_controller.loaded &&
allRows.isEmpty &&
allNotices.isEmpty &&
_commandNotices.isEmpty &&
_controller.error == null)
const Padding(
key: Key('chat-thread-empty'),
padding: EdgeInsets.all(16),
child: Text('No messages in this chat yet.'),
),
for (var index = 0; index < rows.length; index++)
Padding(
key: ValueKey<String>(keys[index]),
padding: const EdgeInsets.symmetric(
horizontal: 16,
),
child: _transcriptRow(
rows[index],
onDismissCompaction:
compactionNotice != null &&
chatNoticeActivityCondition(
rows[index],
) ==
compactionNotice.condition
? () => _dismiss(compactionNotice)
: null,
),
),
// The conversation's own command lines sit after the
// turns, as on the web; they are never bubbles.
for (final notice in _commandNotices)
_ChatNoticeLine(
key: ValueKey<String>(
'chat-command-notice-${notice.condition}',
),
notice: notice,
onDismiss: _dismiss,
),
],
),
if (showJump)
PositionedDirectional(
end: 16,
bottom: 16,
end: side + 16,
bottom: media.bottom + 16,
child: _ChatJumpToLatest(
key: const Key('chat-jump-to-latest'),
label: chatJumpToLatestLabel(newMessages),
@@ -843,29 +868,12 @@ class _ChatThreadViewState extends State<ChatThreadView> {
),
),
],
),
),
);
},
),
),
),
ChatComposerBar(
key: ValueKey<String>('chat-composer-${widget.sessionId}'),
composer: _composer,
running: _controller.running,
commands: _commandActions(),
picker: widget.attachmentPicker,
images: _images,
placeholder: chatComposerPlaceholderFor(
'${widget.session?['directory'] ?? ''}',
),
backgroundTasks: ChatBackgroundTasks(
key: ValueKey('chat-background-tasks-${widget.sessionId}'),
gateway: widget.gateway,
sessionId: widget.sessionId,
syncToken: widget.syncToken,
),
),
],
),
);
if (!inShellBar) return column;
// The conversation draws its own floating bar; the page shows none.
@@ -885,6 +893,10 @@ class _ChatThreadViewState extends State<ChatThreadView> {
final session = widget.session;
final hasModel =
session != null && supportsChatModels('${session['backend'] ?? ''}');
// The mode control has nothing to show (or change) without both facts.
final hasMode =
'${session?['mode'] ?? ''}'.trim().isNotEmpty &&
'${session?['mode_name'] ?? ''}'.trim().isNotEmpty;
final canGoBack = inShellBar
? ModalRoute.of(context)?.impliesAppBarDismissal ?? false
: true;
@@ -901,23 +913,40 @@ class _ChatThreadViewState extends State<ChatThreadView> {
// A pushed page keeps the platform's stock Back (pop this route); a
// standalone conversation calls its owner.
onBack: inShellBar ? null : widget.onBack,
// Natural width while the bar has room; past the title's share both
// controls ellipsise. A session without a mode draws no mode control,
// so no empty pill is ever drawn.
controls: [
if (hasModel)
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 160),
child: ChatModelControl(
key: ValueKey<String>('chat-model-${widget.sessionId}'),
gateway: widget.gateway,
sessionId: widget.sessionId,
session: session,
onChanged: widget.onModelChanged,
answeredBy: latestReplyModel(_controller.messages),
if (hasModel || hasMode)
LayoutBuilder(
builder: (context, constraints) => Row(
mainAxisSize: MainAxisSize.min,
children: [
if (hasModel)
Flexible(
child: ChatModelControl(
key: ValueKey<String>('chat-model-${widget.sessionId}'),
gateway: widget.gateway,
sessionId: widget.sessionId,
session: session,
onChanged: widget.onModelChanged,
answeredBy: latestReplyModel(_controller.messages),
),
),
if (hasMode)
// The mode keeps its whole name until it would take more
// than half the pill; the model takes the rest.
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: hasModel
? constraints.maxWidth / 2
: constraints.maxWidth,
),
child: _modeControl(),
),
],
),
),
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 140),
child: _modeControl(),
),
],
);
}
@@ -193,66 +193,75 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
return ListenableBuilder(
listenable: _controller,
builder: (context, _) {
final controls = chatControlsStyleOf(context);
final body = Column(
children: [
if (_controller.error != null)
ChatErrorNotice(
message: _controller.error!,
onRetry: _controller.refresh,
),
Expanded(
child: Stack(
children: [
ContentWidth(
child: ChatSessionsBody(
sessions: _controller.sessions,
activeSessionId: widget.activeSessionId,
query: _search.text,
loading: _controller.loading,
error: _controller.error,
onOpen: _open,
onRename: _rename,
onClose: _close,
onReopen: (session) =>
_controller.reopen(_sessionId(session)),
onStar: (session) => _controller.star(
_sessionId(session),
session['starred'] != true,
),
onHide: _hide,
onClearSearch: () {
_search.clear();
setState(() {});
},
isUnseen: _controller.isUnseen,
errorFor: _controller.errorFor,
onDismissError: _controller.dismissError,
),
// Built under the page's scaffold, whose media padding carries the
// floating bar's height.
final body = Builder(
builder: (context) => Column(
children: [
// A notice above the list starts below the floating bar; the list
// under it then needs no inset of its own.
if (_controller.error != null)
Padding(
padding: EdgeInsets.only(
top: MediaQuery.paddingOf(context).top,
),
// The web's hide report is a fixed overlay: replacing or
// growing it must never move the list or overflow the screen.
// A standalone Material screen keeps it clear of the FAB.
if (_controller.lastHidden != null)
Positioned(
left: 8,
right: 8,
bottom:
!widget.embedded &&
controls == ChatControlsStyle.material
? 88
: 8,
child: ChatUndoBar(
key: const Key('chat-undo-hide'),
message:
'Hidden on this device; the chat stays on the server.',
onUndo: _undoHide,
child: ChatErrorNotice(
message: _controller.error!,
onRetry: _controller.refresh,
),
),
Expanded(
child: MediaQuery.removePadding(
context: context,
removeTop: _controller.error != null,
child: Stack(
children: [
ContentWidth(
child: ChatSessionsBody(
sessions: _controller.sessions,
activeSessionId: widget.activeSessionId,
query: _search.text,
loading: _controller.loading,
error: _controller.error,
onOpen: _open,
onRename: _rename,
onClose: _close,
onReopen: (session) =>
_controller.reopen(_sessionId(session)),
onStar: (session) => _controller.star(
_sessionId(session),
session['starred'] != true,
),
onHide: _hide,
onClearSearch: () {
_search.clear();
setState(() {});
},
isUnseen: _controller.isUnseen,
errorFor: _controller.errorFor,
onDismissError: _controller.dismissError,
),
),
),
],
// The web's hide report is a fixed overlay: replacing or
// growing it must never move the list or overflow the screen.
if (_controller.lastHidden != null)
Positioned(
left: 8,
right: 8,
bottom: 8,
child: ChatUndoBar(
key: const Key('chat-undo-hide'),
message:
'Hidden on this device; the chat stays on the server.',
onUndo: _undoHide,
),
),
],
),
),
),
),
],
],
),
);
// Under the shell, New chat and Refresh are its bar's actions; the
@@ -291,7 +300,9 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
title: 'Chats',
actions: _actions(),
),
child: SafeArea(child: body),
// The list scrolls behind the bar, which does not fully obstruct;
// it pads its first row by the bar's height itself.
child: SafeArea(top: false, child: body),
);
}
return Scaffold(
@@ -301,13 +312,9 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
title: 'Chats',
actions: _actions(),
),
body: SafeArea(left: false, right: false, bottom: false, child: body),
floatingActionButton: FloatingActionButton.extended(
key: const Key('chat-new-chat-fab'),
onPressed: _newChat,
icon: const Icon(Icons.add),
label: const Text('New chat'),
),
// The list scrolls behind the floating bar; New chat is the bar's
// own action, so there is no second create button.
body: body,
);
},
);
@@ -48,9 +48,11 @@ class CupertinoSessionList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView(
// Starts below a floating top bar (its height arrives as media top
// padding) and ends clear of a floating bottom bar.
padding: withFloatingBarClearance(
context,
const EdgeInsets.only(bottom: 24),
EdgeInsets.only(top: MediaQuery.paddingOf(context).top, bottom: 24),
),
children: [
for (final section in sections) ..._section(section),
+107
View File
@@ -0,0 +1,107 @@
# Chat chrome fixes (style review F5, F23, F29, F14, F24, F1-chat)
Findings from the whole-app style review (`/tmp/app-style-review/report.md`),
chat screens only (`lib/features/chat/**`). Shared primitives in
`lib/ui/adaptive/` are used, not changed.
## F5 — floating glass composer
- `ChatThreadView` no longer stacks the transcript above the composer in a
`Column`. The transcript fills the page inside `FloatingBarOverlay(bar:
ChatComposerBar, child: SegmentedBarOverlay(header, transcript))`: the header
floats over its top, the composer over its bottom, and history scrolls behind
both.
- The list pads its end by `MediaQuery.paddingOf(context).bottom + 8` (the
composer's measured height from the overlay), so at rest the last message sits
fully above the composer. The follow logic is unchanged: a taller composer
(multi-line draft, attachments, notices) changes the list's extent, and a
following view stays pinned to the end (`_onScrollMetrics`). Jump to latest
floats 16 above the composer.
- `ChatComposerBar._pill` is a `GlassPill` (rounded rectangle, radius 28), key
`chat-composer-pill`. The attachment strip, upload/attachment-error/command
report/queued/error notices now sit inside the glass above the field row; the
command palette (an opaque card/menu) still floats above the pill. Keyboard
insets, `SafeArea(top: false)`, Send/Stop, attach and every key are unchanged.
The space beside and above the pill passes taps through to the transcript.
## F23 — no "0 tasks"
`ChatBackgroundTasks` builds nothing when no task runs (also while the first
read is loading); with tasks it is a quiet neutral control (`onSurfaceVariant` /
`secondaryLabel`, a layers icon and "n task(s)") inside the composer pill,
before Send. A list that cannot be read still shows "Tasks" so its refusal stays
reachable. Key `chat-background-tasks-button` kept.
## F29 — reading width
`chat_reading_width.dart`: `kChatReadingWidth = 760`, `chatReadingInset(width)`.
The transcript `ListView` still spans the window (its margins scroll it) and
pads each side by the inset; the composer is centred and capped at the same
760, so the pill lines up with the rows (both keep the 16 margins).
## F14 — header controls
- No fixed 160/140 caps: the controls take their natural width while the bar
has room ("Ask for permission" whole at 560 and 1200 in Material). Under
pressure the mode keeps at most half the actions pill and the model ellipsises
first (`SegmentedBar` still caps the whole pill at the title's 25% share).
- A session without both `mode` and `mode_name` gets no mode control, and with
no model either there are no actions, so `SegmentedBar` draws no (empty)
actions pill.
- Neutral colours (`chat_bar_control_style.dart`): Material `TextButton` in
`onSurfaceVariant` (the bar's icon buttons' role), Cupertino content in
`CupertinoColors.label`.
## F24 / F1 — chat list
- The standalone Material list's "New chat" FAB is gone; the bar's +
(`chat-new-chat`) is the one create action. The hide/undo bar sits 8 from the
bottom on every host.
- The standalone list scrolls behind its bar: Material drops the top-only
`SafeArea` (the default `ListView` padding takes the bar height), Cupertino
keeps `SafeArea(top: false)` and the list pads its top by the media top. The
body is built under the scaffold (`Builder`) so it reads the scaffold's
padding, and a load-error notice is pushed below the bar while the list under
it drops the inset. Under the shell (`embedded`) nothing changes; the shell
owns that.
## Tests
New: `test/features/chat/conversation/chat_floating_chrome_test.dart` (both
hosts: composer is a `GlassPill` over a full-height transcript and the last
message rests above it, then scrolls behind; 1200 window caps pill and rows to
the centred 760 column while the list spans the window; 560 pill = width − 32;
no empty actions pill without model/mode; at 1200 neither control is truncated;
neutral colours), `test/features/chat/ui/sessions/chat_sessions_floating_bar_test.dart`
(both hosts: list reaches under the bar, first section starts below it; no FAB,
one New chat in the bar).
Updated: background-task tests (no control and never "0 tasks" for an empty
snapshot or after a session switch; the control sits inside the pill beside
Send in neutral colour; the owner-disposal test now has a task to open), the
three create-dialog tests tap `chat-new-chat` instead of the removed FAB, and
`expand_closed.dart` centres the Closed heading before tapping it (at the top
edge it is under the floating bar).
## Evidence
Headless Chrome (`/tmp/fix-b-scripts/shoot.mjs`, a copy of the review's
script) in `/tmp/fix-b-evidence/`:
- `cc-*`: `tool/chat_composer_probe_entry.dart`, which now also reads
`?platform=`, `?theme=`, `?long=1`, `?tasks=n`, `?mode=0`, `?model=0`:
560/1200 × light/dark × Material/Cupertino, scrolled behind the composer,
with tasks, without model/mode, and a three-line draft at 1200.
- `cs-*`: `tool/chat_sessions_probe_entry.dart` (now `?platform=` and
`?many=1`): 560/1200 × light/dark × Material/Cupertino, scrolled behind the
bar.
- `app-*`: the full web build over the runs fixture (thread 560/1200
light/dark, the command palette above the pill, the shell chat list).
## Not done / notes
- Cupertino dark glass is nearly invisible against black (review F17); that is
`GlassPill`'s fill, owned by another batch.
- The conversation header is not width-capped (it spans the pane like every
other segmented bar).
- No device run; Android/iOS keyboard behaviour is unverified on hardware
(the structure keeps the scaffold's inset handling and the composer's
`SafeArea`).
@@ -94,7 +94,12 @@ void main() {
find.byKey(const Key('chat-background-tasks-modal')),
findsNothing,
);
expect(find.text('0 tasks'), findsOneWidget);
// The other session runs nothing: no control, never a "0 tasks".
expect(find.text('0 tasks'), findsNothing);
expect(
find.byKey(const Key('chat-background-tasks-button')),
findsNothing,
);
expect(find.text('old session output'), findsNothing);
expect(tester.takeException(), isNull);
},
@@ -104,7 +109,10 @@ void main() {
testWidgets(
'owner disposal removes only its modal, not an unrelated top route',
(tester) async {
final gateway = TasksGateway();
final gateway = TasksGateway()
..shells = (_) async => {
'chat_shells': [task('a')],
};
addTearDown(gateway.close);
var visible = true;
late StateSetter rebuild;
@@ -156,7 +156,7 @@ void main() {
]);
});
testWidgets('an empty snapshot shows zero tasks and an honest empty modal', (
testWidgets('an empty snapshot shows no task control, never "0 tasks"', (
tester,
) async {
final gateway = _TasksGateway();
@@ -165,11 +165,10 @@ void main() {
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(find.text('0 tasks'), findsOneWidget);
expect(find.text('Background tasks'), findsNothing);
expect(find.text('0 tasks'), findsNothing);
expect(find.textContaining('task'), findsNothing);
expect(find.byKey(const Key('chat-background-tasks-button')), findsNothing);
expect(gateway.fieldsFor('chat_shells'), hasLength(1));
await _openTasks(tester);
expect(find.text('No background tasks running.'), findsOneWidget);
});
testWidgets('pushed shell frames add and remove this session tasks', (
@@ -612,7 +611,7 @@ void main() {
expect(find.text('go test ./...'), findsNothing);
});
testWidgets('the task badge sits above Send, outside the transcript', (
testWidgets('the task control sits inside the composer pill beside Send', (
tester,
) async {
final gateway = _TasksGateway();
@@ -622,19 +621,39 @@ void main() {
await tester.pumpWidget(_thread(gateway));
await tester.pumpAndSettle();
final tasks = tester.getRect(
find.byKey(const Key('chat-background-tasks-button')),
);
final list = tester.getRect(
find.byKey(const ValueKey<String>('chat-thread-s')),
final button = find.byKey(const Key('chat-background-tasks-button'));
expect(
find.descendant(
of: find.byKey(const Key('chat-composer-pill')),
matching: button,
),
findsOneWidget,
);
final tasks = tester.getRect(button);
final send = tester.getRect(find.byKey(const Key('chat-composer-primary')));
final composer = tester.getRect(
find.byKey(const ValueKey('chat-composer-s')),
expect(tasks.right, lessThanOrEqualTo(send.left));
expect(tasks.bottom, greaterThan(send.top));
expect(tasks.top, lessThan(send.bottom));
// Neutral, not the primary tint.
final style = tester.widget<TextButton>(button).style!;
final theme = Theme.of(tester.element(button));
expect(
style.foregroundColor!.resolve({}),
theme.colorScheme.onSurfaceVariant,
);
expect(tasks.bottom, lessThanOrEqualTo(send.top));
expect(send.center.dx, inInclusiveRange(tasks.left, tasks.right));
expect(tasks.top, greaterThanOrEqualTo(composer.top));
expect(list.bottom, lessThanOrEqualTo(composer.top));
});
testWidgets('a conversation without tasks shows no task caption', (
tester,
) async {
final gateway = _TasksGateway();
addTearDown(gateway.close);
await tester.pumpWidget(_thread(gateway));
await tester.pumpAndSettle();
expect(find.text('0 tasks'), findsNothing);
expect(find.byKey(const Key('chat-background-tasks-button')), findsNothing);
expect(find.byKey(const Key('chat-composer-primary')), findsOneWidget);
});
}
@@ -0,0 +1,210 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/conversation/chat_reading_width.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar_pieces.dart';
import 'chat_thread_fixtures.dart';
/// Floating composer, reading width and header controls of a conversation.
Widget _host(Widget child, {required bool cupertino}) => cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: child))
: MaterialApp(
theme: ThemeData(platform: TargetPlatform.android),
home: Scaffold(body: child),
);
void _size(WidgetTester tester, Size size) {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
}
List<Map<String, dynamic>> _messages(int count) => [
for (var index = 0; index < count; index++)
chatMessage(
'm$index',
index.isEven ? 'user' : 'assistant',
parts: [
{'type': 'text', 'text': 'Message number $index of the transcript.'},
],
),
];
Future<FakeChatGateway> _pump(
WidgetTester tester, {
required bool cupertino,
int messages = 30,
Map<String, dynamic>? session,
}) async {
final gateway = FakeChatGateway();
addTearDown(gateway.close);
gateway.history = (_) async => chatPage(_messages(messages));
gateway.subscribe = () async => const {};
await tester.pumpWidget(
_host(
ChatThreadView(
gateway: gateway,
sessionId: 's',
title: 'Floating chrome',
session: session,
onBack: () {},
),
cupertino: cupertino,
),
);
await tester.pumpAndSettle();
return gateway;
}
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host composer floats as glass with the transcript behind', (
tester,
) async {
_size(tester, const Size(560, 800));
await _pump(tester, cupertino: cupertino);
final pill = find.byKey(const Key('chat-composer-pill'));
expect(tester.widget(pill), isA<GlassPill>());
// The transcript fills the page: it runs under the composer.
final list = tester.getRect(find.byKey(const ValueKey('chat-thread-s')));
final composer = tester.getRect(pill);
expect(list.bottom, 800);
expect(composer.bottom, lessThanOrEqualTo(800));
expect(composer.top, greaterThan(list.top));
expect(list.bottom, greaterThanOrEqualTo(composer.bottom));
// Following the end, the last message rests fully above the composer.
final last = tester.getRect(
find.text('Message number 29 of the transcript.'),
);
expect(last.bottom, lessThanOrEqualTo(composer.top));
// Scrolling back up passes history behind the floating composer.
await tester.drag(
find.byKey(const ValueKey('chat-thread-s')),
const Offset(0, 120),
);
await tester.pumpAndSettle();
final behind = find.text('Message number 29 of the transcript.');
if (behind.evaluate().isNotEmpty) {
expect(tester.getRect(behind).top, greaterThan(last.top));
}
expect(tester.takeException(), isNull);
});
testWidgets('$host transcript and composer share a centred reading width', (
tester,
) async {
_size(tester, const Size(1200, 800));
await _pump(tester, cupertino: cupertino, messages: 4);
final pill = tester.getRect(find.byKey(const Key('chat-composer-pill')));
expect(pill.width, lessThanOrEqualTo(kChatReadingWidth));
expect(pill.center.dx, closeTo(600, 1));
final message = tester.getRect(
find.text('Message number 0 of the transcript.'),
);
final inset = chatReadingInset(1200);
expect(message.left, greaterThanOrEqualTo(inset));
expect(message.right, lessThanOrEqualTo(1200 - inset));
// The list itself still spans the window, so its margins scroll it.
expect(
tester.getRect(find.byKey(const ValueKey('chat-thread-s'))).width,
1200,
);
// Narrow, the column fills the width less the usual margins.
_size(tester, const Size(560, 800));
await tester.pumpAndSettle();
expect(
tester.getRect(find.byKey(const Key('chat-composer-pill'))).width,
560 - 32,
);
});
testWidgets('$host header draws no empty pill without model or mode', (
tester,
) async {
_size(tester, const Size(560, 800));
await _pump(
tester,
cupertino: cupertino,
messages: 1,
session: const {'id': 's', 'backend': 'pi', 'directory': '/srv'},
);
final header = find.byKey(const Key('chat-thread-header'));
expect(find.byKey(const Key('chat-mode')), findsNothing);
// Only the round Back and the title pill: no (empty) actions pill.
expect(
find.descendant(of: header, matching: find.byType(SegmentedPill)),
findsNWidgets(2),
);
});
testWidgets('$host header controls keep their natural width when wide', (
tester,
) async {
_size(tester, const Size(1200, 800));
await _pump(
tester,
cupertino: cupertino,
messages: 1,
session: const {
'id': 's',
'backend': 'opencode',
'model': 'p/sonnet-4-5',
'mode': 'default',
'mode_name': 'Ask for permission',
},
);
final mode = find.byKey(const Key('chat-mode'));
final model = find.byKey(const Key('chat-model'));
expect(mode, findsOneWidget);
expect(model, findsOneWidget);
for (final control in [mode, model]) {
final texts = find.descendant(of: control, matching: find.byType(Text));
for (final element in texts.evaluate()) {
final paragraph = element.renderObject! as RenderParagraph;
expect(
paragraph.didExceedMaxLines,
isFalse,
reason: 'truncated at 1200',
);
}
}
// Neutral like the bar's other actions, not the primary tint.
if (!cupertino) {
final button = tester.widget<TextButton>(mode);
final theme = Theme.of(tester.element(mode));
expect(
button.style!.foregroundColor!.resolve({}),
theme.colorScheme.onSurfaceVariant,
);
} else {
final label = tester.widget<RichText>(
find.descendant(
of: mode,
matching: find.byWidgetPredicate(
(widget) =>
widget is RichText &&
widget.text.toPlainText() == 'Ask for permission',
),
),
);
expect(
label.text.style?.color,
CupertinoColors.label.resolveFrom(tester.element(mode)),
);
}
});
}
}
@@ -21,7 +21,7 @@ void main() {
onOpen: (session) => opened = session,
);
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
await tester.tap(find.byKey(const Key('chat-new-chat')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
expect(find.text('Loading directories…'), findsOneWidget);
@@ -115,7 +115,7 @@ void main() {
gateway.directoriesHandler = () async => {'chat_directories': []};
await pumpMaterialChat(tester, gateway);
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
await tester.tap(find.byKey(const Key('chat-new-chat')));
await tester.pumpAndSettle();
expect(find.text('Home (~) — ~'), findsOneWidget);
await tester.tap(find.byKey(const Key('chat-create-confirm')));
@@ -210,7 +210,7 @@ void main() {
final refresh = Completer<JsonMap>();
gateway.pendingSessions.add(refresh);
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
await tester.tap(find.byKey(const Key('chat-new-chat')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-create-confirm')));
await tester.pump();
@@ -65,7 +65,7 @@ void main() {
};
await pumpMaterialChat(tester, gateway);
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
await tester.tap(find.byKey(const Key('chat-new-chat')));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
await tester.ensureVisible(find.byKey(const Key('chat-create-send-prompt')));
@@ -30,7 +30,7 @@ void main() {
onOpen: (session) => opened = session,
);
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
await tester.tap(find.byKey(const Key('chat-new-chat')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
await tester.pumpAndSettle();
@@ -63,7 +63,7 @@ void main() {
gateway.createHandler = (_) => reply.future;
await pumpMaterialChat(tester, gateway);
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
await tester.tap(find.byKey(const Key('chat-new-chat')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-create-confirm')));
await tester.pump();
@@ -196,7 +196,7 @@ void main() {
final gateway = FakeChatGateway()..createReply = const {};
await pumpMaterialChat(tester, gateway);
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
await tester.tap(find.byKey(const Key('chat-new-chat')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
await tester.pumpAndSettle();
@@ -0,0 +1,62 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'chat_test_harness.dart';
import 'fake_chat_gateway.dart';
/// The standalone chat list scrolls behind its floating bar and creates chats
/// from the bar's one New chat action.
List<JsonMap> _many() => [
for (var index = 0; index < 30; index++)
{'id': 's$index', 'title': 'Chat $index', 'directory': '/work'},
];
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host list scrolls behind the bar and starts below it', (
tester,
) async {
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': _many()};
if (cupertino) {
await pumpCupertinoChat(tester, gateway);
} else {
await pumpMaterialChat(tester, gateway);
}
final bar = tester.getRect(find.byType(SegmentedBar));
final list = tester.getRect(find.byType(ListView).first);
// The list reaches under the bar ...
expect(list.top, lessThan(bar.bottom));
// ... yet at rest its first row is clear of it.
final first = tester.getRect(
find.byKey(const ValueKey('chat-section-Chats')),
);
expect(first.top, greaterThanOrEqualTo(bar.bottom));
expect(tester.takeException(), isNull);
});
}
testWidgets('the standalone Material list has one New chat, in the bar', (
tester,
) async {
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': _many()};
await pumpMaterialChat(tester, gateway);
expect(find.byType(FloatingActionButton), findsNothing);
expect(find.byKey(const Key('chat-new-chat-fab')), findsNothing);
expect(
find.descendant(
of: find.byType(SegmentedBar),
matching: find.byKey(const Key('chat-new-chat')),
),
findsOneWidget,
);
});
}
@@ -12,7 +12,10 @@ Future<void> expandClosedChats(WidgetTester tester) async {
);
}
final heading = find.descendant(of: section, matching: find.text('Closed'));
await tester.ensureVisible(heading.first);
// Centred rather than at the top edge: the list scrolls behind a floating
// bar, which would take a tap at the edge.
await Scrollable.ensureVisible(tester.element(heading.first), alignment: 0.5);
await tester.pumpAndSettle();
await tester.tap(heading.first);
await tester.pumpAndSettle();
}
+32 -6
View File
@@ -27,12 +27,24 @@ class _ProbeGateway implements ApiGateway {
switch (type) {
case 'chat_subscribe':
return <String, dynamic>{};
case 'chat_shells':
// `?tasks=2` reports that many running background tasks.
return {
'chat_shells': [
for (var i = 0; i < _probeTasks; i++)
{
'id': 'probe-shell-$i',
'status': 'running',
'command': 'go test ./... #$i',
},
],
};
case 'chat_messages':
return {
'chat_history': {
'messages': [
// A long history scrolls behind the floating header.
if (_probeLong)
if (_probeLong || _query['long'] == '1')
for (var i = 0; i < 12; i++)
{
'id': 'probe-history-$i',
@@ -133,26 +145,40 @@ const _probeStyle = String.fromEnvironment(
defaultValue: 'material',
);
/// Browser overrides: `?platform=cupertino|material`, `?theme=dark|light`,
/// `?long=1`, `?tasks=<n>`, `?mode=0` (no permission mode recorded) and
/// `?model=0` (a backend without models).
Map<String, String> get _query => Uri.base.queryParameters;
int get _probeTasks => int.tryParse(_query['tasks'] ?? '') ?? 0;
void main() {
final gateway = _ProbeGateway();
final cupertino = (_query['platform'] ?? _probeStyle) == 'cupertino';
final dark = _query['theme'] == null ? cupertino : _query['theme'] == 'dark';
final thread = ChatThreadView(
gateway: gateway,
sessionId: 'probe-composer',
title: 'Composer fixture',
session: const {
session: {
'id': 'probe-composer',
'backend': 'opencode',
'backend': _query['model'] == '0' ? 'pi' : 'opencode',
'model': _probeModel,
'directory': '/Users/ada/repos/tank',
if (_query['mode'] != '0') ...{
'mode': 'default',
'mode_name': 'Ask for permission',
},
},
onBack: () {},
drafts: MemoryChatDraftStore(),
newOperationId: gateway.nextOperation,
);
if (_probeStyle == 'cupertino') {
if (cupertino) {
runApp(
CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark),
theme: CupertinoThemeData(
brightness: dark ? Brightness.dark : Brightness.light,
),
home: CupertinoPageScaffold(child: _framed(SafeArea(child: thread))),
),
);
@@ -162,7 +188,7 @@ void main() {
MaterialApp(
theme: ThemeData(
platform: TargetPlatform.android,
brightness: Brightness.light,
brightness: dark ? Brightness.dark : Brightness.light,
),
home: Scaffold(body: _framed(SafeArea(child: thread))),
),
+16 -5
View File
@@ -132,11 +132,22 @@ const _probeStyle = String.fromEnvironment(
void main() {
final dark = Uri.base.queryParameters['dark'] == '1';
final unseen = Uri.base.queryParameters['unseen'] == '1';
final home = ChatSessionsScreen(
gateway: _FixtureGateway(bumpAfterFirstRead: unseen),
onOpen: (_) {},
);
if (_probeStyle == 'cupertino') {
final gateway = _FixtureGateway(bumpAfterFirstRead: unseen);
// `?many=1` adds enough chats to scroll the list behind the bar.
if (Uri.base.queryParameters['many'] == '1') {
gateway._sessions.addAll([
for (var i = 0; i < 24; i++)
{
'id': 'probe-many-$i',
'title': 'Fixture chat ${i + 1}',
'directory': '/workspace/demo',
},
]);
}
final home = ChatSessionsScreen(gateway: gateway, onOpen: (_) {});
// `?platform=cupertino` overrides the compile-time style.
final style = Uri.base.queryParameters['platform'] ?? _probeStyle;
if (style == 'cupertino') {
runApp(
CupertinoApp(
theme: CupertinoThemeData(