Remove Cupertino chat transcript branches
Keep the existing Material transcript path while preserving public Cupertino parameters for callers. Narrow transcript tests to the Material-only behavior and remove Cupertino-only fixtures.
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
|
||||
/// Rounds an attachment thumbnail and draws a subtle hairline around it, so a
|
||||
/// dark screenshot on a dark page (or a light one on a light page) still reads
|
||||
/// as a separate object. The line sits over the image's edge, in the host's
|
||||
@@ -19,11 +16,7 @@ class ChatAttachmentFrame extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final line = cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.outlineVariant;
|
||||
final line = Theme.of(context).colorScheme.outlineVariant;
|
||||
return Container(
|
||||
key: const Key('chat-attachment-frame'),
|
||||
foregroundDecoration: BoxDecoration(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/chat_attachment_images.dart';
|
||||
@@ -87,9 +86,7 @@ class _ChatAttachmentThumbnailState extends State<ChatAttachmentThumbnail> {
|
||||
Widget _decoding(BuildContext context) => SizedBox.square(
|
||||
dimension: 96,
|
||||
child: ColoredBox(
|
||||
color: widget.cupertino
|
||||
? CupertinoColors.systemGrey5.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -97,11 +94,7 @@ class _ChatAttachmentThumbnailState extends State<ChatAttachmentThumbnail> {
|
||||
Widget _pending(BuildContext context) => SizedBox.square(
|
||||
key: const Key('chat-attachment-thumbnail-loading'),
|
||||
dimension: 96,
|
||||
child: Center(
|
||||
child: widget.cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
),
|
||||
child: const Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
|
||||
Widget _thumbnail(BuildContext context, Uint8List bytes) {
|
||||
@@ -147,30 +140,20 @@ class _ChatAttachmentThumbnailState extends State<ChatAttachmentThumbnail> {
|
||||
label: widget.name,
|
||||
excludeSemantics: true,
|
||||
onTap: open,
|
||||
child: widget.cupertino
|
||||
? CupertinoButton(
|
||||
key: const Key('chat-attachment-thumbnail'),
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: Size.zero,
|
||||
onPressed: open,
|
||||
child: constrained,
|
||||
)
|
||||
: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
key: const Key('chat-attachment-thumbnail'),
|
||||
borderRadius: _radius,
|
||||
onTap: open,
|
||||
child: constrained,
|
||||
),
|
||||
),
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
key: const Key('chat-attachment-thumbnail'),
|
||||
borderRadius: _radius,
|
||||
onTap: open,
|
||||
child: constrained,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _placeholder(BuildContext context, String reason) {
|
||||
final secondary = widget.cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
return Semantics(
|
||||
key: const Key('chat-attachment-thumbnail-unavailable'),
|
||||
label: '${widget.name}, $reason',
|
||||
@@ -180,12 +163,7 @@ class _ChatAttachmentThumbnailState extends State<ChatAttachmentThumbnail> {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
widget.cupertino
|
||||
? CupertinoIcons.photo
|
||||
: Icons.broken_image_outlined,
|
||||
color: secondary,
|
||||
),
|
||||
Icon(Icons.broken_image_outlined, color: secondary),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'chat_copy_button.dart';
|
||||
@@ -62,31 +61,15 @@ class ChatCodeHover {
|
||||
child: MouseRegion(
|
||||
onEnter: (_) => _exit?.cancel(),
|
||||
onExit: (_) => scheduleHide(token),
|
||||
child: cupertino
|
||||
? DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.secondarySystemBackground
|
||||
.resolveFrom(context),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: CupertinoColors.separator.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
child: ChatCopyButton(
|
||||
text: text,
|
||||
cupertino: true,
|
||||
showLabel: true,
|
||||
),
|
||||
)
|
||||
: Material(
|
||||
elevation: 3,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: ChatCopyButton(
|
||||
text: text,
|
||||
cupertino: false,
|
||||
showLabel: true,
|
||||
),
|
||||
),
|
||||
child: Material(
|
||||
elevation: 3,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: ChatCopyButton(
|
||||
text: text,
|
||||
cupertino: false,
|
||||
showLabel: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
@@ -62,38 +61,13 @@ class _ChatCopyButtonState extends State<ChatCopyButton> {
|
||||
Widget build(BuildContext context) {
|
||||
final label = _copied ? chatCopiedLabel : chatCopyLabel;
|
||||
if (widget.showLabel) {
|
||||
final icon = Icon(
|
||||
_copied
|
||||
? (widget.cupertino ? CupertinoIcons.checkmark : Icons.check)
|
||||
: (widget.cupertino
|
||||
? CupertinoIcons.doc_on_doc
|
||||
: Icons.copy_outlined),
|
||||
);
|
||||
final icon = Icon(_copied ? Icons.check : Icons.copy_outlined);
|
||||
return Semantics(
|
||||
identifier: 'chat-code-copy',
|
||||
child: widget.cupertino
|
||||
? CupertinoButton(
|
||||
onPressed: _copy,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [icon, const SizedBox(width: 6), Text(label)],
|
||||
),
|
||||
)
|
||||
: TextButton.icon(onPressed: _copy, icon: icon, label: Text(label)),
|
||||
);
|
||||
}
|
||||
if (widget.cupertino) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: label,
|
||||
excludeSemantics: true,
|
||||
child: CupertinoButton(
|
||||
key: const Key('chat-message-copy'),
|
||||
padding: EdgeInsets.zero,
|
||||
child: TextButton.icon(
|
||||
onPressed: _copy,
|
||||
child: Icon(
|
||||
_copied ? CupertinoIcons.checkmark : CupertinoIcons.doc_on_doc,
|
||||
),
|
||||
icon: icon,
|
||||
label: Text(label),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import '../../../../ui/layout/wheel_scroll_forwarding.dart';
|
||||
|
||||
/// Native, persistent overflow affordances for a code block or table. The
|
||||
@@ -93,29 +91,18 @@ class _ChatHorizontalViewportState extends State<ChatHorizontalViewport> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final color = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final focusColor = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final color = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final focusColor = Theme.of(context).colorScheme.primary;
|
||||
final view = Padding(
|
||||
padding: EdgeInsets.only(bottom: _overflow ? 12 : 0),
|
||||
child: HorizontalScrollView(controller: _controller, child: widget.child),
|
||||
);
|
||||
final scrollbar = cupertino
|
||||
? CupertinoScrollbar(
|
||||
controller: _controller,
|
||||
thumbVisibility: _overflow,
|
||||
child: view,
|
||||
)
|
||||
: Scrollbar(
|
||||
controller: _controller,
|
||||
thumbVisibility: _overflow,
|
||||
trackVisibility: _overflow,
|
||||
child: view,
|
||||
);
|
||||
final scrollbar = Scrollbar(
|
||||
controller: _controller,
|
||||
thumbVisibility: _overflow,
|
||||
trackVisibility: _overflow,
|
||||
child: view,
|
||||
);
|
||||
return NotificationListener<ScrollMetricsNotification>(
|
||||
onNotification: (notification) {
|
||||
if (notification.metrics.axis == Axis.horizontal) _scheduleMetrics();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import '../../../../ui/adaptive/segmented_bar.dart';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// The accessible name and visible label of the viewer's close control.
|
||||
@@ -35,34 +34,13 @@ class ChatImageViewer extends StatelessWidget {
|
||||
key: const Key('chat-image-viewer-image'),
|
||||
fit: BoxFit.contain,
|
||||
gaplessPlayback: true,
|
||||
errorBuilder: (context, _, _) => Icon(
|
||||
cupertino ? CupertinoIcons.photo : Icons.broken_image_outlined,
|
||||
),
|
||||
errorBuilder: (context, _, _) =>
|
||||
const Icon(Icons.broken_image_outlined),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
void close() => Navigator.of(context).maybePop();
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: CupertinoColors.black,
|
||||
navigationBar: SegmentedBar(
|
||||
cupertino: true,
|
||||
automaticallyImplyLeading: false,
|
||||
title: name,
|
||||
backgroundColor: CupertinoColors.black,
|
||||
pillColor: CupertinoColors.darkBackgroundGray,
|
||||
foregroundColor: CupertinoColors.white,
|
||||
leading: CupertinoButton(
|
||||
key: const Key('chat-image-viewer-close'),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
onPressed: close,
|
||||
child: const Text(chatImageViewerClose),
|
||||
),
|
||||
),
|
||||
child: body,
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
backgroundColor: Colors.black,
|
||||
@@ -93,8 +71,7 @@ Future<void> openChatImageViewer(
|
||||
required bool cupertino,
|
||||
}) {
|
||||
final page = ChatImageViewer(name: name, bytes: bytes, cupertino: cupertino);
|
||||
final route = cupertino
|
||||
? CupertinoPageRoute<void>(fullscreenDialog: true, builder: (_) => page)
|
||||
: MaterialPageRoute<void>(fullscreenDialog: true, builder: (_) => page);
|
||||
return Navigator.of(context).push(route);
|
||||
return Navigator.of(
|
||||
context,
|
||||
).push(MaterialPageRoute<void>(fullscreenDialog: true, builder: (_) => page));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
import 'chat_message_bubble.dart';
|
||||
import 'chat_message_view.dart';
|
||||
|
||||
@@ -63,66 +61,39 @@ class _ChatAgentReportCardState extends State<ChatAgentReportCard> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final content = _content(widget.row);
|
||||
final title = content.sender.isEmpty
|
||||
? 'Agent report'
|
||||
: 'Agent report · ${content.sender}';
|
||||
final summary = chatAgentReportSummary(content.text);
|
||||
final secondary = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final header = Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 12, top: 2),
|
||||
child: Icon(
|
||||
cupertino ? CupertinoIcons.person_crop_rectangle : Icons.assignment,
|
||||
color: secondary,
|
||||
),
|
||||
child: Icon(Icons.assignment, color: secondary),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
)
|
||||
: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
Text(title, style: Theme.of(context).textTheme.titleSmall),
|
||||
if (summary.isNotEmpty)
|
||||
Text(
|
||||
summary,
|
||||
maxLines: _expanded ? null : 1,
|
||||
overflow: _expanded ? null : TextOverflow.ellipsis,
|
||||
style:
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium)
|
||||
?.copyWith(
|
||||
// This summary is readable content, not disabled
|
||||
// chrome; translucent secondaryLabel falls below
|
||||
// normal-text contrast on a light card.
|
||||
color: cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: secondary,
|
||||
),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodyMedium?.copyWith(color: secondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
cupertino
|
||||
? (_expanded
|
||||
? CupertinoIcons.chevron_up
|
||||
: CupertinoIcons.chevron_down)
|
||||
: (_expanded ? Icons.expand_less : Icons.expand_more),
|
||||
_expanded ? Icons.expand_less : Icons.expand_more,
|
||||
color: secondary,
|
||||
),
|
||||
],
|
||||
@@ -135,29 +106,17 @@ class _ChatAgentReportCardState extends State<ChatAgentReportCard> {
|
||||
value: summary,
|
||||
onTap: _toggle,
|
||||
child: ExcludeSemantics(
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
padding: const EdgeInsets.all(12),
|
||||
onPressed: _toggle,
|
||||
child: DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: header,
|
||||
),
|
||||
)
|
||||
: InkWell(
|
||||
onTap: _toggle,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: header,
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: _toggle,
|
||||
child: Padding(padding: const EdgeInsets.all(12), child: header),
|
||||
),
|
||||
),
|
||||
);
|
||||
final body = _expanded
|
||||
? Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(12, 0, 12, 12),
|
||||
child: DefaultTextStyle.merge(
|
||||
style: chatMessageTextStyle(context, cupertino),
|
||||
style: chatMessageTextStyle(context, false),
|
||||
child:
|
||||
widget.textBuilder?.call(context, content.text) ??
|
||||
SelectableText(content.text),
|
||||
@@ -179,23 +138,11 @@ class _ChatAgentReportCardState extends State<ChatAgentReportCard> {
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 720),
|
||||
child: cupertino
|
||||
? DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.secondarySystemGroupedBackground
|
||||
.resolveFrom(context),
|
||||
border: Border.all(
|
||||
color: CupertinoColors.separator.resolveFrom(context),
|
||||
),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
),
|
||||
child: column,
|
||||
)
|
||||
: Card.outlined(
|
||||
margin: EdgeInsets.zero,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: column,
|
||||
),
|
||||
child: Card.outlined(
|
||||
margin: EdgeInsets.zero,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: column,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -211,22 +158,10 @@ class ChatSystemNoticeLine extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final text = _content(row).text;
|
||||
if (text.isEmpty) return const SizedBox.shrink();
|
||||
final color = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final style =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall)
|
||||
?.copyWith(
|
||||
color: cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: color,
|
||||
);
|
||||
final color = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final style = Theme.of(context).textTheme.bodySmall?.copyWith(color: color);
|
||||
return Semantics(
|
||||
container: true,
|
||||
label: 'System notice',
|
||||
@@ -240,7 +175,7 @@ class ChatSystemNoticeLine extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 8),
|
||||
child: Icon(
|
||||
cupertino ? CupertinoIcons.info_circle : Icons.info_outline,
|
||||
Icons.info_outline,
|
||||
size: style?.fontSize == null ? 16 : style!.fontSize! * 1.2,
|
||||
color: color,
|
||||
),
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import 'chat_link_browser_menu.dart';
|
||||
import 'chat_links.dart';
|
||||
import 'chat_transcript_selection.dart';
|
||||
@@ -77,8 +76,7 @@ class ChatLinkSpans {
|
||||
..onSecondaryTapUp = _ownsSecondaryClick
|
||||
? (details) => _showLinkMenu(context, details.globalPosition, url)
|
||||
: null;
|
||||
// The host's primary colour: a Material app's colour scheme primary, a
|
||||
// Cupertino app's tint.
|
||||
// The app theme's primary colour, read from the app's Cupertino theme.
|
||||
final color = CupertinoTheme.of(context).primaryColor;
|
||||
return _leaves(
|
||||
TextSpan(
|
||||
@@ -96,12 +94,10 @@ class ChatLinkSpans {
|
||||
}
|
||||
|
||||
/// The native [SelectionArea] around [child], with "Copy link" in its menu
|
||||
/// when the press that opened the menu was on a link. A Cupertino-only app
|
||||
/// has no `MaterialLocalizations`, which `SelectionArea` asserts on, so one
|
||||
/// English default localization scope is added there for its context menu.
|
||||
/// when the press that opened the menu was on a link.
|
||||
Widget selectionArea(BuildContext context, Widget child) {
|
||||
final transcriptSelection = ChatTranscriptSelectionScope.maybeOf(context);
|
||||
final area = Listener(
|
||||
return Listener(
|
||||
onPointerDown: (event) {
|
||||
_menuLink = event.buttons == kSecondaryMouseButton ? _hovered : null;
|
||||
transcriptSelection?.menuLink = _menuLink;
|
||||
@@ -111,18 +107,6 @@ class ChatLinkSpans {
|
||||
? SelectionArea(contextMenuBuilder: _selectionMenu, child: child)
|
||||
: child,
|
||||
);
|
||||
if (transcriptSelection != null || !usesCupertinoHost(context)) {
|
||||
return area;
|
||||
}
|
||||
return Localizations(
|
||||
locale: Localizations.maybeLocaleOf(context) ?? const Locale('en'),
|
||||
delegates: const [
|
||||
DefaultWidgetsLocalizations.delegate,
|
||||
DefaultMaterialLocalizations.delegate,
|
||||
DefaultCupertinoLocalizations.delegate,
|
||||
],
|
||||
child: area,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _selectionMenu(BuildContext context, SelectableRegionState state) {
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/semantics.dart';
|
||||
|
||||
import 'chat_transcript_selection.dart';
|
||||
import 'chat_code_hover.dart';
|
||||
import '../../../../ui/text/monospace.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
import 'chat_link_launcher.dart';
|
||||
import 'chat_link_spans.dart';
|
||||
import 'chat_markdown.dart';
|
||||
@@ -82,8 +80,6 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
// A new token or usage update elsewhere in the turn must not reparse and
|
||||
// rebuild every earlier answer part, or disturb its text selection.
|
||||
if (_rendered != null) return _rendered!;
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final gap = chatParagraphGap(context);
|
||||
final blocks = chatMarkdownCache.blocksFor(widget.text);
|
||||
return _rendered = Listener(
|
||||
@@ -105,7 +101,7 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
padding: EdgeInsets.only(
|
||||
top: index == 0 ? 0 : _gapAfter(blocks[index - 1], gap),
|
||||
),
|
||||
child: _block(context, blocks[index], cupertino),
|
||||
child: _block(context, blocks[index]),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -119,28 +115,23 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
double _gapAfter(MarkdownBlock previous, double paragraphGap) =>
|
||||
previous is MarkdownHeading ? 8 : paragraphGap;
|
||||
|
||||
Widget _block(BuildContext context, MarkdownBlock block, bool cupertino) {
|
||||
Widget _block(BuildContext context, MarkdownBlock block) {
|
||||
switch (block) {
|
||||
case MarkdownHeading(level: final level, text: final text):
|
||||
return Semantics(
|
||||
container: true,
|
||||
headingLevel: level,
|
||||
child: _text(
|
||||
context,
|
||||
text,
|
||||
cupertino: cupertino,
|
||||
style: _headingStyle(context, level, cupertino),
|
||||
),
|
||||
child: _text(context, text, style: _headingStyle(context, level)),
|
||||
);
|
||||
case MarkdownParagraph(text: final text):
|
||||
return _text(context, text, cupertino: cupertino);
|
||||
return _text(context, text);
|
||||
case MarkdownRule():
|
||||
return Divider(color: _dividerColor(context, cupertino));
|
||||
return Divider(color: _dividerColor(context));
|
||||
case MarkdownQuote(lines: final lines):
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: BorderDirectional(
|
||||
start: BorderSide(color: _dividerColor(context, cupertino)),
|
||||
start: BorderSide(color: _dividerColor(context)),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
@@ -151,8 +142,7 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
spacing: 4,
|
||||
children: [
|
||||
for (final line in lines)
|
||||
if (line.trim().isNotEmpty)
|
||||
_text(context, line, cupertino: cupertino),
|
||||
if (line.trim().isNotEmpty) _text(context, line),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -176,15 +166,9 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 8),
|
||||
child: Text(ordered ? '${index + 1}.' : '\u2022'),
|
||||
),
|
||||
Expanded(
|
||||
child: _text(
|
||||
context,
|
||||
items[index],
|
||||
cupertino: cupertino,
|
||||
),
|
||||
child: Text(ordered ? '${index + 1}.' : '•'),
|
||||
),
|
||||
Expanded(child: _text(context, items[index])),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -196,22 +180,17 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
label: 'table',
|
||||
child: Table(
|
||||
defaultColumnWidth: const IntrinsicColumnWidth(),
|
||||
border: TableBorder.all(color: _dividerColor(context, cupertino)),
|
||||
border: TableBorder.all(color: _dividerColor(context)),
|
||||
children: [
|
||||
TableRow(
|
||||
decoration: BoxDecoration(
|
||||
color: _headerFill(context, cupertino),
|
||||
),
|
||||
decoration: BoxDecoration(color: _headerFill(context)),
|
||||
children: [
|
||||
for (final cell in header)
|
||||
_cell(context, cell, cupertino, header: true),
|
||||
for (final cell in header) _cell(context, cell, header: true),
|
||||
],
|
||||
),
|
||||
for (final row in rows)
|
||||
TableRow(
|
||||
children: [
|
||||
for (final cell in row) _cell(context, cell, cupertino),
|
||||
],
|
||||
children: [for (final cell in row) _cell(context, cell)],
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -219,16 +198,14 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
case MarkdownCode(language: final language, code: final code):
|
||||
final labelStyle = _roleStyle(
|
||||
context,
|
||||
cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.labelSmall,
|
||||
Theme.of(context).textTheme.labelSmall,
|
||||
);
|
||||
return ChatCodeCopyRegion(
|
||||
code: code,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
label: Text(markdownCodeLabel(language), style: labelStyle),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(color: _codeFill(context, cupertino)),
|
||||
decoration: BoxDecoration(color: _codeFill(context)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: ChatTranscriptHorizontalScrollView(
|
||||
@@ -244,80 +221,56 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _cell(
|
||||
BuildContext context,
|
||||
String text,
|
||||
bool cupertino, {
|
||||
bool header = false,
|
||||
}) {
|
||||
Widget _cell(BuildContext context, String text, {bool header = false}) {
|
||||
final style = header
|
||||
? _roleStyle(
|
||||
context,
|
||||
cupertino
|
||||
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
|
||||
: Theme.of(context).textTheme.labelLarge,
|
||||
)
|
||||
? _roleStyle(context, Theme.of(context).textTheme.labelLarge)
|
||||
: null;
|
||||
return Semantics(
|
||||
role: header ? SemanticsRole.columnHeader : null,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: _text(context, text, cupertino: cupertino, style: style),
|
||||
child: _text(context, text, style: style),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _text(
|
||||
BuildContext context,
|
||||
String text, {
|
||||
required bool cupertino,
|
||||
TextStyle? style,
|
||||
}) {
|
||||
Widget _text(BuildContext context, String text, {TextStyle? style}) {
|
||||
return Builder(
|
||||
builder: (textContext) => Text.rich(
|
||||
TextSpan(children: _spans(textContext, parseInline(text), cupertino)),
|
||||
TextSpan(children: _spans(textContext, parseInline(text))),
|
||||
style: style,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<InlineSpan> _spans(
|
||||
BuildContext context,
|
||||
List<MarkdownInline> spans,
|
||||
bool cupertino,
|
||||
) => [
|
||||
List<InlineSpan> _spans(BuildContext context, List<MarkdownInline> spans) => [
|
||||
for (final span in spans)
|
||||
switch (span) {
|
||||
MarkdownPlain(text: final text) => TextSpan(text: text),
|
||||
MarkdownInlineCode(text: final text) => _inlineCode(
|
||||
context,
|
||||
text,
|
||||
cupertino,
|
||||
),
|
||||
MarkdownInlineCode(text: final text) => _inlineCode(context, text),
|
||||
MarkdownStrong(spans: final inner) => TextSpan(
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
children: _spans(context, inner, cupertino),
|
||||
children: _spans(context, inner),
|
||||
),
|
||||
MarkdownEmphasis(spans: final inner) => TextSpan(
|
||||
style: const TextStyle(fontStyle: FontStyle.italic),
|
||||
children: _spans(context, inner, cupertino),
|
||||
children: _spans(context, inner),
|
||||
),
|
||||
MarkdownLink(url: final url, spans: final inner) => _link(
|
||||
context,
|
||||
url,
|
||||
inner,
|
||||
cupertino,
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
TextSpan _inlineCode(BuildContext context, String text, bool cupertino) {
|
||||
TextSpan _inlineCode(BuildContext context, String text) {
|
||||
final token = text;
|
||||
return TextSpan(
|
||||
text: text,
|
||||
style: TextStyle(
|
||||
fontFamily: appMonospaceFamily,
|
||||
backgroundColor: _codeFill(context, cupertino),
|
||||
backgroundColor: _codeFill(context),
|
||||
),
|
||||
onEnter: (event) {
|
||||
if (_route?.isCurrent != false) {
|
||||
@@ -326,7 +279,7 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
token,
|
||||
text,
|
||||
event.position,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -338,11 +291,10 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
BuildContext context,
|
||||
String url,
|
||||
List<MarkdownInline> spans,
|
||||
bool cupertino,
|
||||
) => _links.link(
|
||||
context,
|
||||
url,
|
||||
_spans(context, spans, cupertino),
|
||||
_spans(context, spans),
|
||||
onOpen: (uri) {
|
||||
final onOpenLink = widget.onOpenLink;
|
||||
if (onOpenLink != null) return onOpenLink(uri.toString());
|
||||
@@ -353,46 +305,32 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
/// Heading roles are a non-increasing sequence from the host's own text
|
||||
/// theme. H3–H6 share one title role, matching the web renderer's flat
|
||||
/// lower-heading treatment, and no level falls back to a body role, so a
|
||||
/// heading never reads like a paragraph. Cupertino has two title roles, so
|
||||
/// H2–H6 share the middle-title role rather than plain body text.
|
||||
TextStyle? _headingStyle(BuildContext context, int level, bool cupertino) {
|
||||
final TextStyle? role;
|
||||
if (cupertino) {
|
||||
final theme = CupertinoTheme.of(context).textTheme;
|
||||
role = switch (level) {
|
||||
1 => theme.navLargeTitleTextStyle,
|
||||
_ => theme.navTitleTextStyle,
|
||||
};
|
||||
} else {
|
||||
final text = Theme.of(context).textTheme;
|
||||
role = switch (level) {
|
||||
1 => text.headlineSmall,
|
||||
2 => text.titleLarge,
|
||||
_ => text.titleMedium,
|
||||
};
|
||||
}
|
||||
/// heading never reads like a paragraph.
|
||||
TextStyle? _headingStyle(BuildContext context, int level) {
|
||||
final text = Theme.of(context).textTheme;
|
||||
final role = switch (level) {
|
||||
1 => text.headlineSmall,
|
||||
2 => text.titleLarge,
|
||||
_ => text.titleMedium,
|
||||
};
|
||||
return _roleStyle(context, role);
|
||||
}
|
||||
|
||||
/// Merges a host theme role into the ambient text style. Cupertino roles are
|
||||
/// `inherit: false`, which `Text` cannot merge directly.
|
||||
/// Merges a host theme role into the ambient text style.
|
||||
TextStyle? _roleStyle(BuildContext context, TextStyle? role) => role == null
|
||||
? null
|
||||
: DefaultTextStyle.of(
|
||||
context,
|
||||
).style.copyWith(inherit: true).merge(role.copyWith(inherit: true));
|
||||
|
||||
Color _dividerColor(BuildContext context, bool cupertino) {
|
||||
if (cupertino) return CupertinoColors.separator.resolveFrom(context);
|
||||
Color _dividerColor(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return theme.dividerTheme.color ?? theme.dividerColor;
|
||||
}
|
||||
|
||||
Color _codeFill(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
Color _codeFill(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
|
||||
Color _headerFill(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHigh;
|
||||
Color _headerFill(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.surfaceContainerHigh;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../sessions/chat_color_palette.dart';
|
||||
@@ -49,18 +48,6 @@ class ChatUserBubble extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (cupertino) {
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: chatBubbleFill(
|
||||
context,
|
||||
CupertinoColors.systemGrey5.resolveFrom(context),
|
||||
),
|
||||
borderRadius: _radius,
|
||||
),
|
||||
child: Padding(padding: _padding, child: child),
|
||||
);
|
||||
}
|
||||
// A Material surface (not a bare DecoratedBox) so a disclosure ListTile
|
||||
// inside the bubble keeps its ink and background.
|
||||
return Material(
|
||||
@@ -88,17 +75,14 @@ class ChatAgentSurface extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => cupertino
|
||||
? child
|
||||
: Material(type: MaterialType.transparency, child: child);
|
||||
Widget build(BuildContext context) =>
|
||||
Material(type: MaterialType.transparency, child: child);
|
||||
}
|
||||
|
||||
/// The transcript's reading text: the host's large body role, so answers read
|
||||
/// at a comfortable size and still follow the operator's text scaling.
|
||||
TextStyle? chatMessageTextStyle(BuildContext context, bool cupertino) =>
|
||||
cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyLarge;
|
||||
Theme.of(context).textTheme.bodyLarge;
|
||||
|
||||
/// The empty-line gap between two paragraphs of a reply: about one line of
|
||||
/// body text at [fontSize] (else the ambient text size), scaled by the
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
|
||||
/// The small, non-selectable metadata line for a recorded chat message time.
|
||||
/// The visible value includes a local date so messages from different days are
|
||||
/// not ambiguous; the tooltip and semantics expose the full localized value.
|
||||
@@ -21,38 +18,18 @@ class ChatMessageTimestamp extends StatelessWidget {
|
||||
).toLocal();
|
||||
if (instant == null) return const SizedBox.shrink();
|
||||
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final material = Localizations.of<MaterialLocalizations>(
|
||||
context,
|
||||
MaterialLocalizations,
|
||||
final material = MaterialLocalizations.of(context);
|
||||
final time = material.formatTimeOfDay(
|
||||
TimeOfDay.fromDateTime(instant),
|
||||
alwaysUse24HourFormat: true,
|
||||
);
|
||||
final String date, time, full;
|
||||
if (material != null) {
|
||||
time = material.formatTimeOfDay(
|
||||
TimeOfDay.fromDateTime(instant),
|
||||
alwaysUse24HourFormat: true,
|
||||
);
|
||||
date = '${instant.day} ${material.formatMonthYear(instant)}';
|
||||
full = '$date, $time';
|
||||
} else {
|
||||
final local = CupertinoLocalizations.of(context);
|
||||
time =
|
||||
'${local.datePickerHour(instant.hour).padLeft(2, '0')}:${local.datePickerMinute(instant.minute)}';
|
||||
date =
|
||||
'${local.datePickerDayOfMonth(instant.day)} ${local.datePickerMonth(instant.month)} ${local.datePickerYear(instant.year)}';
|
||||
full = '$date, $time';
|
||||
}
|
||||
final style =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: (Theme.of(context).textTheme.bodySmall ?? const TextStyle()))
|
||||
.copyWith(
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: 12,
|
||||
);
|
||||
final date = '${instant.day} ${material.formatMonthYear(instant)}';
|
||||
final full = '$date, $time';
|
||||
final style = (Theme.of(context).textTheme.bodySmall ?? const TextStyle())
|
||||
.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: 12,
|
||||
);
|
||||
final label = 'Sent $full';
|
||||
final text = Text('$date · $time', style: style);
|
||||
return SelectionContainer.disabled(
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../data/chat_attachment_images.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
import 'chat_attachment_gallery.dart';
|
||||
import '../../domain/chat_tool_calls.dart';
|
||||
import '../../domain/chat_transcript.dart';
|
||||
@@ -48,7 +46,6 @@ class ChatMessageView extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final user = row['kind'] == 'user';
|
||||
final role = user ? 'User' : 'Assistant';
|
||||
final cupertino = _isCupertino(context);
|
||||
final content = user ? _userParts(context) : _agentParts(context);
|
||||
// A wide window draws an answer's Copy in the gutter left of the reading
|
||||
// column; without room it stays at the start of the answer's footer.
|
||||
@@ -58,7 +55,7 @@ class ChatMessageView extends StatelessWidget {
|
||||
// that shrinks to its content; the agent's answer sits on the page with no
|
||||
// bubble, so long replies read as a document rather than a balloon.
|
||||
final body = DefaultTextStyle.merge(
|
||||
style: chatMessageTextStyle(context, cupertino),
|
||||
style: chatMessageTextStyle(context, false),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -86,11 +83,11 @@ class ChatMessageView extends StatelessWidget {
|
||||
: 720 + gutter,
|
||||
),
|
||||
child: user
|
||||
? _userTurn(cupertino, content, body)
|
||||
? _userTurn(content, body)
|
||||
: _agentRow(
|
||||
context,
|
||||
content,
|
||||
ChatAgentSurface(cupertino: cupertino, child: body),
|
||||
ChatAgentSurface(cupertino: false, child: body),
|
||||
gutter,
|
||||
),
|
||||
),
|
||||
@@ -100,12 +97,8 @@ class ChatMessageView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Color _secondaryColor(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
bool _isCupertino(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
Color _secondaryColor(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
JsonMap get _userMessage => row['message'] is Map
|
||||
? Map<String, dynamic>.from(row['message'] as Map)
|
||||
@@ -114,7 +107,7 @@ class ChatMessageView extends StatelessWidget {
|
||||
/// Attached images sit above the operator's bubble, as their own thumbnails;
|
||||
/// an images-only turn draws no empty bubble. The footer (the delivery line)
|
||||
/// sits under the bubble's trailing corner.
|
||||
Widget _userTurn(bool cupertino, List<Widget> content, Widget body) {
|
||||
Widget _userTurn(List<Widget> content, Widget body) {
|
||||
final thumbnails = [
|
||||
for (final part in _partsOf(_userMessage))
|
||||
if (_isFile(part) && chatPartIsThumbnail(part)) part,
|
||||
@@ -124,7 +117,7 @@ class ChatMessageView extends StatelessWidget {
|
||||
);
|
||||
final hasTimestamp = chatMessageCreatedAt(_userMessage) != null;
|
||||
if (thumbnails.isEmpty && footer.isEmpty && !hasTimestamp) {
|
||||
return ChatUserBubble(cupertino: cupertino, child: body);
|
||||
return ChatUserBubble(cupertino: false, child: body);
|
||||
}
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -134,12 +127,12 @@ class ChatMessageView extends StatelessWidget {
|
||||
ChatAttachmentGallery(
|
||||
parts: thumbnails,
|
||||
images: images ?? _inlineImages,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
),
|
||||
if (thumbnails.isNotEmpty && content.isNotEmpty)
|
||||
const SizedBox(height: 6),
|
||||
if (content.isNotEmpty || thumbnails.isEmpty)
|
||||
ChatUserBubble(cupertino: cupertino, child: body),
|
||||
ChatUserBubble(cupertino: false, child: body),
|
||||
if (footer.isNotEmpty) ...[
|
||||
const SizedBox(height: 2),
|
||||
Wrap(
|
||||
@@ -190,7 +183,7 @@ class ChatMessageView extends StatelessWidget {
|
||||
final copyText = row['streaming'] == true ? '' : _answerText(_partsOf(row));
|
||||
final copy = copyText.isEmpty
|
||||
? null
|
||||
: ChatCopyButton(text: copyText, cupertino: _isCupertino(context));
|
||||
: ChatCopyButton(text: copyText, cupertino: false);
|
||||
if (gutter <= 0) return _agentTurn(context, content, answer, copy);
|
||||
return ChatCopyGutterRow(
|
||||
width: gutter,
|
||||
@@ -226,10 +219,7 @@ class ChatMessageView extends StatelessWidget {
|
||||
Text(
|
||||
model,
|
||||
key: const Key('chat-reply-model'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: _secondaryColor(context, _isCupertino(context)),
|
||||
),
|
||||
style: TextStyle(fontSize: 12, color: _secondaryColor(context)),
|
||||
),
|
||||
if (chatMessageCreatedAt(row) case final time?)
|
||||
ChatMessageTimestamp(createdAt: time),
|
||||
@@ -296,7 +286,7 @@ class ChatMessageView extends StatelessWidget {
|
||||
// empty line between consecutive ones keeps them reading as paragraphs.
|
||||
final gap = chatParagraphGap(
|
||||
context,
|
||||
chatMessageTextStyle(context, _isCupertino(context))?.fontSize,
|
||||
chatMessageTextStyle(context, false)?.fontSize,
|
||||
);
|
||||
var previousText = false;
|
||||
for (var index = 0; index < parts.length; index++) {
|
||||
@@ -363,21 +353,18 @@ class ChatMessageView extends StatelessWidget {
|
||||
}
|
||||
|
||||
TextStyle? _clientStyle(BuildContext context) {
|
||||
final cupertino = _isCupertino(context);
|
||||
return (cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall)
|
||||
?.copyWith(color: _secondaryColor(context, cupertino));
|
||||
return Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: _secondaryColor(context));
|
||||
}
|
||||
|
||||
Widget _attachment(BuildContext context, JsonMap part) {
|
||||
final cupertino = _isCupertino(context);
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: Icon(cupertino ? CupertinoIcons.paperclip : Icons.attach_file),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(right: 8),
|
||||
child: Icon(Icons.attach_file),
|
||||
),
|
||||
Expanded(child: SelectableText(chatAttachmentPartName(part))),
|
||||
],
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
import 'chat_turn_chip.dart';
|
||||
|
||||
/// `Reasoning` / `Reasoning · N steps`.
|
||||
@@ -61,21 +59,13 @@ class _ChatReasoningChipState extends State<ChatReasoningChip> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final color = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final color = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final label = chatReasoningLabel(widget.steps.length);
|
||||
return ChatTurnChip(
|
||||
chipKey: const Key('chat-reasoning-chip'),
|
||||
leading: widget.streaming
|
||||
? _spinner(cupertino)
|
||||
: Icon(
|
||||
cupertino ? CupertinoIcons.lightbulb : Icons.lightbulb_outline,
|
||||
size: 14,
|
||||
color: color,
|
||||
),
|
||||
? _spinner()
|
||||
: Icon(Icons.lightbulb_outline, size: 14, color: color),
|
||||
label: label,
|
||||
color: color,
|
||||
semanticsLabel: '$label, expand for details',
|
||||
@@ -90,12 +80,10 @@ class _ChatReasoningChipState extends State<ChatReasoningChip> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _spinner(bool cupertino) => cupertino
|
||||
? const CupertinoActivityIndicator(radius: 7)
|
||||
: const SizedBox.square(
|
||||
dimension: 12,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
);
|
||||
Widget _spinner() => const SizedBox.square(
|
||||
dimension: 12,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
);
|
||||
|
||||
/// The steps an open sheet listens to. The turn can leave the tree while its
|
||||
/// sheet is still open (its row scrolled away or replaced), so the notifier is
|
||||
@@ -132,16 +120,9 @@ class _ReasoningSheet extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
final secondary = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
return DefaultTextStyle.merge(
|
||||
style: style,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.8,
|
||||
@@ -161,10 +142,7 @@ class _ReasoningSheet extends StatelessWidget {
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
if (streaming) ...[
|
||||
const SizedBox(width: 8),
|
||||
_spinner(cupertino),
|
||||
],
|
||||
if (streaming) ...[const SizedBox(width: 8), _spinner()],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../domain/chat_task_notices.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
import 'chat_turn_chip.dart';
|
||||
|
||||
/// A run of background-task notices as one quiet chip on the agent's side,
|
||||
@@ -19,25 +17,17 @@ class ChatTaskNoticesGroup extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final notices = chatTaskNoticesOf(row);
|
||||
if (notices.isEmpty) return const SizedBox.shrink();
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final failed = notices
|
||||
.where((n) => n.outcome == ChatTaskOutcome.failed)
|
||||
.length;
|
||||
final color = failed > 0
|
||||
? _errorColor(context, cupertino)
|
||||
: _secondaryColor(context, cupertino);
|
||||
final color = failed > 0 ? _errorColor(context) : _secondaryColor(context);
|
||||
final label = chatTaskNoticesLabel(notices.length);
|
||||
final shown = failed > 0 ? '$label · $failed failed' : label;
|
||||
return Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: ChatTurnChip(
|
||||
chipKey: const Key('chat-task-notices-chip'),
|
||||
leading: Icon(
|
||||
cupertino ? CupertinoIcons.square_stack_3d_up : Icons.task_alt,
|
||||
size: 14,
|
||||
color: color,
|
||||
),
|
||||
leading: Icon(Icons.task_alt, size: 14, color: color),
|
||||
label: shown,
|
||||
color: color,
|
||||
semanticsLabel: '$shown ended, expand for details',
|
||||
@@ -47,13 +37,10 @@ class ChatTaskNoticesGroup extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Color _secondaryColor(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
Color _secondaryColor(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
Color _errorColor(BuildContext context, bool cupertino) => cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error;
|
||||
Color _errorColor(BuildContext context) => Theme.of(context).colorScheme.error;
|
||||
|
||||
String _outcomeLabel(ChatTaskOutcome outcome) => switch (outcome) {
|
||||
ChatTaskOutcome.finished => 'Finished',
|
||||
@@ -69,13 +56,8 @@ class _TaskNoticesSheet extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
return DefaultTextStyle.merge(
|
||||
style: style,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.8,
|
||||
@@ -108,25 +90,12 @@ class _TaskNoticeRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final secondary = _secondaryColor(context, cupertino);
|
||||
final secondary = _secondaryColor(context);
|
||||
final outcome = _outcomeLabel(notice.outcome);
|
||||
final (icon, color) = switch (notice.outcome) {
|
||||
ChatTaskOutcome.finished => (
|
||||
cupertino
|
||||
? CupertinoIcons.checkmark_circle
|
||||
: Icons.check_circle_outline,
|
||||
secondary,
|
||||
),
|
||||
ChatTaskOutcome.failed => (
|
||||
cupertino ? CupertinoIcons.xmark_circle : Icons.error_outline,
|
||||
_errorColor(context, cupertino),
|
||||
),
|
||||
ChatTaskOutcome.stopped => (
|
||||
cupertino ? CupertinoIcons.stop_circle : Icons.stop_circle_outlined,
|
||||
secondary,
|
||||
),
|
||||
ChatTaskOutcome.finished => (Icons.check_circle_outline, secondary),
|
||||
ChatTaskOutcome.failed => (Icons.error_outline, _errorColor(context)),
|
||||
ChatTaskOutcome.stopped => (Icons.stop_circle_outlined, secondary),
|
||||
};
|
||||
final summary = notice.summary.isEmpty
|
||||
? 'Background task ${outcome.toLowerCase()}'
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../ui/text/monospace.dart';
|
||||
import '../../domain/chat_tool_calls.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
import 'chat_turn_chip.dart';
|
||||
import 'native_disclosure.dart';
|
||||
|
||||
@@ -18,30 +16,18 @@ class ChatToolCallsChip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final running = calls.any(chatToolRunning);
|
||||
final failed = calls.any(chatToolFailed);
|
||||
final color = failed
|
||||
? (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error)
|
||||
: (cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant);
|
||||
? Theme.of(context).colorScheme.error
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final label = chatToolCallsLabel(calls.length);
|
||||
final leading = running
|
||||
? (cupertino
|
||||
? const CupertinoActivityIndicator(radius: 7)
|
||||
: const SizedBox.square(
|
||||
dimension: 12,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
))
|
||||
: Icon(
|
||||
cupertino ? CupertinoIcons.wrench : Icons.build_outlined,
|
||||
size: 14,
|
||||
color: color,
|
||||
);
|
||||
? const SizedBox.square(
|
||||
dimension: 12,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: Icon(Icons.build_outlined, size: 14, color: color);
|
||||
return ChatTurnChip(
|
||||
chipKey: const Key('chat-tool-chip'),
|
||||
leading: leading,
|
||||
@@ -62,13 +48,8 @@ class _ToolCallsSheet extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
return DefaultTextStyle.merge(
|
||||
style: style,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.8,
|
||||
@@ -102,8 +83,6 @@ class ChatToolCallDetail extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final detail = chatToolDetail(call);
|
||||
final duration = chatToolDurationMillis(call);
|
||||
final failed = chatToolFailed(call);
|
||||
@@ -136,9 +115,7 @@ class ChatToolCallDetail extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import 'chat_horizontal_viewport.dart';
|
||||
|
||||
/// The selection controller shared by all link spans in one transcript.
|
||||
@@ -76,16 +74,7 @@ class _ChatTranscriptSelectionAreaState
|
||||
),
|
||||
),
|
||||
);
|
||||
if (!usesCupertinoHost(context)) return area;
|
||||
return Localizations(
|
||||
locale: Localizations.maybeLocaleOf(context) ?? const Locale('en'),
|
||||
delegates: const [
|
||||
DefaultWidgetsLocalizations.delegate,
|
||||
DefaultMaterialLocalizations.delegate,
|
||||
DefaultCupertinoLocalizations.delegate,
|
||||
],
|
||||
child: area,
|
||||
);
|
||||
return area;
|
||||
}
|
||||
|
||||
Widget _selectionMenu(
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../domain/chat_turn_activity.dart';
|
||||
import '../../domain/chat_activity_detail.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
import 'chat_tool_calls_view.dart';
|
||||
import 'native_disclosure.dart';
|
||||
|
||||
@@ -13,12 +11,8 @@ class ChatTurnActivityDetails extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
return DefaultTextStyle.merge(
|
||||
style: cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../domain/chat_turn_activity.dart';
|
||||
import '../../../../ui/adaptive/platform.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
import 'chat_response_pending.dart';
|
||||
import 'chat_turn_activity_details.dart';
|
||||
|
||||
@@ -68,8 +66,6 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
|
||||
void _open() {
|
||||
if (_modal != null) return;
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
Widget dialog(BuildContext dialogContext) {
|
||||
final content = ValueListenableBuilder<ChatTurnActivityData>(
|
||||
valueListenable: _live,
|
||||
@@ -77,34 +73,15 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
SingleChildScrollView(child: ChatTurnActivityDetails(data: data)),
|
||||
);
|
||||
void close() => Navigator.of(dialogContext).pop();
|
||||
return cupertino
|
||||
? CupertinoAlertDialog(
|
||||
title: const Text('Activity details'),
|
||||
content: content,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: close,
|
||||
child: const Text('Done'),
|
||||
),
|
||||
],
|
||||
)
|
||||
: AlertDialog(
|
||||
title: const Text('Activity details'),
|
||||
scrollable: true,
|
||||
content: content,
|
||||
actions: [
|
||||
TextButton(onPressed: close, child: const Text('Done')),
|
||||
],
|
||||
);
|
||||
return AlertDialog(
|
||||
title: const Text('Activity details'),
|
||||
scrollable: true,
|
||||
content: content,
|
||||
actions: [TextButton(onPressed: close, child: const Text('Done'))],
|
||||
);
|
||||
}
|
||||
|
||||
final TransitionRoute<void> route = cupertino
|
||||
? CupertinoDialogRoute<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: dialog,
|
||||
)
|
||||
: DialogRoute<void>(context: context, builder: dialog);
|
||||
final route = DialogRoute<void>(context: context, builder: dialog);
|
||||
_modal = route;
|
||||
Navigator.of(context, rootNavigator: true).push(route);
|
||||
route.completed.then((_) {
|
||||
@@ -132,18 +109,10 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final data = _data;
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final accent = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final accent = Theme.of(context).colorScheme.primary;
|
||||
final color = data.failed && !widget.streaming
|
||||
? (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error)
|
||||
: (cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant);
|
||||
? Theme.of(context).colorScheme.error
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final started = data.started;
|
||||
final duration = started == null
|
||||
? _clock.elapsed - _observedAt
|
||||
@@ -153,7 +122,7 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
// Desktop hover hugs the label; phones keep the full-width touch row.
|
||||
final compact = prefersCompactHitTargets(context);
|
||||
final content = ConstrainedBox(
|
||||
constraints: BoxConstraints(minHeight: cupertino ? 28 : 32),
|
||||
constraints: const BoxConstraints(minHeight: 32),
|
||||
child: Row(
|
||||
mainAxisSize: compact ? MainAxisSize.min : MainAxisSize.max,
|
||||
children: [
|
||||
@@ -175,32 +144,21 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
cupertino ? CupertinoIcons.chevron_right : Icons.chevron_right,
|
||||
color: color,
|
||||
),
|
||||
Icon(Icons.chevron_right, color: color),
|
||||
],
|
||||
),
|
||||
);
|
||||
final button = cupertino
|
||||
? CupertinoButton(
|
||||
key: const Key('chat-turn-activity'),
|
||||
minimumSize: const Size(0, 44),
|
||||
padding: const EdgeInsets.all(chatAgentContentInset),
|
||||
onPressed: _open,
|
||||
child: content,
|
||||
)
|
||||
: TextButton(
|
||||
key: const Key('chat-turn-activity'),
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 48),
|
||||
padding: const EdgeInsets.all(chatAgentContentInset),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
),
|
||||
onPressed: _open,
|
||||
child: content,
|
||||
);
|
||||
final button = TextButton(
|
||||
key: const Key('chat-turn-activity'),
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 48),
|
||||
padding: const EdgeInsets.all(chatAgentContentInset),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
),
|
||||
onPressed: _open,
|
||||
child: content,
|
||||
);
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: '$label, expand for details',
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/app_popups.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
|
||||
/// The quiet chip under an agent turn (its tools, its permissions) and the
|
||||
/// native sheet it opens.
|
||||
@@ -42,8 +40,6 @@ class ChatTurnChip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final content = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -53,42 +49,27 @@ class ChatTurnChip extends StatelessWidget {
|
||||
Flexible(child: _label(maxLines: 1, overflow: TextOverflow.ellipsis))
|
||||
else
|
||||
_label(),
|
||||
Icon(
|
||||
cupertino ? CupertinoIcons.chevron_up : Icons.expand_less,
|
||||
size: 14,
|
||||
color: color,
|
||||
),
|
||||
Icon(Icons.expand_less, size: 14, color: color),
|
||||
],
|
||||
);
|
||||
return Semantics(
|
||||
button: true,
|
||||
// The child's own action is excluded with its label, so the node
|
||||
// carries the activation for assistive technology.
|
||||
onTap: () => _open(context, cupertino),
|
||||
onTap: () => _open(context),
|
||||
label: semanticsLabel,
|
||||
excludeSemantics: true,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
key: chipKey,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
|
||||
minimumSize: Size.zero,
|
||||
onPressed: () => _open(context, cupertino),
|
||||
child: content,
|
||||
)
|
||||
: InkWell(
|
||||
key: chipKey,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: () => _open(context, cupertino),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
vertical: 6,
|
||||
),
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
key: chipKey,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: () => _open(context),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 6),
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -109,8 +90,8 @@ class ChatTurnChip extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _open(BuildContext context, bool cupertino) {
|
||||
if (open case final open?) return open(context, cupertino);
|
||||
Future<void> _open(BuildContext context) {
|
||||
if (open case final open?) return open(context, false);
|
||||
return showChatTurnSheet(context, sheet!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import '../../../../shell/windows/window_scope.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
@@ -7,7 +6,6 @@ import '../../../../ui/adaptive/app_popups.dart';
|
||||
import '../../../changes/widgets/change_style.dart'
|
||||
show addedColor, removedColor;
|
||||
import '../../domain/chat_turn_diffs.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
import 'chat_turn_chip.dart';
|
||||
import 'chat_turn_diff_view.dart';
|
||||
|
||||
@@ -28,18 +26,10 @@ class ChatTurnDiffChip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final color = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final color = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
return ChatTurnChip(
|
||||
chipKey: const Key('chat-turn-diff-chip'),
|
||||
leading: Icon(
|
||||
cupertino ? CupertinoIcons.doc_text : Icons.difference_outlined,
|
||||
size: 14,
|
||||
color: color,
|
||||
),
|
||||
leading: Icon(Icons.difference_outlined, size: 14, color: color),
|
||||
label: chatTurnDiffLabel(summary),
|
||||
// The counts take the run Changes colours: additions green, removals red.
|
||||
labelSpans: (context) {
|
||||
@@ -65,6 +55,7 @@ class ChatTurnDiffChip extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// The flag is unused: the Material presentation is the only one.
|
||||
Future<void> _open(BuildContext context, bool cupertino) {
|
||||
// A dialog in the tiled app on a wide layout. A phone keeps the
|
||||
// full-screen page, and a floating window opens it as a page of that
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../changes/changes.dart';
|
||||
import '../../domain/chat_turn_diffs.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
|
||||
/// One chat turn's recorded file changes: the counts, an honest note when the
|
||||
/// capture was partial or truncated, and one row per file that opens the
|
||||
@@ -41,11 +39,7 @@ class _ChatTurnDiffViewState extends State<ChatTurnDiffView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
final style = Theme.of(context).textTheme.bodyMedium;
|
||||
final list = FutureBuilder<JsonMap>(
|
||||
future: _reply,
|
||||
builder: (context, snapshot) {
|
||||
@@ -58,7 +52,7 @@ class _ChatTurnDiffViewState extends State<ChatTurnDiffView> {
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
..._body(context, snapshot, cupertino),
|
||||
..._body(context, snapshot),
|
||||
];
|
||||
return ListView(
|
||||
key: const Key('chat-turn-diff-list'),
|
||||
@@ -68,7 +62,6 @@ class _ChatTurnDiffViewState extends State<ChatTurnDiffView> {
|
||||
);
|
||||
},
|
||||
);
|
||||
// File rows may be Material list tiles inside a Cupertino surface.
|
||||
final content = Material(
|
||||
type: MaterialType.transparency,
|
||||
child: DefaultTextStyle.merge(style: style, child: list),
|
||||
@@ -82,20 +75,12 @@ class _ChatTurnDiffViewState extends State<ChatTurnDiffView> {
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _body(
|
||||
BuildContext context,
|
||||
AsyncSnapshot<JsonMap> snapshot,
|
||||
bool cupertino,
|
||||
) {
|
||||
List<Widget> _body(BuildContext context, AsyncSnapshot<JsonMap> snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Center(
|
||||
child: cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -104,9 +89,7 @@ class _ChatTurnDiffViewState extends State<ChatTurnDiffView> {
|
||||
Text('Could not load the changes: ${snapshot.error}'),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: cupertino
|
||||
? CupertinoButton(onPressed: _retry, child: const Text('Retry'))
|
||||
: TextButton(onPressed: _retry, child: const Text('Retry')),
|
||||
child: TextButton(onPressed: _retry, child: const Text('Retry')),
|
||||
),
|
||||
];
|
||||
}
|
||||
@@ -127,9 +110,7 @@ class _ChatTurnDiffViewState extends State<ChatTurnDiffView> {
|
||||
chatTurnDiffTruncationNote(capture.diagnostic),
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
|
||||
/// A block opened with the host's own disclosure control (collapsed by default).
|
||||
///
|
||||
/// [childBuilder] runs only while the block is open, so a closed disclosure
|
||||
/// never encodes or lays out its body.
|
||||
class NativeDisclosure extends StatefulWidget {
|
||||
/// never encodes or lays out its body. The [ExpansionTile] keeps the open state.
|
||||
class NativeDisclosure extends StatelessWidget {
|
||||
const NativeDisclosure({
|
||||
super.key,
|
||||
required this.label,
|
||||
@@ -20,63 +17,16 @@ class NativeDisclosure extends StatefulWidget {
|
||||
final bool initiallyExpanded;
|
||||
|
||||
@override
|
||||
State<NativeDisclosure> createState() => _NativeDisclosureState();
|
||||
}
|
||||
|
||||
class _NativeDisclosureState extends State<NativeDisclosure> {
|
||||
late bool _expanded = widget.initiallyExpanded;
|
||||
|
||||
void _toggle() => setState(() => _expanded = !_expanded);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (chatControlsStyleOf(context) != ChatControlsStyle.cupertino) {
|
||||
return ExpansionTile(
|
||||
title: Text(widget.label),
|
||||
initiallyExpanded: widget.initiallyExpanded,
|
||||
maintainState: false,
|
||||
// A transcript block starts at the row edge, like its answer text; the
|
||||
// tile's own padding would indent it, and its body defaults to centred,
|
||||
// which floats a short body in the middle of the row.
|
||||
tilePadding: EdgeInsets.zero,
|
||||
expandedAlignment: AlignmentDirectional.centerStart,
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [Builder(builder: widget.childBuilder)],
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// One node carries the label, the button action and the state; the
|
||||
// Cupertino button's own node would otherwise drop the state.
|
||||
Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
expanded: _expanded,
|
||||
label: widget.label,
|
||||
onTap: _toggle,
|
||||
child: ExcludeSemantics(
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: _toggle,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(widget.label, textAlign: TextAlign.start),
|
||||
),
|
||||
Icon(
|
||||
_expanded
|
||||
? CupertinoIcons.chevron_up
|
||||
: CupertinoIcons.chevron_down,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_expanded) widget.childBuilder(context),
|
||||
],
|
||||
);
|
||||
}
|
||||
Widget build(BuildContext context) => ExpansionTile(
|
||||
title: Text(label),
|
||||
initiallyExpanded: initiallyExpanded,
|
||||
maintainState: false,
|
||||
// A transcript block starts at the row edge, like its answer text; the
|
||||
// tile's own padding would indent it, and its body defaults to centred,
|
||||
// which floats a short body in the middle of the row.
|
||||
tilePadding: EdgeInsets.zero,
|
||||
expandedAlignment: AlignmentDirectional.centerStart,
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [Builder(builder: childBuilder)],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -100,22 +99,12 @@ class ChatShownFileCard extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
);
|
||||
final cupertino = chatShownCupertino(context);
|
||||
return ChatShownSurface(
|
||||
label: image ? 'Shown image $title' : 'Shown file $title',
|
||||
child: Semantics(
|
||||
button: true,
|
||||
onTap: open,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: open,
|
||||
child: DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: body,
|
||||
),
|
||||
)
|
||||
: InkWell(onTap: open, child: body),
|
||||
child: InkWell(onTap: open, child: body),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/api_gateway.dart';
|
||||
import '../../../../../ui/adaptive/host.dart';
|
||||
import '../../../../artifacts/ui/artifact_fullscreen.dart';
|
||||
import '../../../../artifacts/ui/artifact_html_view.dart';
|
||||
import '../../../../artifacts/ui/artifact_viewer_scaffold.dart';
|
||||
@@ -42,12 +40,11 @@ class ChatShownHtmlCard extends StatelessWidget {
|
||||
final expired = item['expired'] == true || html.isEmpty;
|
||||
final bytes = item['html_bytes'];
|
||||
final size = bytes is num ? fileSizeLabel(bytes.toInt()) : null;
|
||||
final cupertino = chatShownCupertino(context);
|
||||
final open = expired
|
||||
? null
|
||||
: () => Navigator.of(context, rootNavigator: true).push(
|
||||
artifactFullscreenRoute(
|
||||
cupertino: usesCupertinoHost(context),
|
||||
cupertino: false,
|
||||
builder: (_) => ChatShownHtmlPage(
|
||||
title: title,
|
||||
html: html,
|
||||
@@ -57,13 +54,6 @@ class ChatShownHtmlCard extends StatelessWidget {
|
||||
);
|
||||
final action = open == null
|
||||
? null
|
||||
: cupertino
|
||||
? CupertinoButton(
|
||||
key: const Key('chat-shown-html-open'),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: open,
|
||||
child: const Text('Open'),
|
||||
)
|
||||
: TextButton(
|
||||
key: const Key('chat-shown-html-open'),
|
||||
onPressed: open,
|
||||
@@ -76,10 +66,7 @@ class ChatShownHtmlCard extends StatelessWidget {
|
||||
subtitle: expired
|
||||
? 'This view is no longer retained'
|
||||
: ['View', ?size].join(' · '),
|
||||
leading: Icon(
|
||||
cupertino ? CupertinoIcons.chart_bar_square : Icons.web_asset,
|
||||
color: chatShownSecondary(context),
|
||||
),
|
||||
leading: Icon(Icons.web_asset, color: chatShownSecondary(context)),
|
||||
trailing: action,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/api_gateway.dart';
|
||||
@@ -84,16 +83,7 @@ class ChatShownLinkImage extends StatelessWidget {
|
||||
button: true,
|
||||
link: true,
|
||||
onTap: open,
|
||||
child: chatShownCupertino(context)
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: open,
|
||||
child: DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: body,
|
||||
),
|
||||
)
|
||||
: InkWell(onTap: open, child: body),
|
||||
child: InkWell(onTap: open, child: body),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/api_gateway.dart';
|
||||
@@ -24,24 +23,15 @@ class ChatShownNotifyRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = chatShownCupertino(context);
|
||||
final delivered = item['delivered'] == true;
|
||||
final secondary = chatShownSecondary(context);
|
||||
final color = delivered
|
||||
? secondary
|
||||
: (cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error);
|
||||
final base = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall;
|
||||
final color = delivered ? secondary : Theme.of(context).colorScheme.error;
|
||||
final base = Theme.of(context).textTheme.bodySmall;
|
||||
final text = chatShownNotifyText(item);
|
||||
final message = '${item['message'] ?? ''}'.trim();
|
||||
final icon = delivered
|
||||
? (cupertino ? CupertinoIcons.bell : Icons.notifications_outlined)
|
||||
: (cupertino
|
||||
? CupertinoIcons.bell_slash
|
||||
: Icons.notifications_off_outlined);
|
||||
? Icons.notifications_outlined
|
||||
: Icons.notifications_off_outlined;
|
||||
return Semantics(
|
||||
container: true,
|
||||
label: text,
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/api_gateway.dart';
|
||||
import '../../sessions/chat_adaptive.dart';
|
||||
|
||||
/// Whether the transcript draws Cupertino controls.
|
||||
bool chatShownCupertino(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
|
||||
/// The secondary text colour of either host.
|
||||
Color chatShownSecondary(BuildContext context) => chatShownCupertino(context)
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
/// The secondary text colour of the transcript's cards.
|
||||
Color chatShownSecondary(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
/// The item's title, else [fallback].
|
||||
String chatShownTitle(JsonMap item, String fallback) {
|
||||
@@ -36,25 +29,11 @@ class ChatShownSurface extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = chatShownCupertino(context);
|
||||
const radius = BorderRadius.all(Radius.circular(12));
|
||||
final card = cupertino
|
||||
? DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.secondarySystemGroupedBackground
|
||||
.resolveFrom(context),
|
||||
border: Border.all(
|
||||
color: CupertinoColors.separator.resolveFrom(context),
|
||||
),
|
||||
borderRadius: radius,
|
||||
),
|
||||
child: ClipRRect(borderRadius: radius, child: child),
|
||||
)
|
||||
: Card.outlined(
|
||||
margin: EdgeInsets.zero,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: child,
|
||||
);
|
||||
final card = Card.outlined(
|
||||
margin: EdgeInsets.zero,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: child,
|
||||
);
|
||||
return Semantics(
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
@@ -90,22 +69,10 @@ class ChatShownHeading extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = chatShownCupertino(context);
|
||||
final titleStyle = cupertino
|
||||
? CupertinoTheme.of(
|
||||
context,
|
||||
).textTheme.textStyle.copyWith(fontWeight: FontWeight.w600)
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
// Cupertino has no caption role; the body style at a smaller size keeps
|
||||
// the line secondary while still following text scaling.
|
||||
final cupertinoBody = CupertinoTheme.of(context).textTheme.textStyle;
|
||||
final subtitleStyle =
|
||||
(cupertino
|
||||
? cupertinoBody.copyWith(
|
||||
fontSize: (cupertinoBody.fontSize ?? 17) * 0.8,
|
||||
)
|
||||
: Theme.of(context).textTheme.bodySmall)
|
||||
?.copyWith(color: chatShownSecondary(context));
|
||||
final titleStyle = Theme.of(context).textTheme.titleSmall;
|
||||
final subtitleStyle = Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: chatShownSecondary(context));
|
||||
final sub = subtitle;
|
||||
return Row(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user