Design: Terminal is the default when none is stored; Default is now Classic

An unset (or unknown) design id resolves to Terminal, in the controller's
initial value, AppDesign.fromId and the boot spinner. A stored choice,
including Classic's stable 'default' id, is respected. The picker calls the
original Material look Classic so no row reads 'Default'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 21:33:05 +00:00
parent 8c224fecf8
commit 8ed3998dd5
10 changed files with 101 additions and 52 deletions
+3 -2
View File
@@ -18,7 +18,6 @@ import '../features/settings/settings_store.dart';
import '../ui/scale/ui_scale.dart';
import '../ui/theme/app_design_controller.dart';
import '../ui/theme/app_font_controller.dart';
import '../ui/theme/app_theme.dart';
import 'detached/detached_app.dart';
import 'detached/detached_route.dart';
import 'pipelines_app.dart';
@@ -322,7 +321,9 @@ class _PipelinesRootState extends State<PipelinesRoot> {
child: Directionality(
textDirection: TextDirection.ltr,
child: Theme(
data: appLightTheme(),
// The device's design (Terminal until one is chosen), so the
// spinner does not flash another look before the app.
data: AppDesignController.instance.design.light(),
child: const Center(child: CircularProgressIndicator()),
),
),
+11 -5
View File
@@ -25,13 +25,15 @@ final Map<(AppDesign, Brightness, String?), ThemeData> _themes = {};
/// 3. give the theme an [AppDesignTokens] extension: set only the tokens it
/// changes (corners, flat surfaces, frame, panel fill, transcript,
/// composer and selected-row styles, reading type); every token defaults
/// to the Default look;
/// to the Classic look;
/// 4. give it a [swatch] for the picker and say whether it [usesInterfaceFont].
/// 5. run the design budget (app/tool/perf/README.md) and keep it passing.
/// Widgets read the tokens, so most surfaces follow without per-widget code.
enum AppDesign {
/// The app's own Material look.
standard('default', 'Default', 'The app’s Material look.'),
/// The app's original Material look. Its stored id stays `default` (the
/// id it had when it was the default); the picker calls it Classic so it
/// does not read as "whatever the app starts with".
standard('default', 'Classic', 'The app’s original Material look.'),
/// A terminal-style look: monospace text, near-black pages, thin frames
/// and a transcript drawn as prompt and tool lines.
@@ -60,12 +62,16 @@ enum AppDesign {
/// The picker's one-line summary of the design.
final String description;
/// The design stored as [id], or [standard] for an unknown or missing id.
/// The design a device has before it chooses one: Terminal.
static const AppDesign defaultDesign = terminal;
/// The design stored as [id], or [defaultDesign] for an unknown or missing
/// id. A stored choice (Classic's `default` included) is kept.
static AppDesign fromId(String? id) {
for (final design in values) {
if (design.id == id) return design;
}
return standard;
return defaultDesign;
}
/// The design's light theme. [fontFamily] is the device's interface font;
+1 -1
View File
@@ -71,7 +71,7 @@ class AppDesignController extends ChangeNotifier {
static final AppDesignController instance = AppDesignController();
final AppDesignStore _store;
AppDesign _design = AppDesign.standard;
AppDesign _design = AppDesign.defaultDesign;
int _revision = 0;
bool _saveFailed = false;
+2 -2
View File
@@ -5,7 +5,7 @@ import 'package:flutter/painting.dart';
/// transcript widgets branch on it, never on the design itself.
enum TranscriptStyle {
/// The operator's turns as bubbles on the trailing side, the agent's
/// answers on the page and its activity as a one-line button (Default).
/// answers on the page and its activity as a one-line button (Classic).
bubbles,
/// A CLI's prompt line, glyph-led tool lines and bracketed injected
@@ -32,7 +32,7 @@ enum ComposerStyle {
/// How a list (AppListRow) marks the row that is open. Every style keeps
/// the leading bar in the row's accent; they differ in the fill and frame.
enum SelectedRowStyle {
/// Material's tonal `secondaryContainer` fill (Default).
/// Material's tonal `secondaryContainer` fill (Classic).
tonal,
/// The accent washed over the page, stronger than a tinted row, inside a
+3 -3
View File
@@ -6,7 +6,7 @@ import 'app_design_styles.dart';
export 'app_design_styles.dart';
/// The muted ANSI-style accents a design names for status and roles. The
/// Default design leaves them to its colour scheme; Terminal sets them, and
/// Classic design leaves them to its colour scheme; Terminal sets them, and
/// Paper sets ink-toned ones.
@immutable
class AnsiAccents {
@@ -46,7 +46,7 @@ class AnsiAccents {
/// typography. Every theme an [AppDesign] builds carries one; a theme without
/// one (a test's bare `ThemeData`) reads as [standard].
///
/// Adding a design: every field has a default that keeps the Default look,
/// Adding a design: every field has a default that keeps the Classic look,
/// so a new design sets only what it changes. Widgets branch on the named
/// styles ([transcript], [composer], [selectedRow]) rather than on [design],
/// so two designs can share a behaviour.
@@ -67,7 +67,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
this.chatColorSaturation = 1,
});
/// The Default design: every widget keeps its own shapes.
/// The Classic design: every widget keeps its own shapes.
static const AppDesignTokens standard = AppDesignTokens(
design: AppDesign.standard,
);
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
@@ -18,6 +19,8 @@ import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dar
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../native_back.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'package:pipelines_app/ui/theme/app_design.dart';
import 'package:pipelines_app/ui/theme/app_design_controller.dart';
ServerEndpoint webServer() => ServerEndpoint.resolve(
base: Uri.parse('http://127.0.0.1:8096/'),
@@ -300,6 +303,15 @@ void main() {
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
// The Classic design's transcript (its activity summary line); the
// app starts on Terminal when no design is stored.
// The choice applies at once; its save need not finish here.
unawaited(AppDesignController.instance.select(AppDesign.standard));
addTearDown(
() => unawaited(
AppDesignController.instance.select(AppDesign.defaultDesign),
),
);
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(
@@ -29,7 +29,7 @@ AppDesignTokens _tokens(WidgetTester tester) =>
AppDesignTokens.of(tester.element(find.text(designSectionTitle)));
void main() {
testWidgets('every design is a radio row; Default is chosen at first', (
testWidgets('every design is a radio row; Terminal is chosen at first', (
tester,
) async {
final designs = AppDesignController(store: MemoryAppDesignStore());
@@ -43,40 +43,43 @@ void main() {
final group = tester.widget<RadioGroup<AppDesign>>(
find.byType(RadioGroup<AppDesign>),
);
expect(group.groupValue, AppDesign.standard);
expect(_tokens(tester).terminal, isFalse);
expect(group.groupValue, AppDesign.terminal);
expect(_tokens(tester).terminal, isTrue);
// The Material look is called Classic, so no row reads "Default".
expect(find.text('Classic'), findsOneWidget);
expect(find.text('Default'), findsNothing);
});
testWidgets('choosing Terminal stores it and restyles the page live', (
testWidgets('choosing Classic stores it and restyles the page live', (
tester,
) async {
final store = MemoryAppDesignStore();
final designs = AppDesignController(store: store);
await _pump(tester, designs);
await tester.tap(find.text(AppDesign.terminal.label));
await tester.pumpAndSettle();
expect(store.id, AppDesign.terminal.id);
expect(designs.design, AppDesign.terminal);
expect(_tokens(tester).terminal, isTrue);
expect(find.text(designSaveFailedText), findsNothing);
await tester.tap(find.text(AppDesign.standard.label));
await tester.pumpAndSettle();
expect(store.id, AppDesign.standard.id);
expect(designs.design, AppDesign.standard);
expect(_tokens(tester).terminal, isFalse);
expect(find.text(designSaveFailedText), findsNothing);
await tester.tap(find.text(AppDesign.terminal.label));
await tester.pumpAndSettle();
expect(store.id, AppDesign.terminal.id);
expect(_tokens(tester).terminal, isTrue);
});
testWidgets('a stored choice is restored into the picker', (tester) async {
final designs = AppDesignController(
store: MemoryAppDesignStore(AppDesign.terminal.id),
store: MemoryAppDesignStore(AppDesign.standard.id),
);
await designs.restore();
await _pump(tester, designs);
final group = tester.widget<RadioGroup<AppDesign>>(
find.byType(RadioGroup<AppDesign>),
);
expect(group.groupValue, AppDesign.terminal);
expect(group.groupValue, AppDesign.standard);
});
testWidgets('a failed save says the choice lasts until reload', (
@@ -86,10 +89,10 @@ void main() {
store: MemoryAppDesignStore()..failSaves = true,
);
await _pump(tester, designs);
await tester.tap(find.text(AppDesign.terminal.label));
await tester.tap(find.text(AppDesign.paper.label));
await tester.pumpAndSettle();
expect(find.text(designSaveFailedText), findsOneWidget);
expect(designs.design, AppDesign.terminal);
expect(designs.design, AppDesign.paper);
});
testWidgets('choosing Paper stores it, restyles the page live and is '
@@ -4,34 +4,52 @@ import 'package:pipelines_app/ui/theme/app_design_controller.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() {
test('restore applies the stored design; unknown ids keep Default', () async {
final stored = AppDesignController(store: MemoryAppDesignStore('terminal'));
var notified = 0;
stored.addListener(() => notified++);
await stored.restore();
expect(stored.design, AppDesign.terminal);
expect(notified, 1);
final unknown = AppDesignController(store: MemoryAppDesignStore('neon'));
await unknown.restore();
expect(unknown.design, AppDesign.standard);
test('an unset device starts on Terminal and keeps it', () async {
final unset = AppDesignController(store: MemoryAppDesignStore());
expect(unset.design, AppDesign.terminal);
await unset.restore();
expect(unset.design, AppDesign.terminal);
});
test(
'restore applies the stored design; unknown ids are the default',
() async {
// An explicit Classic choice, stored as `default` back when Classic was
// the default, is respected.
final stored = AppDesignController(
store: MemoryAppDesignStore('default'),
);
var notified = 0;
stored.addListener(() => notified++);
await stored.restore();
expect(stored.design, AppDesign.standard);
expect(notified, 1);
final paper = AppDesignController(store: MemoryAppDesignStore('paper'));
await paper.restore();
expect(paper.design, AppDesign.paper);
final unknown = AppDesignController(store: MemoryAppDesignStore('neon'));
await unknown.restore();
expect(unknown.design, AppDesign.terminal);
},
);
test('select applies at once and stores the id', () async {
final store = MemoryAppDesignStore();
final designs = AppDesignController(store: store);
final pending = designs.select(AppDesign.terminal);
expect(designs.design, AppDesign.terminal);
final pending = designs.select(AppDesign.standard);
expect(designs.design, AppDesign.standard);
await pending;
expect(store.id, 'terminal');
expect(store.id, 'default');
expect(designs.saveFailed, isFalse);
});
test('a failed save is reported and the choice still applies', () async {
final store = MemoryAppDesignStore()..failSaves = true;
final designs = AppDesignController(store: store);
await designs.select(AppDesign.terminal);
expect(designs.design, AppDesign.terminal);
await designs.select(AppDesign.paper);
expect(designs.design, AppDesign.paper);
expect(designs.saveFailed, isTrue);
store.failSaves = false;
await designs.select(AppDesign.standard);
+12 -8
View File
@@ -11,16 +11,19 @@ import 'package:pipelines_app/ui/theme/app_font_store.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
void main() {
test('ids round-trip and an unknown id is the Default design', () {
test('ids round-trip and a missing or unknown id is Terminal', () {
for (final design in AppDesign.values) {
expect(AppDesign.fromId(design.id), design);
}
expect(AppDesign.fromId(null), AppDesign.standard);
expect(AppDesign.fromId('neon'), AppDesign.standard);
expect(AppDesign.defaultDesign, AppDesign.terminal);
expect(AppDesign.fromId(null), AppDesign.terminal);
expect(AppDesign.fromId('neon'), AppDesign.terminal);
// Classic keeps the id it was stored under when it was the default.
expect(AppDesign.standard.id, 'default');
expect(AppDesign.standard.label, 'Classic');
});
test('the Default design builds exactly the existing themes', () {
test('the Classic design builds exactly the existing themes', () {
expect(AppDesign.standard.light(), appLightTheme());
expect(AppDesign.standard.dark(), appDarkTheme());
expect(
@@ -97,14 +100,15 @@ void main() {
},
),
);
expect(tokens.terminal, isFalse);
expect(family, isNot(appMonospaceFamily));
await designs.select(AppDesign.terminal);
await tester.pumpAndSettle();
// Terminal until the device chooses.
expect(tokens.terminal, isTrue);
expect(family, appMonospaceFamily);
await designs.select(AppDesign.standard);
await tester.pumpAndSettle();
expect(tokens.terminal, isFalse);
expect(family, isNot(appMonospaceFamily));
await designs.select(AppDesign.terminal);
await tester.pumpAndSettle();
expect(tokens.terminal, isTrue);
});
}
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/app.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/theme/app_design_controller.dart';
import 'package:pipelines_app/ui/theme/app_font.dart';
import 'package:pipelines_app/ui/theme/app_font_controller.dart';
import 'package:pipelines_app/ui/theme/app_font_store.dart';
@@ -36,10 +37,14 @@ void main() {
store: MemoryAppFontStore(),
loader: (family, assets) async {},
);
// Classic follows the interface font (Terminal keeps its monospace).
final designs = AppDesignController(store: MemoryAppDesignStore('default'));
await designs.restore();
String? family;
await tester.pumpWidget(
MyApp(
fonts: fonts,
designs: designs,
destination: AppDestination.settings,
destinationBodies: <AppDestination, WidgetBuilder>{
AppDestination.settings: (context) => Builder(