Merge main (Paper design) into the design perf budget
Paper's theme joins the cached builder; AppDesignTokens and ReadingType compare every new token by value, and Paper's tab indicator and switch outline resolver are kept per colour so a rebuilt Paper theme equals the last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,3 +51,17 @@ which is also registered with `LicenseRegistry`.
|
|||||||
|
|
||||||
The files are unmodified (no subsetting), so the Reserved Font Names stay
|
The files are unmodified (no subsetting), so the Reserved Font Names stay
|
||||||
usable.
|
usable.
|
||||||
|
|
||||||
|
## Paper reading serif
|
||||||
|
|
||||||
|
`source-serif-4/` holds Source Serif 4.005 (github.com/adobe-fonts/source-serif
|
||||||
|
release 4.005R, `source-serif-4.005_Desktop.zip`, `TTF/`): the unmodified
|
||||||
|
Regular, Italic, Semibold and Semibold Italic files of the default (Text)
|
||||||
|
optical size, and `LICENSE.md` from the same archive as `OFL.txt` (SIL Open
|
||||||
|
Font License 1.1, (c) Adobe, Reserved Font Name "Source"). The Paper design
|
||||||
|
sets chat and document text in it (`lib/ui/theme/paper_fonts.dart`). Like the
|
||||||
|
interface fonts it is a plain asset registered with a `FontLoader` when Paper
|
||||||
|
is first chosen, so neither the web build nor the other designs download it.
|
||||||
|
It draws the transcript's `•`, `→` and `✓` itself (no fallback fetch). Its
|
||||||
|
italic has no small-caps feature, so Paper's small-caps labels are set as
|
||||||
|
spaced capitals at a smaller size.
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2014 - 2023 Adobe (http://www.adobe.com/), with Reserved Font Name ‘Source’. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
|
||||||
|
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// Open, Copy and the file actions float over the top of the content: shown
|
/// Open, Copy and the file actions float over the top of the content: shown
|
||||||
/// when the page opens and whenever the content is touched, hidden again after
|
/// when the page opens and whenever the content is touched, hidden again after
|
||||||
@@ -81,10 +82,19 @@ class _ArtifactControlsOverlayState extends State<ArtifactControlsOverlay> {
|
|||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: surface,
|
color: surface,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: AppDesignTokens.of(
|
||||||
boxShadow: const [
|
context,
|
||||||
BoxShadow(color: Color(0x22000000), blurRadius: 6),
|
).corners(BorderRadius.circular(12)),
|
||||||
],
|
// A flat design frames the bar instead of shadowing it.
|
||||||
|
border: switch (AppDesignTokens.of(context).frameSide) {
|
||||||
|
final side? => Border.fromBorderSide(side),
|
||||||
|
null => null,
|
||||||
|
},
|
||||||
|
boxShadow: AppDesignTokens.of(context).flat
|
||||||
|
? null
|
||||||
|
: const [
|
||||||
|
BoxShadow(color: Color(0x22000000), blurRadius: 6),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import '../domain/artifact_url.dart';
|
|||||||
import 'artifact_row_labels.dart';
|
import 'artifact_row_labels.dart';
|
||||||
import 'artifact_thumbnail_image.dart';
|
import 'artifact_thumbnail_image.dart';
|
||||||
import 'artifact_viewer_fetch.dart';
|
import 'artifact_viewer_fetch.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// One artifact in the gallery grid: a thumbnail for an image, otherwise an
|
/// One artifact in the gallery grid: a thumbnail for an image, otherwise an
|
||||||
/// icon for its kind of file, with its name and facts underneath.
|
/// icon for its kind of file, with its name and facts underneath.
|
||||||
@@ -55,7 +56,12 @@ class _ArtifactTileState extends State<ArtifactTile> {
|
|||||||
AspectRatio(
|
AspectRatio(
|
||||||
aspectRatio: 4 / 3,
|
aspectRatio: 4 / 3,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(11)),
|
// Just inside the tile's frame: its corners less the line.
|
||||||
|
borderRadius: BorderRadius.vertical(
|
||||||
|
top: Radius.circular(
|
||||||
|
(AppDesignTokens.of(context).radius ?? 12) - 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
child: ColoredBox(color: surface, child: preview),
|
child: ColoredBox(color: surface, child: preview),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -81,7 +87,9 @@ class _ArtifactTileState extends State<ArtifactTile> {
|
|||||||
final decorated = DecoratedBox(
|
final decorated = DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: border, width: widget.selected ? 2 : 1),
|
border: Border.all(color: border, width: widget.selected ? 2 : 1),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(12)),
|
||||||
),
|
),
|
||||||
child: body,
|
child: body,
|
||||||
);
|
);
|
||||||
@@ -94,7 +102,9 @@ class _ArtifactTileState extends State<ArtifactTile> {
|
|||||||
child: Material(
|
child: Material(
|
||||||
type: MaterialType.transparency,
|
type: MaterialType.transparency,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(12)),
|
||||||
onTap: onSelected == null ? null : tap,
|
onTap: onSelected == null ? null : tap,
|
||||||
child: decorated,
|
child: decorated,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import '../domain/chat_shells.dart';
|
|||||||
import '../domain/chat_task_metadata.dart';
|
import '../domain/chat_task_metadata.dart';
|
||||||
import 'chat_task_metadata_view.dart';
|
import 'chat_task_metadata_view.dart';
|
||||||
import 'chat_task_presentation.dart';
|
import 'chat_task_presentation.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// One scan-friendly task card; only the explicit Details control loads output.
|
/// One scan-friendly task card; only the explicit Details control loads output.
|
||||||
class ChatBackgroundTaskCard extends StatelessWidget {
|
class ChatBackgroundTaskCard extends StatelessWidget {
|
||||||
@@ -32,7 +33,9 @@ class ChatBackgroundTaskCard extends StatelessWidget {
|
|||||||
final status = DecoratedBox(
|
final status = DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.secondaryContainer,
|
color: Theme.of(context).colorScheme.secondaryContainer,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(8)),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||||
@@ -128,7 +131,9 @@ class ChatBackgroundTaskCard extends StatelessWidget {
|
|||||||
DecoratedBox(
|
DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(8)),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import '../../../ui/text/monospace.dart';
|
import '../../../ui/text/monospace.dart';
|
||||||
import '../domain/chat_shells.dart';
|
import '../domain/chat_shells.dart';
|
||||||
import 'chat_task_presentation.dart';
|
import 'chat_task_presentation.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
const _outputVisibleLines = 12;
|
const _outputVisibleLines = 12;
|
||||||
const _outputLineHeight = 1.5;
|
const _outputLineHeight = 1.5;
|
||||||
@@ -54,7 +55,9 @@ class ChatBackgroundTaskOutput extends StatelessWidget {
|
|||||||
DecoratedBox(
|
DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(8)),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/glass_pill.dart';
|
import '../../../ui/adaptive/glass_pill.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
import '../ui/sessions/chat_color_palette.dart';
|
import '../ui/sessions/chat_color_palette.dart';
|
||||||
|
|
||||||
/// How strongly the chat's shade colours the bar's glass pieces over the
|
/// How strongly the chat's shade colours the bar's glass pieces over the
|
||||||
@@ -75,7 +76,10 @@ ChatBarTint? chatBarTintOf(BuildContext context, String? name) {
|
|||||||
if (shade == null) return null;
|
if (shade == null) return null;
|
||||||
return ChatBarTint.from(
|
return ChatBarTint.from(
|
||||||
shade: shade,
|
shade: shade,
|
||||||
raised: Theme.of(context).colorScheme.surfaceContainerHigh,
|
// A design with its own panel fill (Paper's page) tints that instead.
|
||||||
|
raised:
|
||||||
|
AppDesignTokens.of(context).panel ??
|
||||||
|
Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||||
dark: chatColorDarkSurface(context),
|
dark: chatColorDarkSurface(context),
|
||||||
inactive: ChatPaneActivity.inactiveOf(context),
|
inactive: ChatPaneActivity.inactiveOf(context),
|
||||||
solid: MediaQuery.maybeHighContrastOf(context) ?? false,
|
solid: MediaQuery.maybeHighContrastOf(context) ?? false,
|
||||||
|
|||||||
@@ -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 'composer_underline.dart';
|
||||||
import '../../../ui/theme/app_design_tokens.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';
|
||||||
@@ -1003,7 +1004,9 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
|||||||
child: Align(
|
child: Align(
|
||||||
heightFactor: 1,
|
heightFactor: 1,
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(maxWidth: kChatReadingWidth),
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: chatReadingWidthOf(context),
|
||||||
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
key: const Key('chat-composer'),
|
key: const Key('chat-composer'),
|
||||||
padding: EdgeInsetsDirectional.fromSTEB(
|
padding: EdgeInsetsDirectional.fromSTEB(
|
||||||
@@ -1108,7 +1111,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);
|
final tokens = AppDesignTokens.of(context);
|
||||||
|
if (tokens.composer == ComposerStyle.underline) {
|
||||||
|
return ComposerUnderline(
|
||||||
|
focus: _focus,
|
||||||
|
accent: accent,
|
||||||
|
running: widget.running,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final shape = tokens.shape(_pillShape);
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
ComposerFocusRing(
|
ComposerFocusRing(
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import '../ui/transcript/native_disclosure.dart';
|
import '../ui/transcript/native_disclosure.dart';
|
||||||
import 'chat_card_styles.dart';
|
import 'chat_card_styles.dart';
|
||||||
import 'chat_permission_card_model.dart';
|
import 'chat_permission_card_model.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// One recorded permission request as a native card.
|
/// One recorded permission request as a native card.
|
||||||
///
|
///
|
||||||
@@ -61,7 +62,9 @@ class ChatPermissionCard extends StatelessWidget {
|
|||||||
DecoratedBox(
|
DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: chatCardFillColor(context),
|
color: chatCardFillColor(context),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(8)),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
@@ -104,7 +107,9 @@ class ChatPermissionCard extends StatelessWidget {
|
|||||||
return DecoratedBox(
|
return DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: chatCardWarningFillColor(context),
|
color: chatCardWarningFillColor(context),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(8)),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
|
|||||||
@@ -1,13 +1,38 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
import '../ui/transcript/chat_message_bubble.dart';
|
||||||
|
import '../ui/transcript/chat_turn_activity_view.dart';
|
||||||
|
|
||||||
/// The widest the conversation's reading column grows: transcript rows and
|
/// The widest the conversation's reading column grows: transcript rows and
|
||||||
/// the floating composer share it, centred, so a wide window keeps a
|
/// the floating composer share it, centred, so a wide window keeps a
|
||||||
/// comfortable line length instead of stretching messages edge to edge.
|
/// comfortable line length instead of stretching messages edge to edge.
|
||||||
const double kChatReadingWidth = 760;
|
const double kChatReadingWidth = 760;
|
||||||
|
|
||||||
/// The space on each side of the centred reading column in [width].
|
/// The reading column's width under the design at [context]:
|
||||||
double chatReadingInset(double width) =>
|
/// [kChatReadingWidth], or, for a design that sets a reading measure
|
||||||
math.max(0, (width - kChatReadingWidth) / 2);
|
/// ([ReadingType.measure], Paper's ~70ch), that many reading characters plus
|
||||||
|
/// the rows' own side padding (16 each side, then the answer's inset), so
|
||||||
|
/// the text itself is that wide. It follows the operator's text scaling.
|
||||||
|
double chatReadingWidthOf(BuildContext context) {
|
||||||
|
final reading = AppDesignTokens.of(context).reading;
|
||||||
|
final measure = reading.measure;
|
||||||
|
if (measure == null) return kChatReadingWidth;
|
||||||
|
final size = MediaQuery.textScalerOf(
|
||||||
|
context,
|
||||||
|
).scale(chatMessageTextStyle(context)?.fontSize ?? 16);
|
||||||
|
return measure * size * reading.figureWidth +
|
||||||
|
2 * (16 + chatAgentContentInset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The space on each side of the centred reading column in [width], for a
|
||||||
|
/// column [readingWidth] wide.
|
||||||
|
double chatReadingInset(
|
||||||
|
double width, [
|
||||||
|
double readingWidth = kChatReadingWidth,
|
||||||
|
]) => math.max(0, (width - readingWidth) / 2);
|
||||||
|
|
||||||
/// The strip left of the reading column that holds an answer's Copy button,
|
/// The strip left of the reading column that holds an answer's Copy button,
|
||||||
/// outside the answer itself.
|
/// outside the answer itself.
|
||||||
@@ -17,5 +42,9 @@ const double kChatCopyGutterWidth = 48;
|
|||||||
/// [kChatCopyGutterWidth] when the margin left of the centred reading column
|
/// [kChatCopyGutterWidth] when the margin left of the centred reading column
|
||||||
/// fits it, else 0, and Copy stays in the answer's footer (phones, narrow
|
/// fits it, else 0, and Copy stays in the answer's footer (phones, narrow
|
||||||
/// panes).
|
/// panes).
|
||||||
double chatCopyGutter(double width) =>
|
double chatCopyGutter(
|
||||||
chatReadingInset(width) >= kChatCopyGutterWidth ? kChatCopyGutterWidth : 0;
|
double width, [
|
||||||
|
double readingWidth = kChatReadingWidth,
|
||||||
|
]) => chatReadingInset(width, readingWidth) >= kChatCopyGutterWidth
|
||||||
|
? kChatCopyGutterWidth
|
||||||
|
: 0;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../domain/chat_task_metadata.dart';
|
import '../domain/chat_task_metadata.dart';
|
||||||
import '../../../ui/text/monospace.dart';
|
import '../../../ui/text/monospace.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
Color taskSecondary(BuildContext context) =>
|
Color taskSecondary(BuildContext context) =>
|
||||||
Theme.of(context).colorScheme.onSurfaceVariant;
|
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||||
@@ -72,6 +73,9 @@ class ChatTaskSurface extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Card.filled(
|
Widget build(BuildContext context) => Card.filled(
|
||||||
|
// A design with its own panel fill (Paper's page under a hairline)
|
||||||
|
// draws the card in it rather than a filled tone.
|
||||||
|
color: AppDesignTokens.of(context).panel,
|
||||||
margin: EdgeInsets.zero,
|
margin: EdgeInsets.zero,
|
||||||
child: Padding(padding: padding, child: child),
|
child: Padding(padding: padding, child: child),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1356,10 +1356,17 @@ class _ChatThreadViewState extends State<ChatThreadView> with ChatFindHost {
|
|||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
// Rows keep to the centred reading column on a wide
|
// Rows keep to the centred reading column on a wide
|
||||||
// window; the margins beside it still scroll the list.
|
// window; the margins beside it still scroll the list.
|
||||||
final side = chatReadingInset(constraints.maxWidth);
|
final reading = chatReadingWidthOf(context);
|
||||||
|
final side = chatReadingInset(
|
||||||
|
constraints.maxWidth,
|
||||||
|
reading,
|
||||||
|
);
|
||||||
// Answers draw Copy in a strip left of the column; every
|
// Answers draw Copy in a strip left of the column; every
|
||||||
// other row keeps to the column by insetting past it.
|
// other row keeps to the column by insetting past it.
|
||||||
final gutter = chatCopyGutter(constraints.maxWidth);
|
final gutter = chatCopyGutter(
|
||||||
|
constraints.maxWidth,
|
||||||
|
reading,
|
||||||
|
);
|
||||||
final media = MediaQuery.paddingOf(context);
|
final media = MediaQuery.paddingOf(context);
|
||||||
// The date shows once per calendar day, above that day's
|
// The date shows once per calendar day, above that day's
|
||||||
// first row; each row itself shows only its time.
|
// first row; each row itself shows only its time.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import 'chat_claude_accounts_controller.dart';
|
|||||||
import 'chat_composer_controller.dart';
|
import 'chat_composer_controller.dart';
|
||||||
import 'chat_schedule_time.dart';
|
import 'chat_schedule_time.dart';
|
||||||
import 'chat_thread_controller.dart';
|
import 'chat_thread_controller.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// Above the composer while the chat's account is out of quota, as Claude
|
/// Above the composer while the chat's account is out of quota, as Claude
|
||||||
/// Code's own app shows it: "Out of usage credits" (or the refusal's own
|
/// Code's own app shows it: "Out of usage credits" (or the refusal's own
|
||||||
@@ -265,8 +266,16 @@ class _ChatUsageLimitBannerState extends State<ChatUsageLimitBanner> {
|
|||||||
padding: const EdgeInsetsDirectional.only(bottom: 8),
|
padding: const EdgeInsetsDirectional.only(bottom: 8),
|
||||||
child: Material(
|
child: Material(
|
||||||
key: const Key('chat-usage-limit'),
|
key: const Key('chat-usage-limit'),
|
||||||
color: scheme.surfaceContainerHigh,
|
// A flat design's panel: its own fill and corners, framed.
|
||||||
borderRadius: BorderRadius.circular(16),
|
color: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).panelFill(scheme, scheme.surfaceContainerHigh),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(16)),
|
||||||
|
side: AppDesignTokens.of(context).frameSide ?? BorderSide.none,
|
||||||
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 12, 8),
|
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 12, 8),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -356,7 +365,9 @@ class _ChatUsageLimitBannerState extends State<ChatUsageLimitBanner> {
|
|||||||
return MergeSemantics(
|
return MergeSemantics(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
key: const Key('chat-usage-limit-auto-continue'),
|
key: const Key('chat-usage-limit-auto-continue'),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(8)),
|
||||||
onTap: () => toggle(!enabled),
|
onTap: () => toggle(!enabled),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/glass_bar.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
import 'composer_focus_ring.dart';
|
||||||
|
|
||||||
|
/// The composer's writing area under a design whose composer is an
|
||||||
|
/// underline ([ComposerStyle.underline], Paper): the field and its controls
|
||||||
|
/// on the page's own colour (it floats over the transcript, so it is
|
||||||
|
/// opaque) above a hairline rule. While the field has focus the rule
|
||||||
|
/// thickens in [accent]; while a turn runs a thin moving line runs along it
|
||||||
|
/// instead, in place of the pill's travelling highlight.
|
||||||
|
class ComposerUnderline extends StatelessWidget {
|
||||||
|
const ComposerUnderline({
|
||||||
|
super.key,
|
||||||
|
required this.focus,
|
||||||
|
required this.accent,
|
||||||
|
required this.running,
|
||||||
|
required this.child,
|
||||||
|
});
|
||||||
|
|
||||||
|
final FocusNode focus;
|
||||||
|
|
||||||
|
/// The chat's focus colour (the host's primary for a chat with none).
|
||||||
|
final Color accent;
|
||||||
|
|
||||||
|
/// Whether a turn is running.
|
||||||
|
final bool running;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
final tokens = AppDesignTokens.of(context);
|
||||||
|
return Material(
|
||||||
|
key: const Key('chat-composer-underline'),
|
||||||
|
color: tokens.panelFill(scheme, scheme.surface),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(GlassBarMetrics.fieldEdgeGap),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: ComposerFocusRing.ringWidth,
|
||||||
|
child: running
|
||||||
|
? LinearProgressIndicator(
|
||||||
|
key: const Key('chat-composer-running-rule'),
|
||||||
|
minHeight: ComposerFocusRing.ringWidth,
|
||||||
|
color: accent,
|
||||||
|
backgroundColor: scheme.outlineVariant,
|
||||||
|
)
|
||||||
|
: ListenableBuilder(
|
||||||
|
listenable: focus,
|
||||||
|
builder: (context, _) {
|
||||||
|
final focused = focus.hasFocus;
|
||||||
|
return Align(
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: AnimatedContainer(
|
||||||
|
key: const Key('chat-composer-rule'),
|
||||||
|
duration: ComposerFocusRing.duration,
|
||||||
|
curve: Curves.easeOutCubic,
|
||||||
|
height: focused ? ComposerFocusRing.ringWidth : 1,
|
||||||
|
color: focused ? accent : scheme.outline,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,23 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
import '../../domain/chat_colors.dart';
|
import '../../domain/chat_colors.dart';
|
||||||
|
|
||||||
/// The host's own shade for a chat colour name, tuned for the current
|
/// The host's own shade for a chat colour name, tuned for the current
|
||||||
/// brightness: Material's standard swatches (a deeper tone on light surfaces,
|
/// brightness: Material's standard swatches (a deeper tone on light surfaces,
|
||||||
/// a lighter one on dark), so the mark keeps its contrast in both. Null for no
|
/// a lighter one on dark), so the mark keeps its contrast in both, quietened
|
||||||
/// (or an unknown) colour.
|
/// to the design's [AppDesignTokens.chatColorSaturation] (Paper's ink tones).
|
||||||
|
/// Null for no (or an unknown) colour.
|
||||||
Color? chatColorShade(BuildContext context, String? name) {
|
Color? chatColorShade(BuildContext context, String? name) {
|
||||||
|
final shade = _materialShade(context, name);
|
||||||
|
if (shade == null) return null;
|
||||||
|
final saturation = AppDesignTokens.of(context).chatColorSaturation;
|
||||||
|
if (saturation >= 1) return shade;
|
||||||
|
final hsl = HSLColor.fromColor(shade);
|
||||||
|
return hsl.withSaturation(hsl.saturation * saturation).toColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
Color? _materialShade(BuildContext context, String? name) {
|
||||||
if (name == null || !chatColorNames.contains(name)) return null;
|
if (name == null || !chatColorNames.contains(name)) return null;
|
||||||
final dark = Theme.of(context).brightness == Brightness.dark;
|
final dark = Theme.of(context).brightness == Brightness.dark;
|
||||||
final MaterialColor swatch = switch (name) {
|
final MaterialColor swatch = switch (name) {
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// Rounds an attachment thumbnail and draws a subtle hairline around it, so a
|
/// Rounds an attachment thumbnail and draws a subtle hairline around it, so a
|
||||||
/// dark screenshot on a dark page (or a light one on a light page) still reads
|
/// dark screenshot on a dark page (or a light one on a light page) still reads
|
||||||
/// as a separate object. The line sits over the image's edge, in the host's
|
/// as a separate object. The line sits over the image's edge, in the host's
|
||||||
/// own outline role.
|
/// own outline role. A design with its own corners ([AppDesignTokens.radius])
|
||||||
|
/// rounds it with those.
|
||||||
class ChatAttachmentFrame extends StatelessWidget {
|
class ChatAttachmentFrame extends StatelessWidget {
|
||||||
const ChatAttachmentFrame({
|
const ChatAttachmentFrame({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -17,6 +20,7 @@ class ChatAttachmentFrame extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final line = Theme.of(context).colorScheme.outlineVariant;
|
final line = Theme.of(context).colorScheme.outlineVariant;
|
||||||
|
final radius = AppDesignTokens.of(context).corners(this.radius);
|
||||||
return Container(
|
return Container(
|
||||||
key: const Key('chat-attachment-frame'),
|
key: const Key('chat-attachment-frame'),
|
||||||
foregroundDecoration: BoxDecoration(
|
foregroundDecoration: BoxDecoration(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import '../../../../core/api_gateway.dart';
|
import '../../../../core/api_gateway.dart';
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
import '../../data/chat_attachment_images.dart';
|
import '../../data/chat_attachment_images.dart';
|
||||||
import '../../domain/chat_attachment_image.dart';
|
import '../../domain/chat_attachment_image.dart';
|
||||||
import 'chat_attachment_thumbnail.dart';
|
import 'chat_attachment_thumbnail.dart';
|
||||||
@@ -12,7 +13,8 @@ bool chatPartIsThumbnail(JsonMap part) =>
|
|||||||
chatImageSourceOf('${part['uri'] ?? ''}'.trim()) != null;
|
chatImageSourceOf('${part['uri'] ?? ''}'.trim()) != null;
|
||||||
|
|
||||||
/// The operator's attached images above their message, end-aligned like the
|
/// The operator's attached images above their message, end-aligned like the
|
||||||
/// turn itself, wrapping onto further lines on a narrow pane.
|
/// turn itself (start-aligned under a manuscript's block quote), wrapping
|
||||||
|
/// onto further lines on a narrow pane.
|
||||||
class ChatAttachmentGallery extends StatelessWidget {
|
class ChatAttachmentGallery extends StatelessWidget {
|
||||||
const ChatAttachmentGallery({
|
const ChatAttachmentGallery({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -27,7 +29,10 @@ class ChatAttachmentGallery extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Wrap(
|
Widget build(BuildContext context) => Wrap(
|
||||||
key: const Key('chat-attachment-gallery'),
|
key: const Key('chat-attachment-gallery'),
|
||||||
alignment: WrapAlignment.end,
|
alignment:
|
||||||
|
AppDesignTokens.of(context).transcript == TranscriptStyle.manuscript
|
||||||
|
? WrapAlignment.start
|
||||||
|
: WrapAlignment.end,
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'dart:typed_data';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../../../ui/status/app_spinner.dart';
|
import '../../../../ui/status/app_spinner.dart';
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
import '../../data/chat_attachment_images.dart';
|
import '../../data/chat_attachment_images.dart';
|
||||||
import 'chat_attachment_frame.dart';
|
import 'chat_attachment_frame.dart';
|
||||||
@@ -139,7 +140,7 @@ class _ChatAttachmentThumbnailState extends State<ChatAttachmentThumbnail> {
|
|||||||
type: MaterialType.transparency,
|
type: MaterialType.transparency,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
key: const Key('chat-attachment-thumbnail'),
|
key: const Key('chat-attachment-thumbnail'),
|
||||||
borderRadius: _radius,
|
borderRadius: AppDesignTokens.of(context).corners(_radius),
|
||||||
onTap: open,
|
onTap: open,
|
||||||
child: constrained,
|
child: constrained,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ 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 'paper/paper_editorial_note.dart';
|
||||||
|
import 'paper/paper_quote.dart';
|
||||||
import 'terminal/terminal_glyphs.dart';
|
import 'terminal/terminal_glyphs.dart';
|
||||||
|
|
||||||
/// The header words of an automated prompt.
|
/// The header words of an automated prompt.
|
||||||
@@ -67,7 +69,15 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final card = AppDesignTokens.of(context).terminal
|
final transcript = AppDesignTokens.of(context).transcript;
|
||||||
|
final card = transcript == TranscriptStyle.manuscript
|
||||||
|
? PaperEditorialNote(
|
||||||
|
label: label,
|
||||||
|
detail: detail,
|
||||||
|
body: body,
|
||||||
|
hasBody: prompt.body.trim().isNotEmpty,
|
||||||
|
)
|
||||||
|
: transcript == TranscriptStyle.prompt
|
||||||
? _terminalLine(context, label, detail)
|
? _terminalLine(context, label, detail)
|
||||||
: Material(
|
: Material(
|
||||||
key: const Key('chat-automated-prompt'),
|
key: const Key('chat-automated-prompt'),
|
||||||
@@ -98,9 +108,11 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
|||||||
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
|
final footerInset = switch (transcript) {
|
||||||
? 8 + terminalGlyphColumn(context)
|
TranscriptStyle.prompt => 8 + terminalGlyphColumn(context),
|
||||||
: 14.0;
|
TranscriptStyle.manuscript => paperQuoteTextInset,
|
||||||
|
TranscriptStyle.bubbles => 14.0,
|
||||||
|
};
|
||||||
return ChatHoverRegion(
|
return ChatHoverRegion(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|||||||
@@ -57,8 +57,15 @@ class ChatCodeHover {
|
|||||||
onEnter: (_) => _exit?.cancel(),
|
onEnter: (_) => _exit?.cancel(),
|
||||||
onExit: (_) => scheduleHide(token),
|
onExit: (_) => scheduleHide(token),
|
||||||
child: Material(
|
child: Material(
|
||||||
elevation: 3,
|
// A floating piece, shaped as the design's menus are.
|
||||||
borderRadius: BorderRadius.circular(8),
|
elevation: Theme.of(context).popupMenuTheme.elevation ?? 3,
|
||||||
|
shadowColor: Theme.of(context).popupMenuTheme.shadowColor,
|
||||||
|
color: Theme.of(context).popupMenuTheme.color,
|
||||||
|
shape:
|
||||||
|
Theme.of(context).popupMenuTheme.shape ??
|
||||||
|
const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||||
|
),
|
||||||
child: ChatCopyButton(text: text, showLabel: true),
|
child: ChatCopyButton(text: text, showLabel: true),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
|||||||
(part) => TextSpan(text: part),
|
(part) => TextSpan(text: part),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
style: const TextStyle(fontFamily: appMonospaceFamily),
|
style: _codeStyle(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -429,9 +429,14 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Beside a reading face (Paper's serif) the monospace runs large: it
|
||||||
|
// drops to about the serif's x-height.
|
||||||
|
final ambient = DefaultTextStyle.of(context).style.fontSize;
|
||||||
|
final reading = AppDesignTokens.of(context).reading.family != null;
|
||||||
return TextSpan(
|
return TextSpan(
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontFamily: appMonospaceFamily,
|
fontFamily: appMonospaceFamily,
|
||||||
|
fontSize: reading && ambient != null ? ambient * 0.86 : null,
|
||||||
// A span's background is painted over the selection highlight, so an
|
// A span's background is painted over the selection highlight, so an
|
||||||
// opaque fill hid a selected code span; a partial fill keeps code
|
// opaque fill hid a selected code span; a partial fill keeps code
|
||||||
// distinct and lets the selection show through.
|
// distinct and lets the selection show through.
|
||||||
@@ -525,7 +530,25 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
|||||||
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
|
// A terminal prints headings at the text's own size, in bold; the top
|
||||||
// level takes the accent colour.
|
// level takes the accent colour.
|
||||||
if (AppDesignTokens.of(context).terminal) {
|
final transcript = AppDesignTokens.of(context).transcript;
|
||||||
|
// A manuscript sets headings like a book's: the reading face itself,
|
||||||
|
// semibold, a step or two larger, with a tighter line.
|
||||||
|
if (transcript == TranscriptStyle.manuscript) {
|
||||||
|
final ambient = DefaultTextStyle.of(context).style;
|
||||||
|
final size = ambient.fontSize ?? 16;
|
||||||
|
return ambient.copyWith(
|
||||||
|
fontSize:
|
||||||
|
size *
|
||||||
|
switch (level) {
|
||||||
|
1 => 1.4,
|
||||||
|
2 => 1.2,
|
||||||
|
_ => 1.0,
|
||||||
|
},
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
height: 1.3,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (transcript == TranscriptStyle.prompt) {
|
||||||
return _roleStyle(
|
return _roleStyle(
|
||||||
context,
|
context,
|
||||||
text.bodyLarge?.copyWith(
|
text.bodyLarge?.copyWith(
|
||||||
@@ -542,6 +565,21 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
|||||||
return _roleStyle(context, role);
|
return _roleStyle(context, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A code block's text: the bundled monospace face. A design with its
|
||||||
|
/// own reading type (Paper) sets code a step smaller than its prose and on
|
||||||
|
/// a tighter line, as a technical book does.
|
||||||
|
TextStyle _codeStyle(BuildContext context) {
|
||||||
|
const mono = TextStyle(fontFamily: appMonospaceFamily);
|
||||||
|
final reading = AppDesignTokens.of(context).reading;
|
||||||
|
if (reading.family == null) return mono;
|
||||||
|
final size = DefaultTextStyle.of(context).style.fontSize ?? 16;
|
||||||
|
return mono.copyWith(
|
||||||
|
fontSize: size * 0.82,
|
||||||
|
height: 1.45,
|
||||||
|
fontStyle: FontStyle.normal,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Merges a host theme role into the ambient text style.
|
/// Merges a host theme role into the ambient text style.
|
||||||
TextStyle? _roleStyle(BuildContext context, TextStyle? role) => role == null
|
TextStyle? _roleStyle(BuildContext context, TextStyle? role) => role == null
|
||||||
? null
|
? null
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../../ui/theme/app_design_tokens.dart';
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
import '../sessions/chat_color_palette.dart';
|
import '../sessions/chat_color_palette.dart';
|
||||||
|
import 'paper/paper_quote.dart';
|
||||||
import 'terminal/terminal_prompt_line.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
|
||||||
@@ -45,8 +46,13 @@ class ChatUserBubble extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (AppDesignTokens.of(context).terminal) {
|
switch (AppDesignTokens.of(context).transcript) {
|
||||||
return TerminalPromptLine(child: child);
|
case TranscriptStyle.prompt:
|
||||||
|
return TerminalPromptLine(child: child);
|
||||||
|
case TranscriptStyle.manuscript:
|
||||||
|
return PaperQuote(child: child);
|
||||||
|
case TranscriptStyle.bubbles:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// 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.
|
||||||
@@ -75,9 +81,11 @@ class ChatAgentSurface extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The transcript's reading text: the host's large body role, so answers read
|
/// The transcript's reading text: the host's large body role, so answers read
|
||||||
/// at a comfortable size and still follow the operator's text scaling.
|
/// at a comfortable size and still follow the operator's text scaling, in
|
||||||
TextStyle? chatMessageTextStyle(BuildContext context) =>
|
/// the design's reading face and line height (Paper's serif).
|
||||||
Theme.of(context).textTheme.bodyLarge;
|
TextStyle? chatMessageTextStyle(BuildContext context) => AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).reading.apply(Theme.of(context).textTheme.bodyLarge);
|
||||||
|
|
||||||
/// The empty-line gap between two paragraphs of a reply: about one line of
|
/// The empty-line gap between two paragraphs of a reply: about one line of
|
||||||
/// body text at [fontSize] (else the ambient text size), scaled by the
|
/// body text at [fontSize] (else the ambient text size), scaled by the
|
||||||
|
|||||||
@@ -18,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 'paper/paper_quote.dart';
|
||||||
import 'terminal/terminal_glyphs.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';
|
||||||
@@ -79,11 +80,12 @@ 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
|
// A terminal or manuscript transcript reads top to bottom: the
|
||||||
// prompt line starts at the same edge as the answer and spans its
|
// operator's prompt line or block quote starts at the same edge as the
|
||||||
// column.
|
// answer and spans its column.
|
||||||
final terminal = AppDesignTokens.of(context).terminal;
|
final transcript = AppDesignTokens.of(context).transcript;
|
||||||
final trailingUser = user && !automated && !terminal;
|
final trailingUser =
|
||||||
|
user && !automated && transcript == TranscriptStyle.bubbles;
|
||||||
// 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
|
||||||
@@ -101,7 +103,11 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
explicitChildNodes: true,
|
explicitChildNodes: true,
|
||||||
label: '$role message',
|
label: '$role message',
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
// A manuscript leaves a little more air between turns, as a page
|
||||||
|
// spaces its paragraphs, since no bubble sets them apart.
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
vertical: transcript == TranscriptStyle.manuscript ? 12 : 6,
|
||||||
|
),
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) => Align(
|
builder: (context, constraints) => Align(
|
||||||
alignment: trailingUser
|
alignment: trailingUser
|
||||||
@@ -119,7 +125,7 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
child: automated
|
child: automated
|
||||||
? _automatedTurn(origin, content)
|
? _automatedTurn(origin, content)
|
||||||
: user
|
: user
|
||||||
? _userTurn(content, body, origin, terminal: terminal)
|
? _userTurn(content, body, origin, transcript: transcript)
|
||||||
: _agentRow(
|
: _agentRow(
|
||||||
context,
|
context,
|
||||||
content,
|
content,
|
||||||
@@ -147,8 +153,9 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
List<Widget> content,
|
List<Widget> content,
|
||||||
Widget body,
|
Widget body,
|
||||||
ChatPromptOrigin origin, {
|
ChatPromptOrigin origin, {
|
||||||
required bool terminal,
|
required TranscriptStyle transcript,
|
||||||
}) {
|
}) {
|
||||||
|
final stacked = transcript != TranscriptStyle.bubbles;
|
||||||
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,
|
||||||
@@ -163,14 +170,21 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: terminal
|
crossAxisAlignment: stacked
|
||||||
? CrossAxisAlignment.stretch
|
? CrossAxisAlignment.stretch
|
||||||
: CrossAxisAlignment.end,
|
: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (thumbnails.isNotEmpty)
|
if (thumbnails.isNotEmpty)
|
||||||
ChatAttachmentGallery(
|
Padding(
|
||||||
parts: thumbnails,
|
padding: EdgeInsetsDirectional.only(
|
||||||
images: images ?? _inlineImages,
|
start: transcript == TranscriptStyle.manuscript
|
||||||
|
? paperQuoteTextInset
|
||||||
|
: 0,
|
||||||
|
),
|
||||||
|
child: ChatAttachmentGallery(
|
||||||
|
parts: thumbnails,
|
||||||
|
images: images ?? _inlineImages,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (thumbnails.isNotEmpty && content.isNotEmpty)
|
if (thumbnails.isNotEmpty && content.isNotEmpty)
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
@@ -179,16 +193,24 @@ class ChatMessageView extends StatelessWidget {
|
|||||||
// The delivery line and the time share one line under the bubble.
|
// The delivery line and the time share one line under the bubble.
|
||||||
if (footer.isNotEmpty || hasTimestamp || marked) ...[
|
if (footer.isNotEmpty || hasTimestamp || marked) ...[
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
Wrap(
|
Padding(
|
||||||
key: const Key('chat-message-footer'),
|
// Under a manuscript the line starts at the quoted text.
|
||||||
spacing: 8,
|
padding: EdgeInsetsDirectional.only(
|
||||||
alignment: terminal ? WrapAlignment.start : WrapAlignment.end,
|
start: transcript == TranscriptStyle.manuscript
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
? paperQuoteTextInset
|
||||||
children: [
|
: 0,
|
||||||
...footer,
|
),
|
||||||
if (marked) const ChatScheduledMark(),
|
child: Wrap(
|
||||||
if (hasTimestamp) timestamp,
|
key: const Key('chat-message-footer'),
|
||||||
],
|
spacing: 8,
|
||||||
|
alignment: stacked ? WrapAlignment.start : WrapAlignment.end,
|
||||||
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
|
children: [
|
||||||
|
...footer,
|
||||||
|
if (marked) const ChatScheduledMark(),
|
||||||
|
if (hasTimestamp) timestamp,
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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 'paper/paper_activity_note.dart';
|
||||||
import 'terminal/terminal_activity_rows.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.
|
||||||
@@ -122,14 +123,25 @@ 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) {
|
switch (AppDesignTokens.of(context).transcript) {
|
||||||
return TerminalActivityRows(
|
case TranscriptStyle.prompt:
|
||||||
data: data,
|
return TerminalActivityRows(
|
||||||
status: label,
|
data: data,
|
||||||
streaming: widget.streaming,
|
status: label,
|
||||||
seconds: seconds,
|
streaming: widget.streaming,
|
||||||
onOpen: _open,
|
seconds: seconds,
|
||||||
);
|
onOpen: _open,
|
||||||
|
);
|
||||||
|
case TranscriptStyle.manuscript:
|
||||||
|
return PaperActivityNote(
|
||||||
|
data: data,
|
||||||
|
status: label,
|
||||||
|
streaming: widget.streaming,
|
||||||
|
failed: data.failed,
|
||||||
|
onOpen: _open,
|
||||||
|
);
|
||||||
|
case TranscriptStyle.bubbles:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// 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);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../../ui/adaptive/app_popups.dart';
|
import '../../../../ui/adaptive/app_popups.dart';
|
||||||
import 'chat_turn_activity_view.dart';
|
import 'chat_turn_activity_view.dart';
|
||||||
|
import '../../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// The quiet chip under an agent turn (its tools, its permissions) and the
|
/// The quiet chip under an agent turn (its tools, its permissions) and the
|
||||||
/// native sheet it opens.
|
/// native sheet it opens.
|
||||||
@@ -103,7 +104,9 @@ class _ChatTurnChipState extends State<ChatTurnChip> {
|
|||||||
padding: const EdgeInsets.only(top: 2),
|
padding: const EdgeInsets.only(top: 2),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
key: widget.chipKey,
|
key: widget.chipKey,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(8)),
|
||||||
onTap: _show,
|
onTap: _show,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../../ui/adaptive/platform.dart';
|
||||||
|
import '../../../domain/chat_tool_calls.dart';
|
||||||
|
import '../../../domain/chat_turn_activity.dart';
|
||||||
|
import '../chat_message_bubble.dart';
|
||||||
|
import '../chat_response_pending.dart';
|
||||||
|
|
||||||
|
/// How many distinct tool names a marginal note lists before "and more".
|
||||||
|
const int paperActivityNamedTools = 3;
|
||||||
|
|
||||||
|
/// A turn's activity under a manuscript transcript: a small muted note in
|
||||||
|
/// the margin of the answer, as a book prints a side note. A short rule,
|
||||||
|
/// then the turn's status in small italic reading type and, once settled,
|
||||||
|
/// the tools it used ("Used 6 tools — Bash, Read, Edit"). The note is one
|
||||||
|
/// button that opens the activity details, like the Default design's line.
|
||||||
|
class PaperActivityNote extends StatelessWidget {
|
||||||
|
const PaperActivityNote({
|
||||||
|
super.key,
|
||||||
|
required this.data,
|
||||||
|
required this.status,
|
||||||
|
required this.streaming,
|
||||||
|
required this.failed,
|
||||||
|
required this.onOpen,
|
||||||
|
});
|
||||||
|
|
||||||
|
final ChatTurnActivityData data;
|
||||||
|
|
||||||
|
/// The turn's one-line status (with its running seconds while streaming).
|
||||||
|
final String status;
|
||||||
|
final bool streaming;
|
||||||
|
final bool failed;
|
||||||
|
final VoidCallback onOpen;
|
||||||
|
|
||||||
|
/// The note's words: the status, then the distinct tools it used.
|
||||||
|
static String noteText(ChatTurnActivityData data, String status) {
|
||||||
|
final names = <String>[];
|
||||||
|
for (final call in data.tools) {
|
||||||
|
final name = chatToolLabel(call);
|
||||||
|
if (!names.contains(name)) names.add(name);
|
||||||
|
}
|
||||||
|
if (names.isEmpty) return status;
|
||||||
|
final shown = names.take(paperActivityNamedTools).join(', ');
|
||||||
|
final more = names.length > paperActivityNamedTools ? ', …' : '';
|
||||||
|
return '$status — $shown$more';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
final color = failed && !streaming ? scheme.error : scheme.onSurfaceVariant;
|
||||||
|
final reading = chatMessageTextStyle(context);
|
||||||
|
final style = reading?.copyWith(
|
||||||
|
fontSize: (reading.fontSize ?? 16) * 0.82,
|
||||||
|
fontStyle: FontStyle.italic,
|
||||||
|
height: 1.3,
|
||||||
|
color: color,
|
||||||
|
);
|
||||||
|
final compact = prefersCompactHitTargets(context);
|
||||||
|
final text = streaming ? status : noteText(data, status);
|
||||||
|
return Semantics(
|
||||||
|
button: true,
|
||||||
|
label: '$status, expand for details',
|
||||||
|
excludeSemantics: true,
|
||||||
|
onTap: onOpen,
|
||||||
|
child: Align(
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
widthFactor: 1,
|
||||||
|
child: InkWell(
|
||||||
|
key: const Key('chat-turn-activity'),
|
||||||
|
onTap: onOpen,
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(minHeight: compact ? 32 : 40),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
child: Row(
|
||||||
|
key: const Key('chat-paper-activity-note'),
|
||||||
|
mainAxisSize: compact ? MainAxisSize.min : MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
if (streaming)
|
||||||
|
ExcludeSemantics(
|
||||||
|
child: DefaultTextStyle.merge(
|
||||||
|
style: TextStyle(color: scheme.primary),
|
||||||
|
child: const ChatResponsePending(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
// The margin rule a side note hangs from.
|
||||||
|
Container(width: 16, height: 1, color: scheme.outline),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: style,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../chat_message_bubble.dart';
|
||||||
|
import 'paper_quote.dart';
|
||||||
|
|
||||||
|
/// A prompt the agent or the server sent (a follow-up, an auto-continue)
|
||||||
|
/// under a manuscript transcript: not a card but a small italic editorial
|
||||||
|
/// note, as an editor's aside is set in a book. A spaced small-caps header
|
||||||
|
/// names what sent it, then the prompt in the muted italic reading face, set
|
||||||
|
/// in from the page like the operator's quoted words.
|
||||||
|
class PaperEditorialNote extends StatelessWidget {
|
||||||
|
const PaperEditorialNote({
|
||||||
|
super.key,
|
||||||
|
required this.label,
|
||||||
|
required this.detail,
|
||||||
|
required this.body,
|
||||||
|
required this.hasBody,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// What sent the prompt ("Follow-up from agent").
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
/// When or why it was sent, or null.
|
||||||
|
final String? detail;
|
||||||
|
final Widget body;
|
||||||
|
final bool hasBody;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final muted = theme.colorScheme.onSurfaceVariant;
|
||||||
|
final caps = paperSmallCapsStyle(context);
|
||||||
|
final reading = chatMessageTextStyle(context);
|
||||||
|
final note = reading?.copyWith(
|
||||||
|
fontSize: (reading.fontSize ?? 16) * 0.92,
|
||||||
|
fontStyle: FontStyle.italic,
|
||||||
|
height: 1.45,
|
||||||
|
color: muted,
|
||||||
|
);
|
||||||
|
final header = SelectionContainer.disabled(
|
||||||
|
child: Text.rich(
|
||||||
|
key: const Key('chat-automated-prompt-header'),
|
||||||
|
TextSpan(
|
||||||
|
children: [
|
||||||
|
TextSpan(text: label.toUpperCase(), style: caps),
|
||||||
|
if (detail != null)
|
||||||
|
TextSpan(
|
||||||
|
text: ' · $detail',
|
||||||
|
style: caps?.copyWith(letterSpacing: 0.2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return Material(
|
||||||
|
key: const Key('chat-automated-prompt'),
|
||||||
|
type: MaterialType.transparency,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(
|
||||||
|
start: paperQuoteTextInset,
|
||||||
|
top: 2,
|
||||||
|
bottom: 2,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
header,
|
||||||
|
if (hasBody) ...[
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
DefaultTextStyle.merge(style: note, child: body),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../sessions/chat_color_palette.dart';
|
||||||
|
import '../chat_message_bubble.dart';
|
||||||
|
|
||||||
|
/// How far a manuscript's block quote (the operator's turn) sits in from the
|
||||||
|
/// answer's text edge, so the reader sees whose words they are by indent.
|
||||||
|
const double paperQuoteIndent = 16;
|
||||||
|
|
||||||
|
/// The width of the quote's rule.
|
||||||
|
const double paperQuoteRule = 2;
|
||||||
|
|
||||||
|
/// The gap between the rule and the quoted text.
|
||||||
|
const double paperQuoteGap = 12;
|
||||||
|
|
||||||
|
/// Where the quoted text starts, from the row's edge: the footer under the
|
||||||
|
/// quote (its delivery line and time) starts here too.
|
||||||
|
const double paperQuoteTextInset =
|
||||||
|
paperQuoteIndent + paperQuoteRule + paperQuoteGap;
|
||||||
|
|
||||||
|
/// The words of the small-caps label above the operator's turn.
|
||||||
|
const String paperQuoteLabel = 'You';
|
||||||
|
|
||||||
|
/// The style of a manuscript's small editorial labels: italic capitals set
|
||||||
|
/// small and spaced, the way a book sets small caps (the serif's italic has
|
||||||
|
/// no small-caps feature, so they are spaced capitals), in the muted ink.
|
||||||
|
TextStyle? paperSmallCapsStyle(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final reading = chatMessageTextStyle(context);
|
||||||
|
final size = (reading?.fontSize ?? 16) * 0.72;
|
||||||
|
return reading?.copyWith(
|
||||||
|
fontSize: size,
|
||||||
|
fontStyle: FontStyle.italic,
|
||||||
|
letterSpacing: size * 0.12,
|
||||||
|
height: 1.2,
|
||||||
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The operator's turn under a manuscript transcript: an indented block
|
||||||
|
/// quote with a thin rule in the chat's colour (the outline for a chat with
|
||||||
|
/// none) and a small-caps "You" above it, instead of a bubble. It spans the
|
||||||
|
/// reading column, like the answer below it.
|
||||||
|
class PaperQuote extends StatelessWidget {
|
||||||
|
const PaperQuote({super.key, required this.child});
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
final shade = chatColorShade(context, ChatBubbleColor.of(context));
|
||||||
|
return Material(
|
||||||
|
key: const Key('chat-paper-quote'),
|
||||||
|
type: MaterialType.transparency,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(start: paperQuoteIndent),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
ExcludeSemantics(
|
||||||
|
child: SelectionContainer.disabled(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(
|
||||||
|
start: paperQuoteRule + paperQuoteGap,
|
||||||
|
bottom: 4,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
paperQuoteLabel.toUpperCase(),
|
||||||
|
key: const Key('chat-paper-quote-label'),
|
||||||
|
style: paperSmallCapsStyle(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: BorderDirectional(
|
||||||
|
start: BorderSide(
|
||||||
|
color: shade ?? scheme.outline,
|
||||||
|
width: paperQuoteRule,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(
|
||||||
|
start: paperQuoteGap,
|
||||||
|
top: 2,
|
||||||
|
bottom: 2,
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ class EdgeHighlightPainter extends CustomPainter {
|
|||||||
required this.endpoints,
|
required this.endpoints,
|
||||||
required this.color,
|
required this.color,
|
||||||
required this.strokeWidth,
|
required this.strokeWidth,
|
||||||
|
this.glowRadius = 14,
|
||||||
});
|
});
|
||||||
|
|
||||||
final EdgeRoute route;
|
final EdgeRoute route;
|
||||||
@@ -26,13 +27,17 @@ class EdgeHighlightPainter extends CustomPainter {
|
|||||||
/// The highlighted stroke; the halo is wider.
|
/// The highlighted stroke; the halo is wider.
|
||||||
final double strokeWidth;
|
final double strokeWidth;
|
||||||
|
|
||||||
|
/// The corner radius of the glow around each endpoint stage: the stage
|
||||||
|
/// card's own corners plus the glow's spread.
|
||||||
|
final double glowRadius;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
final glow = Paint()..color = color.withValues(alpha: 0.18);
|
final glow = Paint()..color = color.withValues(alpha: 0.18);
|
||||||
for (final box in endpoints) {
|
for (final box in endpoints) {
|
||||||
final rect = Rect.fromLTWH(box.x, box.y, box.width, box.height);
|
final rect = Rect.fromLTWH(box.x, box.y, box.width, box.height);
|
||||||
canvas.drawRRect(
|
canvas.drawRRect(
|
||||||
RRect.fromRectAndRadius(rect.inflate(5), const Radius.circular(14)),
|
RRect.fromRectAndRadius(rect.inflate(5), Radius.circular(glowRadius)),
|
||||||
glow,
|
glow,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -79,6 +84,7 @@ class EdgeHighlightPainter extends CustomPainter {
|
|||||||
oldDelegate.route != route ||
|
oldDelegate.route != route ||
|
||||||
oldDelegate.color != color ||
|
oldDelegate.color != color ||
|
||||||
oldDelegate.strokeWidth != strokeWidth ||
|
oldDelegate.strokeWidth != strokeWidth ||
|
||||||
|
oldDelegate.glowRadius != glowRadius ||
|
||||||
oldDelegate.endpoints.length != endpoints.length ||
|
oldDelegate.endpoints.length != endpoints.length ||
|
||||||
!_sameBoxes(oldDelegate.endpoints, endpoints);
|
!_sameBoxes(oldDelegate.endpoints, endpoints);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/gestures.dart' show PointerDeviceKind;
|
import 'package:flutter/gestures.dart' show PointerDeviceKind;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
import '../domain/graph_protocol.dart';
|
import '../domain/graph_protocol.dart';
|
||||||
import '../layout/layout_models.dart';
|
import '../layout/layout_models.dart';
|
||||||
import '../painting/edge_highlight_layer.dart';
|
import '../painting/edge_highlight_layer.dart';
|
||||||
@@ -160,6 +161,7 @@ class _GraphEdgeHoverState extends State<GraphEdgeHover> {
|
|||||||
final size = overlay.size;
|
final size = overlay.size;
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final colors = theme.colorScheme;
|
final colors = theme.colorScheme;
|
||||||
|
final tokens = AppDesignTokens.of(context);
|
||||||
const gap = 14.0;
|
const gap = 14.0;
|
||||||
final flipX = local.dx > size.width * 0.6;
|
final flipX = local.dx > size.width * 0.6;
|
||||||
final flipY = local.dy > size.height * 0.75;
|
final flipY = local.dy > size.height * 0.75;
|
||||||
@@ -174,8 +176,10 @@ class _GraphEdgeHoverState extends State<GraphEdgeHover> {
|
|||||||
child: Material(
|
child: Material(
|
||||||
key: const Key('graph-edge-tooltip'),
|
key: const Key('graph-edge-tooltip'),
|
||||||
color: colors.inverseSurface,
|
color: colors.inverseSurface,
|
||||||
elevation: 2,
|
// A floating piece: the design's menu elevation and corners.
|
||||||
borderRadius: BorderRadius.circular(6),
|
elevation: theme.popupMenuTheme.elevation ?? 2,
|
||||||
|
shadowColor: theme.popupMenuTheme.shadowColor,
|
||||||
|
borderRadius: tokens.corners(BorderRadius.circular(6)),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -216,6 +220,12 @@ Widget graphEdgeHighlight({
|
|||||||
endpoints: endpoints,
|
endpoints: endpoints,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
strokeWidth: edgeWidth * 2.5,
|
strokeWidth: edgeWidth * 2.5,
|
||||||
|
// A design's own corners (the stage cards take them) plus the
|
||||||
|
// glow's 5px spread; the Default keeps its rounder glow.
|
||||||
|
glowRadius: switch (AppDesignTokens.of(context).radius) {
|
||||||
|
final radius? => radius + 5,
|
||||||
|
null => 14,
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -270,7 +280,9 @@ Widget graphEdgeLabel({
|
|||||||
: DecoratedBox(
|
: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: colors.primaryContainer,
|
color: colors.primaryContainer,
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(4)),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(color: colors.primaryContainer, spreadRadius: 2),
|
BoxShadow(color: colors.primaryContainer, spreadRadius: 2),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../domain/run_outcome_line.dart';
|
import '../domain/run_outcome_line.dart';
|
||||||
|
import '../../../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// The run Summary's prominent "Why it failed" note: a failed run's recorded
|
/// The run Summary's prominent "Why it failed" note: a failed run's recorded
|
||||||
/// failure reason (else its diagnostic), selectable, at the top of the
|
/// failure reason (else its diagnostic), selectable, at the top of the
|
||||||
@@ -29,7 +30,9 @@ class RunFailureBanner extends StatelessWidget {
|
|||||||
decoration: ShapeDecoration(
|
decoration: ShapeDecoration(
|
||||||
color: scheme.errorContainer,
|
color: scheme.errorContainer,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(BorderRadius.circular(12)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|||||||
@@ -10,8 +10,9 @@ import 'settings_theme.dart';
|
|||||||
const designSectionTitle = 'Design';
|
const designSectionTitle = 'Design';
|
||||||
const designSectionFooter =
|
const designSectionFooter =
|
||||||
'Saved on this device only and applied at once. Light and dark follow '
|
'Saved on this device only and applied at once. Light and dark follow '
|
||||||
'the system under every design; Terminal uses its monospace font '
|
'the system under every design. Terminal uses its monospace font '
|
||||||
'instead of the Font choice below.';
|
'instead of the Font choice below; Paper keeps that font for the '
|
||||||
|
'interface and sets reading text in its own serif.';
|
||||||
const designSaveFailedText =
|
const designSaveFailedText =
|
||||||
'Not saved on this device; it applies until reload.';
|
'Not saved on this device; it applies until reload.';
|
||||||
|
|
||||||
@@ -53,9 +54,60 @@ class SettingsDesignSection extends StatelessWidget {
|
|||||||
value: design,
|
value: design,
|
||||||
title: Text(design.label),
|
title: Text(design.label),
|
||||||
subtitle: Text(design.description),
|
subtitle: Text(design.description),
|
||||||
|
secondary: DesignSwatchPreview(
|
||||||
|
swatch: design.swatch(Theme.of(context).brightness),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A design's small preview in the picker: its page with a line of its ink
|
||||||
|
/// and a dot of its accent, framed by a hairline.
|
||||||
|
class DesignSwatchPreview extends StatelessWidget {
|
||||||
|
const DesignSwatchPreview({super.key, required this.swatch});
|
||||||
|
|
||||||
|
final DesignSwatch swatch;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => ExcludeSemantics(
|
||||||
|
child: Container(
|
||||||
|
width: 48,
|
||||||
|
height: 32,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: swatch.page,
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(6)),
|
||||||
|
border: Border.all(color: Theme.of(context).colorScheme.outlineVariant),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(height: 2, color: swatch.ink),
|
||||||
|
FractionallySizedBox(
|
||||||
|
widthFactor: 0.6,
|
||||||
|
child: Container(height: 2, color: swatch.ink),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Container(
|
||||||
|
width: 6,
|
||||||
|
height: 6,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: swatch.accent,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,9 +52,10 @@ class SettingsGroup extends StatelessWidget {
|
|||||||
if (children.isNotEmpty)
|
if (children.isNotEmpty)
|
||||||
Material(
|
Material(
|
||||||
type: MaterialType.card,
|
type: MaterialType.card,
|
||||||
color: tokens.flat
|
color: tokens.panelFill(
|
||||||
? theme.colorScheme.surfaceContainerLow
|
theme.colorScheme,
|
||||||
: theme.colorScheme.surfaceContainer,
|
theme.colorScheme.surfaceContainer,
|
||||||
|
),
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: tokens.corners(
|
borderRadius: tokens.corners(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../ui/theme/app_design_tokens.dart';
|
||||||
import 'settings_section.dart';
|
import 'settings_section.dart';
|
||||||
|
|
||||||
/// The Settings search field: filters the sections as the operator types.
|
/// The Settings search field: filters the sections as the operator types.
|
||||||
@@ -35,7 +36,11 @@ class SettingsSearchField extends StatelessWidget {
|
|||||||
onChanged('');
|
onChanged('');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
border: const OutlineInputBorder(),
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: AppDesignTokens.of(
|
||||||
|
context,
|
||||||
|
).corners(const BorderRadius.all(Radius.circular(4))),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../features/attention/domain/attention_models.dart';
|
import '../features/attention/domain/attention_models.dart';
|
||||||
import '../ui/motion/motion.dart';
|
import '../ui/motion/motion.dart';
|
||||||
|
import '../ui/theme/app_design_tokens.dart';
|
||||||
|
|
||||||
/// A generic attention count, separate from the Runs tab's status counts.
|
/// A generic attention count, separate from the Runs tab's status counts.
|
||||||
///
|
///
|
||||||
@@ -116,7 +117,9 @@ class ActivityBadge extends StatelessWidget {
|
|||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: ShapeDecoration(
|
decoration: ShapeDecoration(
|
||||||
color: color,
|
color: color,
|
||||||
shape: const StadiumBorder(),
|
// A design's own corners (Terminal's square badge); the
|
||||||
|
// Default keeps the round count.
|
||||||
|
shape: AppDesignTokens.of(context).shape(const StadiumBorder()),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
|
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
|
||||||
|
|||||||
@@ -169,12 +169,21 @@ class _AnchoredMenuRoute<T> extends PopupRoute<T> {
|
|||||||
label: label,
|
label: label,
|
||||||
child: Material(
|
child: Material(
|
||||||
key: const ValueKey('app-choice-menu'),
|
key: const ValueKey('app-choice-menu'),
|
||||||
elevation: 3,
|
// A design's menus (Terminal's flat frame, Paper's whisper
|
||||||
|
// of shadow) shape this panel too.
|
||||||
|
elevation: Theme.of(context).popupMenuTheme.elevation ?? 3,
|
||||||
|
shadowColor: Theme.of(context).popupMenuTheme.shadowColor,
|
||||||
// A step above a window's own surface, so the panel reads
|
// A step above a window's own surface, so the panel reads
|
||||||
// as raised when it opens over one.
|
// as raised when it opens over one.
|
||||||
color: colors.surfaceContainerHigh,
|
color:
|
||||||
|
Theme.of(context).popupMenuTheme.color ??
|
||||||
|
colors.surfaceContainerHigh,
|
||||||
surfaceTintColor: Colors.transparent,
|
surfaceTintColor: Colors.transparent,
|
||||||
borderRadius: BorderRadius.circular(12),
|
shape:
|
||||||
|
Theme.of(context).popupMenuTheme.shape ??
|
||||||
|
const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||||
|
),
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class GlassPill extends StatelessWidget {
|
|||||||
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 = flat ? scheme.surfaceContainerLow : scheme.surfaceContainerHigh;
|
base = tokens.panelFill(scheme, scheme.surfaceContainerHigh);
|
||||||
edge = flat ? tokens.frame ?? scheme.outline : 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);
|
||||||
|
|||||||
@@ -136,6 +136,15 @@ class AppListRow extends StatelessWidget {
|
|||||||
alpha: Theme.of(context).brightness == Brightness.dark ? 0.12 : 0.07,
|
alpha: Theme.of(context).brightness == Brightness.dark ? 0.12 : 0.07,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// How strongly a flat design's open row washes its bar colour over the
|
||||||
|
/// page: Terminal's framed row strongly, Paper's unframed wash a little
|
||||||
|
/// lighter (its frameless row still stands well apart from tinted rows).
|
||||||
|
static double _washAlpha(SelectedRowStyle style, bool dark) =>
|
||||||
|
switch (style) {
|
||||||
|
SelectedRowStyle.washed => dark ? .22 : .15,
|
||||||
|
_ => dark ? .26 : .2,
|
||||||
|
};
|
||||||
|
|
||||||
/// The open row's fill is Material `secondaryContainer`.
|
/// The open row's fill is Material `secondaryContainer`.
|
||||||
static Color selectedColor(BuildContext context) =>
|
static Color selectedColor(BuildContext context) =>
|
||||||
Theme.of(context).colorScheme.secondaryContainer;
|
Theme.of(context).colorScheme.secondaryContainer;
|
||||||
@@ -188,22 +197,26 @@ class AppListRow extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
final tint = tintFor(context, accent);
|
final tint = tintFor(context, accent);
|
||||||
// A terminal design's flat surfaces make a tonal fill too faint
|
// How the design marks the open row: Material's tonal fill, or
|
||||||
// beside tinted rows: the open row takes its bar colour, stronger,
|
// (on a flat design, where a tonal fill is too faint beside tinted
|
||||||
// and a hairline frame (below).
|
// rows) its bar colour washed over the page, stronger, with a
|
||||||
final framed = selected && AppDesignTokens.of(context).terminal;
|
// hairline frame in it when the design frames it (below).
|
||||||
|
final rowStyle = AppDesignTokens.of(context).selectedRow;
|
||||||
|
final washed = selected && rowStyle != SelectedRowStyle.tonal;
|
||||||
|
final framed = selected && rowStyle == SelectedRowStyle.framed;
|
||||||
final frameColor =
|
final frameColor =
|
||||||
selectionAccent ??
|
selectionAccent ??
|
||||||
accent ??
|
accent ??
|
||||||
Theme.of(context).colorScheme.primary;
|
Theme.of(context).colorScheme.primary;
|
||||||
final surface = Material(
|
final surface = Material(
|
||||||
key: appListRowSurfaceKey,
|
key: appListRowSurfaceKey,
|
||||||
color: framed
|
color: washed
|
||||||
? Color.alphaBlend(
|
? Color.alphaBlend(
|
||||||
frameColor.withValues(
|
frameColor.withValues(
|
||||||
alpha: Theme.of(context).brightness == Brightness.dark
|
alpha: _washAlpha(
|
||||||
? .26
|
rowStyle,
|
||||||
: .2,
|
Theme.of(context).brightness == Brightness.dark,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Theme.of(context).scaffoldBackgroundColor,
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,20 +2,33 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'app_design_tokens.dart';
|
import 'app_design_tokens.dart';
|
||||||
import 'app_theme.dart';
|
import 'app_theme.dart';
|
||||||
|
import 'paper_theme.dart';
|
||||||
import 'terminal_theme.dart';
|
import 'terminal_theme.dart';
|
||||||
|
|
||||||
|
/// Every theme a design has built, by design, brightness and interface font.
|
||||||
|
/// ThemeData is immutable; a handful of fonts and two brightnesses per design
|
||||||
|
/// keep this small.
|
||||||
|
final Map<(AppDesign, Brightness, String?), ThemeData> _themes = {};
|
||||||
|
|
||||||
/// An app-wide design: how every surface is shaped, typed and coloured, not
|
/// 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
|
/// only a colour. Each design builds a light and a dark [ThemeData] carrying
|
||||||
/// its [AppDesignTokens], so widgets that draw design-specific shapes read the
|
/// its [AppDesignTokens], so widgets that draw design-specific shapes read the
|
||||||
/// tokens instead of hard-coding one look.
|
/// tokens instead of hard-coding one look.
|
||||||
///
|
///
|
||||||
/// Adding a design means one more value here and its theme builder; the
|
/// Adding a design:
|
||||||
/// Settings picker lists [AppDesign.values].
|
/// 1. add a value here with a stable [id], a [label] and a one-line
|
||||||
/// Every theme a design has built, by design, brightness and interface font.
|
/// [description] (the Settings picker lists [AppDesign.values]);
|
||||||
/// ThemeData is immutable; a handful of fonts and two brightnesses per design
|
/// 2. write its theme builder (`<name>_theme.dart` beside this file, with a
|
||||||
/// keep this small.
|
/// palette and, when it needs one, its own typography) and return it from
|
||||||
final Map<(AppDesign, Brightness, String?), ThemeData> _themes = {};
|
/// [build] ([light] and [dark] cache it); keep the theme value-equal when
|
||||||
|
/// rebuilt (no fresh `Decoration`s or extensions without `==`);
|
||||||
|
/// 3. give the theme an [AppDesignTokens] extension: set only the tokens it
|
||||||
|
/// changes (corners, flat surfaces, frame, panel fill, transcript,
|
||||||
|
/// composer and selected-row styles, reading type); every token defaults
|
||||||
|
/// to the Default look;
|
||||||
|
/// 4. give it a [swatch] for the picker and say whether it [usesInterfaceFont].
|
||||||
|
/// 5. run the design budget (app/tool/perf/README.md) and keep it passing.
|
||||||
|
/// Widgets read the tokens, so most surfaces follow without per-widget code.
|
||||||
enum AppDesign {
|
enum AppDesign {
|
||||||
/// The app's own Material look.
|
/// The app's own Material look.
|
||||||
standard('default', 'Default', 'The app’s Material look.'),
|
standard('default', 'Default', 'The app’s Material look.'),
|
||||||
@@ -26,6 +39,14 @@ enum AppDesign {
|
|||||||
'terminal',
|
'terminal',
|
||||||
'Terminal',
|
'Terminal',
|
||||||
'Monospace, flat frames and prompt-style chat, like a CLI agent.',
|
'Monospace, flat frames and prompt-style chat, like a CLI agent.',
|
||||||
|
),
|
||||||
|
|
||||||
|
/// A calm reading look: a warm paper page, a serif for reading, ink
|
||||||
|
/// colours, hairline rules and the chat set as a typeset page.
|
||||||
|
paper(
|
||||||
|
'paper',
|
||||||
|
'Paper',
|
||||||
|
'Warm paper, serif reading text and ink colours; calm for long reads.',
|
||||||
);
|
);
|
||||||
|
|
||||||
const AppDesign(this.id, this.label, this.description);
|
const AppDesign(this.id, this.label, this.description);
|
||||||
@@ -72,8 +93,69 @@ enum AppDesign {
|
|||||||
(standard, Brightness.light) => appLightTheme(fontFamily: fontFamily),
|
(standard, Brightness.light) => appLightTheme(fontFamily: fontFamily),
|
||||||
(standard, Brightness.dark) => appDarkTheme(fontFamily: fontFamily),
|
(standard, Brightness.dark) => appDarkTheme(fontFamily: fontFamily),
|
||||||
(terminal, _) => terminalTheme(brightness),
|
(terminal, _) => terminalTheme(brightness),
|
||||||
|
(paper, _) => paperTheme(brightness, fontFamily: fontFamily),
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Whether the device's interface font applies under this design.
|
/// Whether the device's interface font applies under this design (Paper
|
||||||
bool get usesInterfaceFont => this == standard;
|
/// keeps it for its interface text and sets reading text in its serif).
|
||||||
|
bool get usesInterfaceFont => this != terminal;
|
||||||
|
|
||||||
|
/// The picker's preview: the design's page, ink and accent in [brightness],
|
||||||
|
/// without building its theme.
|
||||||
|
DesignSwatch swatch(Brightness brightness) {
|
||||||
|
final dark = brightness == Brightness.dark;
|
||||||
|
return switch (this) {
|
||||||
|
standard =>
|
||||||
|
dark
|
||||||
|
? const DesignSwatch(
|
||||||
|
Color(0xFF141416),
|
||||||
|
Color(0xFFE6E0E9),
|
||||||
|
Color(0xFFCFBDFE),
|
||||||
|
)
|
||||||
|
: const DesignSwatch(
|
||||||
|
Color(0xFFFDF7FF),
|
||||||
|
Color(0xFF1D1B20),
|
||||||
|
Color(0xFF65558F),
|
||||||
|
),
|
||||||
|
terminal =>
|
||||||
|
dark
|
||||||
|
? const DesignSwatch(
|
||||||
|
Color(0xFF0B0B0B),
|
||||||
|
Color(0xFFD7D7D2),
|
||||||
|
Color(0xFF8CC38F),
|
||||||
|
)
|
||||||
|
: const DesignSwatch(
|
||||||
|
Color(0xFFF7F6F1),
|
||||||
|
Color(0xFF1E1E1C),
|
||||||
|
Color(0xFF2F7434),
|
||||||
|
),
|
||||||
|
paper =>
|
||||||
|
dark
|
||||||
|
? const DesignSwatch(
|
||||||
|
Color(0xFF1E1B17),
|
||||||
|
Color(0xFFE9E1D3),
|
||||||
|
Color(0xFF9DB4DC),
|
||||||
|
)
|
||||||
|
: const DesignSwatch(
|
||||||
|
Color(0xFFF8F4EB),
|
||||||
|
Color(0xFF221E19),
|
||||||
|
Color(0xFF2C4F86),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A design's three defining colours, for the picker's small preview.
|
||||||
|
@immutable
|
||||||
|
class DesignSwatch {
|
||||||
|
const DesignSwatch(this.page, this.ink, this.accent);
|
||||||
|
|
||||||
|
/// The page (scaffold) colour.
|
||||||
|
final Color page;
|
||||||
|
|
||||||
|
/// The main text colour.
|
||||||
|
final Color ink;
|
||||||
|
|
||||||
|
/// The accent (primary) colour.
|
||||||
|
final Color accent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/painting.dart';
|
||||||
|
|
||||||
|
/// How the chat transcript draws a conversation. Each design picks one; the
|
||||||
|
/// transcript widgets branch on it, never on the design itself.
|
||||||
|
enum TranscriptStyle {
|
||||||
|
/// The operator's turns as bubbles on the trailing side, the agent's
|
||||||
|
/// answers on the page and its activity as a one-line button (Default).
|
||||||
|
bubbles,
|
||||||
|
|
||||||
|
/// A CLI's prompt line, glyph-led tool lines and bracketed injected
|
||||||
|
/// prompts, every turn starting at the same edge (Terminal).
|
||||||
|
prompt,
|
||||||
|
|
||||||
|
/// A typeset page: the operator's turns as indented block quotes under a
|
||||||
|
/// small-caps label, answers as prose, activity as a muted marginal note
|
||||||
|
/// and injected prompts as italic editorial notes (Paper).
|
||||||
|
manuscript,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How the chat composer frames its writing area.
|
||||||
|
enum ComposerStyle {
|
||||||
|
/// A floating pill (frosted, or flat and framed under a flat design) in
|
||||||
|
/// the design's corners, with a focus ring along its edge.
|
||||||
|
pill,
|
||||||
|
|
||||||
|
/// An open writing area on the page with a rule beneath it that takes
|
||||||
|
/// the accent while the field has focus.
|
||||||
|
underline,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// How a list (AppListRow) marks the row that is open. Every style keeps
|
||||||
|
/// the leading bar in the row's accent; they differ in the fill and frame.
|
||||||
|
enum SelectedRowStyle {
|
||||||
|
/// Material's tonal `secondaryContainer` fill (Default).
|
||||||
|
tonal,
|
||||||
|
|
||||||
|
/// The accent washed over the page, stronger than a tinted row, inside a
|
||||||
|
/// hairline frame in the accent (Terminal).
|
||||||
|
framed,
|
||||||
|
|
||||||
|
/// The accent washed over the page, without a frame (Paper).
|
||||||
|
washed,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The typography of reading text: chat messages, markdown answers and
|
||||||
|
/// documents. Interface text (navigation, buttons, chips, labels, metadata)
|
||||||
|
/// keeps the theme's own text roles.
|
||||||
|
@immutable
|
||||||
|
class ReadingType {
|
||||||
|
const ReadingType({
|
||||||
|
this.family,
|
||||||
|
this.height,
|
||||||
|
this.measure,
|
||||||
|
this.scale = 1,
|
||||||
|
this.figureWidth = 0.5,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The reading face; null keeps the theme's body face.
|
||||||
|
final String? family;
|
||||||
|
|
||||||
|
/// The line height as a multiple of the font size; null keeps the role's.
|
||||||
|
final double? height;
|
||||||
|
|
||||||
|
/// The widest reading column in `ch` (widths of the digit zero in the
|
||||||
|
/// reading face); null keeps the app's fixed reading width.
|
||||||
|
final double? measure;
|
||||||
|
|
||||||
|
/// The reading size relative to the theme's `bodyLarge`.
|
||||||
|
final double scale;
|
||||||
|
|
||||||
|
/// The width of the reading face's digit zero, in ems: what one `ch` of
|
||||||
|
/// [measure] is worth (half an em for Source Serif's figures).
|
||||||
|
final double figureWidth;
|
||||||
|
|
||||||
|
/// [base] in the reading face, size and line height.
|
||||||
|
TextStyle? apply(TextStyle? base) {
|
||||||
|
if (base == null) return null;
|
||||||
|
if (family == null && height == null && scale == 1) return base;
|
||||||
|
final size = base.fontSize;
|
||||||
|
return base.copyWith(
|
||||||
|
fontFamily: family,
|
||||||
|
// The interface face stays as the fallback, so a glyph the reading
|
||||||
|
// face lacks still draws from a bundled family.
|
||||||
|
fontFamilyFallback: family == null || base.fontFamily == null
|
||||||
|
? null
|
||||||
|
: <String>[base.fontFamily!, ...?base.fontFamilyFallback],
|
||||||
|
fontSize: size == null ? null : size * scale,
|
||||||
|
height: height,
|
||||||
|
letterSpacing: family == null ? null : 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
other is ReadingType &&
|
||||||
|
other.family == family &&
|
||||||
|
other.height == height &&
|
||||||
|
other.measure == measure &&
|
||||||
|
other.scale == scale &&
|
||||||
|
other.figureWidth == figureWidth;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(family, height, measure, scale, figureWidth);
|
||||||
|
}
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'app_design.dart';
|
import 'app_design.dart';
|
||||||
|
import 'app_design_styles.dart';
|
||||||
|
|
||||||
|
export 'app_design_styles.dart';
|
||||||
|
|
||||||
/// The muted ANSI-style accents a design names for status and roles. The
|
/// The muted ANSI-style accents a design names for status and roles. The
|
||||||
/// Default design leaves them to its colour scheme; Terminal sets them.
|
/// Default design leaves them to its colour scheme; Terminal sets them, and
|
||||||
|
/// Paper sets ink-toned ones.
|
||||||
@immutable
|
@immutable
|
||||||
class AnsiAccents {
|
class AnsiAccents {
|
||||||
const AnsiAccents({
|
const AnsiAccents({
|
||||||
@@ -37,9 +41,15 @@ class AnsiAccents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The design-specific facts widgets read instead of hard-coding one look:
|
/// The design-specific facts widgets read instead of hard-coding one look:
|
||||||
/// corner shapes, whether surfaces are flat, frame colour and how the chat
|
/// corner shapes, whether surfaces are flat, frame colour, how the chat
|
||||||
/// transcript is drawn. Every theme an [AppDesign] builds carries one; a
|
/// transcript, the composer and the open list row are drawn, and the reading
|
||||||
/// theme without one (a test's bare `ThemeData`) reads as [standard].
|
/// typography. Every theme an [AppDesign] builds carries one; a theme without
|
||||||
|
/// one (a test's bare `ThemeData`) reads as [standard].
|
||||||
|
///
|
||||||
|
/// Adding a design: every field has a default that keeps the Default look,
|
||||||
|
/// so a new design sets only what it changes. Widgets branch on the named
|
||||||
|
/// styles ([transcript], [composer], [selectedRow]) rather than on [design],
|
||||||
|
/// so two designs can share a behaviour.
|
||||||
@immutable
|
@immutable
|
||||||
class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||||
const AppDesignTokens({
|
const AppDesignTokens({
|
||||||
@@ -47,8 +57,14 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
|||||||
this.radius,
|
this.radius,
|
||||||
this.flat = false,
|
this.flat = false,
|
||||||
this.frame,
|
this.frame,
|
||||||
|
this.panel,
|
||||||
this.ansi,
|
this.ansi,
|
||||||
this.promptGlyph = '>',
|
this.promptGlyph = '>',
|
||||||
|
this.transcript = TranscriptStyle.bubbles,
|
||||||
|
this.composer = ComposerStyle.pill,
|
||||||
|
this.selectedRow = SelectedRowStyle.tonal,
|
||||||
|
this.reading = const ReadingType(),
|
||||||
|
this.chatColorSaturation = 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The Default design: every widget keeps its own shapes.
|
/// The Default design: every widget keeps its own shapes.
|
||||||
@@ -59,7 +75,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
|||||||
final AppDesign design;
|
final AppDesign design;
|
||||||
|
|
||||||
/// The corner radius of framed surfaces (cards, pills, the composer,
|
/// The corner radius of framed surfaces (cards, pills, the composer,
|
||||||
/// bubbles); null keeps each widget's own shape.
|
/// bubbles, thumbnails, badges); null keeps each widget's own shape.
|
||||||
final double? radius;
|
final double? radius;
|
||||||
|
|
||||||
/// Whether surfaces are flat: no frosted glass, blur, highlight or shadow.
|
/// Whether surfaces are flat: no frosted glass, blur, highlight or shadow.
|
||||||
@@ -68,6 +84,10 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
|||||||
/// The 1px frame colour around flat surfaces; null keeps each widget's own.
|
/// The 1px frame colour around flat surfaces; null keeps each widget's own.
|
||||||
final Color? frame;
|
final Color? frame;
|
||||||
|
|
||||||
|
/// The fill of a flat design's own panels (settings groups, floating bars,
|
||||||
|
/// cards a widget draws itself); null keeps `surfaceContainerLow`.
|
||||||
|
final Color? panel;
|
||||||
|
|
||||||
/// The design's ANSI-style accents; null for a design that uses its colour
|
/// The design's ANSI-style accents; null for a design that uses its colour
|
||||||
/// scheme's roles.
|
/// scheme's roles.
|
||||||
final AnsiAccents? ansi;
|
final AnsiAccents? ansi;
|
||||||
@@ -75,8 +95,24 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
|||||||
/// The glyph before the operator's prompt line and the composer's field.
|
/// The glyph before the operator's prompt line and the composer's field.
|
||||||
final String promptGlyph;
|
final String promptGlyph;
|
||||||
|
|
||||||
|
/// How the chat transcript draws the operator's and the agent's turns.
|
||||||
|
final TranscriptStyle transcript;
|
||||||
|
|
||||||
|
/// How the chat composer frames its writing area.
|
||||||
|
final ComposerStyle composer;
|
||||||
|
|
||||||
|
/// How a list marks its open row.
|
||||||
|
final SelectedRowStyle selectedRow;
|
||||||
|
|
||||||
|
/// The face, line height and measure of reading text (chat, documents).
|
||||||
|
final ReadingType reading;
|
||||||
|
|
||||||
|
/// How much of a chat colour's saturation the transcript keeps: 1 for the
|
||||||
|
/// palette as is, lower to quieten it towards ink.
|
||||||
|
final double chatColorSaturation;
|
||||||
|
|
||||||
/// Whether the transcript draws prompt and tool lines rather than bubbles.
|
/// Whether the transcript draws prompt and tool lines rather than bubbles.
|
||||||
bool get terminal => design == AppDesign.terminal;
|
bool get terminal => transcript == TranscriptStyle.prompt;
|
||||||
|
|
||||||
/// The tokens of the theme at [context]; [standard] when it has none.
|
/// The tokens of the theme at [context]; [standard] when it has none.
|
||||||
static AppDesignTokens of(BuildContext context) =>
|
static AppDesignTokens of(BuildContext context) =>
|
||||||
@@ -96,21 +132,43 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
|||||||
return r == null ? designed : BorderRadius.circular(r);
|
return r == null ? designed : BorderRadius.circular(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [designed] (a widget's own fill) or, under a flat design, its [panel].
|
||||||
|
Color panelFill(ColorScheme scheme, Color designed) =>
|
||||||
|
flat ? panel ?? scheme.surfaceContainerLow : designed;
|
||||||
|
|
||||||
|
/// The hairline a flat design frames its panels with; null keeps none.
|
||||||
|
BorderSide? get frameSide {
|
||||||
|
final color = frame;
|
||||||
|
return color == null ? null : BorderSide(color: color);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
AppDesignTokens copyWith({
|
AppDesignTokens copyWith({
|
||||||
AppDesign? design,
|
AppDesign? design,
|
||||||
double? radius,
|
double? radius,
|
||||||
bool? flat,
|
bool? flat,
|
||||||
Color? frame,
|
Color? frame,
|
||||||
|
Color? panel,
|
||||||
AnsiAccents? ansi,
|
AnsiAccents? ansi,
|
||||||
String? promptGlyph,
|
String? promptGlyph,
|
||||||
|
TranscriptStyle? transcript,
|
||||||
|
ComposerStyle? composer,
|
||||||
|
SelectedRowStyle? selectedRow,
|
||||||
|
ReadingType? reading,
|
||||||
|
double? chatColorSaturation,
|
||||||
}) => AppDesignTokens(
|
}) => AppDesignTokens(
|
||||||
design: design ?? this.design,
|
design: design ?? this.design,
|
||||||
radius: radius ?? this.radius,
|
radius: radius ?? this.radius,
|
||||||
flat: flat ?? this.flat,
|
flat: flat ?? this.flat,
|
||||||
frame: frame ?? this.frame,
|
frame: frame ?? this.frame,
|
||||||
|
panel: panel ?? this.panel,
|
||||||
ansi: ansi ?? this.ansi,
|
ansi: ansi ?? this.ansi,
|
||||||
promptGlyph: promptGlyph ?? this.promptGlyph,
|
promptGlyph: promptGlyph ?? this.promptGlyph,
|
||||||
|
transcript: transcript ?? this.transcript,
|
||||||
|
composer: composer ?? this.composer,
|
||||||
|
selectedRow: selectedRow ?? this.selectedRow,
|
||||||
|
reading: reading ?? this.reading,
|
||||||
|
chatColorSaturation: chatColorSaturation ?? this.chatColorSaturation,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Value equality keeps a rebuilt theme equal to the one it replaces, so
|
// Value equality keeps a rebuilt theme equal to the one it replaces, so
|
||||||
@@ -123,12 +181,30 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
|||||||
other.radius == radius &&
|
other.radius == radius &&
|
||||||
other.flat == flat &&
|
other.flat == flat &&
|
||||||
other.frame == frame &&
|
other.frame == frame &&
|
||||||
|
other.panel == panel &&
|
||||||
other.ansi == ansi &&
|
other.ansi == ansi &&
|
||||||
other.promptGlyph == promptGlyph;
|
other.promptGlyph == promptGlyph &&
|
||||||
|
other.transcript == transcript &&
|
||||||
|
other.composer == composer &&
|
||||||
|
other.selectedRow == selectedRow &&
|
||||||
|
other.reading == reading &&
|
||||||
|
other.chatColorSaturation == chatColorSaturation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode => Object.hash(
|
||||||
Object.hash(design, radius, flat, frame, ansi, promptGlyph);
|
design,
|
||||||
|
radius,
|
||||||
|
flat,
|
||||||
|
frame,
|
||||||
|
panel,
|
||||||
|
ansi,
|
||||||
|
promptGlyph,
|
||||||
|
transcript,
|
||||||
|
composer,
|
||||||
|
selectedRow,
|
||||||
|
reading,
|
||||||
|
chatColorSaturation,
|
||||||
|
);
|
||||||
|
|
||||||
/// Designs switch whole: a theme animation snaps halfway rather than
|
/// Designs switch whole: a theme animation snaps halfway rather than
|
||||||
/// blending two designs' shapes.
|
/// blending two designs' shapes.
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ import 'package:flutter/services.dart';
|
|||||||
|
|
||||||
import '../text/terminal_symbols_font.dart';
|
import '../text/terminal_symbols_font.dart';
|
||||||
import 'app_font.dart';
|
import 'app_font.dart';
|
||||||
|
import 'paper_fonts.dart';
|
||||||
|
|
||||||
bool _registered = false;
|
bool _registered = false;
|
||||||
|
|
||||||
/// Adds each bundled interface font's SIL Open Font License, and the
|
/// Adds each bundled interface font's SIL Open Font License, Paper's reading
|
||||||
|
/// serif's, and the
|
||||||
/// terminal symbols font's MIT licence, to the
|
/// terminal symbols font's MIT licence, to the
|
||||||
/// [LicenseRegistry]. The texts are read from the bundle only when a licence
|
/// [LicenseRegistry]. The texts are read from the bundle only when a licence
|
||||||
/// page asks for them.
|
/// page asks for them.
|
||||||
@@ -21,6 +23,9 @@ void registerAppFontLicenses() {
|
|||||||
font.label,
|
font.label,
|
||||||
], await rootBundle.loadString(asset));
|
], await rootBundle.loadString(asset));
|
||||||
}
|
}
|
||||||
|
yield LicenseEntryWithLineBreaks(<String>[
|
||||||
|
paperSerifFamily,
|
||||||
|
], await rootBundle.loadString(paperSerifLicenseAsset));
|
||||||
yield LicenseEntryWithLineBreaks(<String>[
|
yield LicenseEntryWithLineBreaks(<String>[
|
||||||
'Symbols Nerd Font Mono',
|
'Symbols Nerd Font Mono',
|
||||||
], await rootBundle.loadString(terminalSymbolsLicenseAsset));
|
], await rootBundle.loadString(terminalSymbolsLicenseAsset));
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'paper_theme.dart';
|
||||||
|
|
||||||
|
const Color _clear = Color(0x00000000);
|
||||||
|
|
||||||
|
// Kept per colour: a tab indicator and a resolver compare by identity, so
|
||||||
|
// fresh ones would make a rebuilt theme unequal to the last
|
||||||
|
// (test/perf/design_bench_test.dart).
|
||||||
|
final Map<Color, Decoration> _tabIndicators = {};
|
||||||
|
final Map<(Color, Color), WidgetStateProperty<Color?>> _trackOutlines = {};
|
||||||
|
|
||||||
|
/// [base] with Paper's controls: buttons, menus, chips, fields, search bars,
|
||||||
|
/// tabs, segmented buttons, switches, checkboxes, sliders, badges and
|
||||||
|
/// progress, all in [paperRadius] corners with hairline outlines, no
|
||||||
|
/// elevation and the ink-blue accent.
|
||||||
|
ThemeData paperControls(ThemeData base, PaperSurfaces surfaces) {
|
||||||
|
final scheme = base.colorScheme;
|
||||||
|
const rounded = PaperSurfaces.rounded;
|
||||||
|
ButtonStyle buttons(ButtonStyle? style) =>
|
||||||
|
(style ?? const ButtonStyle()).copyWith(
|
||||||
|
shape: const WidgetStatePropertyAll(rounded),
|
||||||
|
elevation: const WidgetStatePropertyAll(0),
|
||||||
|
shadowColor: const WidgetStatePropertyAll(_clear),
|
||||||
|
);
|
||||||
|
final outline = WidgetStatePropertyAll(BorderSide(color: scheme.outline));
|
||||||
|
final menu = MenuStyle(
|
||||||
|
backgroundColor: WidgetStatePropertyAll(surfaces.floating),
|
||||||
|
elevation: const WidgetStatePropertyAll(PaperSurfaces.floatElevation),
|
||||||
|
shadowColor: WidgetStatePropertyAll(surfaces.shadow),
|
||||||
|
surfaceTintColor: const WidgetStatePropertyAll(_clear),
|
||||||
|
shape: WidgetStatePropertyAll(surfaces.framed),
|
||||||
|
padding: const WidgetStatePropertyAll(EdgeInsets.symmetric(vertical: 4)),
|
||||||
|
);
|
||||||
|
return base.copyWith(
|
||||||
|
menuTheme: MenuThemeData(style: menu),
|
||||||
|
dropdownMenuTheme: DropdownMenuThemeData(menuStyle: menu),
|
||||||
|
menuButtonTheme: MenuButtonThemeData(
|
||||||
|
style: MenuItemButton.styleFrom(shape: rounded),
|
||||||
|
),
|
||||||
|
filledButtonTheme: FilledButtonThemeData(
|
||||||
|
style: buttons(base.filledButtonTheme.style),
|
||||||
|
),
|
||||||
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||||
|
style: buttons(base.elevatedButtonTheme.style).copyWith(
|
||||||
|
backgroundColor: WidgetStatePropertyAll(scheme.surface),
|
||||||
|
side: outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||||
|
style: buttons(base.outlinedButtonTheme.style).copyWith(side: outline),
|
||||||
|
),
|
||||||
|
textButtonTheme: TextButtonThemeData(
|
||||||
|
style: buttons(base.textButtonTheme.style),
|
||||||
|
),
|
||||||
|
iconButtonTheme: IconButtonThemeData(
|
||||||
|
style: buttons(base.iconButtonTheme.style),
|
||||||
|
),
|
||||||
|
segmentedButtonTheme: SegmentedButtonThemeData(
|
||||||
|
style: buttons(base.segmentedButtonTheme.style).copyWith(
|
||||||
|
side: WidgetStatePropertyAll(BorderSide(color: scheme.outline)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButtonTheme: FloatingActionButtonThemeData(
|
||||||
|
elevation: 0,
|
||||||
|
focusElevation: 0,
|
||||||
|
hoverElevation: 0,
|
||||||
|
highlightElevation: 0,
|
||||||
|
backgroundColor: scheme.surface,
|
||||||
|
foregroundColor: scheme.primary,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: PaperSurfaces.corners,
|
||||||
|
side: BorderSide(color: scheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
chipTheme: ChipThemeData(
|
||||||
|
backgroundColor: _clear,
|
||||||
|
selectedColor: scheme.secondaryContainer,
|
||||||
|
shape: surfaces.framed,
|
||||||
|
side: surfaces.hairline,
|
||||||
|
elevation: 0,
|
||||||
|
pressElevation: 0,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
|
||||||
|
),
|
||||||
|
// Only the base border: a field that sets `InputBorder.none` (the
|
||||||
|
// composer, whose rule it draws itself) keeps none in every state.
|
||||||
|
// An underline is a writing line on the page, not a box.
|
||||||
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
|
border: UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: scheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
searchBarTheme: SearchBarThemeData(
|
||||||
|
elevation: const WidgetStatePropertyAll(0),
|
||||||
|
shape: const WidgetStatePropertyAll(rounded),
|
||||||
|
side: WidgetStatePropertyAll(surfaces.hairline),
|
||||||
|
backgroundColor: WidgetStatePropertyAll(scheme.surfaceContainerLowest),
|
||||||
|
surfaceTintColor: const WidgetStatePropertyAll(_clear),
|
||||||
|
padding: const WidgetStatePropertyAll(
|
||||||
|
EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
listTileTheme: const ListTileThemeData(shape: rounded),
|
||||||
|
expansionTileTheme: const ExpansionTileThemeData(
|
||||||
|
shape: Border(),
|
||||||
|
collapsedShape: Border(),
|
||||||
|
),
|
||||||
|
tabBarTheme: TabBarThemeData(
|
||||||
|
dividerColor: scheme.outlineVariant,
|
||||||
|
labelColor: scheme.onSurface,
|
||||||
|
unselectedLabelColor: scheme.onSurfaceVariant,
|
||||||
|
indicatorSize: TabBarIndicatorSize.label,
|
||||||
|
indicator: _tabIndicators[scheme.primary] ??= UnderlineTabIndicator(
|
||||||
|
borderSide: BorderSide(color: scheme.primary, width: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
switchTheme: SwitchThemeData(
|
||||||
|
trackOutlineColor: _trackOutlines[(scheme.primary, scheme.outline)] ??=
|
||||||
|
WidgetStateProperty.resolveWith(
|
||||||
|
(states) => states.contains(WidgetState.selected)
|
||||||
|
? scheme.primary
|
||||||
|
: scheme.outline,
|
||||||
|
),
|
||||||
|
trackOutlineWidth: const WidgetStatePropertyAll(1),
|
||||||
|
),
|
||||||
|
checkboxTheme: CheckboxThemeData(
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(3)),
|
||||||
|
),
|
||||||
|
side: WidgetStateBorderSide.resolveWith(
|
||||||
|
(states) => states.contains(WidgetState.selected)
|
||||||
|
? BorderSide(color: scheme.primary, width: 1.5)
|
||||||
|
: BorderSide(color: scheme.outline, width: 1.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// A thin rule with a small round thumb, like a reading-app slider.
|
||||||
|
sliderTheme: SliderThemeData(
|
||||||
|
trackHeight: 2,
|
||||||
|
activeTrackColor: scheme.primary,
|
||||||
|
inactiveTrackColor: scheme.outlineVariant,
|
||||||
|
thumbColor: scheme.primary,
|
||||||
|
overlayColor: scheme.primary.withValues(alpha: 0.1),
|
||||||
|
thumbShape: const RoundSliderThumbShape(
|
||||||
|
enabledThumbRadius: 7,
|
||||||
|
elevation: 0,
|
||||||
|
pressedElevation: 0,
|
||||||
|
),
|
||||||
|
overlayShape: const RoundSliderOverlayShape(overlayRadius: 16),
|
||||||
|
trackShape: const RoundedRectSliderTrackShape(),
|
||||||
|
tickMarkShape: const RoundSliderTickMarkShape(tickMarkRadius: 1.5),
|
||||||
|
activeTickMarkColor: scheme.onPrimary,
|
||||||
|
inactiveTickMarkColor: scheme.outline,
|
||||||
|
valueIndicatorColor: scheme.inverseSurface,
|
||||||
|
valueIndicatorTextStyle: TextStyle(color: scheme.onInverseSurface),
|
||||||
|
),
|
||||||
|
// Counts in the accent's ink rather than an alarm red.
|
||||||
|
badgeTheme: BadgeThemeData(
|
||||||
|
backgroundColor: scheme.primary,
|
||||||
|
textColor: scheme.onPrimary,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
|
),
|
||||||
|
progressIndicatorTheme: ProgressIndicatorThemeData(
|
||||||
|
color: scheme.primary,
|
||||||
|
linearTrackColor: scheme.outlineVariant,
|
||||||
|
circularTrackColor: _clear,
|
||||||
|
linearMinHeight: 2,
|
||||||
|
),
|
||||||
|
scrollbarTheme: const ScrollbarThemeData(
|
||||||
|
radius: Radius.circular(4),
|
||||||
|
thickness: WidgetStatePropertyAll(6),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
/// Paper's reading serif (fonts/README.md): Source Serif 4.
|
||||||
|
const String paperSerifFamily = 'Source Serif 4';
|
||||||
|
|
||||||
|
const String _directory = 'fonts/source-serif-4';
|
||||||
|
|
||||||
|
/// The licence shipped beside the files, registered with the app's other
|
||||||
|
/// font licences.
|
||||||
|
const String paperSerifLicenseAsset = '$_directory/OFL.txt';
|
||||||
|
|
||||||
|
/// Every face of [paperSerifFamily]: regular, italic, semibold and semibold
|
||||||
|
/// italic. The loader reads each file's own weight and style.
|
||||||
|
const List<String> paperSerifAssets = <String>[
|
||||||
|
'$_directory/SourceSerif4-Regular.ttf',
|
||||||
|
'$_directory/SourceSerif4-It.ttf',
|
||||||
|
'$_directory/SourceSerif4-Semibold.ttf',
|
||||||
|
'$_directory/SourceSerif4-SemiboldIt.ttf',
|
||||||
|
];
|
||||||
|
|
||||||
|
Future<void>? _loading;
|
||||||
|
|
||||||
|
/// Registers [paperSerifFamily] the first time Paper's theme is built. The
|
||||||
|
/// files are plain assets, not a `fonts:` family, so the web build fetches
|
||||||
|
/// them only for a device that chooses Paper. Once registered the engine
|
||||||
|
/// reports a font change and text lays out again in the serif; until then
|
||||||
|
/// it reads in the interface face (the reading style's fallback). A failed
|
||||||
|
/// load is logged and the interface face stays.
|
||||||
|
Future<void> ensurePaperFonts() => _loading ??= _load();
|
||||||
|
|
||||||
|
Future<void> _load() async {
|
||||||
|
try {
|
||||||
|
final loader = FontLoader(paperSerifFamily);
|
||||||
|
for (final asset in paperSerifAssets) {
|
||||||
|
loader.addFont(rootBundle.load(asset));
|
||||||
|
}
|
||||||
|
await loader.load();
|
||||||
|
} catch (error) {
|
||||||
|
debugPrint('Paper serif font did not load: $error');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'app_design_tokens.dart';
|
||||||
|
|
||||||
|
/// Paper's status accents on its warm page: the usual hues pulled towards
|
||||||
|
/// ink, so a status still reads by colour without shouting.
|
||||||
|
const AnsiAccents paperLightAccents = AnsiAccents(
|
||||||
|
green: Color(0xFF3D6B3F),
|
||||||
|
cyan: Color(0xFF2E6670),
|
||||||
|
yellow: Color(0xFF8A6A1F),
|
||||||
|
red: Color(0xFF9B3B32),
|
||||||
|
magenta: Color(0xFF7A4570),
|
||||||
|
blue: Color(0xFF2C4F86),
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Paper's status accents on its night page.
|
||||||
|
const AnsiAccents paperDarkAccents = AnsiAccents(
|
||||||
|
green: Color(0xFF9DBE95),
|
||||||
|
cyan: Color(0xFF8DB8BE),
|
||||||
|
yellow: Color(0xFFD5B977),
|
||||||
|
red: Color(0xFFDE9A8E),
|
||||||
|
magenta: Color(0xFFC6A0C0),
|
||||||
|
blue: Color(0xFF9DB4DC),
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Paper's colour scheme: a warm off-white page (or a sepia-tinted charcoal
|
||||||
|
/// "night paper"), near-black ink with a muted secondary ink, surfaces that
|
||||||
|
/// step only slightly from the page, hairline rules, and one restrained
|
||||||
|
/// accent, a deep ink blue. Secondary and tertiary roles are quiet sepia
|
||||||
|
/// tones, so nothing but the accent carries colour.
|
||||||
|
ColorScheme paperColorScheme(Brightness brightness) {
|
||||||
|
if (brightness == Brightness.dark) {
|
||||||
|
return const ColorScheme(
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
primary: Color(0xFF9DB4DC),
|
||||||
|
onPrimary: Color(0xFF13213A),
|
||||||
|
primaryContainer: Color(0xFF2B3447),
|
||||||
|
onPrimaryContainer: Color(0xFFD7E1F2),
|
||||||
|
secondary: Color(0xFFC2B6A2),
|
||||||
|
onSecondary: Color(0xFF2A241C),
|
||||||
|
secondaryContainer: Color(0xFF3A342B),
|
||||||
|
onSecondaryContainer: Color(0xFFEAE1D1),
|
||||||
|
tertiary: Color(0xFFD5B977),
|
||||||
|
onTertiary: Color(0xFF2E2410),
|
||||||
|
tertiaryContainer: Color(0xFF433824),
|
||||||
|
onTertiaryContainer: Color(0xFFF0E1BC),
|
||||||
|
error: Color(0xFFE39C90),
|
||||||
|
onError: Color(0xFF3A120D),
|
||||||
|
errorContainer: Color(0xFF4D2620),
|
||||||
|
onErrorContainer: Color(0xFFF6D3CC),
|
||||||
|
surface: Color(0xFF1E1B17),
|
||||||
|
onSurface: Color(0xFFE9E1D3),
|
||||||
|
onSurfaceVariant: Color(0xFFADA393),
|
||||||
|
surfaceDim: Color(0xFF1A1814),
|
||||||
|
surfaceBright: Color(0xFF3B362F),
|
||||||
|
surfaceContainerLowest: Color(0xFF181612),
|
||||||
|
surfaceContainerLow: Color(0xFF221F1A),
|
||||||
|
surfaceContainer: Color(0xFF27231E),
|
||||||
|
surfaceContainerHigh: Color(0xFF2D2923),
|
||||||
|
surfaceContainerHighest: Color(0xFF35302A),
|
||||||
|
outline: Color(0xFF746B5E),
|
||||||
|
outlineVariant: Color(0xFF3D3830),
|
||||||
|
shadow: Color(0xFF000000),
|
||||||
|
scrim: Color(0xFF000000),
|
||||||
|
inverseSurface: Color(0xFFE9E1D3),
|
||||||
|
onInverseSurface: Color(0xFF26221D),
|
||||||
|
inversePrimary: Color(0xFF2C4F86),
|
||||||
|
surfaceTint: Color(0x00000000),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return const ColorScheme(
|
||||||
|
brightness: Brightness.light,
|
||||||
|
primary: Color(0xFF2C4F86),
|
||||||
|
onPrimary: Color(0xFFFFFFFF),
|
||||||
|
primaryContainer: Color(0xFFDDE4EF),
|
||||||
|
onPrimaryContainer: Color(0xFF132A4D),
|
||||||
|
secondary: Color(0xFF6B5E4B),
|
||||||
|
onSecondary: Color(0xFFFFFFFF),
|
||||||
|
secondaryContainer: Color(0xFFEAE2D2),
|
||||||
|
onSecondaryContainer: Color(0xFF2E271C),
|
||||||
|
tertiary: Color(0xFF8A6A1F),
|
||||||
|
onTertiary: Color(0xFFFFFFFF),
|
||||||
|
tertiaryContainer: Color(0xFFF1E6C9),
|
||||||
|
onTertiaryContainer: Color(0xFF3A2C08),
|
||||||
|
error: Color(0xFF9B3B32),
|
||||||
|
onError: Color(0xFFFFFFFF),
|
||||||
|
errorContainer: Color(0xFFF4DCD6),
|
||||||
|
onErrorContainer: Color(0xFF451410),
|
||||||
|
surface: Color(0xFFF8F4EB),
|
||||||
|
onSurface: Color(0xFF221E19),
|
||||||
|
onSurfaceVariant: Color(0xFF655D51),
|
||||||
|
surfaceDim: Color(0xFFE7E0D3),
|
||||||
|
surfaceBright: Color(0xFFFCFAF5),
|
||||||
|
surfaceContainerLowest: Color(0xFFFCFAF5),
|
||||||
|
surfaceContainerLow: Color(0xFFF3EEE3),
|
||||||
|
surfaceContainer: Color(0xFFEEE8DC),
|
||||||
|
surfaceContainerHigh: Color(0xFFE9E2D5),
|
||||||
|
surfaceContainerHighest: Color(0xFFE3DBCC),
|
||||||
|
outline: Color(0xFFA09686),
|
||||||
|
outlineVariant: Color(0xFFDDD5C6),
|
||||||
|
shadow: Color(0xFF3B2F1E),
|
||||||
|
scrim: Color(0xFF000000),
|
||||||
|
inverseSurface: Color(0xFF2E2A24),
|
||||||
|
onInverseSurface: Color(0xFFF3EEE3),
|
||||||
|
inversePrimary: Color(0xFF9DB4DC),
|
||||||
|
surfaceTint: Color(0x00000000),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,193 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'app_design.dart';
|
||||||
|
import 'app_design_tokens.dart';
|
||||||
|
import 'app_theme.dart';
|
||||||
|
import 'paper_controls.dart';
|
||||||
|
import 'paper_fonts.dart';
|
||||||
|
import 'paper_palette.dart';
|
||||||
|
import 'paper_typography.dart';
|
||||||
|
|
||||||
|
/// Paper's corner radius: every card, field, menu, dialog, chip, button and
|
||||||
|
/// thumbnail takes it, so the page has one soft corner throughout.
|
||||||
|
const double paperRadius = 8;
|
||||||
|
|
||||||
|
/// Paper's surfaces: hairline rules on the page rather than filled panels,
|
||||||
|
/// and no elevation except a whisper of shadow under the pieces that float
|
||||||
|
/// over the page (menus, dialogs, sheets, snack bars).
|
||||||
|
class PaperSurfaces {
|
||||||
|
PaperSurfaces(this.scheme);
|
||||||
|
|
||||||
|
final ColorScheme scheme;
|
||||||
|
|
||||||
|
static const BorderRadius corners = BorderRadius.all(
|
||||||
|
Radius.circular(paperRadius),
|
||||||
|
);
|
||||||
|
|
||||||
|
/// The whisper: a low elevation in the page's warm shadow at low alpha.
|
||||||
|
static const double floatElevation = 3;
|
||||||
|
|
||||||
|
Color get shadow => scheme.shadow.withValues(
|
||||||
|
alpha: scheme.brightness == Brightness.dark ? 0.5 : 0.22,
|
||||||
|
);
|
||||||
|
|
||||||
|
BorderSide get hairline => BorderSide(color: scheme.outlineVariant);
|
||||||
|
|
||||||
|
/// A floating piece's fill: the brightest paper, so it lifts off the page
|
||||||
|
/// by tone and hairline rather than by shadow.
|
||||||
|
Color get floating => scheme.brightness == Brightness.dark
|
||||||
|
? scheme.surfaceContainerHigh
|
||||||
|
: scheme.surfaceContainerLowest;
|
||||||
|
|
||||||
|
RoundedRectangleBorder get framed =>
|
||||||
|
RoundedRectangleBorder(borderRadius: corners, side: hairline);
|
||||||
|
|
||||||
|
static const RoundedRectangleBorder rounded = RoundedRectangleBorder(
|
||||||
|
borderRadius: corners,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The Paper design's theme: a warm paper page (or night paper in dark), ink
|
||||||
|
/// text with a muted secondary ink and one deep-blue accent, titles and
|
||||||
|
/// reading text in a bundled serif with the interface font for chrome, soft
|
||||||
|
/// [paperRadius] corners, hairline rules and almost no elevation. Building it
|
||||||
|
/// starts loading the serif ([ensurePaperFonts]).
|
||||||
|
ThemeData paperTheme(Brightness brightness, {String? fontFamily}) {
|
||||||
|
unawaited(ensurePaperFonts());
|
||||||
|
final scheme = paperColorScheme(brightness);
|
||||||
|
final surfaces = PaperSurfaces(scheme);
|
||||||
|
final base = ThemeData(
|
||||||
|
platform: kIsWeb ? TargetPlatform.android : null,
|
||||||
|
colorScheme: scheme,
|
||||||
|
fontFamily: fontFamily,
|
||||||
|
scaffoldBackgroundColor: scheme.surface,
|
||||||
|
canvasColor: scheme.surface,
|
||||||
|
pageTransitionsTheme: appPageTransitions,
|
||||||
|
dividerColor: scheme.outlineVariant,
|
||||||
|
shadowColor: surfaces.shadow,
|
||||||
|
extensions: [
|
||||||
|
AppDesignTokens(
|
||||||
|
design: AppDesign.paper,
|
||||||
|
radius: paperRadius,
|
||||||
|
flat: true,
|
||||||
|
frame: scheme.outlineVariant,
|
||||||
|
panel: scheme.surface,
|
||||||
|
ansi: brightness == Brightness.dark
|
||||||
|
? paperDarkAccents
|
||||||
|
: paperLightAccents,
|
||||||
|
transcript: TranscriptStyle.manuscript,
|
||||||
|
composer: ComposerStyle.underline,
|
||||||
|
selectedRow: SelectedRowStyle.washed,
|
||||||
|
reading: paperReading,
|
||||||
|
chatColorSaturation: 0.45,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
final floating = surfaces.floating;
|
||||||
|
final floatingShape = RoundedRectangleBorder(
|
||||||
|
borderRadius: PaperSurfaces.corners,
|
||||||
|
side: surfaces.hairline,
|
||||||
|
);
|
||||||
|
return paperControls(
|
||||||
|
base.copyWith(
|
||||||
|
textTheme: paperTextTheme(base.textTheme),
|
||||||
|
primaryTextTheme: paperTextTheme(base.primaryTextTheme),
|
||||||
|
appBarTheme: AppBarTheme(
|
||||||
|
backgroundColor: scheme.surface,
|
||||||
|
foregroundColor: scheme.onSurface,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
elevation: 0,
|
||||||
|
scrolledUnderElevation: 0,
|
||||||
|
shape: Border(bottom: surfaces.hairline),
|
||||||
|
),
|
||||||
|
// Only the hairline and the corners: each card variant 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: surfaces.framed,
|
||||||
|
),
|
||||||
|
dialogTheme: DialogThemeData(
|
||||||
|
backgroundColor: floating,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
elevation: PaperSurfaces.floatElevation,
|
||||||
|
shadowColor: surfaces.shadow,
|
||||||
|
shape: floatingShape,
|
||||||
|
),
|
||||||
|
bottomSheetTheme: BottomSheetThemeData(
|
||||||
|
backgroundColor: floating,
|
||||||
|
modalBackgroundColor: floating,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
elevation: PaperSurfaces.floatElevation,
|
||||||
|
modalElevation: PaperSurfaces.floatElevation,
|
||||||
|
shadowColor: surfaces.shadow,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(
|
||||||
|
top: Radius.circular(paperRadius),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
dragHandleColor: scheme.outline,
|
||||||
|
),
|
||||||
|
popupMenuTheme: PopupMenuThemeData(
|
||||||
|
color: floating,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
elevation: PaperSurfaces.floatElevation,
|
||||||
|
shadowColor: surfaces.shadow,
|
||||||
|
shape: floatingShape,
|
||||||
|
),
|
||||||
|
snackBarTheme: SnackBarThemeData(
|
||||||
|
backgroundColor: scheme.inverseSurface,
|
||||||
|
contentTextStyle: base.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: scheme.onInverseSurface,
|
||||||
|
),
|
||||||
|
actionTextColor: scheme.inversePrimary,
|
||||||
|
elevation: PaperSurfaces.floatElevation,
|
||||||
|
shape: PaperSurfaces.rounded,
|
||||||
|
),
|
||||||
|
tooltipTheme: TooltipThemeData(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: scheme.inverseSurface.withValues(alpha: 0.94),
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
textStyle: base.textTheme.bodySmall?.copyWith(
|
||||||
|
color: scheme.onInverseSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
dividerTheme: DividerThemeData(
|
||||||
|
color: scheme.outlineVariant,
|
||||||
|
thickness: 1,
|
||||||
|
space: 1,
|
||||||
|
),
|
||||||
|
navigationRailTheme: NavigationRailThemeData(
|
||||||
|
backgroundColor: scheme.surface,
|
||||||
|
elevation: 0,
|
||||||
|
indicatorColor: scheme.secondaryContainer,
|
||||||
|
indicatorShape: PaperSurfaces.rounded,
|
||||||
|
),
|
||||||
|
navigationBarTheme: NavigationBarThemeData(
|
||||||
|
backgroundColor: scheme.surface,
|
||||||
|
elevation: 0,
|
||||||
|
indicatorColor: scheme.secondaryContainer,
|
||||||
|
indicatorShape: PaperSurfaces.rounded,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
),
|
||||||
|
drawerTheme: DrawerThemeData(
|
||||||
|
backgroundColor: scheme.surface,
|
||||||
|
surfaceTintColor: const Color(0x00000000),
|
||||||
|
elevation: PaperSurfaces.floatElevation,
|
||||||
|
shadowColor: surfaces.shadow,
|
||||||
|
),
|
||||||
|
textSelectionTheme: TextSelectionThemeData(
|
||||||
|
cursorColor: scheme.primary,
|
||||||
|
selectionColor: scheme.primary.withValues(alpha: 0.22),
|
||||||
|
selectionHandleColor: scheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
surfaces,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'app_design_styles.dart';
|
||||||
|
import 'paper_fonts.dart';
|
||||||
|
|
||||||
|
/// Paper's reading type: the serif at a little over the body size, with a
|
||||||
|
/// book's line height and a measure of about seventy characters.
|
||||||
|
const ReadingType paperReading = ReadingType(
|
||||||
|
family: paperSerifFamily,
|
||||||
|
height: 1.55,
|
||||||
|
measure: 70,
|
||||||
|
scale: 17 / 16,
|
||||||
|
);
|
||||||
|
|
||||||
|
/// [base] for Paper: the page's titles (display, headline and the large
|
||||||
|
/// title role a page or dialog heads with) in the reading serif, semibold
|
||||||
|
/// and without added tracking; every interface role (list titles, labels,
|
||||||
|
/// buttons, chips, metadata and body text in controls) keeps the interface
|
||||||
|
/// face, so chrome stays a clean sans.
|
||||||
|
TextTheme paperTextTheme(TextTheme base) {
|
||||||
|
TextStyle? serif(TextStyle? style) => style?.copyWith(
|
||||||
|
fontFamily: paperSerifFamily,
|
||||||
|
fontFamilyFallback: style.fontFamily == null
|
||||||
|
? null
|
||||||
|
: <String>[style.fontFamily!],
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
letterSpacing: 0,
|
||||||
|
);
|
||||||
|
return base.copyWith(
|
||||||
|
displayLarge: serif(base.displayLarge),
|
||||||
|
displayMedium: serif(base.displayMedium),
|
||||||
|
displaySmall: serif(base.displaySmall),
|
||||||
|
headlineLarge: serif(base.headlineLarge),
|
||||||
|
headlineMedium: serif(base.headlineMedium),
|
||||||
|
headlineSmall: serif(base.headlineSmall),
|
||||||
|
titleLarge: serif(base.titleLarge),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -49,6 +49,8 @@ ThemeData terminalTheme(Brightness brightness) {
|
|||||||
flat: true,
|
flat: true,
|
||||||
frame: scheme.outlineVariant,
|
frame: scheme.outlineVariant,
|
||||||
ansi: ansi,
|
ansi: ansi,
|
||||||
|
transcript: TranscriptStyle.prompt,
|
||||||
|
selectedRow: SelectedRowStyle.framed,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# Paper design
|
||||||
|
|
||||||
|
A calm reading design (Settings > Design > Paper): warm paper page (sepia
|
||||||
|
charcoal "night paper" in dark), Source Serif 4 for reading text and titles,
|
||||||
|
the interface font for chrome, ink colours with one deep-blue accent, 8px
|
||||||
|
corners, hairline rules and a whisper of shadow only on menus, dialogs, sheets
|
||||||
|
and snack bars.
|
||||||
|
|
||||||
|
## Tokens added to `AppDesignTokens` (all default to the Default look)
|
||||||
|
|
||||||
|
- `transcript` (`TranscriptStyle.bubbles | prompt | manuscript`): how the chat
|
||||||
|
draws turns. Terminal = `prompt`; Paper = `manuscript` (block-quote operator
|
||||||
|
turns with a small-caps "YOU", serif prose, marginal activity note, italic
|
||||||
|
editorial notes for follow-ups/auto-continue). `tokens.terminal` now means
|
||||||
|
`transcript == prompt`.
|
||||||
|
- `composer` (`pill | underline`): Paper's composer is an underlined writing
|
||||||
|
area (`composer_underline.dart`).
|
||||||
|
- `selectedRow` (`tonal | framed | washed`): AppListRow's open row; replaces
|
||||||
|
the hard-coded Terminal frame. Terminal = `framed` (unchanged look).
|
||||||
|
- `reading` (`ReadingType`: family, height, measure in ch, scale,
|
||||||
|
figureWidth): reading text style (`chatMessageTextStyle`) and the chat
|
||||||
|
reading column width (`chatReadingWidthOf`).
|
||||||
|
- `panel`: fill of a flat design's own panels (settings groups, floating bar
|
||||||
|
pieces, task cards, the usage banner); `panelFill()` and `frameSide` helpers.
|
||||||
|
- `chatColorSaturation`: quietens chat colours (`chatColorShade`).
|
||||||
|
|
||||||
|
## Adding a design
|
||||||
|
|
||||||
|
See the `AppDesign` doc comment: add the enum value (id, label, one line),
|
||||||
|
a `<name>_theme.dart` builder, its tokens and a `swatch`. Floating pieces
|
||||||
|
(app choice menu, code Copy hover, graph edge tooltip) follow the theme's
|
||||||
|
`popupMenuTheme`; custom radii go through `tokens.corners()` / `shape()`.
|
||||||
|
|
||||||
|
## Font
|
||||||
|
|
||||||
|
`fonts/source-serif-4/` (OFL, see fonts/README.md), plain assets loaded on
|
||||||
|
demand by `ensurePaperFonts()` when Paper's theme is first built; no network
|
||||||
|
font fetch. Its italic has no `smcp`, so small caps are spaced capitals.
|
||||||
@@ -86,6 +86,9 @@ flutter:
|
|||||||
- fonts/ibm-plex-sans/
|
- fonts/ibm-plex-sans/
|
||||||
- fonts/source-sans-3/
|
- fonts/source-sans-3/
|
||||||
- fonts/atkinson-hyperlegible-next/
|
- fonts/atkinson-hyperlegible-next/
|
||||||
|
# Paper design's reading serif, registered when Paper is first chosen
|
||||||
|
# (lib/ui/theme/paper_fonts.dart).
|
||||||
|
- fonts/source-serif-4/
|
||||||
# Terminal icon fallback, registered when a terminal is first drawn
|
# Terminal icon fallback, registered when a terminal is first drawn
|
||||||
# (lib/ui/text/terminal_symbols_font.dart).
|
# (lib/ui/text/terminal_symbols_font.dart).
|
||||||
- fonts/symbols-nerd-font/
|
- fonts/symbols-nerd-font/
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/conversation/chat_draft_store.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/app_design.dart';
|
||||||
|
|
||||||
|
import 'chat_composer_bar_fixtures.dart';
|
||||||
|
|
||||||
|
Widget _thread(ComposerBarGateway gateway, AppDesign design) => MaterialApp(
|
||||||
|
theme: design.light(),
|
||||||
|
home: Scaffold(
|
||||||
|
body: ChatThreadView(
|
||||||
|
gateway: gateway,
|
||||||
|
sessionId: 's',
|
||||||
|
session: const {'id': 's', 'directory': '/Users/ada/repos/tank'},
|
||||||
|
syncToken: 0,
|
||||||
|
onBack: () {},
|
||||||
|
drafts: MemoryChatDraftStore(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('Paper: the composer is an underlined writing area, not a '
|
||||||
|
'pill, and its rule takes the accent on focus', (tester) async {
|
||||||
|
final gateway = ComposerBarGateway();
|
||||||
|
addTearDown(gateway.close);
|
||||||
|
await tester.pumpWidget(_thread(gateway, AppDesign.paper));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(find.byKey(const Key('chat-composer-pill')), findsNothing);
|
||||||
|
final area = find.byKey(const Key('chat-composer-underline'));
|
||||||
|
expect(area, findsOneWidget);
|
||||||
|
for (final key in [
|
||||||
|
'chat-composer-attach',
|
||||||
|
'chat-composer-field',
|
||||||
|
'chat-composer-primary',
|
||||||
|
]) {
|
||||||
|
expect(
|
||||||
|
find.descendant(of: area, matching: find.byKey(Key(key))),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final scheme = Theme.of(tester.element(area)).colorScheme;
|
||||||
|
Color? rule() =>
|
||||||
|
(tester
|
||||||
|
.widget<AnimatedContainer>(
|
||||||
|
find.byKey(const Key('chat-composer-rule')),
|
||||||
|
)
|
||||||
|
.decoration
|
||||||
|
as BoxDecoration?)
|
||||||
|
?.color;
|
||||||
|
expect(rule(), scheme.outline);
|
||||||
|
|
||||||
|
await tester.tap(find.byKey(const Key('chat-composer-field')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(rule(), scheme.primary);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Default keeps the pill', (tester) async {
|
||||||
|
final gateway = ComposerBarGateway();
|
||||||
|
addTearDown(gateway.close);
|
||||||
|
await tester.pumpWidget(_thread(gateway, AppDesign.standard));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byKey(const Key('chat-composer-pill')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('chat-composer-underline')), findsNothing);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
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_markdown_view.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/paper/paper_activity_note.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/transcript/paper/paper_editorial_note.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/transcript/paper/paper_quote.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/transcript/terminal/terminal_activity_rows.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/ui/transcript/terminal/terminal_prompt_line.dart';
|
||||||
|
import 'package:pipelines_app/ui/text/monospace.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/app_design.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/paper_fonts.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) => {
|
||||||
|
'type': 'tool',
|
||||||
|
'id': id,
|
||||||
|
'name': name,
|
||||||
|
'state': {
|
||||||
|
'status': status,
|
||||||
|
'input': {'command': 'go test ./...'},
|
||||||
|
if (status == 'error') 'error': {'message': 'exit status 1'},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
final JsonMap _agent = _row({
|
||||||
|
'id': 'a1',
|
||||||
|
'role': 'assistant',
|
||||||
|
'parts': [
|
||||||
|
_tool('t1', 'Bash', 'completed'),
|
||||||
|
_tool('t2', 'Read', 'completed'),
|
||||||
|
_tool('t3', 'Bash', 'completed'),
|
||||||
|
{
|
||||||
|
'type': 'text',
|
||||||
|
'text':
|
||||||
|
'## Cause\n\nFixed the separators.\n\n'
|
||||||
|
'- one\n- two\n\n```go\nreturn filepath.Join(a, b)\n```',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
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.light(),
|
||||||
|
home: Scaffold(
|
||||||
|
body: ListView(
|
||||||
|
children: [
|
||||||
|
for (final row in rows)
|
||||||
|
ChatMessageView(row: row, textBuilder: chatMarkdownText),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
double _left(WidgetTester tester, Finder finder) =>
|
||||||
|
tester.getTopLeft(finder).dx;
|
||||||
|
|
||||||
|
/// The style the text containing [text] is laid out in: the root of the
|
||||||
|
/// first [RichText] that draws it.
|
||||||
|
TextStyle _style(WidgetTester tester, String text) {
|
||||||
|
final rich = tester
|
||||||
|
.widgetList<RichText>(find.byType(RichText))
|
||||||
|
.firstWhere((rich) => rich.text.toPlainText().contains(text));
|
||||||
|
return rich.text.style ?? const TextStyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('Paper: the operator turn is an indented block quote with a '
|
||||||
|
'small-caps label and a rule, not a bubble', (tester) async {
|
||||||
|
await tester.pumpWidget(_host(AppDesign.paper, [_operator, _agent]));
|
||||||
|
final quote = find.byType(PaperQuote);
|
||||||
|
expect(quote, findsOneWidget);
|
||||||
|
expect(find.byType(TerminalPromptLine), findsNothing);
|
||||||
|
final label = find.byKey(const Key('chat-paper-quote-label'));
|
||||||
|
expect(tester.widget<Text>(label).data, 'YOU');
|
||||||
|
expect(tester.widget<Text>(label).style?.fontStyle, FontStyle.italic);
|
||||||
|
// Indented past the answer's text edge, not on the trailing side.
|
||||||
|
final words = find.text('Fix the Windows paths.');
|
||||||
|
final answer = find.text('Fixed the separators.');
|
||||||
|
expect(_left(tester, words), greaterThan(_left(tester, answer)));
|
||||||
|
expect(_left(tester, words) - _left(tester, answer), lessThan(40));
|
||||||
|
// The rule runs down the quote's leading edge.
|
||||||
|
final rule = tester.widget<DecoratedBox>(
|
||||||
|
find.descendant(of: quote, matching: find.byType(DecoratedBox)).first,
|
||||||
|
);
|
||||||
|
final side =
|
||||||
|
((rule.decoration as BoxDecoration).border! as BorderDirectional).start;
|
||||||
|
expect(side.width, paperQuoteRule);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Paper: answers are serif prose, code keeps the monospace', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await tester.pumpWidget(_host(AppDesign.paper, [_agent]));
|
||||||
|
final prose = _style(tester, 'Fixed the separators.');
|
||||||
|
expect(prose.fontFamily, paperSerifFamily);
|
||||||
|
expect(prose.height, closeTo(1.55, 0.01));
|
||||||
|
final heading = _style(tester, 'Cause');
|
||||||
|
expect(heading.fontFamily, paperSerifFamily);
|
||||||
|
expect(heading.fontWeight, FontWeight.w600);
|
||||||
|
expect(heading.fontSize, greaterThan(prose.fontSize!));
|
||||||
|
final code = _style(tester, 'return filepath.Join(a, b)');
|
||||||
|
expect(code.fontFamily, appMonospaceFamily);
|
||||||
|
expect(code.fontSize, lessThan(prose.fontSize!));
|
||||||
|
expect(find.text('•'), findsNWidgets(2));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Paper: tool activity is a muted marginal note naming the '
|
||||||
|
'tools, and it still opens the details', (tester) async {
|
||||||
|
await tester.pumpWidget(_host(AppDesign.paper, [_agent]));
|
||||||
|
expect(find.byType(TerminalActivityRows), findsNothing);
|
||||||
|
final note = find.byType(PaperActivityNote);
|
||||||
|
expect(note, findsOneWidget);
|
||||||
|
expect(
|
||||||
|
find.descendant(
|
||||||
|
of: note,
|
||||||
|
matching: find.textContaining('Used 3 tools — Bash, Read'),
|
||||||
|
),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
final text = tester.widget<Text>(
|
||||||
|
find.descendant(of: note, matching: find.byType(Text)),
|
||||||
|
);
|
||||||
|
expect(text.style?.fontStyle, FontStyle.italic);
|
||||||
|
await tester.tap(note);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Activity details'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Paper: a follow-up is a small italic editorial note', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await tester.pumpWidget(_host(AppDesign.paper, [_followup]));
|
||||||
|
expect(find.byType(PaperEditorialNote), findsOneWidget);
|
||||||
|
final header = find.byKey(const Key('chat-automated-prompt-header'));
|
||||||
|
final text = tester.widget<Text>(header).textSpan!.toPlainText();
|
||||||
|
expect(text, startsWith('FOLLOW-UP FROM AGENT'));
|
||||||
|
// The body is selectable text in the note's ambient style.
|
||||||
|
final body = DefaultTextStyle.of(
|
||||||
|
tester.element(find.text('Check whether run 42 finished.')),
|
||||||
|
).style;
|
||||||
|
expect(body.fontStyle, FontStyle.italic);
|
||||||
|
// No card: the note has no Material fill.
|
||||||
|
final note = tester.widget<Material>(
|
||||||
|
find.byKey(const Key('chat-automated-prompt')),
|
||||||
|
);
|
||||||
|
expect(note.type, MaterialType.transparency);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Default is unchanged: a trailing bubble, no Paper pieces', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
_host(AppDesign.standard, [_operator, _agent, _followup]),
|
||||||
|
);
|
||||||
|
expect(find.byType(PaperQuote), findsNothing);
|
||||||
|
expect(find.byType(PaperActivityNote), findsNothing);
|
||||||
|
expect(find.byType(PaperEditorialNote), findsNothing);
|
||||||
|
expect(find.byType(ChatUserBubble), findsOneWidget);
|
||||||
|
final bubble = find.byType(ChatUserBubble);
|
||||||
|
final answer = find.text('Fixed the separators.');
|
||||||
|
expect(_left(tester, bubble), greaterThan(_left(tester, answer)));
|
||||||
|
expect(
|
||||||
|
_style(tester, 'Fixed the separators.').fontFamily,
|
||||||
|
isNot(paperSerifFamily),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Terminal is unchanged: prompt line and tool rows', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await tester.pumpWidget(_host(AppDesign.terminal, [_operator, _agent]));
|
||||||
|
expect(find.byType(TerminalPromptLine), findsOneWidget);
|
||||||
|
expect(find.byType(TerminalActivityRows), findsOneWidget);
|
||||||
|
expect(find.byType(PaperQuote), findsNothing);
|
||||||
|
expect(find.byType(PaperActivityNote), findsNothing);
|
||||||
|
expect(
|
||||||
|
_style(tester, 'Fixed the separators.').fontFamily,
|
||||||
|
appMonospaceFamily,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -91,4 +91,27 @@ void main() {
|
|||||||
expect(find.text(designSaveFailedText), findsOneWidget);
|
expect(find.text(designSaveFailedText), findsOneWidget);
|
||||||
expect(designs.design, AppDesign.terminal);
|
expect(designs.design, AppDesign.terminal);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('choosing Paper stores it, restyles the page live and is '
|
||||||
|
'restored on the next launch', (tester) async {
|
||||||
|
final store = MemoryAppDesignStore();
|
||||||
|
final designs = AppDesignController(store: store);
|
||||||
|
await _pump(tester, designs);
|
||||||
|
|
||||||
|
// Every row shows its design's swatch.
|
||||||
|
expect(
|
||||||
|
find.byType(DesignSwatchPreview),
|
||||||
|
findsNWidgets(AppDesign.values.length),
|
||||||
|
);
|
||||||
|
expect(find.text(AppDesign.paper.description), findsOneWidget);
|
||||||
|
await tester.tap(find.text(AppDesign.paper.label));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(store.id, 'paper');
|
||||||
|
expect(designs.design, AppDesign.paper);
|
||||||
|
expect(_tokens(tester).transcript, TranscriptStyle.manuscript);
|
||||||
|
|
||||||
|
final next = AppDesignController(store: MemoryAppDesignStore(store.id));
|
||||||
|
await next.restore();
|
||||||
|
expect(next.design, AppDesign.paper);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:pipelines_app/ui/layout/app_list_avatar.dart';
|
import 'package:pipelines_app/ui/layout/app_list_avatar.dart';
|
||||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||||
import 'package:pipelines_app/ui/layout/app_overflow_menu.dart';
|
import 'package:pipelines_app/ui/layout/app_overflow_menu.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/app_design.dart';
|
||||||
|
|
||||||
const _longTitle = 'A row title long enough that it must ellipsise somewhere';
|
const _longTitle = 'A row title long enough that it must ellipsise somewhere';
|
||||||
const _longLine = 'a muted line of facts that is far too long for one line';
|
const _longLine = 'a muted line of facts that is far too long for one line';
|
||||||
@@ -257,4 +258,63 @@ void main() {
|
|||||||
expect(_paint(tester, 'B').fontSize, 18);
|
expect(_paint(tester, 'B').fontSize, 18);
|
||||||
expect(_paint(tester, 'B').fontWeight, FontWeight.w700);
|
expect(_paint(tester, 'B').fontWeight, FontWeight.w700);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Each design marks the open row its own way (AppDesignTokens.selectedRow);
|
||||||
|
// every way keeps the leading bar in the accent.
|
||||||
|
for (final (design, framed, tonal) in [
|
||||||
|
(AppDesign.standard, false, true),
|
||||||
|
(AppDesign.terminal, true, false),
|
||||||
|
(AppDesign.paper, false, false),
|
||||||
|
]) {
|
||||||
|
testWidgets('${design.label}: the open row is clearly marked', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, 560);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
theme: design.light(),
|
||||||
|
home: Scaffold(body: ListView(children: [_row(selected: true)])),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final row = find.byKey(const Key('row'));
|
||||||
|
final context = tester.element(row);
|
||||||
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
final fill = tester
|
||||||
|
.widget<Material>(
|
||||||
|
find.descendant(
|
||||||
|
of: row,
|
||||||
|
matching: find.byKey(appListRowSurfaceKey),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.color!;
|
||||||
|
if (tonal) {
|
||||||
|
expect(fill, AppListRow.selectedColor(context));
|
||||||
|
} else {
|
||||||
|
// The accent washed over the page, visibly apart from it.
|
||||||
|
expect(fill, isNot(Theme.of(context).scaffoldBackgroundColor));
|
||||||
|
expect(fill.a, 1);
|
||||||
|
final page = Theme.of(context).scaffoldBackgroundColor;
|
||||||
|
expect(
|
||||||
|
(fill.computeLuminance() - page.computeLuminance()).abs(),
|
||||||
|
greaterThan(0.04),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final border =
|
||||||
|
(tester
|
||||||
|
.widget<DecoratedBox>(
|
||||||
|
find.descendant(
|
||||||
|
of: row,
|
||||||
|
matching: find.byKey(appListRowSelectionKey),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.decoration
|
||||||
|
as BoxDecoration)
|
||||||
|
.border!
|
||||||
|
as BorderDirectional;
|
||||||
|
expect(border.start.color, scheme.primary);
|
||||||
|
expect(border.start.width, kAppListRowBarWidth);
|
||||||
|
expect(border.top == BorderSide.none, !framed);
|
||||||
|
expect(border.end == BorderSide.none, !framed);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,177 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.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_tokens.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/paper_fonts.dart';
|
||||||
|
|
||||||
|
ThemeData _theme(AppDesign design, Brightness brightness, {String? font}) =>
|
||||||
|
brightness == Brightness.dark
|
||||||
|
? design.dark(fontFamily: font)
|
||||||
|
: design.light(fontFamily: font);
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('Paper is listed with a stable id, a label and one line', () {
|
||||||
|
expect(AppDesign.values, contains(AppDesign.paper));
|
||||||
|
expect(AppDesign.fromId('paper'), AppDesign.paper);
|
||||||
|
expect(AppDesign.paper.label, 'Paper');
|
||||||
|
expect(AppDesign.paper.description, isNot(contains('\n')));
|
||||||
|
expect(AppDesign.paper.usesInterfaceFont, isTrue);
|
||||||
|
expect(AppDesign.terminal.usesInterfaceFont, isFalse);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Paper tokens: manuscript transcript, underline composer, washed '
|
||||||
|
'row, serif reading at ~70ch, soft corners, hairlines', () {
|
||||||
|
for (final brightness in Brightness.values) {
|
||||||
|
final theme = _theme(AppDesign.paper, brightness);
|
||||||
|
final tokens = theme.extension<AppDesignTokens>()!;
|
||||||
|
expect(tokens.design, AppDesign.paper);
|
||||||
|
expect(tokens.transcript, TranscriptStyle.manuscript);
|
||||||
|
expect(tokens.terminal, isFalse);
|
||||||
|
expect(tokens.composer, ComposerStyle.underline);
|
||||||
|
expect(tokens.selectedRow, SelectedRowStyle.washed);
|
||||||
|
expect(tokens.reading.family, paperSerifFamily);
|
||||||
|
expect(tokens.reading.height, closeTo(1.5, 0.1));
|
||||||
|
expect(tokens.reading.measure, 70);
|
||||||
|
expect(tokens.radius, inInclusiveRange(8, 10));
|
||||||
|
expect(tokens.flat, isTrue);
|
||||||
|
expect(tokens.frame, theme.colorScheme.outlineVariant);
|
||||||
|
expect(tokens.panel, theme.colorScheme.surface);
|
||||||
|
expect(tokens.chatColorSaturation, lessThan(1));
|
||||||
|
expect(tokens.ansi, isNotNull);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Paper pages: warm off-white by day, sepia charcoal by night', () {
|
||||||
|
final light = _theme(AppDesign.paper, Brightness.light);
|
||||||
|
final page = light.scaffoldBackgroundColor;
|
||||||
|
expect(page.computeLuminance(), greaterThan(0.8));
|
||||||
|
expect(page, isNot(const Color(0xFFFFFFFF)));
|
||||||
|
expect(page.r, greaterThan(page.b), reason: 'a warm page');
|
||||||
|
final dark = _theme(AppDesign.paper, Brightness.dark);
|
||||||
|
final night = dark.scaffoldBackgroundColor;
|
||||||
|
expect(night.computeLuminance(), inExclusiveRange(0.008, 0.05));
|
||||||
|
expect(night.r, greaterThan(night.b), reason: 'sepia, not neutral');
|
||||||
|
for (final theme in [light, dark]) {
|
||||||
|
// Ink, a muted secondary ink and one accent.
|
||||||
|
final scheme = theme.colorScheme;
|
||||||
|
expect(scheme.onSurface, isNot(scheme.onSurfaceVariant));
|
||||||
|
expect(scheme.primary.b, greaterThan(scheme.primary.r));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Paper sets titles in the serif and keeps chrome in the interface '
|
||||||
|
'font', () {
|
||||||
|
for (final brightness in Brightness.values) {
|
||||||
|
final text = _theme(AppDesign.paper, brightness, font: 'Inter').textTheme;
|
||||||
|
for (final title in [
|
||||||
|
text.headlineSmall,
|
||||||
|
text.titleLarge,
|
||||||
|
text.displaySmall,
|
||||||
|
]) {
|
||||||
|
expect(title?.fontFamily, paperSerifFamily);
|
||||||
|
}
|
||||||
|
for (final chrome in [
|
||||||
|
text.labelLarge,
|
||||||
|
text.labelSmall,
|
||||||
|
text.titleMedium,
|
||||||
|
text.bodyMedium,
|
||||||
|
text.bodySmall,
|
||||||
|
]) {
|
||||||
|
expect(chrome?.fontFamily, 'Inter');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The reading style sets the serif over the body role and keeps the
|
||||||
|
// interface face as its fallback.
|
||||||
|
final paper = _theme(AppDesign.paper, Brightness.light, font: 'Inter');
|
||||||
|
final tokens = paper.extension<AppDesignTokens>()!;
|
||||||
|
const body = TextStyle(fontFamily: 'Inter', fontSize: 16);
|
||||||
|
final reading = tokens.reading.apply(body)!;
|
||||||
|
expect(reading.fontFamily, paperSerifFamily);
|
||||||
|
expect(reading.fontFamilyFallback, contains('Inter'));
|
||||||
|
expect(reading.height, tokens.reading.height);
|
||||||
|
expect(reading.fontSize, greaterThan(16));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Paper floats only menus and dialogs, by a whisper, in its corners', () {
|
||||||
|
final theme = _theme(AppDesign.paper, Brightness.light);
|
||||||
|
final radius = theme.extension<AppDesignTokens>()!.radius!;
|
||||||
|
expect(theme.cardTheme.elevation, 0);
|
||||||
|
expect(theme.appBarTheme.scrolledUnderElevation, 0);
|
||||||
|
expect(theme.floatingActionButtonTheme.elevation, 0);
|
||||||
|
expect(theme.dialogTheme.elevation, inInclusiveRange(1, 4));
|
||||||
|
expect(theme.popupMenuTheme.elevation, inInclusiveRange(1, 4));
|
||||||
|
expect(theme.dialogTheme.shadowColor!.a, lessThan(0.5));
|
||||||
|
for (final shape in [
|
||||||
|
theme.cardTheme.shape,
|
||||||
|
theme.dialogTheme.shape,
|
||||||
|
theme.popupMenuTheme.shape,
|
||||||
|
theme.chipTheme.shape,
|
||||||
|
theme.snackBarTheme.shape,
|
||||||
|
]) {
|
||||||
|
expect(
|
||||||
|
(shape! as RoundedRectangleBorder).borderRadius,
|
||||||
|
BorderRadius.circular(radius),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Controls the Default leaves to Material are Paper's own.
|
||||||
|
expect(theme.sliderTheme.trackHeight, 2);
|
||||||
|
expect(theme.sliderTheme.thumbShape, isA<RoundSliderThumbShape>());
|
||||||
|
expect(theme.badgeTheme.backgroundColor, theme.colorScheme.primary);
|
||||||
|
expect(theme.checkboxTheme.shape, isA<RoundedRectangleBorder>());
|
||||||
|
expect(theme.switchTheme.trackOutlineWidth, isNotNull);
|
||||||
|
expect(theme.tabBarTheme.indicator, isA<UnderlineTabIndicator>());
|
||||||
|
expect(theme.inputDecorationTheme.border, isA<UnderlineInputBorder>());
|
||||||
|
expect(theme.searchBarTheme.elevation?.resolve({}), 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the Default design is unchanged: no tokens, every style defaulted', () {
|
||||||
|
expect(AppDesign.standard.light(), appLightTheme());
|
||||||
|
expect(AppDesign.standard.dark(), appDarkTheme());
|
||||||
|
const tokens = AppDesignTokens.standard;
|
||||||
|
expect(tokens.transcript, TranscriptStyle.bubbles);
|
||||||
|
expect(tokens.composer, ComposerStyle.pill);
|
||||||
|
expect(tokens.selectedRow, SelectedRowStyle.tonal);
|
||||||
|
expect(tokens.reading.family, isNull);
|
||||||
|
expect(tokens.reading.measure, isNull);
|
||||||
|
expect(tokens.chatColorSaturation, 1);
|
||||||
|
expect(tokens.panel, isNull);
|
||||||
|
final style = const TextStyle(fontSize: 16, fontFamily: 'Inter');
|
||||||
|
expect(tokens.reading.apply(style), same(style));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Terminal is unchanged: prompt transcript, framed row, pill, its own '
|
||||||
|
'monospace and no reading type', () {
|
||||||
|
for (final brightness in Brightness.values) {
|
||||||
|
final theme = _theme(AppDesign.terminal, brightness, font: 'Inter');
|
||||||
|
final tokens = theme.extension<AppDesignTokens>()!;
|
||||||
|
expect(tokens.transcript, TranscriptStyle.prompt);
|
||||||
|
expect(tokens.terminal, isTrue);
|
||||||
|
expect(tokens.selectedRow, SelectedRowStyle.framed);
|
||||||
|
expect(tokens.composer, ComposerStyle.pill);
|
||||||
|
expect(tokens.reading.family, isNull);
|
||||||
|
expect(tokens.panel, isNull);
|
||||||
|
expect(tokens.chatColorSaturation, 1);
|
||||||
|
expect(tokens.radius, 3);
|
||||||
|
expect(theme.textTheme.bodyLarge?.fontFamily, appMonospaceFamily);
|
||||||
|
// A flat panel keeps Terminal's own low surface.
|
||||||
|
expect(
|
||||||
|
tokens.panelFill(theme.colorScheme, Colors.red),
|
||||||
|
theme.colorScheme.surfaceContainerLow,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('each design swatch matches its theme', () {
|
||||||
|
for (final design in AppDesign.values) {
|
||||||
|
for (final brightness in Brightness.values) {
|
||||||
|
final theme = _theme(design, brightness);
|
||||||
|
final swatch = design.swatch(brightness);
|
||||||
|
expect(swatch.page, theme.scaffoldBackgroundColor, reason: '$design');
|
||||||
|
expect(swatch.ink, theme.colorScheme.onSurface, reason: '$design');
|
||||||
|
expect(swatch.accent, theme.colorScheme.primary, reason: '$design');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"git.a-wan.net/alan/pipelines/internal/filediff"
|
"git.a-wan.net/alan/pipelines/internal/filediff"
|
||||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||||
|
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Per-turn chat diffs (protocol/chat_turn_diff.go). The hub snapshots the
|
// Per-turn chat diffs (protocol/chat_turn_diff.go). The hub snapshots the
|
||||||
@@ -193,6 +194,10 @@ func (h *chatHub) finishTurnDiff(sessionID string, capture *chatTurnCapture, end
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
changes := filediff.Compare(capture.baseline, after)
|
changes := filediff.Compare(capture.baseline, after)
|
||||||
|
// The harness's own home inside the folder (CLAUDE_CONFIG_DIR, e.g. a
|
||||||
|
// per-project .claude-profile) changes on every turn; it is not the
|
||||||
|
// operator's work.
|
||||||
|
changes = withoutHarnessState(changes, capture.dir, stage.HarnessStateDirs(workspaceEnv(ctx, capture.dir)))
|
||||||
summary, ok := chatTurnDiffSummary(capture, ended, changes)
|
summary, ok := chatTurnDiffSummary(capture, ended, changes)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
@@ -292,3 +297,36 @@ func handleChatTurnDiff(ctx context.Context, request protocol.Message, hub *chat
|
|||||||
Changes: &changes,
|
Changes: &changes,
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// withoutHarnessState drops the files under any of dirs that lie inside
|
||||||
|
// workspace; the rest of changes is kept as it was.
|
||||||
|
func withoutHarnessState(changes *protocol.StageFileChanges, workspace string, dirs []string) *protocol.StageFileChanges {
|
||||||
|
if changes == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var prefixes []string
|
||||||
|
for _, dir := range dirs {
|
||||||
|
if rel, ok := workspaceRelative(workspace, dir); ok && rel != "." {
|
||||||
|
prefixes = append(prefixes, rel+"/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(prefixes) == 0 {
|
||||||
|
return changes
|
||||||
|
}
|
||||||
|
kept := changes.Files[:0:0]
|
||||||
|
for _, file := range changes.Files {
|
||||||
|
inside := false
|
||||||
|
for _, prefix := range prefixes {
|
||||||
|
if strings.HasPrefix(file.Path+"/", prefix) {
|
||||||
|
inside = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !inside {
|
||||||
|
kept = append(kept, file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
filtered := *changes
|
||||||
|
filtered.Files = kept
|
||||||
|
return &filtered
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestTurnDiffDropsTheHarnessHomeInsideTheFolder(t *testing.T) {
|
||||||
|
changes := &protocol.StageFileChanges{Status: "complete", Files: []protocol.FileChange{
|
||||||
|
{Path: ".claude-profile/.claude.json"},
|
||||||
|
{Path: ".claude-profile/projects/x/1.jsonl"},
|
||||||
|
{Path: ".claude-profile-notes.md"},
|
||||||
|
{Path: "src/app.py"},
|
||||||
|
}}
|
||||||
|
got := withoutHarnessState(changes, "/w/caplens", []string{"/w/caplens/.claude-profile", "/home/me/.claude"})
|
||||||
|
if len(got.Files) != 2 || got.Files[0].Path != ".claude-profile-notes.md" || got.Files[1].Path != "src/app.py" {
|
||||||
|
t.Fatalf("files = %+v", got.Files)
|
||||||
|
}
|
||||||
|
if len(changes.Files) != 4 {
|
||||||
|
t.Fatalf("input changed: %+v", changes.Files)
|
||||||
|
}
|
||||||
|
if same := withoutHarnessState(changes, "/w/caplens", []string{"/home/me/.claude"}); same != changes {
|
||||||
|
t.Fatal("no harness dir inside the folder should keep the changes as they are")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user