Keep Cupertino chat summaries and contextual prompts readable

This commit is contained in:
2026-11-07 21:07:55 +00:00
parent b9332dda0a
commit bbcfcd32a2
4 changed files with 201 additions and 4 deletions
@@ -1129,8 +1129,10 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
placeholder: widget.placeholder,
// The pill draws the field's surface; the field adds no border.
decoration: null,
placeholderStyle: const TextStyle(
color: CupertinoColors.placeholderText,
// The contextual prompt must stay readable on the glass fill;
// placeholderText falls below normal-text contrast here.
placeholderStyle: TextStyle(
color: CupertinoColors.label.resolveFrom(context),
overflow: TextOverflow.ellipsis,
),
minLines: lines,
@@ -105,7 +105,14 @@ class _ChatAgentReportCardState extends State<ChatAgentReportCard> {
(cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.bodyMedium)
?.copyWith(color: secondary),
?.copyWith(
// This summary is readable content, not disabled
// chrome; translucent secondaryLabel falls below
// normal-text contrast on a light card.
color: cupertino
? CupertinoColors.label.resolveFrom(context)
: secondary,
),
),
],
),
@@ -215,7 +222,11 @@ class ChatSystemNoticeLine extends StatelessWidget {
(cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.bodySmall)
?.copyWith(color: color);
?.copyWith(
color: cupertino
? CupertinoColors.label.resolveFrom(context)
: color,
);
return Semantics(
container: true,
label: 'System notice',
+37
View File
@@ -0,0 +1,37 @@
# Bounded Cupertino chat text contrast follow-up
The reviewed light screenshot showed meaningful report summaries, completion
notices and contextual composer prompts rendered like inactive text. Resolved
native colors confirmed this was more than a screenshot impression:
| Named state / standard surface | Before | After |
| --- | ---: | ---: |
| Light report summary on native report-card fill | 3.44:1 | 21.00:1 |
| Light completion notice on native page fill | 3.44:1 | 21.00:1 |
| Light contextual placeholder on normal glass | 1.68:1 | 17.45:1 |
| Dark report summary on native report-card fill | 5.95:1 | 17.01:1 |
| Dark contextual placeholder on normal glass | 2.45:1 | 15.48:1 |
Ratios use resolved dynamic colors and alpha-composite text over the actual
native surface role before calculating relative luminance. In light high-
contrast mode the old secondaryLabel variant measured4.23:1 on the report
surface, still below4.5 for normal-sized copy; the new native label role is21:1.
Normal glass calculations compose systemGrey5 at GlassPill.fillOpacity over
the page; tests also cover solid high-contrast fill, highlight and white/black
backdrop bounds. This is a bounded color-role check, not pixel measurement,
a complete contrast audit, or a claim covering all states/backdrops.
Only the three named readable text states move to CupertinoColors.label.
Material roles, disabled Send, decorative icons, focus indication, typography,
opacity/blur design and selection behavior are unchanged. In particular the
report's metadata hierarchy remains through layout/typography and muted icons;
the contextual placeholder is still a native placeholder that disappears on
input, rather than user-entered content.
25 contrast/report/notice/composer-placeholder/focus tests passed in4s,
peak1539MB (/tmp/memwatch/out.oozXZt), including both brightnesses, dynamic
high-contrast report/notice roles and2x text. Analyzer clean
(flutter-analyze.irwu1w). Initial test compile had a nullable placeholderStyle
access; corrected before the successful run. Browser review of the integrated
Cupertino light state remains with the parent; no production mutation/device
work or publication happened in this lane.
@@ -0,0 +1,147 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_injected_rows.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/glass_surface.dart';
import 'chat_composer_bar_fixtures.dart';
// Contrast uses the rendered/composited foreground, not the RGB of an alpha
// system color as though it were opaque. These assertions cover only these
// named text states/surfaces, not the whole app or every possible backdrop.
double _contrast(Color foreground, Color background) {
final ink = Color.alphaBlend(foreground, background).computeLuminance();
final paper = background.computeLuminance();
return (ink > paper ? ink + .05 : paper + .05) /
(ink > paper ? paper + .05 : ink + .05);
}
const _report = {
'message': {
'parts': [
{'type': 'text', 'text': 'Report summary', 'name': 'reviewer'},
],
},
};
const _notice = {
'message': {
'parts': [
{'type': 'text', 'text': 'Background task finished'},
],
},
};
void main() {
for (final brightness in Brightness.values) {
for (final highContrast in [false, true]) {
testWidgets(
'report and completion text contrast $brightness highContrast=$highContrast',
(tester) async {
await tester.pumpWidget(
CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
builder: (context, child) => MediaQuery(
data: MediaQuery.of(context).copyWith(
highContrast: highContrast,
textScaler: const TextScaler.linear(2),
),
child: child!,
),
home: const CupertinoPageScaffold(
child: Column(
children: [
ChatAgentReportCard(row: _report),
ChatSystemNoticeLine(row: _notice),
],
),
),
),
);
await tester.pumpAndSettle();
final context = tester.element(find.byType(ChatAgentReportCard));
final card = CupertinoColors.secondarySystemGroupedBackground
.resolveFrom(context);
final page = CupertinoTheme.of(context).scaffoldBackgroundColor;
final summary = tester.widget<Text>(find.text('Report summary'));
final notice = tester.widget<Text>(
find.text('Background task finished'),
);
expect(
_contrast(summary.style!.color!, card),
greaterThanOrEqualTo(4.5),
);
expect(
_contrast(notice.style!.color!, page),
greaterThanOrEqualTo(4.5),
);
debugPrint(
'contrast $brightness highContrast=$highContrast report=${_contrast(summary.style!.color!, card).toStringAsFixed(2)} notice=${_contrast(notice.style!.color!, page).toStringAsFixed(2)} oldSecondary=${_contrast(CupertinoColors.secondaryLabel.resolveFrom(context), card).toStringAsFixed(2)}',
);
expect(tester.takeException(), isNull);
},
);
}
testWidgets(
'contextual placeholder stays readable on the glass fill $brightness',
(tester) async {
final gateway = ComposerBarGateway();
addTearDown(gateway.close);
await tester.pumpWidget(
CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: CupertinoPageScaffold(
child: ChatThreadView(
gateway: gateway,
sessionId: 's',
onBack: () {},
),
),
),
);
await tester.pumpAndSettle();
final field = tester.widget<CupertinoTextField>(
find.byType(CupertinoTextField),
);
final context = tester.element(find.byType(CupertinoTextField));
final base = CupertinoColors.systemGrey5.resolveFrom(context);
final backdrop = CupertinoTheme.of(context).scaffoldBackgroundColor;
final glass = Color.alphaBlend(
base.withValues(alpha: GlassPill.fillOpacity),
backdrop,
);
final highlighted = Color.alphaBlend(
GlassLook.forFill(base).highlight,
glass,
);
final foreground = CupertinoDynamicColor.resolve(
field.placeholderStyle!.color!,
context,
);
// White/black backdrop bounds also cover arbitrary blurred content
// below the 82% native fill. High-contrast mode uses solid base.
final backdropBounds = [
const Color(0xFF000000),
const Color(0xFFFFFFFF),
];
final boundedFills = [
for (final background in backdropBounds)
Color.alphaBlend(
base.withValues(alpha: GlassPill.fillOpacity),
background,
),
];
for (final fill in [base, glass, highlighted, ...boundedFills]) {
expect(_contrast(foreground, fill), greaterThanOrEqualTo(4.5));
}
debugPrint(
'contrast $brightness placeholder=${_contrast(foreground, glass).toStringAsFixed(2)} oldPlaceholder=${_contrast(CupertinoColors.placeholderText.resolveFrom(context), glass).toStringAsFixed(2)} glass=${glass.toARGB32().toRadixString(16)}',
);
expect(
field.placeholderStyle!.color,
CupertinoColors.label.resolveFrom(context),
);
expect(tester.takeException(), isNull);
},
);
}
}