diff --git a/app/lib/features/chat/conversation/chat_composer_bar.dart b/app/lib/features/chat/conversation/chat_composer_bar.dart index 63035ed5..7ae068e0 100644 --- a/app/lib/features/chat/conversation/chat_composer_bar.dart +++ b/app/lib/features/chat/conversation/chat_composer_bar.dart @@ -1129,8 +1129,10 @@ class _ChatComposerBarState extends State { 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, diff --git a/app/lib/features/chat/ui/transcript/chat_injected_rows.dart b/app/lib/features/chat/ui/transcript/chat_injected_rows.dart index 2283da73..82dd9896 100644 --- a/app/lib/features/chat/ui/transcript/chat_injected_rows.dart +++ b/app/lib/features/chat/ui/transcript/chat_injected_rows.dart @@ -105,7 +105,14 @@ class _ChatAgentReportCardState extends State { (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', diff --git a/app/notes/cupertino-chat-readable-text.md b/app/notes/cupertino-chat-readable-text.md new file mode 100644 index 00000000..4e2ff06e --- /dev/null +++ b/app/notes/cupertino-chat-readable-text.md @@ -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. diff --git a/app/test/features/chat/conversation/chat_cupertino_readable_text_test.dart b/app/test/features/chat/conversation/chat_cupertino_readable_text_test.dart new file mode 100644 index 00000000..df61f733 --- /dev/null +++ b/app/test/features/chat/conversation/chat_cupertino_readable_text_test.dart @@ -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(find.text('Report summary')); + final notice = tester.widget( + 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( + 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); + }, + ); + } +}