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
@@ -265,6 +265,7 @@ void main() {
(AppDesign.standard, false, true),
(AppDesign.terminal, true, false),
(AppDesign.paper, false, false),
(AppDesign.compact, false, true),
]) {
testWidgets('${design.label}: the open row is clearly marked', (
tester,
+199
View File
@@ -0,0 +1,199 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/theme/app_design.dart';
import 'package:pipelines_app/ui/theme/app_design_controller.dart';
import 'package:pipelines_app/ui/theme/app_design_tokens.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
ThemeData _theme(AppDesign design, Brightness brightness, {String? font}) =>
brightness == Brightness.dark
? design.dark(fontFamily: font)
: design.light(fontFamily: font);
BorderRadius? _radiusOf(ShapeBorder? shape) =>
(shape as RoundedRectangleBorder?)?.borderRadius as BorderRadius?;
void main() {
const six = BorderRadius.all(Radius.circular(6));
test('Compact is listed with a stable id, a label and one line', () {
expect(AppDesign.fromId('compact'), AppDesign.compact);
expect(AppDesign.compact.label, 'Compact');
expect(AppDesign.compact.description, isNot(contains('\n')));
expect(AppDesign.compact.usesInterfaceFont, isTrue);
expect(AppDesign.compact.swatchLines, greaterThan(2));
for (final design in AppDesign.values) {
if (design != AppDesign.compact) expect(design.swatchLines, 2);
}
});
test('Compact tokens: Default chat and composer, tonal rows, 6px corners, '
'the compact density and tighter paragraphs', () {
for (final brightness in Brightness.values) {
final tokens = _theme(
AppDesign.compact,
brightness,
).extension<AppDesignTokens>()!;
expect(tokens.design, AppDesign.compact);
expect(tokens.radius, 6);
expect(tokens.flat, isFalse);
expect(tokens.frame, isNull);
expect(tokens.transcript, TranscriptStyle.bubbles);
expect(tokens.composer, ComposerStyle.pill);
expect(tokens.selectedRow, SelectedRowStyle.tonal);
expect(tokens.density, DesignDensity.compact);
expect(tokens.density.dense, isTrue);
expect(tokens.density.iconSize, 18);
expect(tokens.density.railLabels, isFalse);
expect(tokens.density.railWidth, lessThan(96));
expect(tokens.reading.family, isNull);
expect(tokens.reading.paragraphGap, lessThan(0.9));
expect(tokens.denseCorners(BorderRadius.circular(12)), six);
}
});
test('the comfortable designs keep the comfortable density', () {
for (final design in [AppDesign.terminal, AppDesign.paper]) {
final tokens = design.light().extension<AppDesignTokens>()!;
expect(tokens.density, DesignDensity.comfortable);
expect(tokens.reading.paragraphGap, 0.9);
final twelve = BorderRadius.circular(12);
expect(tokens.denseCorners(twelve), twelve);
}
expect(AppDesignTokens.standard.density, DesignDensity.comfortable);
// Default still builds its exact themes, with no tokens at all.
expect(AppDesign.standard.light(), appLightTheme());
expect(AppDesign.standard.dark(), appDarkTheme());
});
test('density spacing: unchanged when comfortable, 4px grid when dense', () {
const comfortable = DesignDensity.comfortable;
for (final value in [2.0, 4.0, 6.0, 10.0, 13.0, 16.0, 24.0]) {
expect(comfortable.space(value), value);
expect(comfortable.inset(value), value);
}
expect(comfortable.minTouchRow, 0);
const compact = DesignDensity.compact;
expect(compact.space(16), 8);
expect(compact.space(13), 8);
expect(compact.space(12), 8);
expect(compact.space(8), 4);
expect(compact.space(6), 4);
expect(compact.space(4), 2);
expect(compact.space(24), 16);
expect(compact.inset(16), 12);
expect(compact.inset(12), 8);
for (final value in [8.0, 12.0, 16.0, 24.0, 32.0]) {
expect(compact.space(value) % 4, 0, reason: 'on the 4px grid');
expect(compact.space(value), lessThan(value));
}
});
test('Compact keeps Default colours and packs type, icons and density', () {
for (final brightness in Brightness.values) {
final theme = _theme(AppDesign.compact, brightness, font: 'Inter');
final standard = _theme(AppDesign.standard, brightness, font: 'Inter');
expect(theme.colorScheme, standard.colorScheme);
expect(theme.scaffoldBackgroundColor, standard.scaffoldBackgroundColor);
final text = theme.textTheme;
expect(text.bodyMedium?.fontSize, 13);
expect(text.bodyLarge?.fontSize, 14);
expect(text.labelMedium?.fontSize, 12);
expect(text.labelSmall?.fontSize, 11);
expect(text.titleMedium?.fontSize, 14);
for (final style in [text.bodyMedium, text.titleLarge, text.labelLarge]) {
// The device's interface font still applies.
expect(style?.fontFamily, 'Inter');
expect(style?.fontSize, lessThan(20));
// Line heights on a 2px step.
expect((style!.fontSize! * style.height!) % 2, closeTo(0, 0.01));
}
expect(theme.visualDensity, VisualDensity.compact);
expect(theme.iconTheme.size, 18);
expect(
theme.iconButtonTheme.style?.visualDensity,
VisualDensity.compact,
reason: 'Material 3 icon buttons ignore the theme density otherwise',
);
}
});
test('every floating and framed surface takes the same 6px corners', () {
final theme = AppDesign.compact.light();
expect(_radiusOf(theme.dialogTheme.shape), six);
expect(_radiusOf(theme.popupMenuTheme.shape), six);
expect(_radiusOf(theme.snackBarTheme.shape), six);
expect(_radiusOf(theme.cardTheme.shape), six);
expect(_radiusOf(theme.chipTheme.shape), six);
expect(_radiusOf(theme.floatingActionButtonTheme.shape), six);
expect(_radiusOf(theme.listTileTheme.shape), six);
expect(_radiusOf(theme.navigationRailTheme.indicatorShape), six);
expect(_radiusOf(theme.menuTheme.style?.shape?.resolve(const {})), six);
expect(
_radiusOf(theme.filledButtonTheme.style?.shape?.resolve(const {})),
six,
);
expect(
_radiusOf(theme.iconButtonTheme.style?.shape?.resolve(const {})),
six,
);
expect(
(theme.tooltipTheme.decoration as BoxDecoration?)?.borderRadius,
six,
);
final sheet = _radiusOf(theme.bottomSheetTheme.shape)!;
expect(sheet.topLeft, const Radius.circular(6));
expect(sheet.bottomLeft, Radius.zero);
// A card keeps its outline under the theme's shape (outlined graph
// nodes would otherwise lose it).
final card = theme.cardTheme.shape! as RoundedRectangleBorder;
expect(card.side.color, theme.colorScheme.outlineVariant);
});
test('pointer devices shrink targets; touch devices keep 40px', () {
for (final (platform, pointer) in [
(TargetPlatform.linux, true),
(TargetPlatform.macOS, true),
(TargetPlatform.windows, true),
(TargetPlatform.android, false),
(TargetPlatform.iOS, false),
]) {
debugDefaultTargetPlatformOverride = platform;
// Built afresh: the cached theme is the device's, built once.
final theme = AppDesign.compact.build(Brightness.light);
expect(
theme.materialTapTargetSize,
pointer
? MaterialTapTargetSize.shrinkWrap
: MaterialTapTargetSize.padded,
);
expect(DesignDensity.compact.minTouchRow, pointer ? 0 : 40);
}
debugDefaultTargetPlatformOverride = null;
});
test(
'a switch into or out of Compact snaps; others keep the blend',
() async {
final designs = AppDesignController(store: MemoryAppDesignStore());
expect(AppDesign.compact.dense, isTrue);
for (final design in [
AppDesign.standard,
AppDesign.terminal,
AppDesign.paper,
]) {
expect(design.dense, isFalse);
}
expect(designs.themeAnimationDuration, kThemeAnimationDuration);
await designs.select(AppDesign.terminal);
expect(designs.themeAnimationDuration, kThemeAnimationDuration);
await designs.select(AppDesign.compact);
expect(designs.themeAnimationDuration, Duration.zero);
await designs.select(AppDesign.paper);
expect(designs.themeAnimationDuration, Duration.zero);
await designs.select(AppDesign.standard);
expect(designs.themeAnimationDuration, kThemeAnimationDuration);
},
);
}
@@ -0,0 +1,232 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_bubble.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/navigation_rail.dart';
import 'package:pipelines_app/shell/windows/window_frame.dart';
import 'package:pipelines_app/ui/layout/app_list_avatar.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/ui/theme/app_design.dart';
import 'package:pipelines_app/ui/theme/app_design_tokens.dart';
/// Compact as drawn: thin rows, a narrow icon-only rail, 32px icon buttons
/// (40px targets on touch), tight bubbles, a slim window title bar, and no
/// clipping at a large text scale.
void main() {
tearDown(() => debugDefaultTargetPlatformOverride = null);
Future<void> pump(
WidgetTester tester,
Widget child, {
AppDesign design = AppDesign.compact,
double textScale = 1,
double width = 560,
}) async {
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
MaterialApp(
// Built afresh, so the platform this test sets is the theme's.
theme: design.build(Brightness.light),
home: MediaQuery(
data: MediaQueryData(
size: Size(width, 900),
textScaler: TextScaler.linear(textScale),
),
child: Scaffold(body: child),
),
),
);
await tester.pumpAndSettle();
}
Widget rows() => ListView(
children: [
AppListRow(
key: const Key('one'),
title: const Text('Release train'),
time: '09:12',
onTap: () {},
),
AppListRow(
key: const Key('two'),
leading: AppListAvatar.initial('Release', color: Colors.teal),
title: const Text('Release notes'),
subtitle: const Text('claude-opus · /workspace/demo'),
time: '10m',
selected: true,
onTap: () {},
),
],
);
testWidgets('pointer: a 36px single-line row and a ~52px two-line row', (
tester,
) async {
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
await pump(tester, rows());
// Each row includes its 1px divider.
expect(tester.getSize(find.byKey(const Key('one'))).height, 37);
final two = tester.getSize(find.byKey(const Key('two'))).height;
expect(two, inInclusiveRange(50, 56));
expect(
tester.getSize(find.byType(AppListAvatar)).height,
DesignDensity.compact.avatarSize,
);
debugDefaultTargetPlatformOverride = null;
});
testWidgets('touch: rows keep a 40px target', (tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.android;
await pump(tester, rows());
expect(
tester.getSize(find.byKey(const Key('one'))).height,
greaterThanOrEqualTo(41),
);
debugDefaultTargetPlatformOverride = null;
});
testWidgets('Default rows keep their comfortable size', (tester) async {
await pump(tester, rows(), design: AppDesign.standard);
expect(
tester.getSize(find.byKey(const Key('one'))).height,
greaterThan(48),
);
expect(
tester.getSize(find.byType(AppListAvatar)).height,
kAppListAvatarSize,
);
});
testWidgets('rows and bubbles do not clip at 2x text', (tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
await pump(
tester,
Column(
children: [
SizedBox(height: 300, child: rows()),
const ChatUserBubble(child: Text('Summarise the release notes.')),
],
),
textScale: 2,
width: 360,
);
expect(tester.takeException(), isNull);
final one = tester.getSize(find.byKey(const Key('one'))).height;
expect(one, greaterThan(37), reason: 'the row grows with its text');
debugDefaultTargetPlatformOverride = null;
});
testWidgets('icon buttons: 32px on a pointer device, 40px target on touch', (
tester,
) async {
Widget button() => IconButton(
key: const Key('b'),
onPressed: () {},
icon: const Icon(Icons.add),
);
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
await pump(tester, Center(child: button()));
expect(tester.getSize(find.byKey(const Key('b'))), const Size(32, 32));
debugDefaultTargetPlatformOverride = TargetPlatform.android;
await pump(tester, Center(child: button()));
expect(tester.getSize(find.byKey(const Key('b'))), const Size(40, 40));
debugDefaultTargetPlatformOverride = null;
});
testWidgets('the rail is narrow and icon-only, each icon with a tooltip', (
tester,
) async {
await pump(
tester,
Row(
children: [
ShellNavigationRail(
selected: AppDestination.runs,
icon: (d) => Icon(destinationDetails(d).icon),
onSelected: (_) {},
),
const Expanded(child: SizedBox()),
],
),
width: 1200,
);
final rail = find.byKey(const ValueKey('shell.navigation-rail.surface'));
expect(tester.getSize(rail).width, DesignDensity.compact.railWidth);
expect(
tester.widget<NavigationRail>(find.byType(NavigationRail)).labelType,
NavigationRailLabelType.none,
);
for (final destination in shellTabDestinations) {
expect(
find.byTooltip(destinationDetails(destination).label),
findsOneWidget,
);
}
expect(find.byTooltip('Settings'), findsOneWidget);
// Settings' indicator matches the tabs' 56x32 rather than the rail.
final indicator = find.descendant(
of: find.byKey(const ValueKey('shell.destination.settings')),
matching: find.byType(Container),
);
expect(tester.getSize(indicator.first), const Size(56, 32));
});
testWidgets('the operator bubble is tight, in the design corners', (
tester,
) async {
await pump(tester, const ChatUserBubble(child: Text('Ship it')));
final material = tester.widget<Material>(
find.descendant(
of: find.byType(ChatUserBubble),
matching: find.byType(Material),
),
);
final shape = material.shape! as RoundedRectangleBorder;
expect(shape.borderRadius, BorderRadius.circular(6));
final padding = tester.widget<Padding>(
find.descendant(
of: find.byType(ChatUserBubble),
matching: find.byType(Padding),
),
);
expect(
padding.padding,
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
);
final gap = chatParagraphGap(tester.element(find.text('Ship it')), 14);
expect(gap, closeTo(14 * 0.6, 0.01));
});
testWidgets('a floating window has a 32px title bar and 6px corners', (
tester,
) async {
late BuildContext context;
await pump(
tester,
Builder(
builder: (c) {
context = c;
return const SizedBox();
},
),
);
expect(windowTitleBarHeight(context), 32);
expect(windowCorners(context), BorderRadius.circular(6));
await pump(
tester,
Builder(
builder: (c) {
context = c;
return const SizedBox();
},
),
design: AppDesign.paper,
);
expect(windowTitleBarHeight(context), 40);
expect(windowCorners(context), BorderRadius.circular(windowCornerRadius));
});
}
+121
View File
@@ -0,0 +1,121 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/domain/chat_transcript.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_view.dart';
import 'package:pipelines_app/ui/theme/app_design.dart';
final _rows = transcriptRows([
for (var i = 0; i < 6; i++) ...[
{
'id': 'u$i',
'role': 'user',
'parts': [
{'type': 'text', 'text': 'Step $i'},
],
},
{
'id': 'a$i',
'role': 'assistant',
'parts': [
{
'type': 'tool',
'id': 't$i',
'name': 'Bash',
'state': {
'status': 'completed',
'input': {'command': 'go test'},
},
},
{'type': 'text', 'text': 'Fixed `x`.\n\n- one\n\n```go\nreturn 1\n```'},
],
},
],
]);
/// A live design switch to and from Compact animates the theme without an
/// error in any frame. A component theme that set a text-theme style failed
/// to lerp against Default's unset one, and in the browser the broken
/// frames stopped the app drawing.
void main() {
testWidgets('switching to and from Compact lerps every frame cleanly', (
tester,
) async {
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
final design = ValueNotifier(AppDesign.compact);
await tester.pumpWidget(
ValueListenableBuilder<AppDesign>(
valueListenable: design,
builder: (_, d, _) => MaterialApp(
theme: d.dark(),
darkTheme: d.dark(),
home: Scaffold(
floatingActionButton: FloatingActionButton.extended(
onPressed: () {},
icon: const Icon(Icons.add),
label: const Text('New run'),
),
body: Row(
children: [
NavigationRail(
destinations: const [
NavigationRailDestination(
icon: Icon(Icons.add),
label: Text('a'),
),
NavigationRailDestination(
icon: Icon(Icons.add),
label: Text('b'),
),
],
selectedIndex: 0,
),
Expanded(
child: ListView(
children: [
IconButton(onPressed: () {}, icon: const Icon(Icons.add)),
IconButton.filled(
onPressed: () {},
icon: const Icon(Icons.add),
),
Checkbox(value: true, onChanged: (_) {}),
Switch(value: true, onChanged: (_) {}),
const ListTile(title: Text('t'), subtitle: Text('s')),
const TextField(),
Chip(label: const Text('c'), onDeleted: () {}),
SegmentedButton<int>(
segments: const [
ButtonSegment(value: 1, label: Text('one')),
ButtonSegment(value: 2, label: Text('two')),
],
selected: const {1},
),
for (final row in _rows) ChatMessageView(row: row),
],
),
),
],
),
),
),
),
);
await tester.pumpAndSettle();
for (var round = 0; round < 3; round++) {
for (final other in [
AppDesign.standard,
AppDesign.terminal,
AppDesign.paper,
AppDesign.compact,
]) {
design.value = other;
for (var f = 0; f < 20; f++) {
await tester.pump(const Duration(milliseconds: 16));
final e = tester.takeException();
if (e != null) fail('to ${other.id} frame $f: $e');
}
}
}
debugDefaultTargetPlatformOverride = null;
});
}