Merge main (Compact design) into Glass

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 23:22:56 +00:00
93 changed files with 4110 additions and 313 deletions
@@ -71,8 +71,10 @@ class ChatAutomatedPromptCard extends StatelessWidget {
],
),
);
final transcript = AppDesignTokens.of(context).transcript;
final glass = AppDesignTokens.of(context).glass;
final tokens = AppDesignTokens.of(context);
final density = tokens.density;
final transcript = tokens.transcript;
final glass = tokens.glass;
final card = transcript == TranscriptStyle.manuscript
? PaperEditorialNote(
label: label,
@@ -90,16 +92,21 @@ class ChatAutomatedPromptCard extends StatelessWidget {
// edge.
shape: glass == null
? RoundedRectangleBorder(
borderRadius: _noteCorners,
borderRadius: tokens.corners(_noteCorners),
side: BorderSide(color: scheme.outlineVariant),
)
: GlassBorder(
borderRadius: _noteCorners,
borderRadius: tokens.corners(_noteCorners),
highlight: glass.highlight,
edge: glass.edge,
),
child: Padding(
padding: const EdgeInsets.fromLTRB(14, 8, 14, 10),
padding: EdgeInsets.fromLTRB(
density.inset(14),
density.space(8),
density.inset(14),
density.space(10),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -166,7 +166,11 @@ class ChatCodeCopyRegion extends StatelessWidget {
key: const Key('chat-code-header'),
color: headerFill(context),
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 12, end: 4),
// Its label starts at the code's own inset (tighter when dense).
padding: EdgeInsetsDirectional.only(
start: AppDesignTokens.of(context).density.space(12),
end: 4,
),
child: Row(
children: [
Expanded(child: label),
@@ -272,7 +272,9 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
code: code,
label: Text(markdownCodeLabel(language), style: labelStyle),
child: Padding(
padding: const EdgeInsets.all(12),
padding: EdgeInsets.all(
AppDesignTokens.of(context).density.space(12),
),
child: ChatTranscriptHorizontalScrollView(
label: 'code block',
child: Text.rich(
@@ -570,9 +572,15 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
/// a tighter line, as a technical book does.
TextStyle _codeStyle(BuildContext context) {
const mono = TextStyle(fontFamily: appMonospaceFamily);
final reading = AppDesignTokens.of(context).reading;
if (reading.family == null) return mono;
final tokens = AppDesignTokens.of(context);
final reading = tokens.reading;
final size = DefaultTextStyle.of(context).style.fontSize ?? 16;
// A dense design sets code at its body size (13 beside 14px prose): the
// monospace runs wider than the prose face.
if (reading.family == null && tokens.density.dense) {
return mono.copyWith(fontSize: size * 13 / 14, height: 1.4);
}
if (reading.family == null) return mono;
return mono.copyWith(
fontSize: size * 0.82,
height: 1.45,
@@ -59,7 +59,10 @@ class ChatUserBubble extends StatelessWidget {
// scrolls, so it never filters what is behind it).
final glass = AppDesignTokens.of(context).glass;
// A Material surface (not a bare DecoratedBox) so a disclosure ListTile
// inside the bubble keeps its ink and background.
// inside the bubble keeps its ink and background. A dense design draws
// a tighter bubble in its own corners.
final tokens = AppDesignTokens.of(context);
final density = tokens.density;
return Material(
color: chatBubbleFill(
context,
@@ -67,13 +70,21 @@ class ChatUserBubble extends StatelessWidget {
),
clipBehavior: Clip.antiAlias,
shape: glass == null
? const RoundedRectangleBorder(borderRadius: _radius)
? RoundedRectangleBorder(borderRadius: tokens.corners(_radius))
: GlassBorder(
borderRadius: _radius,
borderRadius: tokens.corners(_radius),
highlight: glass.highlight,
edge: glass.edge,
),
child: Padding(padding: _padding, child: child),
child: Padding(
padding: density.dense
? EdgeInsets.symmetric(
horizontal: density.inset(_padding.left),
vertical: density.space(_padding.top),
)
: _padding,
child: child,
),
);
}
}
@@ -99,8 +110,10 @@ TextStyle? chatMessageTextStyle(BuildContext context) => AppDesignTokens.of(
/// 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
/// operator's text scaling, so chunks read as separate paragraphs.
/// operator's text scaling, so chunks read as separate paragraphs. A design
/// may set a tighter gap ([ReadingType.paragraphGap]).
double chatParagraphGap(BuildContext context, [double? fontSize]) {
final size = fontSize ?? DefaultTextStyle.of(context).style.fontSize ?? 14;
return MediaQuery.textScalerOf(context).scale(size) * 0.9;
return MediaQuery.textScalerOf(context).scale(size) *
AppDesignTokens.of(context).reading.paragraphGap;
}
@@ -22,7 +22,7 @@ import 'paper/paper_quote.dart';
import 'terminal/terminal_glyphs.dart';
import 'chat_message_timestamp.dart';
import 'chat_read_aloud_button.dart';
import '../../speech/speech_controller.dart';
import '../../speech/speech.dart';
/// Builds an assistant text part; the default keeps the server's text exactly.
typedef ChatMessageTextBuilder = Widget Function(BuildContext, String);
@@ -83,7 +83,8 @@ class ChatMessageView extends StatelessWidget {
// A terminal or manuscript transcript reads top to bottom: the
// operator's prompt line or block quote starts at the same edge as the
// answer and spans its column.
final transcript = AppDesignTokens.of(context).transcript;
final tokens = AppDesignTokens.of(context);
final transcript = tokens.transcript;
final trailingUser =
user && !automated && transcript == TranscriptStyle.bubbles;
// No visible role label: side and surface say who spoke and the row's
@@ -104,9 +105,12 @@ class ChatMessageView extends StatelessWidget {
label: '$role message',
child: Padding(
// A manuscript leaves a little more air between turns, as a page
// spaces its paragraphs, since no bubble sets them apart.
// spaces its paragraphs, since no bubble sets them apart; a dense
// design a little less.
padding: EdgeInsets.symmetric(
vertical: transcript == TranscriptStyle.manuscript ? 12 : 6,
vertical: transcript == TranscriptStyle.manuscript
? 12
: tokens.density.space(6),
),
child: LayoutBuilder(
builder: (context, constraints) => Align(
@@ -13,6 +13,8 @@ const chatStopReadingLabel = 'Stop reading';
/// Read aloud for one reply, styled like its Copy button. While this reply
/// reads it becomes Pause (or Resume) and Stop, laid out along [direction]
/// (a column in the narrow copy gutter). Absent where speech is unsupported.
/// The reader is the app's, so a reply still reading after its chat was left
/// shows Pause and Stop again when the chat is reopened.
class ChatReadAloudButton extends StatelessWidget {
const ChatReadAloudButton({
super.key,
@@ -40,7 +42,19 @@ class ChatReadAloudButton extends StatelessWidget {
key: const Key('chat-message-read-aloud'),
style: style,
tooltip: chatReadAloudLabel,
onPressed: () => unawaited(speech.read(messageId, parts)),
onPressed: () {
// The conversation's name labels the reading wherever it is
// shown (the avatar's indicator, the global Stop).
final origin = SpeechOrigin.maybeOf(context);
unawaited(
speech.read(
messageId,
parts,
scope: origin?.scope,
title: origin?.title ?? '',
),
);
},
icon: const Icon(Icons.volume_up_outlined),
);
}
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/material.dart';
@@ -123,7 +124,8 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
: DateTime.now().difference(started);
final seconds = duration.inSeconds.clamp(0, 2147483647);
final label = '${data.label}${widget.streaming ? ' ${seconds}s' : ''}';
switch (AppDesignTokens.of(context).transcript) {
final tokens = AppDesignTokens.of(context);
switch (tokens.transcript) {
case TranscriptStyle.prompt:
return TerminalActivityRows(
data: data,
@@ -145,8 +147,12 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
}
// Desktop hover hugs the label; phones keep the full-width touch row.
final compact = prefersCompactHitTargets(context);
// A dense design draws the line slimmer on a pointer device; a touch
// device keeps a 40px target.
final density = tokens.density;
final dense = density.dense;
final content = ConstrainedBox(
constraints: const BoxConstraints(minHeight: 32),
constraints: BoxConstraints(minHeight: dense ? 20 : 32),
child: Row(
mainAxisSize: compact ? MainAxisSize.min : MainAxisSize.max,
children: [
@@ -157,7 +163,7 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
child: const ChatResponsePending(),
),
),
const SizedBox(width: 8),
SizedBox(width: density.space(8)),
],
Flexible(
child: Text(
@@ -179,8 +185,13 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
final button = TextButton(
key: const Key('chat-turn-activity'),
style: TextButton.styleFrom(
minimumSize: const Size(0, 48),
padding: const EdgeInsets.all(chatAgentContentInset),
minimumSize: Size(0, dense ? math.max(28, density.minTouchRow) : 48),
padding: dense
? const EdgeInsets.symmetric(
horizontal: chatAgentContentInset,
vertical: 4,
)
: const EdgeInsets.all(chatAgentContentInset),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
alignment: AlignmentDirectional.centerStart,
),
@@ -113,9 +113,9 @@ class _ChatTurnChipState extends State<ChatTurnChip> {
borderRadius: corners,
onTap: _show,
child: Padding(
padding: const EdgeInsets.symmetric(
padding: EdgeInsets.symmetric(
horizontal: chatAgentContentInset,
vertical: 6,
vertical: AppDesignTokens.of(context).density.space(6),
),
child: content,
),