App: add a selectable app design with a Terminal look
AppDesign builds each design's light and dark ThemeData with an AppDesignTokens extension (corner radius, flat surfaces, frame colour, ANSI accents, prompt glyph). Settings gains a Design picker stored per device; the theme hosts rebuild live. Terminal is monospace (bundled RobotoMono), near-black or paper, flat 1px frames with 3px corners, and draws the chat transcript as prompt lines, tool dot/result lines and bracketed follow-up lines. Default keeps its exact themes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import '../ui/adaptive/window_margins.dart';
|
import '../ui/adaptive/window_margins.dart';
|
||||||
|
import '../ui/theme/app_design.dart';
|
||||||
|
import '../ui/theme/app_design_controller.dart';
|
||||||
import '../ui/theme/app_font_controller.dart';
|
import '../ui/theme/app_font_controller.dart';
|
||||||
import '../ui/theme/app_theme.dart';
|
|
||||||
import '../ui/scale/ui_scale.dart';
|
import '../ui/scale/ui_scale.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ class MyApp extends StatelessWidget {
|
|||||||
this.destination,
|
this.destination,
|
||||||
this.onDestinationSelected,
|
this.onDestinationSelected,
|
||||||
this.fonts,
|
this.fonts,
|
||||||
|
this.designs,
|
||||||
}) : routerConfig = null;
|
}) : routerConfig = null;
|
||||||
|
|
||||||
/// A host for a [Router]-owned location, so browser Back/Forward and deep
|
/// A host for a [Router]-owned location, so browser Back/Forward and deep
|
||||||
@@ -28,6 +30,7 @@ class MyApp extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required RouterConfig<Object> this.routerConfig,
|
required RouterConfig<Object> this.routerConfig,
|
||||||
this.fonts,
|
this.fonts,
|
||||||
|
this.designs,
|
||||||
}) : destinationBodies = const {},
|
}) : destinationBodies = const {},
|
||||||
destination = null,
|
destination = null,
|
||||||
onDestinationSelected = null;
|
onDestinationSelected = null;
|
||||||
@@ -42,24 +45,29 @@ class MyApp extends StatelessWidget {
|
|||||||
/// A change rebuilds the themes in place, without a restart.
|
/// A change rebuilds the themes in place, without a restart.
|
||||||
final AppFontController? fonts;
|
final AppFontController? fonts;
|
||||||
|
|
||||||
|
/// The device's design; defaults to the app's shared controller. A change
|
||||||
|
/// rebuilds the themes in place, like a font change.
|
||||||
|
final AppDesignController? designs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final fonts = this.fonts ?? AppFontController.instance;
|
final fonts = this.fonts ?? AppFontController.instance;
|
||||||
|
final designs = this.designs ?? AppDesignController.instance;
|
||||||
return ListenableBuilder(
|
return ListenableBuilder(
|
||||||
listenable: fonts,
|
listenable: Listenable.merge([fonts, designs]),
|
||||||
builder: (context, _) => _host(fonts.family),
|
builder: (context, _) => _host(designs.design, fonts.family),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _host(String? fontFamily) {
|
Widget _host(AppDesign design, String? fontFamily) {
|
||||||
final router = routerConfig;
|
final router = routerConfig;
|
||||||
if (router != null) {
|
if (router != null) {
|
||||||
return MaterialApp.router(
|
return MaterialApp.router(
|
||||||
title: 'Pipelines',
|
title: 'Pipelines',
|
||||||
scaffoldMessengerKey: appScaffoldMessengerKey,
|
scaffoldMessengerKey: appScaffoldMessengerKey,
|
||||||
builder: _scaled,
|
builder: _scaled,
|
||||||
theme: appLightTheme(fontFamily: fontFamily),
|
theme: design.light(fontFamily: fontFamily),
|
||||||
darkTheme: appDarkTheme(fontFamily: fontFamily),
|
darkTheme: design.dark(fontFamily: fontFamily),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
routerConfig: router,
|
routerConfig: router,
|
||||||
);
|
);
|
||||||
@@ -68,8 +76,8 @@ class MyApp extends StatelessWidget {
|
|||||||
title: 'Pipelines',
|
title: 'Pipelines',
|
||||||
scaffoldMessengerKey: appScaffoldMessengerKey,
|
scaffoldMessengerKey: appScaffoldMessengerKey,
|
||||||
builder: _scaled,
|
builder: _scaled,
|
||||||
theme: appLightTheme(fontFamily: fontFamily),
|
theme: design.light(fontFamily: fontFamily),
|
||||||
darkTheme: appDarkTheme(fontFamily: fontFamily),
|
darkTheme: design.dark(fontFamily: fontFamily),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
home: AdaptiveShell(
|
home: AdaptiveShell(
|
||||||
destinationBodies: destinationBodies,
|
destinationBodies: destinationBodies,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import 'pipelines_binding.dart';
|
|||||||
import 'pipelines_root.dart';
|
import 'pipelines_root.dart';
|
||||||
import 'server_endpoint.dart';
|
import 'server_endpoint.dart';
|
||||||
import '../features/settings/settings_store.dart';
|
import '../features/settings/settings_store.dart';
|
||||||
|
import '../ui/theme/app_design_controller.dart';
|
||||||
import '../ui/theme/app_font_controller.dart';
|
import '../ui/theme/app_font_controller.dart';
|
||||||
import '../ui/theme/app_font_licenses.dart';
|
import '../ui/theme/app_font_licenses.dart';
|
||||||
import '../ui/motion/animation_speed.dart';
|
import '../ui/motion/animation_speed.dart';
|
||||||
@@ -73,9 +74,11 @@ Future<void> runPipelinesApp({
|
|||||||
final quickSwitchAnimation = QuickSwitchAnimationController.instance
|
final quickSwitchAnimation = QuickSwitchAnimationController.instance
|
||||||
.restore();
|
.restore();
|
||||||
final font = AppFontController.instance.restore(wait: appFontStartupWait);
|
final font = AppFontController.instance.restore(wait: appFontStartupWait);
|
||||||
|
final design = AppDesignController.instance.restore();
|
||||||
// A phone behind the web login reconnects with its kept session.
|
// A phone behind the web login reconnects with its kept session.
|
||||||
await ServerSession.load();
|
await ServerSession.load();
|
||||||
await font;
|
await font;
|
||||||
|
await design;
|
||||||
await animationSpeed;
|
await animationSpeed;
|
||||||
await uiScale;
|
await uiScale;
|
||||||
await terminalLayout;
|
await terminalLayout;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import '../../features/terminal/terminal_layout.dart';
|
|||||||
import '../../ui/adaptive/window_margins.dart';
|
import '../../ui/adaptive/window_margins.dart';
|
||||||
import '../../ui/scale/ui_scale.dart';
|
import '../../ui/scale/ui_scale.dart';
|
||||||
import '../../ui/theme/app_font_controller.dart';
|
import '../../ui/theme/app_font_controller.dart';
|
||||||
import '../../ui/theme/app_theme.dart';
|
import '../../ui/theme/app_design_controller.dart';
|
||||||
import '../app_route.dart';
|
import '../app_route.dart';
|
||||||
import '../app_session.dart';
|
import '../app_session.dart';
|
||||||
import '../app_terminals.dart';
|
import '../app_terminals.dart';
|
||||||
@@ -202,8 +202,9 @@ class _DetachedWindowAppState extends State<DetachedWindowApp> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final fonts = AppFontController.instance;
|
final fonts = AppFontController.instance;
|
||||||
|
final designs = AppDesignController.instance;
|
||||||
final app = ListenableBuilder(
|
final app = ListenableBuilder(
|
||||||
listenable: Listenable.merge([fonts, _title]),
|
listenable: Listenable.merge([fonts, designs, _title]),
|
||||||
builder: (context, _) => MaterialApp(
|
builder: (context, _) => MaterialApp(
|
||||||
title: _title.value.isEmpty
|
title: _title.value.isEmpty
|
||||||
? 'Pipelines'
|
? 'Pipelines'
|
||||||
@@ -213,8 +214,8 @@ class _DetachedWindowAppState extends State<DetachedWindowApp> {
|
|||||||
builder: (context, child) => UiScaleHost(
|
builder: (context, child) => UiScaleHost(
|
||||||
child: WindowMargins(child: child ?? const SizedBox.shrink()),
|
child: WindowMargins(child: child ?? const SizedBox.shrink()),
|
||||||
),
|
),
|
||||||
theme: appLightTheme(fontFamily: fonts.family),
|
theme: designs.design.light(fontFamily: fonts.family),
|
||||||
darkTheme: appDarkTheme(fontFamily: fonts.family),
|
darkTheme: designs.design.dark(fontFamily: fonts.family),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
// The window's one page is named by its route, so the address bar
|
// The window's one page is named by its route, so the address bar
|
||||||
// (and a reload) keeps the detached location instead of `/`.
|
// (and a reload) keeps the detached location instead of `/`.
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import '../features/settings/server_connections.dart';
|
|||||||
import '../features/settings/saved_servers_section.dart';
|
import '../features/settings/saved_servers_section.dart';
|
||||||
import '../features/settings/settings_store.dart';
|
import '../features/settings/settings_store.dart';
|
||||||
import '../ui/scale/ui_scale.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_font_controller.dart';
|
||||||
import '../ui/theme/app_theme.dart';
|
import '../ui/theme/app_theme.dart';
|
||||||
import 'detached/detached_app.dart';
|
import 'detached/detached_app.dart';
|
||||||
@@ -377,15 +378,16 @@ class _PipelinesRootState extends State<PipelinesRoot> {
|
|||||||
const [],
|
const [],
|
||||||
);
|
);
|
||||||
final fonts = AppFontController.instance;
|
final fonts = AppFontController.instance;
|
||||||
|
final designs = AppDesignController.instance;
|
||||||
return ListenableBuilder(
|
return ListenableBuilder(
|
||||||
listenable: fonts,
|
listenable: Listenable.merge([fonts, designs]),
|
||||||
builder: (context, _) => MaterialApp(
|
builder: (context, _) => MaterialApp(
|
||||||
title: 'Pipelines',
|
title: 'Pipelines',
|
||||||
builder: (context, child) => UiScaleHost(
|
builder: (context, child) => UiScaleHost(
|
||||||
child: WindowMargins(child: child ?? const SizedBox.shrink()),
|
child: WindowMargins(child: child ?? const SizedBox.shrink()),
|
||||||
),
|
),
|
||||||
theme: appLightTheme(fontFamily: fonts.family),
|
theme: designs.design.light(fontFamily: fonts.family),
|
||||||
darkTheme: appDarkTheme(fontFamily: fonts.family),
|
darkTheme: designs.design.dark(fontFamily: fonts.family),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
home: flow,
|
home: flow,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import 'composer_focus_request.dart';
|
|||||||
import 'composer_focus_restore.dart';
|
import 'composer_focus_restore.dart';
|
||||||
import 'chat_bar_tint.dart';
|
import 'chat_bar_tint.dart';
|
||||||
import 'composer_focus_ring.dart';
|
import 'composer_focus_ring.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
import 'composer_running_border.dart';
|
import 'composer_running_border.dart';
|
||||||
import '../shell/chat_shell_command.dart';
|
import '../shell/chat_shell_command.dart';
|
||||||
import '../shell/chat_shell_mode_indicator.dart';
|
import '../shell/chat_shell_mode_indicator.dart';
|
||||||
@@ -1107,15 +1108,16 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
|||||||
/// ([ComposerRunningBorder]); it is mounted only for that time.
|
/// ([ComposerRunningBorder]); it is mounted only for that time.
|
||||||
Widget _pill(BuildContext context, Widget child) {
|
Widget _pill(BuildContext context, Widget child) {
|
||||||
final accent = chatFocusRingColor(context, widget.chatColor);
|
final accent = chatFocusRingColor(context, widget.chatColor);
|
||||||
|
final shape = AppDesignTokens.of(context).shape(_pillShape);
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
ComposerFocusRing(
|
ComposerFocusRing(
|
||||||
focus: _focus,
|
focus: _focus,
|
||||||
accent: accent,
|
accent: accent,
|
||||||
shape: _pillShape,
|
shape: shape,
|
||||||
child: GlassPill(
|
child: GlassPill(
|
||||||
key: const Key('chat-composer-pill'),
|
key: const Key('chat-composer-pill'),
|
||||||
shape: _pillShape,
|
shape: shape,
|
||||||
// The end controls keep the same gap from the pill's sides as from
|
// The end controls keep the same gap from the pill's sides as from
|
||||||
// its bottom (and its top while the field is one line).
|
// its bottom (and its top while the field is one line).
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -1130,7 +1132,7 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
|||||||
child: ListenableBuilder(
|
child: ListenableBuilder(
|
||||||
listenable: _focus,
|
listenable: _focus,
|
||||||
builder: (context, _) => ComposerRunningBorder(
|
builder: (context, _) => ComposerRunningBorder(
|
||||||
shape: _pillShape,
|
shape: shape,
|
||||||
primary: accent,
|
primary: accent,
|
||||||
tertiary: Theme.of(context).colorScheme.tertiary,
|
tertiary: Theme.of(context).colorScheme.tertiary,
|
||||||
focused: _focus.hasFocus,
|
focused: _focus.hasFocus,
|
||||||
@@ -1312,6 +1314,10 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
|||||||
// Let a long folder name wrap when the attach and primary controls
|
// Let a long folder name wrap when the attach and primary controls
|
||||||
// leave little horizontal room.
|
// leave little horizontal room.
|
||||||
hintMaxLines: 2,
|
hintMaxLines: 2,
|
||||||
|
// A terminal design's prompt glyph leads the field, as a CLI's
|
||||||
|
// input line does.
|
||||||
|
prefixIcon: _promptGlyph(context),
|
||||||
|
prefixIconConstraints: const BoxConstraints(),
|
||||||
// The pill draws the field's surface; the field adds no border.
|
// The pill draws the field's surface; the field adds no border.
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
isDense: true,
|
isDense: true,
|
||||||
@@ -1320,6 +1326,26 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The prompt glyph before the field under a terminal design; null under
|
||||||
|
/// the Default design.
|
||||||
|
Widget? _promptGlyph(BuildContext context) {
|
||||||
|
final tokens = AppDesignTokens.of(context);
|
||||||
|
if (!tokens.terminal) return null;
|
||||||
|
return ExcludeSemantics(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(start: 4, end: 10),
|
||||||
|
child: Text(
|
||||||
|
tokens.promptGlyph,
|
||||||
|
key: const Key('chat-composer-prompt-glyph'),
|
||||||
|
style: TextStyle(
|
||||||
|
color: chatFocusRingColor(context, widget.chatColor),
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// The single primary control: Send (or Run command for a `!` draft). A
|
/// The single primary control: Send (or Run command for a `!` draft). A
|
||||||
/// prompt sent while a turn runs takes the server's queued-prompt path; the
|
/// prompt sent while a turn runs takes the server's queued-prompt path; the
|
||||||
/// running turn is stopped by Escape twice, `/stop`, or the More menu.
|
/// running turn is stopped by Escape twice, `/stop`, or the More menu.
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
import '../../conversation/chat_schedule_time.dart';
|
import '../../conversation/chat_schedule_time.dart';
|
||||||
import '../../domain/chat_prompt_origin.dart';
|
import '../../domain/chat_prompt_origin.dart';
|
||||||
import 'chat_copy_button.dart';
|
import 'chat_copy_button.dart';
|
||||||
import 'chat_hover_actions.dart';
|
import 'chat_hover_actions.dart';
|
||||||
|
import 'terminal/terminal_glyphs.dart';
|
||||||
|
|
||||||
/// The header words of an automated prompt.
|
/// The header words of an automated prompt.
|
||||||
String chatAutomatedPromptLabel(ChatPromptOrigin origin) => switch (origin) {
|
String chatAutomatedPromptLabel(ChatPromptOrigin origin) => switch (origin) {
|
||||||
@@ -64,35 +67,40 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final card = Material(
|
final card = AppDesignTokens.of(context).terminal
|
||||||
key: const Key('chat-automated-prompt'),
|
? _terminalLine(context, label, detail)
|
||||||
color: scheme.surfaceContainerLow,
|
: Material(
|
||||||
clipBehavior: Clip.antiAlias,
|
key: const Key('chat-automated-prompt'),
|
||||||
shape: RoundedRectangleBorder(
|
color: scheme.surfaceContainerLow,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
clipBehavior: Clip.antiAlias,
|
||||||
side: BorderSide(color: scheme.outlineVariant),
|
shape: RoundedRectangleBorder(
|
||||||
),
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||||
child: Padding(
|
side: BorderSide(color: scheme.outlineVariant),
|
||||||
padding: const EdgeInsets.fromLTRB(14, 8, 14, 10),
|
),
|
||||||
child: Column(
|
child: Padding(
|
||||||
mainAxisSize: MainAxisSize.min,
|
padding: const EdgeInsets.fromLTRB(14, 8, 14, 10),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
header,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
if (prompt.body.trim().isNotEmpty) ...[
|
children: [
|
||||||
const SizedBox(height: 4),
|
header,
|
||||||
DefaultTextStyle.merge(
|
if (prompt.body.trim().isNotEmpty) ...[
|
||||||
style: theme.textTheme.bodyMedium,
|
const SizedBox(height: 4),
|
||||||
child: body,
|
DefaultTextStyle.merge(
|
||||||
|
style: theme.textTheme.bodyMedium,
|
||||||
|
child: body,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
],
|
);
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final copy = prompt.body.trim().isEmpty
|
final copy = prompt.body.trim().isEmpty
|
||||||
? null
|
? null
|
||||||
: ChatHoverReveal(child: ChatCopyButton(text: prompt.body.trim()));
|
: ChatHoverReveal(child: ChatCopyButton(text: prompt.body.trim()));
|
||||||
|
final footerInset = AppDesignTokens.of(context).terminal
|
||||||
|
? 8 + terminalGlyphColumn(context)
|
||||||
|
: 14.0;
|
||||||
return ChatHoverRegion(
|
return ChatHoverRegion(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -101,7 +109,7 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
|||||||
card,
|
card,
|
||||||
if (footer.isNotEmpty || timestamp != null || copy != null)
|
if (footer.isNotEmpty || timestamp != null || copy != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsetsDirectional.only(start: 14, top: 2),
|
padding: EdgeInsetsDirectional.only(start: footerInset, top: 2),
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
key: const Key('chat-message-footer'),
|
key: const Key('chat-message-footer'),
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
@@ -115,6 +123,90 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension on ChatAutomatedPromptCard {
|
||||||
|
/// Under a terminal design the prompt is not a card but dim bracketed
|
||||||
|
/// lines, as a CLI prints a message it injected: `[Follow-up from agent ·
|
||||||
|
/// scheduled …]`, then the prompt behind a dim rule.
|
||||||
|
Widget _terminalLine(BuildContext context, String label, String? detail) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final dim = theme.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
);
|
||||||
|
final header = SelectionContainer.disabled(
|
||||||
|
child: Text.rich(
|
||||||
|
key: const Key('chat-automated-prompt-header'),
|
||||||
|
TextSpan(
|
||||||
|
style: dim,
|
||||||
|
children: [
|
||||||
|
const TextSpan(text: '['),
|
||||||
|
TextSpan(
|
||||||
|
text: label,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
if (detail != null) TextSpan(text: ' · $detail'),
|
||||||
|
const TextSpan(text: ']'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
// Inset like the answer's text, so the bracket starts in the same
|
||||||
|
// column as the agent's dots.
|
||||||
|
return Material(
|
||||||
|
key: const Key('chat-automated-prompt'),
|
||||||
|
type: MaterialType.transparency,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(start: 8),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
header,
|
||||||
|
if (prompt.body.trim().isNotEmpty)
|
||||||
|
IntrinsicHeight(
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: terminalGlyphColumn(context),
|
||||||
|
child: CustomPaint(
|
||||||
|
painter: _RulePainter(theme.colorScheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: DefaultTextStyle.merge(style: dim, child: body),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The dim vertical rule beside an injected prompt's text.
|
||||||
|
class _RulePainter extends CustomPainter {
|
||||||
|
const _RulePainter(this.color);
|
||||||
|
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
final x = size.width * 0.25;
|
||||||
|
canvas.drawLine(
|
||||||
|
Offset(x, 2),
|
||||||
|
Offset(x, size.height - 2),
|
||||||
|
Paint()
|
||||||
|
..color = color
|
||||||
|
..strokeWidth = 1,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(_RulePainter old) => old.color != color;
|
||||||
|
}
|
||||||
|
|
||||||
/// The small "Scheduled" mark under the operator's own message they had
|
/// The small "Scheduled" mark under the operator's own message they had
|
||||||
/// scheduled to send later, once it is no longer waiting.
|
/// scheduled to send later, once it is no longer waiting.
|
||||||
class ChatScheduledMark extends StatelessWidget {
|
class ChatScheduledMark extends StatelessWidget {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'chat_copy_button.dart';
|
import 'chat_copy_button.dart';
|
||||||
|
|
||||||
@@ -151,6 +152,9 @@ class ChatCodeCopyRegion extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final scheme = Theme.of(context).colorScheme;
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
final corners = AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(radius));
|
||||||
final header = ColoredBox(
|
final header = ColoredBox(
|
||||||
key: const Key('chat-code-header'),
|
key: const Key('chat-code-header'),
|
||||||
color: headerFill(context),
|
color: headerFill(context),
|
||||||
@@ -170,10 +174,10 @@ class ChatCodeCopyRegion extends StatelessWidget {
|
|||||||
position: DecorationPosition.foreground,
|
position: DecorationPosition.foreground,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: scheme.outlineVariant),
|
border: Border.all(color: scheme.outlineVariant),
|
||||||
borderRadius: BorderRadius.circular(radius),
|
borderRadius: corners,
|
||||||
),
|
),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(radius),
|
borderRadius: corners,
|
||||||
child: ColoredBox(
|
child: ColoredBox(
|
||||||
key: const Key('chat-code-body'),
|
key: const Key('chat-code-body'),
|
||||||
color: fill(context),
|
color: fill(context),
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
import 'chat_transcript_selection.dart';
|
import 'chat_transcript_selection.dart';
|
||||||
@@ -521,6 +523,17 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
|||||||
/// heading never reads like a paragraph.
|
/// heading never reads like a paragraph.
|
||||||
TextStyle? _headingStyle(BuildContext context, int level) {
|
TextStyle? _headingStyle(BuildContext context, int level) {
|
||||||
final text = Theme.of(context).textTheme;
|
final text = Theme.of(context).textTheme;
|
||||||
|
// A terminal prints headings at the text's own size, in bold; the top
|
||||||
|
// level takes the accent colour.
|
||||||
|
if (AppDesignTokens.of(context).terminal) {
|
||||||
|
return _roleStyle(
|
||||||
|
context,
|
||||||
|
text.bodyLarge?.copyWith(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: level == 1 ? Theme.of(context).colorScheme.primary : null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
final role = switch (level) {
|
final role = switch (level) {
|
||||||
1 => text.headlineSmall,
|
1 => text.headlineSmall,
|
||||||
2 => text.titleLarge,
|
2 => text.titleLarge,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
import '../sessions/chat_color_palette.dart';
|
import '../sessions/chat_color_palette.dart';
|
||||||
|
import 'terminal/terminal_prompt_line.dart';
|
||||||
|
|
||||||
/// How strongly a coloured chat's shade washes the operator's bubbles over
|
/// How strongly a coloured chat's shade washes the operator's bubbles over
|
||||||
/// the host's neutral bubble fill. Text keeps the host's colours.
|
/// the host's neutral bubble fill. Text keeps the host's colours.
|
||||||
@@ -43,6 +45,9 @@ class ChatUserBubble extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
if (AppDesignTokens.of(context).terminal) {
|
||||||
|
return TerminalPromptLine(child: child);
|
||||||
|
}
|
||||||
// A Material surface (not a bare DecoratedBox) so a disclosure ListTile
|
// 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.
|
||||||
return Material(
|
return Material(
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
import '../../../../core/api_gateway.dart';
|
import '../../../../core/api_gateway.dart';
|
||||||
import '../../data/chat_attachment_images.dart';
|
import '../../data/chat_attachment_images.dart';
|
||||||
import 'chat_attachment_gallery.dart';
|
import 'chat_attachment_gallery.dart';
|
||||||
@@ -16,6 +18,7 @@ import 'chat_link_text.dart';
|
|||||||
import 'chat_message_bubble.dart';
|
import 'chat_message_bubble.dart';
|
||||||
import 'chat_turn_activity_view.dart';
|
import 'chat_turn_activity_view.dart';
|
||||||
import 'native_disclosure.dart';
|
import 'native_disclosure.dart';
|
||||||
|
import 'terminal/terminal_glyphs.dart';
|
||||||
import 'chat_message_timestamp.dart';
|
import 'chat_message_timestamp.dart';
|
||||||
import 'chat_read_aloud_button.dart';
|
import 'chat_read_aloud_button.dart';
|
||||||
import '../../speech/speech_controller.dart';
|
import '../../speech/speech_controller.dart';
|
||||||
@@ -76,6 +79,11 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
// A wide window draws an answer's Copy in the gutter left of the reading
|
// A wide window draws an answer's Copy in the gutter left of the reading
|
||||||
// column; without room it trails the time in the answer's footer.
|
// column; without room it trails the time in the answer's footer.
|
||||||
final gutter = user ? 0.0 : ChatCopyGutter.of(context);
|
final gutter = user ? 0.0 : ChatCopyGutter.of(context);
|
||||||
|
// A terminal design reads top to bottom like a CLI: the operator's
|
||||||
|
// prompt line starts at the same edge as the answer and spans its
|
||||||
|
// column.
|
||||||
|
final terminal = AppDesignTokens.of(context).terminal;
|
||||||
|
final trailingUser = user && !automated && !terminal;
|
||||||
// No visible role label: side and surface say who spoke and the row's
|
// No visible role label: side and surface say who spoke and the row's
|
||||||
// semantics label names the role. The operator's turn is a neutral bubble
|
// semantics label names the role. The operator's turn is a neutral bubble
|
||||||
// that shrinks to its content; the agent's answer sits on the page with no
|
// that shrinks to its content; the agent's answer sits on the page with no
|
||||||
@@ -96,7 +104,7 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) => Align(
|
builder: (context, constraints) => Align(
|
||||||
alignment: user && !automated
|
alignment: trailingUser
|
||||||
? AlignmentDirectional.centerEnd
|
? AlignmentDirectional.centerEnd
|
||||||
: AlignmentDirectional.centerStart,
|
: AlignmentDirectional.centerStart,
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
@@ -104,14 +112,14 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
// sides read as a conversation; the answer keeps a readable
|
// sides read as a conversation; the answer keeps a readable
|
||||||
// measure on a wide pane.
|
// measure on a wide pane.
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: user
|
maxWidth: trailingUser
|
||||||
? (constraints.maxWidth * 0.85).clamp(0, 560).toDouble()
|
? (constraints.maxWidth * 0.85).clamp(0, 560).toDouble()
|
||||||
: 720 + gutter,
|
: 720 + gutter,
|
||||||
),
|
),
|
||||||
child: automated
|
child: automated
|
||||||
? _automatedTurn(origin, content)
|
? _automatedTurn(origin, content)
|
||||||
: user
|
: user
|
||||||
? _userTurn(content, body, origin)
|
? _userTurn(content, body, origin, terminal: terminal)
|
||||||
: _agentRow(
|
: _agentRow(
|
||||||
context,
|
context,
|
||||||
content,
|
content,
|
||||||
@@ -135,7 +143,12 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
/// Attached images sit above the operator's bubble, as their own thumbnails;
|
/// 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)
|
/// an images-only turn draws no empty bubble. The footer (the delivery line)
|
||||||
/// sits under the bubble's trailing corner.
|
/// sits under the bubble's trailing corner.
|
||||||
Widget _userTurn(List<Widget> content, Widget body, ChatPromptOrigin origin) {
|
Widget _userTurn(
|
||||||
|
List<Widget> content,
|
||||||
|
Widget body,
|
||||||
|
ChatPromptOrigin origin, {
|
||||||
|
required bool terminal,
|
||||||
|
}) {
|
||||||
final thumbnails = [
|
final thumbnails = [
|
||||||
for (final part in _partsOf(_userMessage))
|
for (final part in _partsOf(_userMessage))
|
||||||
if (_isFile(part) && chatPartIsThumbnail(part)) part,
|
if (_isFile(part) && chatPartIsThumbnail(part)) part,
|
||||||
@@ -150,7 +163,9 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: terminal
|
||||||
|
? CrossAxisAlignment.stretch
|
||||||
|
: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (thumbnails.isNotEmpty)
|
if (thumbnails.isNotEmpty)
|
||||||
ChatAttachmentGallery(
|
ChatAttachmentGallery(
|
||||||
@@ -167,7 +182,7 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
Wrap(
|
Wrap(
|
||||||
key: const Key('chat-message-footer'),
|
key: const Key('chat-message-footer'),
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
alignment: WrapAlignment.end,
|
alignment: terminal ? WrapAlignment.start : WrapAlignment.end,
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
...footer,
|
...footer,
|
||||||
@@ -307,6 +322,7 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
for (final part in parts)
|
for (final part in parts)
|
||||||
if (isChatToolPart(part)) part,
|
if (isChatToolPart(part)) part,
|
||||||
];
|
];
|
||||||
|
final terminal = AppDesignTokens.of(context).terminal;
|
||||||
final model = '${row['model'] ?? ''}'.trim();
|
final model = '${row['model'] ?? ''}'.trim();
|
||||||
// The metadata line: the model that answered and the time, muted; the
|
// The metadata line: the model that answered and the time, muted; the
|
||||||
// actions (when not in the gutter) trail it.
|
// actions (when not in the gutter) trail it.
|
||||||
@@ -345,7 +361,7 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: chatAgentContentInset,
|
horizontal: chatAgentContentInset,
|
||||||
),
|
),
|
||||||
child: answer,
|
child: terminal ? _terminalAnswer(context, answer) : answer,
|
||||||
),
|
),
|
||||||
// Settled permissions, questions and changes: meta rows that, like
|
// Settled permissions, questions and changes: meta rows that, like
|
||||||
// the activity line, sit at the row edge with their content inset to
|
// the activity line, sit at the row edge with their content inset to
|
||||||
@@ -363,7 +379,10 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
// trail it, so hidden actions leave no gap before it. Without
|
// trail it, so hidden actions leave no gap before it. Without
|
||||||
// metadata the buttons' own inset aligns their icons instead.
|
// metadata the buttons' own inset aligns their icons instead.
|
||||||
padding: EdgeInsetsDirectional.only(
|
padding: EdgeInsetsDirectional.only(
|
||||||
start: meta.isEmpty ? 0 : chatAgentContentInset,
|
start: meta.isEmpty
|
||||||
|
? 0
|
||||||
|
: chatAgentContentInset +
|
||||||
|
(terminal ? terminalGlyphColumn(context) : 0),
|
||||||
end: chatAgentContentInset,
|
end: chatAgentContentInset,
|
||||||
),
|
),
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
@@ -377,6 +396,18 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The answer under a terminal design: a dot in the glyph column, as a
|
||||||
|
/// CLI agent marks its reply, then the text.
|
||||||
|
Widget _terminalAnswer(BuildContext context, Widget answer) =>
|
||||||
|
TerminalGlyphRow(
|
||||||
|
glyph: TerminalGlyph(
|
||||||
|
TerminalGlyphKind.dot,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
style: chatMessageTextStyle(context),
|
||||||
|
),
|
||||||
|
child: answer,
|
||||||
|
);
|
||||||
|
|
||||||
/// The answer as the operator reads it: the turn's text parts in order,
|
/// The answer as the operator reads it: the turn's text parts in order,
|
||||||
/// without reasoning, tools or attachments.
|
/// without reasoning, tools or attachments.
|
||||||
List<String> _answerParts(List<JsonMap> parts) => [
|
List<String> _answerParts(List<JsonMap> parts) => [
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import 'package:flutter/material.dart';
|
|||||||
import '../../../../core/api_gateway.dart';
|
import '../../../../core/api_gateway.dart';
|
||||||
import '../../domain/chat_turn_activity.dart';
|
import '../../domain/chat_turn_activity.dart';
|
||||||
import '../../../../ui/adaptive/platform.dart';
|
import '../../../../ui/adaptive/platform.dart';
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
import 'chat_response_pending.dart';
|
import 'chat_response_pending.dart';
|
||||||
import 'chat_turn_activity_details.dart';
|
import 'chat_turn_activity_details.dart';
|
||||||
import 'chat_turn_chip.dart';
|
import 'chat_turn_chip.dart';
|
||||||
|
import 'terminal/terminal_activity_rows.dart';
|
||||||
|
|
||||||
/// The activity control's content inset is shared with the rest of the reply.
|
/// The activity control's content inset is shared with the rest of the reply.
|
||||||
const chatAgentContentInset = 8.0;
|
const chatAgentContentInset = 8.0;
|
||||||
@@ -120,6 +122,15 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
|||||||
: DateTime.now().difference(started);
|
: DateTime.now().difference(started);
|
||||||
final seconds = duration.inSeconds.clamp(0, 2147483647);
|
final seconds = duration.inSeconds.clamp(0, 2147483647);
|
||||||
final label = '${data.label}${widget.streaming ? ' ${seconds}s' : ''}';
|
final label = '${data.label}${widget.streaming ? ' ${seconds}s' : ''}';
|
||||||
|
if (AppDesignTokens.of(context).terminal) {
|
||||||
|
return TerminalActivityRows(
|
||||||
|
data: data,
|
||||||
|
status: label,
|
||||||
|
streaming: widget.streaming,
|
||||||
|
seconds: seconds,
|
||||||
|
onOpen: _open,
|
||||||
|
);
|
||||||
|
}
|
||||||
// Desktop hover hugs the label; phones keep the full-width touch row.
|
// Desktop hover hugs the label; phones keep the full-width touch row.
|
||||||
final compact = prefersCompactHitTargets(context);
|
final compact = prefersCompactHitTargets(context);
|
||||||
final content = ConstrainedBox(
|
final content = ConstrainedBox(
|
||||||
|
|||||||
@@ -0,0 +1,208 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../../core/api_gateway.dart';
|
||||||
|
import '../../../../../ui/theme/app_design_tokens.dart';
|
||||||
|
import '../../../domain/chat_tool_calls.dart';
|
||||||
|
import '../../../domain/chat_turn_activity.dart';
|
||||||
|
import '../chat_response_pending.dart';
|
||||||
|
import 'terminal_glyphs.dart';
|
||||||
|
|
||||||
|
/// How many of a turn's calls the transcript lists; earlier ones fold into
|
||||||
|
/// one "earlier" line (every call stays in the details dialog).
|
||||||
|
const int terminalActivityMaxCalls = 6;
|
||||||
|
|
||||||
|
/// A turn's activity under a terminal design, as a CLI agent prints it: one
|
||||||
|
/// `● Tool(detail)` line per call, its status in the dot's colour, with a
|
||||||
|
/// `⎿ result` line beneath, and while the turn runs a live status line.
|
||||||
|
/// The block is one button that opens the activity details, like the
|
||||||
|
/// Default design's one-line status.
|
||||||
|
class TerminalActivityRows extends StatelessWidget {
|
||||||
|
const TerminalActivityRows({
|
||||||
|
super.key,
|
||||||
|
required this.data,
|
||||||
|
required this.status,
|
||||||
|
required this.streaming,
|
||||||
|
required this.onOpen,
|
||||||
|
this.seconds = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
final ChatTurnActivityData data;
|
||||||
|
|
||||||
|
/// The turn's one-line status (with its running seconds while streaming).
|
||||||
|
final String status;
|
||||||
|
final bool streaming;
|
||||||
|
final VoidCallback onOpen;
|
||||||
|
|
||||||
|
/// How long the running turn has been doing what it does now.
|
||||||
|
final int seconds;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final scheme = theme.colorScheme;
|
||||||
|
final ansi = AppDesignTokens.of(context).ansi;
|
||||||
|
final style = theme.textTheme.bodyMedium!;
|
||||||
|
final dim = style.copyWith(color: scheme.onSurfaceVariant);
|
||||||
|
final calls = data.tools;
|
||||||
|
final shown = calls.length > terminalActivityMaxCalls
|
||||||
|
? calls.sublist(calls.length - terminalActivityMaxCalls)
|
||||||
|
: calls;
|
||||||
|
final hidden = calls.length - shown.length;
|
||||||
|
final lines = <Widget>[
|
||||||
|
if (data.reasoning.isNotEmpty && calls.isEmpty && !streaming)
|
||||||
|
_line(context, TerminalGlyphKind.dot, scheme.onSurfaceVariant, [
|
||||||
|
TextSpan(text: 'Thought', style: dim),
|
||||||
|
]),
|
||||||
|
if (hidden > 0)
|
||||||
|
_line(context, null, scheme.onSurfaceVariant, [
|
||||||
|
TextSpan(
|
||||||
|
text: '… +$hidden earlier tool ${hidden == 1 ? 'use' : 'uses'}',
|
||||||
|
style: dim,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
for (final call in shown) ..._call(context, call, style, dim, ansi),
|
||||||
|
if (calls.isEmpty && data.reasoning.isEmpty && !streaming)
|
||||||
|
_line(context, TerminalGlyphKind.dot, scheme.onSurfaceVariant, [
|
||||||
|
TextSpan(text: status, style: dim),
|
||||||
|
]),
|
||||||
|
if (streaming) _live(context, style),
|
||||||
|
];
|
||||||
|
return Semantics(
|
||||||
|
button: true,
|
||||||
|
label: '$status, expand for details',
|
||||||
|
excludeSemantics: true,
|
||||||
|
onTap: onOpen,
|
||||||
|
child: InkWell(
|
||||||
|
key: const Key('chat-turn-activity'),
|
||||||
|
onTap: onOpen,
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(minHeight: 40),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
child: DefaultTextStyle.merge(
|
||||||
|
style: style,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: lines,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _call(
|
||||||
|
BuildContext context,
|
||||||
|
JsonMap call,
|
||||||
|
TextStyle style,
|
||||||
|
TextStyle dim,
|
||||||
|
AnsiAccents? ansi,
|
||||||
|
) {
|
||||||
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
final failed = chatToolFailed(call);
|
||||||
|
final running = chatToolRunning(call);
|
||||||
|
final color = failed
|
||||||
|
? ansi?.red ?? scheme.error
|
||||||
|
: running
|
||||||
|
? ansi?.yellow ?? scheme.tertiary
|
||||||
|
: ansi?.green ?? scheme.primary;
|
||||||
|
final detail = chatToolDetail(call);
|
||||||
|
final head = [
|
||||||
|
TextSpan(
|
||||||
|
text: chatToolLabel(call),
|
||||||
|
style: style.copyWith(fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
if (detail != null) TextSpan(text: '($detail)', style: dim),
|
||||||
|
];
|
||||||
|
final duration = chatToolDurationMillis(call);
|
||||||
|
final String result;
|
||||||
|
if (running) {
|
||||||
|
result = 'running…';
|
||||||
|
} else {
|
||||||
|
final text = failed ? chatToolErrorText(call) : chatToolOutputText(call);
|
||||||
|
final first = text
|
||||||
|
.split('\n')
|
||||||
|
.map((line) => line.trim())
|
||||||
|
.firstWhere((line) => line.isNotEmpty, orElse: () => '');
|
||||||
|
final more = text.trim().split('\n').length - 1;
|
||||||
|
result = [
|
||||||
|
if (first.isNotEmpty) first,
|
||||||
|
if (more > 0) '+$more lines',
|
||||||
|
if (duration != null) formatChatToolDuration(duration),
|
||||||
|
].join(' · ');
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
_line(context, TerminalGlyphKind.dot, color, head),
|
||||||
|
if (result.isNotEmpty)
|
||||||
|
_line(context, TerminalGlyphKind.elbow, scheme.outline, [
|
||||||
|
TextSpan(
|
||||||
|
text: result,
|
||||||
|
style: failed ? dim.copyWith(color: color) : dim,
|
||||||
|
),
|
||||||
|
], indent: true),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The running status: the pending dots, then what the turn is doing and
|
||||||
|
/// for how long, in the accent colour.
|
||||||
|
Widget _live(BuildContext context, TextStyle style) {
|
||||||
|
final accent =
|
||||||
|
AppDesignTokens.of(context).ansi?.yellow ??
|
||||||
|
Theme.of(context).colorScheme.primary;
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: terminalGlyphColumn(context),
|
||||||
|
child: ExcludeSemantics(
|
||||||
|
child: DefaultTextStyle.merge(
|
||||||
|
style: TextStyle(color: accent),
|
||||||
|
child: const Align(
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
child: ChatResponsePending(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
'${data.label}… (${seconds}s)',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: style.copyWith(color: accent),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _line(
|
||||||
|
BuildContext context,
|
||||||
|
TerminalGlyphKind? glyph,
|
||||||
|
Color glyphColor,
|
||||||
|
List<TextSpan> spans, {
|
||||||
|
bool indent = false,
|
||||||
|
}) {
|
||||||
|
final column = terminalGlyphColumn(context);
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsetsDirectional.only(start: indent ? column * 0.5 : 0),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (glyph == null)
|
||||||
|
SizedBox(width: column)
|
||||||
|
else
|
||||||
|
TerminalGlyph(glyph, color: glyphColor),
|
||||||
|
Flexible(
|
||||||
|
child: Text.rich(
|
||||||
|
TextSpan(children: spans),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// The width of a terminal transcript's glyph column: about two monospace
|
||||||
|
/// cells of the ambient text, so lines after a glyph align like a CLI's.
|
||||||
|
double terminalGlyphColumn(BuildContext context) {
|
||||||
|
final style = DefaultTextStyle.of(context).style;
|
||||||
|
final size = MediaQuery.textScalerOf(context).scale(style.fontSize ?? 14);
|
||||||
|
return size * 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The height of one line of the ambient text, so a painted glyph centres on
|
||||||
|
/// the first line of the text beside it.
|
||||||
|
double terminalLineHeight(BuildContext context, [TextStyle? style]) {
|
||||||
|
final ambient = style ?? DefaultTextStyle.of(context).style;
|
||||||
|
final size = MediaQuery.textScalerOf(context).scale(ambient.fontSize ?? 14);
|
||||||
|
return size * (ambient.height ?? 1.35);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The kind of mark a terminal transcript draws in its glyph column. They
|
||||||
|
/// are painted rather than typed: the bundled monospace family has no
|
||||||
|
/// record (U+25CF) or bracket corner (U+23BF), and the web engine would
|
||||||
|
/// otherwise fetch a fallback font for them.
|
||||||
|
enum TerminalGlyphKind {
|
||||||
|
/// A filled dot: an answer, or a tool call (its colour gives the status).
|
||||||
|
dot,
|
||||||
|
|
||||||
|
/// A bracket corner under a call: its result line.
|
||||||
|
elbow,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One painted terminal glyph, a glyph column wide and one text line tall,
|
||||||
|
/// in [color].
|
||||||
|
class TerminalGlyph extends StatelessWidget {
|
||||||
|
const TerminalGlyph(this.kind, {super.key, required this.color, this.style});
|
||||||
|
|
||||||
|
final TerminalGlyphKind kind;
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
/// The text the glyph sits beside; the ambient style when null.
|
||||||
|
final TextStyle? style;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => ExcludeSemantics(
|
||||||
|
child: SizedBox(
|
||||||
|
width: terminalGlyphColumn(context),
|
||||||
|
height: terminalLineHeight(context, style),
|
||||||
|
child: CustomPaint(painter: _GlyphPainter(kind, color)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GlyphPainter extends CustomPainter {
|
||||||
|
const _GlyphPainter(this.kind, this.color);
|
||||||
|
|
||||||
|
final TerminalGlyphKind kind;
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
final h = size.height;
|
||||||
|
final paint = Paint()
|
||||||
|
..color = color
|
||||||
|
..isAntiAlias = true;
|
||||||
|
switch (kind) {
|
||||||
|
case TerminalGlyphKind.dot:
|
||||||
|
canvas.drawCircle(Offset(h * 0.3, h / 2), h * 0.17, paint);
|
||||||
|
case TerminalGlyphKind.elbow:
|
||||||
|
paint
|
||||||
|
..style = PaintingStyle.stroke
|
||||||
|
..strokeWidth = 1;
|
||||||
|
final x = h * 0.3;
|
||||||
|
final path = Path()
|
||||||
|
..moveTo(x, 0)
|
||||||
|
..lineTo(x, h * 0.55)
|
||||||
|
..lineTo(size.width * 0.95, h * 0.55);
|
||||||
|
canvas.drawPath(path, paint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(_GlyphPainter old) =>
|
||||||
|
old.kind != kind || old.color != color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// [child] after a [glyph] in the glyph column, the glyph centred on the
|
||||||
|
/// child's first line.
|
||||||
|
class TerminalGlyphRow extends StatelessWidget {
|
||||||
|
const TerminalGlyphRow({super.key, required this.glyph, required this.child});
|
||||||
|
|
||||||
|
final Widget glyph;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
glyph,
|
||||||
|
Expanded(child: child),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../../ui/theme/app_design_tokens.dart';
|
||||||
|
import '../../sessions/chat_color_palette.dart';
|
||||||
|
import '../chat_message_bubble.dart';
|
||||||
|
|
||||||
|
/// How strongly a coloured chat's shade washes a prompt line's band.
|
||||||
|
const double terminalPromptTint = 0.1;
|
||||||
|
|
||||||
|
/// The operator's turn under a terminal design: a prompt line, the prompt
|
||||||
|
/// glyph then the message, over a faint band with a dim gutter on its
|
||||||
|
/// leading edge (in the chat's colour when it has one). It spans the reading
|
||||||
|
/// column instead of shrinking into a bubble.
|
||||||
|
class TerminalPromptLine extends StatelessWidget {
|
||||||
|
const TerminalPromptLine({super.key, required this.child});
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final tokens = AppDesignTokens.of(context);
|
||||||
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
final shade = chatColorShade(context, ChatBubbleColor.of(context));
|
||||||
|
final gutter = shade ?? scheme.outline;
|
||||||
|
final glyph = shade ?? scheme.primary;
|
||||||
|
return Material(
|
||||||
|
key: const Key('chat-terminal-prompt-line'),
|
||||||
|
// A faint wash of the chat's colour: its gutter and glyph carry it.
|
||||||
|
color: shade == null
|
||||||
|
? scheme.surfaceContainerLow
|
||||||
|
: Color.alphaBlend(
|
||||||
|
shade.withValues(alpha: terminalPromptTint),
|
||||||
|
scheme.surfaceContainerLow,
|
||||||
|
),
|
||||||
|
shape: BorderDirectional(start: BorderSide(color: gutter, width: 2)),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(10, 6, 12, 6),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
ExcludeSemantics(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(end: 10),
|
||||||
|
child: Text(
|
||||||
|
tokens.promptGlyph,
|
||||||
|
style: chatMessageTextStyle(
|
||||||
|
context,
|
||||||
|
)?.copyWith(color: glyph, fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Flexible(child: child),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -105,10 +105,7 @@ class GraphStageNode extends StatelessWidget {
|
|||||||
// coloured, smaller text in the status's own hue.
|
// coloured, smaller text in the status's own hue.
|
||||||
final color = status == null
|
final color = status == null
|
||||||
? null
|
? null
|
||||||
: runStatusColor(
|
: runStatusColorOf(context, graphStatusState(status));
|
||||||
graphStatusState(status),
|
|
||||||
Theme.of(context).colorScheme,
|
|
||||||
);
|
|
||||||
final caption = node.kindCaption;
|
final caption = node.kindCaption;
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|||||||
@@ -278,10 +278,7 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
? null
|
? null
|
||||||
: AppListStatusDot(
|
: AppListStatusDot(
|
||||||
key: Key('pipeline-status-${pipeline.id}'),
|
key: Key('pipeline-status-${pipeline.id}'),
|
||||||
color: runStatusColor(
|
color: runStatusColorOf(context, badge.state),
|
||||||
badge.state,
|
|
||||||
Theme.of(context).colorScheme,
|
|
||||||
),
|
|
||||||
semanticLabel: runStateLabel(badge.state),
|
semanticLabel: runStateLabel(badge.state),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class RunCheckCommandRow extends StatelessWidget {
|
|||||||
final mono = (theme.textTheme.bodyMedium ?? const TextStyle()).copyWith(
|
final mono = (theme.textTheme.bodyMedium ?? const TextStyle()).copyWith(
|
||||||
fontFamily: appMonospaceFamily,
|
fontFamily: appMonospaceFamily,
|
||||||
);
|
);
|
||||||
final color = runStatusColor(_state(check.status), theme.colorScheme);
|
final color = runStatusColorOf(context, _state(check.status));
|
||||||
final meta = check.meta;
|
final meta = check.meta;
|
||||||
return ExpansionTile(
|
return ExpansionTile(
|
||||||
tilePadding: EdgeInsets.zero,
|
tilePadding: EdgeInsets.zero,
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class RunTimelineRow extends StatelessWidget {
|
|||||||
context,
|
context,
|
||||||
visit.outcome,
|
visit.outcome,
|
||||||
)
|
)
|
||||||
: runStatusColor(_state, Theme.of(context).colorScheme);
|
: runStatusColorOf(context, _state);
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -139,7 +139,7 @@ class RunTimelineRow extends StatelessWidget {
|
|||||||
divider: divider,
|
divider: divider,
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
leading: AppListAvatar(
|
leading: AppListAvatar(
|
||||||
foreground: runStatusColor(state, Theme.of(context).colorScheme),
|
foreground: runStatusColorOf(context, state),
|
||||||
child: RunStatusIcon(
|
child: RunStatusIcon(
|
||||||
state: state,
|
state: state,
|
||||||
label: visit.status.isEmpty ? 'Status unavailable' : visit.status,
|
label: visit.status.isEmpty ? 'Status unavailable' : visit.status,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../../../ui/status/run_status_icon.dart';
|
import '../../../ui/status/run_status_icon.dart';
|
||||||
@@ -116,11 +117,11 @@ class _FactGrid extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _pill(BuildContext context, VisitFact fact) {
|
Widget _pill(BuildContext context, VisitFact fact) {
|
||||||
final color = runStatusColor(_stateOf(fact), Theme.of(context).colorScheme);
|
final color = runStatusColorOf(context, _stateOf(fact));
|
||||||
return DecoratedBox(
|
return DecoratedBox(
|
||||||
decoration: ShapeDecoration(
|
decoration: ShapeDecoration(
|
||||||
color: color.withValues(alpha: 0.16),
|
color: color.withValues(alpha: 0.16),
|
||||||
shape: const StadiumBorder(),
|
shape: AppDesignTokens.of(context).shape(const StadiumBorder()),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/segmented_bar.dart';
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
@@ -46,6 +47,9 @@ class RunGraphPreview extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
final border = Theme.of(context).colorScheme.outlineVariant;
|
final border = Theme.of(context).colorScheme.outlineVariant;
|
||||||
|
final corners = AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(12));
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
@@ -60,10 +64,10 @@ class RunGraphPreview extends StatelessWidget {
|
|||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: border),
|
border: Border.all(color: border),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: corners,
|
||||||
),
|
),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: corners,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: height,
|
height: height,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class RunListRow extends StatelessWidget {
|
|||||||
onLongPress: selecting ? null : onLongPress,
|
onLongPress: selecting ? null : onLongPress,
|
||||||
selectionControl: selecting ? _checkbox(context) : null,
|
selectionControl: selecting ? _checkbox(context) : null,
|
||||||
leading: AppListAvatar(
|
leading: AppListAvatar(
|
||||||
foreground: runStatusColor(state, Theme.of(context).colorScheme),
|
foreground: runStatusColorOf(context, state),
|
||||||
child: RunStatusIcon(state: state, label: runStatusLabel(run)),
|
child: RunStatusIcon(state: state, label: runStatusLabel(run)),
|
||||||
),
|
),
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class RunPathMini extends StatelessWidget {
|
|||||||
width: 14,
|
width: 14,
|
||||||
height: 10,
|
height: 10,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: runStatusColor(stage.state, Theme.of(context).colorScheme),
|
color: runStatusColorOf(context, stage.state),
|
||||||
borderRadius: BorderRadius.circular(3),
|
borderRadius: BorderRadius.circular(3),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -81,9 +81,9 @@ class RunPathMini extends StatelessWidget {
|
|||||||
height: 8,
|
height: 8,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: runStatusColor(
|
color: runStatusColorOf(
|
||||||
|
context,
|
||||||
end == '#success' ? 'succeeded' : 'failed',
|
end == '#success' ? 'succeeded' : 'failed',
|
||||||
Theme.of(context).colorScheme,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -91,13 +91,7 @@ class RunsStatsPage extends StatelessWidget {
|
|||||||
key: const ValueKey('runs.stats.pie'),
|
key: const ValueKey('runs.stats.pie'),
|
||||||
painter: _PiePainter([
|
painter: _PiePainter([
|
||||||
for (final entry in byState.entries)
|
for (final entry in byState.entries)
|
||||||
(
|
(runStatusColorOf(context, entry.key), entry.value),
|
||||||
runStatusColor(
|
|
||||||
entry.key,
|
|
||||||
Theme.of(context).colorScheme,
|
|
||||||
),
|
|
||||||
entry.value,
|
|
||||||
),
|
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../ui/theme/app_design.dart';
|
||||||
|
import '../../ui/theme/app_design_controller.dart';
|
||||||
|
import 'settings_group.dart';
|
||||||
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
|
const designSectionTitle = 'Design';
|
||||||
|
const designSectionFooter =
|
||||||
|
'Saved on this device only and applied at once. Light and dark follow '
|
||||||
|
'the system under every design; Terminal uses its monospace font '
|
||||||
|
'instead of the Font choice below.';
|
||||||
|
const designSaveFailedText =
|
||||||
|
'Not saved on this device; it applies until reload.';
|
||||||
|
|
||||||
|
ValueKey<String> settingsDesignKey(AppDesign design) =>
|
||||||
|
ValueKey<String>('settings-design-${design.id}');
|
||||||
|
|
||||||
|
/// The device's app-wide design: one radio row per [AppDesign], each with a
|
||||||
|
/// one-line summary. A choice applies at once, without a restart.
|
||||||
|
class SettingsDesignSection extends StatelessWidget {
|
||||||
|
const SettingsDesignSection({super.key, required this.controller});
|
||||||
|
|
||||||
|
final AppDesignController controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => ListenableBuilder(
|
||||||
|
listenable: controller,
|
||||||
|
builder: (context, _) => RadioGroup<AppDesign>(
|
||||||
|
groupValue: controller.design,
|
||||||
|
onChanged: (design) {
|
||||||
|
if (design != null) unawaited(controller.select(design));
|
||||||
|
},
|
||||||
|
child: SettingsGroup(
|
||||||
|
title: designSectionTitle,
|
||||||
|
footer: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
const Text(designSectionFooter),
|
||||||
|
if (controller.saveFailed)
|
||||||
|
Text(
|
||||||
|
designSaveFailedText,
|
||||||
|
style: TextStyle(color: settingsErrorColor(context)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
for (final design in AppDesign.values)
|
||||||
|
RadioListTile<AppDesign>(
|
||||||
|
key: settingsDesignKey(design),
|
||||||
|
value: design,
|
||||||
|
title: Text(design.label),
|
||||||
|
subtitle: Text(design.description),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
import 'settings_layout.dart';
|
import 'settings_layout.dart';
|
||||||
|
|
||||||
@@ -31,6 +32,7 @@ class SettingsGroup extends StatelessWidget {
|
|||||||
final title = this.title;
|
final title = this.title;
|
||||||
final footer = this.footer;
|
final footer = this.footer;
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
final tokens = AppDesignTokens.of(context);
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -50,10 +52,17 @@ class SettingsGroup extends StatelessWidget {
|
|||||||
if (children.isNotEmpty)
|
if (children.isNotEmpty)
|
||||||
Material(
|
Material(
|
||||||
type: MaterialType.card,
|
type: MaterialType.card,
|
||||||
color: theme.colorScheme.surfaceContainer,
|
color: tokens.flat
|
||||||
|
? theme.colorScheme.surfaceContainerLow
|
||||||
|
: theme.colorScheme.surfaceContainer,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(settingsGroupRadius),
|
borderRadius: tokens.corners(
|
||||||
|
BorderRadius.circular(settingsGroupRadius),
|
||||||
|
),
|
||||||
|
side: tokens.frame == null
|
||||||
|
? BorderSide.none
|
||||||
|
: BorderSide(color: tokens.frame!),
|
||||||
),
|
),
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ extension _SettingsPageSections on _SettingsScreenState {
|
|||||||
widget.animationSpeed ?? AnimationSpeedController.instance,
|
widget.animationSpeed ?? AnimationSpeedController.instance,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SettingsSection(
|
||||||
|
id: 'design',
|
||||||
|
title: designSectionTitle,
|
||||||
|
keywords: 'design theme look style terminal monospace appearance',
|
||||||
|
builder: (_) => SettingsDesignSection(
|
||||||
|
controller: widget.designs ?? AppDesignController.instance,
|
||||||
|
),
|
||||||
|
),
|
||||||
SettingsSection(
|
SettingsSection(
|
||||||
id: 'font',
|
id: 'font',
|
||||||
title: fontSectionTitle,
|
title: fontSectionTitle,
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ import '../attention/notify/notification_controller.dart';
|
|||||||
import '../attention/notify/notification_models.dart';
|
import '../attention/notify/notification_models.dart';
|
||||||
import 'default_endpoint.dart';
|
import 'default_endpoint.dart';
|
||||||
import 'settings_controller.dart';
|
import 'settings_controller.dart';
|
||||||
|
import 'settings_design_section.dart';
|
||||||
import 'settings_font_section.dart';
|
import 'settings_font_section.dart';
|
||||||
import 'settings_animation_section.dart';
|
import 'settings_animation_section.dart';
|
||||||
import 'settings_scale_section.dart';
|
import 'settings_scale_section.dart';
|
||||||
import '../../ui/motion/animation_speed.dart';
|
import '../../ui/motion/animation_speed.dart';
|
||||||
|
import '../../ui/theme/app_design_controller.dart';
|
||||||
import '../../ui/theme/app_font_controller.dart';
|
import '../../ui/theme/app_font_controller.dart';
|
||||||
import 'settings_group.dart';
|
import 'settings_group.dart';
|
||||||
import 'storage/settings_storage_section.dart';
|
import 'storage/settings_storage_section.dart';
|
||||||
@@ -72,6 +74,7 @@ class SettingsScreen extends StatefulWidget {
|
|||||||
this.deliveryService,
|
this.deliveryService,
|
||||||
this.deliveryServiceController,
|
this.deliveryServiceController,
|
||||||
this.fonts,
|
this.fonts,
|
||||||
|
this.designs,
|
||||||
this.animationSpeed,
|
this.animationSpeed,
|
||||||
this.terminalLayout,
|
this.terminalLayout,
|
||||||
this.onShowWalkthrough,
|
this.onShowWalkthrough,
|
||||||
@@ -83,6 +86,9 @@ class SettingsScreen extends StatefulWidget {
|
|||||||
|
|
||||||
/// The device's interface font; defaults to the app's shared controller.
|
/// The device's interface font; defaults to the app's shared controller.
|
||||||
final AppFontController? fonts;
|
final AppFontController? fonts;
|
||||||
|
|
||||||
|
/// The device's app-wide design; defaults to the app's shared controller.
|
||||||
|
final AppDesignController? designs;
|
||||||
final AnimationSpeedController? animationSpeed;
|
final AnimationSpeedController? animationSpeed;
|
||||||
|
|
||||||
/// The terminal surface's layout (its mode is chosen here); null is the
|
/// The terminal surface's layout (its mode is chosen here); null is the
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
import 'destination.dart';
|
import 'destination.dart';
|
||||||
import 'list_detail_policy.dart';
|
import 'list_detail_policy.dart';
|
||||||
@@ -165,7 +166,9 @@ class _SettingsRailItem extends StatelessWidget {
|
|||||||
height: 32,
|
height: 32,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
decoration: ShapeDecoration(
|
decoration: ShapeDecoration(
|
||||||
shape: const StadiumBorder(),
|
shape: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).shape(const StadiumBorder()),
|
||||||
color: selected ? scheme.secondaryContainer : null,
|
color: selected ? scheme.secondaryContainer : null,
|
||||||
),
|
),
|
||||||
child: Icon(item.icon, color: foreground),
|
child: Icon(item.icon, color: foreground),
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'dart:ui' show SemanticsRole;
|
import 'dart:ui' show SemanticsRole;
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
|
|
||||||
|
import '../theme/app_design_tokens.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../motion/motion.dart';
|
import '../motion/motion.dart';
|
||||||
@@ -109,18 +111,22 @@ class FloatingTabButton extends StatelessWidget {
|
|||||||
({Color tint, Color selectedIcon, Color icon}) colors,
|
({Color tint, Color selectedIcon, Color icon}) colors,
|
||||||
double t,
|
double t,
|
||||||
) {
|
) {
|
||||||
|
// A flat design (Terminal) squares the button and its fill.
|
||||||
|
final shape = AppDesignTokens.of(context).shape(const CircleBorder());
|
||||||
final decoration = ShapeDecoration(
|
final decoration = ShapeDecoration(
|
||||||
color: colors.tint.withValues(alpha: colors.tint.a * t),
|
color: colors.tint.withValues(alpha: colors.tint.a * t),
|
||||||
shape: const CircleBorder(),
|
shape: shape,
|
||||||
);
|
);
|
||||||
final Widget fill = Ink(
|
final Widget fill = Ink(
|
||||||
key: fillKey,
|
key: fillKey,
|
||||||
decoration: decoration,
|
decoration: decoration,
|
||||||
child: InkResponse(
|
child: InkResponse(
|
||||||
onTap: enabled ? onTap : null,
|
onTap: enabled ? onTap : null,
|
||||||
customBorder: const CircleBorder(),
|
customBorder: shape,
|
||||||
containedInkWell: true,
|
containedInkWell: true,
|
||||||
highlightShape: BoxShape.circle,
|
highlightShape: shape is CircleBorder
|
||||||
|
? BoxShape.circle
|
||||||
|
: BoxShape.rectangle,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
Widget glyph = IconTheme.merge(
|
Widget glyph = IconTheme.merge(
|
||||||
@@ -147,7 +153,7 @@ class FloatingTabButton extends StatelessWidget {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: GlassPill(shape: const CircleBorder(), child: fill),
|
child: GlassPill(shape: shape, child: fill),
|
||||||
),
|
),
|
||||||
IgnorePointer(child: glyph),
|
IgnorePointer(child: glyph),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../theme/app_design_tokens.dart';
|
||||||
import 'glass_surface.dart';
|
import 'glass_surface.dart';
|
||||||
|
|
||||||
/// A frosted-glass piece floating over content: the content behind is
|
/// A frosted-glass piece floating over content: the content behind is
|
||||||
@@ -60,20 +61,28 @@ class GlassPill extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _build(BuildContext context, double reveal, Widget child) {
|
Widget _build(BuildContext context, double reveal, Widget child) {
|
||||||
final solid = MediaQuery.maybeHighContrastOf(context) ?? false;
|
// A flat design (Terminal) draws a solid piece in its own corners with
|
||||||
|
// its 1px frame: no blur, highlight, rim or shadow.
|
||||||
|
final tokens = AppDesignTokens.of(context);
|
||||||
|
final flat = tokens.flat;
|
||||||
|
final solid = flat || (MediaQuery.maybeHighContrastOf(context) ?? false);
|
||||||
|
final shape = tokens.shape(this.shape);
|
||||||
final textDirection = Directionality.maybeOf(context);
|
final textDirection = Directionality.maybeOf(context);
|
||||||
final Color base;
|
final Color base;
|
||||||
final Color edge;
|
final Color edge;
|
||||||
final scheme = Theme.of(context).colorScheme;
|
final scheme = Theme.of(context).colorScheme;
|
||||||
base = scheme.surfaceContainerHigh;
|
base = flat ? scheme.surfaceContainerLow : scheme.surfaceContainerHigh;
|
||||||
edge = scheme.outlineVariant;
|
edge = flat ? tokens.frame ?? scheme.outline : scheme.outlineVariant;
|
||||||
final opaque = fill ?? (solid ? base : base.withValues(alpha: fillOpacity));
|
final opaque = fill ?? (solid ? base : base.withValues(alpha: fillOpacity));
|
||||||
final color = opaque.withValues(alpha: opaque.a * reveal);
|
final color = opaque.withValues(alpha: opaque.a * reveal);
|
||||||
final look = GlassLook.forFill(opaque);
|
final look = GlassLook.forFill(opaque);
|
||||||
Color faded(Color c, [double by = 1]) =>
|
Color faded(Color c, [double by = 1]) =>
|
||||||
c.withValues(alpha: c.a * by * reveal);
|
c.withValues(alpha: c.a * by * reveal);
|
||||||
final border = shape.copyWith(
|
final border = shape.copyWith(
|
||||||
side: BorderSide(color: faded(edge, solid ? 1 : 0.6), width: 0.5),
|
side: BorderSide(
|
||||||
|
color: faded(edge, solid ? 1 : 0.6),
|
||||||
|
width: flat ? 1 : 0.5,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
Widget content = Material(type: MaterialType.transparency, child: child);
|
Widget content = Material(type: MaterialType.transparency, child: child);
|
||||||
if (!solid) {
|
if (!solid) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../theme/app_design_tokens.dart';
|
||||||
import 'package:flutter/physics.dart';
|
import 'package:flutter/physics.dart';
|
||||||
|
|
||||||
import '../motion/motion.dart';
|
import '../motion/motion.dart';
|
||||||
@@ -122,7 +123,7 @@ class _SegmentedPressState extends State<SegmentedPress>
|
|||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
position: DecorationPosition.foreground,
|
position: DecorationPosition.foreground,
|
||||||
decoration: ShapeDecoration(
|
decoration: ShapeDecoration(
|
||||||
shape: const StadiumBorder(),
|
shape: AppDesignTokens.of(context).shape(const StadiumBorder()),
|
||||||
color: tint.withValues(
|
color: tint.withValues(
|
||||||
alpha:
|
alpha:
|
||||||
tint.a *
|
tint.a *
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// The leading circle every list row uses, as large as a native contact
|
/// The leading circle every list row uses, as large as a native contact
|
||||||
/// avatar ([CircleAvatar]'s default).
|
/// avatar ([CircleAvatar]'s default).
|
||||||
@@ -58,10 +59,19 @@ class AppListAvatar extends StatelessWidget {
|
|||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
height: 1,
|
height: 1,
|
||||||
);
|
);
|
||||||
|
// A flat design (Terminal) frames the mark in a square box instead of a
|
||||||
|
// tinted circle.
|
||||||
|
final tokens = AppDesignTokens.of(context);
|
||||||
|
final decoration = tokens.flat
|
||||||
|
? BoxDecoration(
|
||||||
|
border: Border.all(color: mark.withValues(alpha: 0.55)),
|
||||||
|
borderRadius: tokens.corners(BorderRadius.zero),
|
||||||
|
)
|
||||||
|
: BoxDecoration(color: fill, shape: BoxShape.circle);
|
||||||
final circle = SizedBox.square(
|
final circle = SizedBox.square(
|
||||||
dimension: kAppListAvatarSize,
|
dimension: kAppListAvatarSize,
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(color: fill, shape: BoxShape.circle),
|
decoration: decoration,
|
||||||
child: Center(
|
child: Center(
|
||||||
// The glyph is identity, not reading text: it scales down to stay
|
// The glyph is identity, not reading text: it scales down to stay
|
||||||
// inside the circle under large text instead of overflowing it.
|
// inside the circle under large text instead of overflowing it.
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// The shared status glyph whose tooltip and accessible name say the state.
|
/// The shared status glyph whose tooltip and accessible name say the state.
|
||||||
///
|
///
|
||||||
/// [state] is the normalised run state (`succeeded`, `failed`, `running`,
|
/// [state] is the normalised run state (`succeeded`, `failed`, `running`,
|
||||||
@@ -20,7 +22,7 @@ class RunStatusIcon extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final color = runStatusColor(state, Theme.of(context).colorScheme);
|
final color = runStatusColorOf(context, state);
|
||||||
// The label is the glyph's accessible name; the tooltip must not repeat it.
|
// The label is the glyph's accessible name; the tooltip must not repeat it.
|
||||||
return Tooltip(
|
return Tooltip(
|
||||||
message: label,
|
message: label,
|
||||||
@@ -35,6 +37,23 @@ class RunStatusIcon extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [runStatusColor] as the design at [context] draws it: a design with ANSI
|
||||||
|
/// accents (Terminal) names its own muted hues; the Default design keeps the
|
||||||
|
/// system colours.
|
||||||
|
Color runStatusColorOf(BuildContext context, String state) {
|
||||||
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
final ansi = AppDesignTokens.of(context).ansi;
|
||||||
|
if (ansi == null) return runStatusColor(state, scheme);
|
||||||
|
return switch (state) {
|
||||||
|
'succeeded' => ansi.green,
|
||||||
|
'failed' => ansi.red,
|
||||||
|
'running' || 'active' => ansi.blue,
|
||||||
|
'waiting' || 'waiting_quota' => ansi.yellow,
|
||||||
|
'interrupted' => ansi.magenta,
|
||||||
|
_ => scheme.onSurfaceVariant,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// The colour for a run state, shared by every status glyph: green
|
/// The colour for a run state, shared by every status glyph: green
|
||||||
/// succeeded, red failed, blue running, yellow waiting, orange interrupted,
|
/// succeeded, red failed, blue running, yellow waiting, orange interrupted,
|
||||||
/// grey otherwise, each with a brighter dark-mode shade.
|
/// grey otherwise, each with a brighter dark-mode shade.
|
||||||
@@ -75,7 +94,7 @@ class RunStatusKicker extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final color = runStatusColor(state, Theme.of(context).colorScheme);
|
final color = runStatusColorOf(context, state);
|
||||||
return Row(
|
return Row(
|
||||||
key: const Key('run-status-kicker'),
|
key: const Key('run-status-kicker'),
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'app_design_tokens.dart';
|
||||||
|
import 'app_theme.dart';
|
||||||
|
import 'terminal_theme.dart';
|
||||||
|
|
||||||
|
/// An app-wide design: how every surface is shaped, typed and coloured, not
|
||||||
|
/// only a colour. Each design builds a light and a dark [ThemeData] carrying
|
||||||
|
/// its [AppDesignTokens], so widgets that draw design-specific shapes read the
|
||||||
|
/// tokens instead of hard-coding one look.
|
||||||
|
///
|
||||||
|
/// Adding a design means one more value here and its theme builder; the
|
||||||
|
/// Settings picker lists [AppDesign.values].
|
||||||
|
enum AppDesign {
|
||||||
|
/// The app's own Material look.
|
||||||
|
standard('default', 'Default', 'The app’s Material look.'),
|
||||||
|
|
||||||
|
/// A terminal-style look: monospace text, near-black pages, thin frames
|
||||||
|
/// and a transcript drawn as prompt and tool lines.
|
||||||
|
terminal(
|
||||||
|
'terminal',
|
||||||
|
'Terminal',
|
||||||
|
'Monospace, flat frames and prompt-style chat, like a CLI agent.',
|
||||||
|
);
|
||||||
|
|
||||||
|
const AppDesign(this.id, this.label, this.description);
|
||||||
|
|
||||||
|
/// The stored value; stable across releases and renames.
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
/// The picker's name for the design.
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
static AppDesign fromId(String? id) {
|
||||||
|
for (final design in values) {
|
||||||
|
if (design.id == id) return design;
|
||||||
|
}
|
||||||
|
return standard;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The design's light theme. [fontFamily] is the device's interface font;
|
||||||
|
/// a design with its own family (Terminal's monospace) keeps that instead.
|
||||||
|
ThemeData light({String? fontFamily}) => switch (this) {
|
||||||
|
standard => appLightTheme(fontFamily: fontFamily),
|
||||||
|
terminal => terminalTheme(Brightness.light),
|
||||||
|
};
|
||||||
|
|
||||||
|
/// The design's dark theme; see [light].
|
||||||
|
ThemeData dark({String? fontFamily}) => switch (this) {
|
||||||
|
standard => appDarkTheme(fontFamily: fontFamily),
|
||||||
|
terminal => terminalTheme(Brightness.dark),
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Whether the device's interface font applies under this design.
|
||||||
|
bool get usesInterfaceFont => this == standard;
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import 'app_design.dart';
|
||||||
|
|
||||||
|
/// The device's design choice. It lives in this device's (or browser's) own
|
||||||
|
/// preferences and is never sent to a server.
|
||||||
|
const String appDesignKey = 'pipelines.design.v1';
|
||||||
|
|
||||||
|
/// The persistence seam for the design choice: an [AppDesign.id].
|
||||||
|
abstract interface class AppDesignStore {
|
||||||
|
/// The stored id; null when nothing is stored or it cannot be read.
|
||||||
|
Future<String?> load();
|
||||||
|
|
||||||
|
/// Whether the choice is actually stored.
|
||||||
|
Future<bool> save(String id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `shared_preferences` storage. An unreadable store means the default; a
|
||||||
|
/// failed save returns false rather than throwing.
|
||||||
|
class SharedPreferencesAppDesignStore implements AppDesignStore {
|
||||||
|
const SharedPreferencesAppDesignStore();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String?> load() async {
|
||||||
|
try {
|
||||||
|
return (await SharedPreferences.getInstance()).getString(appDesignKey);
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> save(String id) async {
|
||||||
|
try {
|
||||||
|
return await (await SharedPreferences.getInstance()).setString(
|
||||||
|
appDesignKey,
|
||||||
|
id,
|
||||||
|
);
|
||||||
|
} catch (_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An in-memory store for tests and fixtures.
|
||||||
|
class MemoryAppDesignStore implements AppDesignStore {
|
||||||
|
MemoryAppDesignStore([this.id]);
|
||||||
|
|
||||||
|
String? id;
|
||||||
|
bool failSaves = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String?> load() async => id;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> save(String id) async {
|
||||||
|
if (failSaves) return false;
|
||||||
|
this.id = id;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The device's app-wide design. The theme hosts listen to it, so a choice
|
||||||
|
/// rebuilds every theme in place without a restart.
|
||||||
|
class AppDesignController extends ChangeNotifier {
|
||||||
|
AppDesignController({AppDesignStore? store})
|
||||||
|
: _store = store ?? const SharedPreferencesAppDesignStore();
|
||||||
|
|
||||||
|
/// The app's own controller, shared by the theme hosts and Settings.
|
||||||
|
static final AppDesignController instance = AppDesignController();
|
||||||
|
|
||||||
|
final AppDesignStore _store;
|
||||||
|
AppDesign _design = AppDesign.standard;
|
||||||
|
int _revision = 0;
|
||||||
|
bool _saveFailed = false;
|
||||||
|
|
||||||
|
AppDesign get design => _design;
|
||||||
|
|
||||||
|
/// The last choice could not be stored on this device.
|
||||||
|
bool get saveFailed => _saveFailed;
|
||||||
|
|
||||||
|
/// Reads the stored choice. A choice made while reading wins.
|
||||||
|
Future<void> restore() async {
|
||||||
|
final revision = _revision;
|
||||||
|
final id = await _store.load();
|
||||||
|
if (revision != _revision || id == null) return;
|
||||||
|
final design = AppDesign.fromId(id);
|
||||||
|
if (design == _design) return;
|
||||||
|
_design = design;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Applies [design] now and stores it.
|
||||||
|
Future<void> select(AppDesign design) async {
|
||||||
|
_revision++;
|
||||||
|
final revision = _revision;
|
||||||
|
if (design != _design) {
|
||||||
|
_design = design;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
final saved = await _store.save(design.id);
|
||||||
|
if (revision != _revision || saved != _saveFailed) return;
|
||||||
|
_saveFailed = !saved;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'app_design.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.
|
||||||
|
@immutable
|
||||||
|
class AnsiAccents {
|
||||||
|
const AnsiAccents({
|
||||||
|
required this.green,
|
||||||
|
required this.cyan,
|
||||||
|
required this.yellow,
|
||||||
|
required this.red,
|
||||||
|
required this.magenta,
|
||||||
|
required this.blue,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Color green;
|
||||||
|
final Color cyan;
|
||||||
|
final Color yellow;
|
||||||
|
final Color red;
|
||||||
|
final Color magenta;
|
||||||
|
final Color blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The design-specific facts widgets read instead of hard-coding one look:
|
||||||
|
/// corner shapes, whether surfaces are flat, frame colour and how the chat
|
||||||
|
/// transcript is drawn. Every theme an [AppDesign] builds carries one; a
|
||||||
|
/// theme without one (a test's bare `ThemeData`) reads as [standard].
|
||||||
|
@immutable
|
||||||
|
class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||||
|
const AppDesignTokens({
|
||||||
|
required this.design,
|
||||||
|
this.radius,
|
||||||
|
this.flat = false,
|
||||||
|
this.frame,
|
||||||
|
this.ansi,
|
||||||
|
this.promptGlyph = '>',
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The Default design: every widget keeps its own shapes.
|
||||||
|
static const AppDesignTokens standard = AppDesignTokens(
|
||||||
|
design: AppDesign.standard,
|
||||||
|
);
|
||||||
|
|
||||||
|
final AppDesign design;
|
||||||
|
|
||||||
|
/// The corner radius of framed surfaces (cards, pills, the composer,
|
||||||
|
/// bubbles); null keeps each widget's own shape.
|
||||||
|
final double? radius;
|
||||||
|
|
||||||
|
/// Whether surfaces are flat: no frosted glass, blur, highlight or shadow.
|
||||||
|
final bool flat;
|
||||||
|
|
||||||
|
/// The 1px frame colour around flat surfaces; null keeps each widget's own.
|
||||||
|
final Color? frame;
|
||||||
|
|
||||||
|
/// The design's ANSI-style accents; null for a design that uses its colour
|
||||||
|
/// scheme's roles.
|
||||||
|
final AnsiAccents? ansi;
|
||||||
|
|
||||||
|
/// The glyph before the operator's prompt line and the composer's field.
|
||||||
|
final String promptGlyph;
|
||||||
|
|
||||||
|
/// Whether the transcript draws prompt and tool lines rather than bubbles.
|
||||||
|
bool get terminal => design == AppDesign.terminal;
|
||||||
|
|
||||||
|
/// The tokens of the theme at [context]; [standard] when it has none.
|
||||||
|
static AppDesignTokens of(BuildContext context) =>
|
||||||
|
Theme.of(context).extension<AppDesignTokens>() ?? standard;
|
||||||
|
|
||||||
|
/// [designed] as this design draws it: the widget's own shape, or a
|
||||||
|
/// rectangle with [radius] corners.
|
||||||
|
OutlinedBorder shape(OutlinedBorder designed) {
|
||||||
|
final r = radius;
|
||||||
|
if (r == null) return designed;
|
||||||
|
return RoundedRectangleBorder(borderRadius: BorderRadius.circular(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// [designed] corners, or [radius] corners under a design that sets it.
|
||||||
|
BorderRadius corners(BorderRadius designed) {
|
||||||
|
final r = radius;
|
||||||
|
return r == null ? designed : BorderRadius.circular(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
AppDesignTokens copyWith({
|
||||||
|
AppDesign? design,
|
||||||
|
double? radius,
|
||||||
|
bool? flat,
|
||||||
|
Color? frame,
|
||||||
|
AnsiAccents? ansi,
|
||||||
|
String? promptGlyph,
|
||||||
|
}) => AppDesignTokens(
|
||||||
|
design: design ?? this.design,
|
||||||
|
radius: radius ?? this.radius,
|
||||||
|
flat: flat ?? this.flat,
|
||||||
|
frame: frame ?? this.frame,
|
||||||
|
ansi: ansi ?? this.ansi,
|
||||||
|
promptGlyph: promptGlyph ?? this.promptGlyph,
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Designs switch whole: a theme animation snaps halfway rather than
|
||||||
|
/// blending two designs' shapes.
|
||||||
|
@override
|
||||||
|
AppDesignTokens lerp(AppDesignTokens? other, double t) =>
|
||||||
|
other == null || t < 0.5 ? this : other;
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'app_design_tokens.dart';
|
||||||
|
|
||||||
|
/// Terminal's muted ANSI accents on its near-black page.
|
||||||
|
const AnsiAccents terminalDarkAnsi = AnsiAccents(
|
||||||
|
green: Color(0xFF8CC38F),
|
||||||
|
cyan: Color(0xFF6FB8C4),
|
||||||
|
yellow: Color(0xFFD6BC7A),
|
||||||
|
red: Color(0xFFE07A80),
|
||||||
|
magenta: Color(0xFFC08BC4),
|
||||||
|
blue: Color(0xFF7FA6D9),
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Terminal's accents darkened to read on its light paper page.
|
||||||
|
const AnsiAccents terminalLightAnsi = AnsiAccents(
|
||||||
|
green: Color(0xFF2F7434),
|
||||||
|
cyan: Color(0xFF1C6E7C),
|
||||||
|
yellow: Color(0xFF7D6316),
|
||||||
|
red: Color(0xFFB3332E),
|
||||||
|
magenta: Color(0xFF8E3F8A),
|
||||||
|
blue: Color(0xFF2E5F9E),
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Terminal's colour scheme: a near-black (or paper) page whose surfaces
|
||||||
|
/// step up only slightly, light grey text with dim grey secondary text, and
|
||||||
|
/// the ANSI accents as the scheme's roles (green primary, cyan secondary,
|
||||||
|
/// yellow tertiary, red error).
|
||||||
|
ColorScheme terminalColorScheme(Brightness brightness) {
|
||||||
|
if (brightness == Brightness.dark) {
|
||||||
|
return const ColorScheme(
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
primary: Color(0xFF8CC38F),
|
||||||
|
onPrimary: Color(0xFF0B0B0B),
|
||||||
|
primaryContainer: Color(0xFF1B2A1C),
|
||||||
|
onPrimaryContainer: Color(0xFFB4DDB5),
|
||||||
|
secondary: Color(0xFF6FB8C4),
|
||||||
|
onSecondary: Color(0xFF0B0B0B),
|
||||||
|
secondaryContainer: Color(0xFF16282B),
|
||||||
|
onSecondaryContainer: Color(0xFFA8D8E0),
|
||||||
|
tertiary: Color(0xFFD6BC7A),
|
||||||
|
onTertiary: Color(0xFF0B0B0B),
|
||||||
|
tertiaryContainer: Color(0xFF2B2516),
|
||||||
|
onTertiaryContainer: Color(0xFFEBD9A9),
|
||||||
|
error: Color(0xFFE07A80),
|
||||||
|
onError: Color(0xFF0B0B0B),
|
||||||
|
errorContainer: Color(0xFF3A1B1E),
|
||||||
|
onErrorContainer: Color(0xFFF3B9BD),
|
||||||
|
surface: Color(0xFF0B0B0B),
|
||||||
|
onSurface: Color(0xFFD7D7D2),
|
||||||
|
onSurfaceVariant: Color(0xFF8D8D88),
|
||||||
|
surfaceDim: Color(0xFF0B0B0B),
|
||||||
|
surfaceBright: Color(0xFF2A2A28),
|
||||||
|
surfaceContainerLowest: Color(0xFF070707),
|
||||||
|
surfaceContainerLow: Color(0xFF111111),
|
||||||
|
surfaceContainer: Color(0xFF151514),
|
||||||
|
surfaceContainerHigh: Color(0xFF1A1A19),
|
||||||
|
surfaceContainerHighest: Color(0xFF21211F),
|
||||||
|
outline: Color(0xFF4A4A46),
|
||||||
|
outlineVariant: Color(0xFF2B2B29),
|
||||||
|
shadow: Color(0xFF000000),
|
||||||
|
scrim: Color(0xFF000000),
|
||||||
|
inverseSurface: Color(0xFFD7D7D2),
|
||||||
|
onInverseSurface: Color(0xFF0B0B0B),
|
||||||
|
inversePrimary: Color(0xFF2F7434),
|
||||||
|
surfaceTint: Color(0x00000000),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return const ColorScheme(
|
||||||
|
brightness: Brightness.light,
|
||||||
|
primary: Color(0xFF2F7434),
|
||||||
|
onPrimary: Color(0xFFFFFFFF),
|
||||||
|
primaryContainer: Color(0xFFDCEBD9),
|
||||||
|
onPrimaryContainer: Color(0xFF14351A),
|
||||||
|
secondary: Color(0xFF1C6E7C),
|
||||||
|
onSecondary: Color(0xFFFFFFFF),
|
||||||
|
secondaryContainer: Color(0xFFD5E8EB),
|
||||||
|
onSecondaryContainer: Color(0xFF0D3239),
|
||||||
|
tertiary: Color(0xFF7D6316),
|
||||||
|
onTertiary: Color(0xFFFFFFFF),
|
||||||
|
tertiaryContainer: Color(0xFFF0E6C8),
|
||||||
|
onTertiaryContainer: Color(0xFF3A2D05),
|
||||||
|
error: Color(0xFFB3332E),
|
||||||
|
onError: Color(0xFFFFFFFF),
|
||||||
|
errorContainer: Color(0xFFF6D9D7),
|
||||||
|
onErrorContainer: Color(0xFF4A0D0B),
|
||||||
|
surface: Color(0xFFF7F6F1),
|
||||||
|
onSurface: Color(0xFF1E1E1C),
|
||||||
|
onSurfaceVariant: Color(0xFF64645F),
|
||||||
|
surfaceDim: Color(0xFFE6E5DF),
|
||||||
|
surfaceBright: Color(0xFFFCFBF7),
|
||||||
|
surfaceContainerLowest: Color(0xFFFCFBF7),
|
||||||
|
surfaceContainerLow: Color(0xFFF1F0EA),
|
||||||
|
surfaceContainer: Color(0xFFECEBE5),
|
||||||
|
surfaceContainerHigh: Color(0xFFE6E5DF),
|
||||||
|
surfaceContainerHighest: Color(0xFFDFDED7),
|
||||||
|
outline: Color(0xFF9C9C95),
|
||||||
|
outlineVariant: Color(0xFFD2D1CA),
|
||||||
|
shadow: Color(0xFF000000),
|
||||||
|
scrim: Color(0xFF000000),
|
||||||
|
inverseSurface: Color(0xFF1E1E1C),
|
||||||
|
onInverseSurface: Color(0xFFF7F6F1),
|
||||||
|
inversePrimary: Color(0xFF8CC38F),
|
||||||
|
surfaceTint: Color(0x00000000),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../text/monospace.dart';
|
||||||
|
import 'app_design.dart';
|
||||||
|
import 'app_design_tokens.dart';
|
||||||
|
import 'app_theme.dart';
|
||||||
|
import 'terminal_palette.dart';
|
||||||
|
|
||||||
|
/// Terminal's corner radius: square enough to read as a terminal frame, soft
|
||||||
|
/// enough not to alias.
|
||||||
|
const double terminalRadius = 3;
|
||||||
|
|
||||||
|
const BorderRadius _corners = BorderRadius.all(Radius.circular(terminalRadius));
|
||||||
|
|
||||||
|
/// The Terminal design's theme: the bundled monospace family everywhere,
|
||||||
|
/// compact text, flat surfaces with 1px dim frames and no elevation, and
|
||||||
|
/// the ANSI accents as the colour roles. Every Material component the app
|
||||||
|
/// uses takes the same shapes, so lists, dialogs, menus and buttons follow
|
||||||
|
/// without per-widget code.
|
||||||
|
ThemeData terminalTheme(Brightness brightness) {
|
||||||
|
final scheme = terminalColorScheme(brightness);
|
||||||
|
final ansi = brightness == Brightness.dark
|
||||||
|
? terminalDarkAnsi
|
||||||
|
: terminalLightAnsi;
|
||||||
|
final frame = BorderSide(color: scheme.outlineVariant);
|
||||||
|
final framed = RoundedRectangleBorder(borderRadius: _corners, side: frame);
|
||||||
|
const square = RoundedRectangleBorder(borderRadius: _corners);
|
||||||
|
final base = ThemeData(
|
||||||
|
platform: kIsWeb ? TargetPlatform.android : null,
|
||||||
|
colorScheme: scheme,
|
||||||
|
fontFamily: appMonospaceFamily,
|
||||||
|
scaffoldBackgroundColor: scheme.surface,
|
||||||
|
canvasColor: scheme.surface,
|
||||||
|
pageTransitionsTheme: appPageTransitions,
|
||||||
|
visualDensity: const VisualDensity(horizontal: -1, vertical: -1),
|
||||||
|
splashFactory: NoSplash.splashFactory,
|
||||||
|
shadowColor: const Color(0x00000000),
|
||||||
|
dividerColor: scheme.outlineVariant,
|
||||||
|
extensions: [
|
||||||
|
AppDesignTokens(
|
||||||
|
design: AppDesign.terminal,
|
||||||
|
radius: terminalRadius,
|
||||||
|
flat: true,
|
||||||
|
frame: scheme.outlineVariant,
|
||||||
|
ansi: ansi,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
ButtonStyle buttons(ButtonStyle? style) =>
|
||||||
|
(style ?? const ButtonStyle()).copyWith(
|
||||||
|
shape: const WidgetStatePropertyAll(square),
|
||||||
|
elevation: const WidgetStatePropertyAll(0),
|
||||||
|
shadowColor: const WidgetStatePropertyAll(Color(0x00000000)),
|
||||||
|
);
|
||||||
|
final menu = MenuStyle(
|
||||||
|
backgroundColor: WidgetStatePropertyAll(scheme.surfaceContainerLow),
|
||||||
|
elevation: const WidgetStatePropertyAll(0),
|
||||||
|
shadowColor: const WidgetStatePropertyAll(Color(0x00000000)),
|
||||||
|
surfaceTintColor: const WidgetStatePropertyAll(Color(0x00000000)),
|
||||||
|
shape: WidgetStatePropertyAll(
|
||||||
|
RoundedRectangleBorder(
|
||||||
|
borderRadius: _corners,
|
||||||
|
side: BorderSide(color: scheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return base.copyWith(
|
||||||
|
textTheme: terminalTextTheme(base.textTheme),
|
||||||
|
primaryTextTheme: terminalTextTheme(base.primaryTextTheme),
|
||||||
|
appBarTheme: AppBarTheme(
|
||||||
|
backgroundColor: scheme.surface,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
elevation: 0,
|
||||||
|
scrolledUnderElevation: 0,
|
||||||
|
shape: Border(bottom: frame),
|
||||||
|
),
|
||||||
|
// Only the frame: each card variant (filled, outlined) keeps its own
|
||||||
|
// fill, so a selected graph node still reads apart.
|
||||||
|
cardTheme: CardThemeData(
|
||||||
|
elevation: 0,
|
||||||
|
shadowColor: const Color(0x00000000),
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
shape: framed,
|
||||||
|
),
|
||||||
|
dialogTheme: DialogThemeData(
|
||||||
|
backgroundColor: scheme.surfaceContainerLow,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: _corners,
|
||||||
|
side: BorderSide(color: scheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
bottomSheetTheme: BottomSheetThemeData(
|
||||||
|
backgroundColor: scheme.surfaceContainerLow,
|
||||||
|
modalBackgroundColor: scheme.surfaceContainerLow,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
elevation: 0,
|
||||||
|
modalElevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: _corners,
|
||||||
|
side: BorderSide(color: scheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
popupMenuTheme: PopupMenuThemeData(
|
||||||
|
color: scheme.surfaceContainerLow,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: _corners,
|
||||||
|
side: BorderSide(color: scheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
menuTheme: MenuThemeData(style: menu),
|
||||||
|
dropdownMenuTheme: DropdownMenuThemeData(menuStyle: menu),
|
||||||
|
menuButtonTheme: MenuButtonThemeData(
|
||||||
|
style: MenuItemButton.styleFrom(shape: square),
|
||||||
|
),
|
||||||
|
filledButtonTheme: FilledButtonThemeData(
|
||||||
|
style: buttons(base.filledButtonTheme.style),
|
||||||
|
),
|
||||||
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||||
|
style: buttons(base.elevatedButtonTheme.style),
|
||||||
|
),
|
||||||
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||||
|
style: buttons(base.outlinedButtonTheme.style).copyWith(
|
||||||
|
side: WidgetStatePropertyAll(BorderSide(color: scheme.outline)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
textButtonTheme: TextButtonThemeData(
|
||||||
|
style: buttons(base.textButtonTheme.style),
|
||||||
|
),
|
||||||
|
iconButtonTheme: IconButtonThemeData(
|
||||||
|
style: buttons(base.iconButtonTheme.style),
|
||||||
|
),
|
||||||
|
segmentedButtonTheme: SegmentedButtonThemeData(
|
||||||
|
style: buttons(base.segmentedButtonTheme.style),
|
||||||
|
),
|
||||||
|
floatingActionButtonTheme: FloatingActionButtonThemeData(
|
||||||
|
elevation: 0,
|
||||||
|
focusElevation: 0,
|
||||||
|
hoverElevation: 0,
|
||||||
|
highlightElevation: 0,
|
||||||
|
backgroundColor: scheme.surfaceContainerHigh,
|
||||||
|
foregroundColor: scheme.primary,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: _corners,
|
||||||
|
side: BorderSide(color: scheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
chipTheme: ChipThemeData(
|
||||||
|
backgroundColor: const Color(0x00000000),
|
||||||
|
shape: framed,
|
||||||
|
side: frame,
|
||||||
|
elevation: 0,
|
||||||
|
pressElevation: 0,
|
||||||
|
),
|
||||||
|
// Only the base border: a field that sets `InputBorder.none` (the
|
||||||
|
// composer, whose frame is its pill) keeps none in every state.
|
||||||
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
|
isDense: true,
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: _corners,
|
||||||
|
borderSide: BorderSide(color: scheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
searchBarTheme: SearchBarThemeData(
|
||||||
|
elevation: const WidgetStatePropertyAll(0),
|
||||||
|
shape: const WidgetStatePropertyAll(square),
|
||||||
|
side: WidgetStatePropertyAll(BorderSide(color: scheme.outline)),
|
||||||
|
backgroundColor: WidgetStatePropertyAll(scheme.surfaceContainerLow),
|
||||||
|
),
|
||||||
|
navigationRailTheme: NavigationRailThemeData(
|
||||||
|
backgroundColor: scheme.surface,
|
||||||
|
elevation: 0,
|
||||||
|
indicatorColor: scheme.primaryContainer,
|
||||||
|
indicatorShape: square,
|
||||||
|
),
|
||||||
|
navigationBarTheme: NavigationBarThemeData(
|
||||||
|
backgroundColor: scheme.surface,
|
||||||
|
elevation: 0,
|
||||||
|
indicatorColor: scheme.primaryContainer,
|
||||||
|
indicatorShape: square,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
),
|
||||||
|
listTileTheme: const ListTileThemeData(shape: square),
|
||||||
|
dividerTheme: DividerThemeData(
|
||||||
|
color: scheme.outlineVariant,
|
||||||
|
thickness: 1,
|
||||||
|
space: 1,
|
||||||
|
),
|
||||||
|
tabBarTheme: TabBarThemeData(
|
||||||
|
dividerColor: scheme.outlineVariant,
|
||||||
|
indicatorSize: TabBarIndicatorSize.tab,
|
||||||
|
indicator: UnderlineTabIndicator(
|
||||||
|
borderSide: BorderSide(color: scheme.primary, width: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
snackBarTheme: SnackBarThemeData(
|
||||||
|
backgroundColor: scheme.surfaceContainerHigh,
|
||||||
|
contentTextStyle: TextStyle(
|
||||||
|
color: scheme.onSurface,
|
||||||
|
fontFamily: appMonospaceFamily,
|
||||||
|
),
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: _corners,
|
||||||
|
side: BorderSide(color: scheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
tooltipTheme: TooltipThemeData(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: scheme.surfaceContainerHighest,
|
||||||
|
borderRadius: _corners,
|
||||||
|
border: Border.all(color: scheme.outline),
|
||||||
|
),
|
||||||
|
textStyle: TextStyle(
|
||||||
|
color: scheme.onSurface,
|
||||||
|
fontFamily: appMonospaceFamily,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
scrollbarTheme: const ScrollbarThemeData(radius: Radius.zero),
|
||||||
|
progressIndicatorTheme: ProgressIndicatorThemeData(
|
||||||
|
color: scheme.primary,
|
||||||
|
linearTrackColor: scheme.outlineVariant,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// [base] in the monospace family at a terminal's compact size: Material's
|
||||||
|
/// roles a step smaller (monospace runs wide), with no added letter spacing.
|
||||||
|
TextTheme terminalTextTheme(TextTheme base) {
|
||||||
|
TextStyle? mono(TextStyle? style) {
|
||||||
|
if (style == null) return null;
|
||||||
|
final size = style.fontSize;
|
||||||
|
return style.copyWith(
|
||||||
|
fontFamily: appMonospaceFamily,
|
||||||
|
fontSize: size == null ? null : (size * 0.875).roundToDouble(),
|
||||||
|
letterSpacing: 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.copyWith(
|
||||||
|
displayLarge: mono(base.displayLarge),
|
||||||
|
displayMedium: mono(base.displayMedium),
|
||||||
|
displaySmall: mono(base.displaySmall),
|
||||||
|
headlineLarge: mono(base.headlineLarge),
|
||||||
|
headlineMedium: mono(base.headlineMedium),
|
||||||
|
headlineSmall: mono(base.headlineSmall),
|
||||||
|
titleLarge: mono(base.titleLarge),
|
||||||
|
titleMedium: mono(base.titleMedium),
|
||||||
|
titleSmall: mono(base.titleSmall),
|
||||||
|
bodyLarge: mono(base.bodyLarge),
|
||||||
|
bodyMedium: mono(base.bodyMedium),
|
||||||
|
bodySmall: mono(base.bodySmall),
|
||||||
|
labelLarge: mono(base.labelLarge),
|
||||||
|
labelMedium: mono(base.labelMedium),
|
||||||
|
labelSmall: mono(base.labelSmall),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/domain/chat_transcript.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_bubble.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_view.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/transcript/terminal/terminal_activity_rows.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/transcript/terminal/terminal_glyphs.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/transcript/terminal/terminal_prompt_line.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/app_design.dart';
|
||||||
|
|
||||||
|
JsonMap _row(JsonMap message) => transcriptRows([message]).single;
|
||||||
|
|
||||||
|
final JsonMap _operator = _row({
|
||||||
|
'id': 'u1',
|
||||||
|
'role': 'user',
|
||||||
|
'parts': [
|
||||||
|
{'type': 'text', 'text': 'Fix the Windows paths.'},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
JsonMap _tool(String id, String name, String status, {String? output}) => {
|
||||||
|
'type': 'tool',
|
||||||
|
'id': id,
|
||||||
|
'name': name,
|
||||||
|
'state': {
|
||||||
|
'status': status,
|
||||||
|
'input': {'command': 'go test ./...'},
|
||||||
|
if (output != null)
|
||||||
|
'content': [
|
||||||
|
{'type': 'text', 'text': output},
|
||||||
|
],
|
||||||
|
if (status == 'error') 'error': {'message': 'exit status 1'},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
final JsonMap _agent = _row({
|
||||||
|
'id': 'a1',
|
||||||
|
'role': 'assistant',
|
||||||
|
'parts': [
|
||||||
|
_tool('t1', 'Bash', 'completed', output: 'ok notes 0.2s\nPASS'),
|
||||||
|
_tool('t2', 'Bash', 'error'),
|
||||||
|
{'type': 'text', 'text': 'Fixed the separators.'},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
final JsonMap _followup = _row({
|
||||||
|
'id': 'f1',
|
||||||
|
'role': 'user',
|
||||||
|
'origin': 'followup',
|
||||||
|
'client': 'Agent follow-up',
|
||||||
|
'parts': [
|
||||||
|
{'type': 'text', 'text': 'Check whether run 42 finished.'},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Widget _host(AppDesign design, List<JsonMap> rows) => MaterialApp(
|
||||||
|
theme: design.dark(),
|
||||||
|
themeMode: ThemeMode.light,
|
||||||
|
home: Scaffold(
|
||||||
|
body: ListView(
|
||||||
|
children: [for (final row in rows) ChatMessageView(row: row)],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
double _left(WidgetTester tester, Finder finder) =>
|
||||||
|
tester.getTopLeft(finder).dx;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('Terminal: the operator turn is a prompt line at the start', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await tester.pumpWidget(_host(AppDesign.terminal, [_operator, _agent]));
|
||||||
|
final line = find.byType(TerminalPromptLine);
|
||||||
|
expect(line, findsOneWidget);
|
||||||
|
expect(find.descendant(of: line, matching: find.text('>')), findsOneWidget);
|
||||||
|
// Same start edge as the answer, not pushed to the trailing side.
|
||||||
|
final answer = find.text('Fixed the separators.');
|
||||||
|
expect(_left(tester, line), lessThan(_left(tester, answer)));
|
||||||
|
expect(_left(tester, line), lessThan(40));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Terminal: tool calls are dot lines with result lines', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await tester.pumpWidget(_host(AppDesign.terminal, [_agent]));
|
||||||
|
final rows = find.byType(TerminalActivityRows);
|
||||||
|
expect(rows, findsOneWidget);
|
||||||
|
expect(
|
||||||
|
find.descendant(of: rows, matching: find.textContaining('Bash')),
|
||||||
|
findsNWidgets(2),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
find.descendant(
|
||||||
|
of: rows,
|
||||||
|
matching: find.textContaining('ok notes 0.2s · +1 lines'),
|
||||||
|
),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
find.descendant(of: rows, matching: find.textContaining('exit status 1')),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
final glyphs = tester
|
||||||
|
.widgetList<TerminalGlyph>(
|
||||||
|
find.descendant(of: rows, matching: find.byType(TerminalGlyph)),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
expect(glyphs.where((g) => g.kind == TerminalGlyphKind.dot), hasLength(2));
|
||||||
|
expect(
|
||||||
|
glyphs.where((g) => g.kind == TerminalGlyphKind.elbow),
|
||||||
|
hasLength(2),
|
||||||
|
);
|
||||||
|
// The failed call's dot is red, the completed one's is not.
|
||||||
|
final dots = glyphs.where((g) => g.kind == TerminalGlyphKind.dot).toList();
|
||||||
|
expect(dots.first.color, isNot(dots.last.color));
|
||||||
|
// The block still opens the activity details.
|
||||||
|
await tester.tap(rows);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Activity details'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Terminal: an agent follow-up is a dim bracketed line', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await tester.pumpWidget(_host(AppDesign.terminal, [_followup]));
|
||||||
|
final header = find.byKey(const Key('chat-automated-prompt-header'));
|
||||||
|
expect(header, findsOneWidget);
|
||||||
|
final text = tester.widget<Text>(header).textSpan!.toPlainText();
|
||||||
|
expect(text, startsWith('[Follow-up from agent'));
|
||||||
|
expect(text, endsWith(']'));
|
||||||
|
expect(find.text('Check whether run 42 finished.'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Default: bubbles and the one-line activity are unchanged', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
_host(AppDesign.standard, [_operator, _agent, _followup]),
|
||||||
|
);
|
||||||
|
expect(find.byType(TerminalPromptLine), findsNothing);
|
||||||
|
expect(find.byType(TerminalActivityRows), findsNothing);
|
||||||
|
expect(find.byType(TerminalGlyph), findsNothing);
|
||||||
|
expect(find.byType(ChatUserBubble), findsOneWidget);
|
||||||
|
expect(find.text('>'), findsNothing);
|
||||||
|
// The operator's bubble sits on the trailing side.
|
||||||
|
final bubble = find.byType(ChatUserBubble);
|
||||||
|
final answer = find.text('Fixed the separators.');
|
||||||
|
expect(_left(tester, bubble), greaterThan(_left(tester, answer)));
|
||||||
|
final header = find.byKey(const Key('chat-automated-prompt-header'));
|
||||||
|
expect(tester.widget(header), isA<Wrap>());
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/features/settings/settings_design_section.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';
|
||||||
|
|
||||||
|
/// The section inside a host whose theme follows [designs], as the app's
|
||||||
|
/// theme hosts do, so a choice is seen to restyle the page live.
|
||||||
|
Future<void> _pump(WidgetTester tester, AppDesignController designs) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
ListenableBuilder(
|
||||||
|
listenable: designs,
|
||||||
|
builder: (context, _) => MaterialApp(
|
||||||
|
theme: designs.design.light(),
|
||||||
|
darkTheme: designs.design.dark(),
|
||||||
|
home: Scaffold(
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: SettingsDesignSection(controller: designs),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
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', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final designs = AppDesignController(store: MemoryAppDesignStore());
|
||||||
|
await _pump(tester, designs);
|
||||||
|
|
||||||
|
expect(find.text(designSectionTitle), findsOneWidget);
|
||||||
|
for (final design in AppDesign.values) {
|
||||||
|
expect(find.byKey(settingsDesignKey(design)), findsOneWidget);
|
||||||
|
expect(find.text(design.label), findsOneWidget);
|
||||||
|
}
|
||||||
|
final group = tester.widget<RadioGroup<AppDesign>>(
|
||||||
|
find.byType(RadioGroup<AppDesign>),
|
||||||
|
);
|
||||||
|
expect(group.groupValue, AppDesign.standard);
|
||||||
|
expect(_tokens(tester).terminal, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('choosing Terminal 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(_tokens(tester).terminal, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a stored choice is restored into the picker', (tester) async {
|
||||||
|
final designs = AppDesignController(
|
||||||
|
store: MemoryAppDesignStore(AppDesign.terminal.id),
|
||||||
|
);
|
||||||
|
await designs.restore();
|
||||||
|
await _pump(tester, designs);
|
||||||
|
final group = tester.widget<RadioGroup<AppDesign>>(
|
||||||
|
find.byType(RadioGroup<AppDesign>),
|
||||||
|
);
|
||||||
|
expect(group.groupValue, AppDesign.terminal);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a failed save says the choice lasts until reload', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final designs = AppDesignController(
|
||||||
|
store: MemoryAppDesignStore()..failSaves = true,
|
||||||
|
);
|
||||||
|
await _pump(tester, designs);
|
||||||
|
await tester.tap(find.text(AppDesign.terminal.label));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text(designSaveFailedText), findsOneWidget);
|
||||||
|
expect(designs.design, AppDesign.terminal);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
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: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('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);
|
||||||
|
await pending;
|
||||||
|
expect(store.id, 'terminal');
|
||||||
|
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);
|
||||||
|
expect(designs.saveFailed, isTrue);
|
||||||
|
store.failSaves = false;
|
||||||
|
await designs.select(AppDesign.standard);
|
||||||
|
expect(designs.saveFailed, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a choice made while restoring wins over the stored one', () async {
|
||||||
|
final designs = AppDesignController(
|
||||||
|
store: MemoryAppDesignStore('terminal'),
|
||||||
|
);
|
||||||
|
final restoring = designs.restore();
|
||||||
|
await designs.select(AppDesign.standard);
|
||||||
|
await restoring;
|
||||||
|
expect(designs.design, AppDesign.standard);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('shared preferences keep the choice per device', () async {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
const store = SharedPreferencesAppDesignStore();
|
||||||
|
expect(await store.load(), isNull);
|
||||||
|
expect(await store.save('terminal'), isTrue);
|
||||||
|
expect(await store.load(), 'terminal');
|
||||||
|
final designs = AppDesignController(store: store);
|
||||||
|
await designs.restore();
|
||||||
|
expect(designs.design, AppDesign.terminal);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
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/text/monospace.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_font_controller.dart';
|
||||||
|
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', () {
|
||||||
|
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.standard.id, 'default');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the Default design builds exactly the existing themes', () {
|
||||||
|
expect(AppDesign.standard.light(), appLightTheme());
|
||||||
|
expect(AppDesign.standard.dark(), appDarkTheme());
|
||||||
|
expect(
|
||||||
|
AppDesign.standard.light(fontFamily: 'Inter'),
|
||||||
|
appLightTheme(fontFamily: 'Inter'),
|
||||||
|
);
|
||||||
|
expect(AppDesign.standard.dark().extension<AppDesignTokens>(), isNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Terminal is monospace, flat and near-black in dark', () {
|
||||||
|
for (final brightness in Brightness.values) {
|
||||||
|
final theme = brightness == Brightness.dark
|
||||||
|
? AppDesign.terminal.dark(fontFamily: 'Inter')
|
||||||
|
: AppDesign.terminal.light(fontFamily: 'Inter');
|
||||||
|
final tokens = theme.extension<AppDesignTokens>()!;
|
||||||
|
expect(tokens.terminal, isTrue);
|
||||||
|
expect(tokens.flat, isTrue);
|
||||||
|
expect(tokens.radius, lessThanOrEqualTo(4));
|
||||||
|
expect(tokens.ansi, isNotNull);
|
||||||
|
expect(theme.colorScheme.brightness, brightness);
|
||||||
|
// The interface font choice does not apply: monospace everywhere.
|
||||||
|
for (final style in [
|
||||||
|
theme.textTheme.bodyLarge,
|
||||||
|
theme.textTheme.titleMedium,
|
||||||
|
theme.textTheme.labelLarge,
|
||||||
|
]) {
|
||||||
|
expect(style?.fontFamily, appMonospaceFamily);
|
||||||
|
expect(style?.letterSpacing, 0);
|
||||||
|
}
|
||||||
|
expect(theme.cardTheme.elevation, 0);
|
||||||
|
expect(theme.dialogTheme.elevation, 0);
|
||||||
|
expect(theme.appBarTheme.scrolledUnderElevation, 0);
|
||||||
|
final dialog = theme.dialogTheme.shape! as RoundedRectangleBorder;
|
||||||
|
expect(dialog.borderRadius, BorderRadius.circular(tokens.radius!));
|
||||||
|
expect(dialog.side.width, 1);
|
||||||
|
}
|
||||||
|
final dark = AppDesign.terminal.dark();
|
||||||
|
expect(dark.scaffoldBackgroundColor.computeLuminance(), lessThan(0.01));
|
||||||
|
final light = AppDesign.terminal.light();
|
||||||
|
expect(light.scaffoldBackgroundColor.computeLuminance(), greaterThan(0.85));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('tokens reshape only under a design that sets a radius', () {
|
||||||
|
const stadium = StadiumBorder();
|
||||||
|
expect(AppDesignTokens.standard.shape(stadium), same(stadium));
|
||||||
|
final terminal = AppDesign.terminal.dark().extension<AppDesignTokens>()!;
|
||||||
|
final shaped = terminal.shape(stadium) as RoundedRectangleBorder;
|
||||||
|
expect(shaped.borderRadius, BorderRadius.circular(terminal.radius!));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('the Material host switches design live, without a restart', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final designs = AppDesignController(store: MemoryAppDesignStore());
|
||||||
|
final fonts = AppFontController(
|
||||||
|
store: MemoryAppFontStore(),
|
||||||
|
loader: (family, assets) async {},
|
||||||
|
);
|
||||||
|
late AppDesignTokens tokens;
|
||||||
|
String? family;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MyApp(
|
||||||
|
fonts: fonts,
|
||||||
|
designs: designs,
|
||||||
|
destination: AppDestination.settings,
|
||||||
|
destinationBodies: <AppDestination, WidgetBuilder>{
|
||||||
|
AppDestination.settings: (context) => Builder(
|
||||||
|
builder: (context) {
|
||||||
|
tokens = AppDesignTokens.of(context);
|
||||||
|
family = DefaultTextStyle.of(context).style.fontFamily;
|
||||||
|
return const Text('body');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(tokens.terminal, isFalse);
|
||||||
|
expect(family, isNot(appMonospaceFamily));
|
||||||
|
await designs.select(AppDesign.terminal);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tokens.terminal, isTrue);
|
||||||
|
expect(family, appMonospaceFamily);
|
||||||
|
await designs.select(AppDesign.standard);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tokens.terminal, isFalse);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
|
|
||||||
|
/// `?cli=1`: a coding exchange shaped like a CLI agent session, for design
|
||||||
|
/// reviews of the transcript's tool rows: an operator request, a turn with
|
||||||
|
/// thinking and several tool calls (a command with output, reads, a search,
|
||||||
|
/// a failed edit and its retry) and a closing answer with a list and code.
|
||||||
|
List<JsonMap> chatCliMessages(String chat) {
|
||||||
|
var minute = 0;
|
||||||
|
int at() => DateTime.utc(2026, 12, 3, 8, minute += 3).millisecondsSinceEpoch;
|
||||||
|
JsonMap tool(
|
||||||
|
String id,
|
||||||
|
String name,
|
||||||
|
JsonMap input, {
|
||||||
|
String output = '',
|
||||||
|
String? error,
|
||||||
|
int millis = 400,
|
||||||
|
}) => {
|
||||||
|
'type': 'tool',
|
||||||
|
'id': '$chat-cli-$id',
|
||||||
|
'name': name,
|
||||||
|
'state': {
|
||||||
|
'status': error == null ? 'completed' : 'error',
|
||||||
|
'input': input,
|
||||||
|
if (output.isNotEmpty)
|
||||||
|
'content': [
|
||||||
|
{'type': 'text', 'text': output},
|
||||||
|
],
|
||||||
|
if (error != null) 'error': {'message': error},
|
||||||
|
},
|
||||||
|
'time': {'created': 1764750000000, 'completed': 1764750000000 + millis},
|
||||||
|
};
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'id': '$chat-cli-q',
|
||||||
|
'role': 'user',
|
||||||
|
'created_at': at(),
|
||||||
|
'parts': [
|
||||||
|
{
|
||||||
|
'type': 'text',
|
||||||
|
'text':
|
||||||
|
'The release notes job fails on Windows paths. Find the cause '
|
||||||
|
'and fix it.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': '$chat-cli-a',
|
||||||
|
'role': 'assistant',
|
||||||
|
'created_at': at(),
|
||||||
|
'model': 'claude-opus',
|
||||||
|
'parts': [
|
||||||
|
{
|
||||||
|
'type': 'reasoning',
|
||||||
|
'text': 'Start from the failing job, then read the path helper.',
|
||||||
|
},
|
||||||
|
tool(
|
||||||
|
'bash',
|
||||||
|
'Bash',
|
||||||
|
{'command': 'go test ./internal/notes/...'},
|
||||||
|
output:
|
||||||
|
'--- FAIL: TestNotesPath (0.01s)\n'
|
||||||
|
' notes_test.go:41: got "C:/repo\\\\notes.md"\n'
|
||||||
|
'FAIL',
|
||||||
|
millis: 2300,
|
||||||
|
),
|
||||||
|
tool('read', 'Read', {
|
||||||
|
'file_path': 'internal/notes/path.go',
|
||||||
|
}, output: 'package notes\n\nimport "path"\n…'),
|
||||||
|
tool(
|
||||||
|
'grep',
|
||||||
|
'Grep',
|
||||||
|
{'pattern': 'path.Join'},
|
||||||
|
output: 'internal/notes/path.go:18\ninternal/notes/render.go:52',
|
||||||
|
),
|
||||||
|
tool('edit1', 'Edit', {
|
||||||
|
'file_path': 'internal/notes/path.go',
|
||||||
|
}, error: 'old_string not found in file'),
|
||||||
|
tool('edit2', 'Edit', {
|
||||||
|
'file_path': 'internal/notes/path.go',
|
||||||
|
}, output: 'Updated internal/notes/path.go (2 lines)'),
|
||||||
|
tool(
|
||||||
|
'bash2',
|
||||||
|
'Bash',
|
||||||
|
{'command': 'go test ./internal/notes/...'},
|
||||||
|
output: 'ok \tpipelines/internal/notes\t0.214s',
|
||||||
|
millis: 1900,
|
||||||
|
),
|
||||||
|
{
|
||||||
|
'type': 'text',
|
||||||
|
'text':
|
||||||
|
'Fixed. The notes job joined paths with `path.Join`, which '
|
||||||
|
'always uses forward slashes, so a Windows checkout produced '
|
||||||
|
'mixed separators.\n\n'
|
||||||
|
'- `internal/notes/path.go` now uses `filepath.Join`\n'
|
||||||
|
'- `TestNotesPath` passes on both separators\n\n'
|
||||||
|
'```go\nreturn filepath.Join(root, name+".md")\n```',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -20,11 +20,14 @@
|
|||||||
// `?tables=1` answers carry a wrapping table, one with a long token and
|
// `?tables=1` answers carry a wrapping table, one with a long token and
|
||||||
// one too wide for a phone (it scrolls sideways);
|
// one too wide for a phone (it scrolls sideways);
|
||||||
// `?timestamps=1` messages carry recorded times over two calendar days.
|
// `?timestamps=1` messages carry recorded times over two calendar days.
|
||||||
|
// `?cli=1` appends a CLI-agent-shaped exchange with several tool calls
|
||||||
|
// (chat_cli_fixture.dart);
|
||||||
// `?followups=1` appends agent follow-ups, auto-continue/switch prompts and
|
// `?followups=1` appends agent follow-ups, auto-continue/switch prompts and
|
||||||
// a scheduled operator message (chat_followup_fixture.dart).
|
// a scheduled operator message (chat_followup_fixture.dart).
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
|
import 'chat_cli_fixture.dart';
|
||||||
import 'chat_followup_fixture.dart';
|
import 'chat_followup_fixture.dart';
|
||||||
|
|
||||||
Map<String, String> _params = const {};
|
Map<String, String> _params = const {};
|
||||||
@@ -279,6 +282,7 @@ JsonMap chatScrollHistory(String sessionId, int index, String cursor) {
|
|||||||
_timed(messages[i], i, messages.length),
|
_timed(messages[i], i, messages.length),
|
||||||
if (_bgwork) ..._backgroundWork(sessionId),
|
if (_bgwork) ..._backgroundWork(sessionId),
|
||||||
if (_params['followups'] == '1') ...chatFollowupMessages(sessionId),
|
if (_params['followups'] == '1') ...chatFollowupMessages(sessionId),
|
||||||
|
if (_params['cli'] == '1') ...chatCliMessages(sessionId),
|
||||||
],
|
],
|
||||||
'next_cursor': _older ? 'older' : '',
|
'next_cursor': _older ? 'older' : '',
|
||||||
'has_more': _older,
|
'has_more': _older,
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
|||||||
import 'package:pipelines_app/features/search/ui/search_bar_controls.dart'
|
import 'package:pipelines_app/features/search/ui/search_bar_controls.dart'
|
||||||
show searchFieldKey;
|
show searchFieldKey;
|
||||||
import 'package:pipelines_app/ui/input/app_search_field.dart';
|
import 'package:pipelines_app/ui/input/app_search_field.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_font.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_controller.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@@ -972,6 +974,7 @@ class _FixtureSink implements WebSocketSink {
|
|||||||
/// kind of popup and a pushed page (tool/capture/window_probe.dart);
|
/// kind of popup and a pushed page (tool/capture/window_probe.dart);
|
||||||
/// `?speech=fake` reads replies aloud with a scripted engine, one word per
|
/// `?speech=fake` reads replies aloud with a scripted engine, one word per
|
||||||
/// `?speechStep=` ms (tool/probe_speech_fixture.dart);
|
/// `?speechStep=` ms (tool/probe_speech_fixture.dart);
|
||||||
|
/// `?design=terminal` chooses that app design (Settings → Design);
|
||||||
/// `?theme=dark` / `?theme=light` pins the platform brightness the app's
|
/// `?theme=dark` / `?theme=light` pins the platform brightness the app's
|
||||||
/// `ThemeMode.system` follows (omitted: the browser's color scheme).
|
/// `ThemeMode.system` follows (omitted: the browser's color scheme).
|
||||||
///
|
///
|
||||||
@@ -1006,6 +1009,14 @@ Future<void> main() async {
|
|||||||
? AppFontController.instance.restore()
|
? AppFontController.instance.restore()
|
||||||
: AppFontController.instance.select(AppFont.fromId(font)),
|
: AppFontController.instance.select(AppFont.fromId(font)),
|
||||||
);
|
);
|
||||||
|
// `?design=terminal` chooses a design as Settings would; otherwise the
|
||||||
|
// stored one.
|
||||||
|
final design = params['design'];
|
||||||
|
unawaited(
|
||||||
|
design == null
|
||||||
|
? AppDesignController.instance.restore()
|
||||||
|
: AppDesignController.instance.select(AppDesign.fromId(design)),
|
||||||
|
);
|
||||||
_fillerRunCount = int.tryParse(params['runs'] ?? '') ?? 0;
|
_fillerRunCount = int.tryParse(params['runs'] ?? '') ?? 0;
|
||||||
_fillerStepCount = int.tryParse(params['steps'] ?? '') ?? 0;
|
_fillerStepCount = int.tryParse(params['steps'] ?? '') ?? 0;
|
||||||
if (params['running'] == '1') {
|
if (params['running'] == '1') {
|
||||||
|
|||||||
Reference in New Issue
Block a user