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,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))),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user