From 2088d4607e46cd61091045f2a58aa8d3d95e57bb Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 21 Oct 2026 21:12:50 +0100 Subject: [PATCH] fix(app): preserve unknown user parts and native transcript typography --- .../chat/ui/transcript/chat_message_view.dart | 12 +++--- app/notes/C2-message.md | 6 +++ .../chat_unknown_user_part_test.dart | 43 +++++++++++++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 app/test/features/chat/ui/transcript/chat_unknown_user_part_test.dart diff --git a/app/lib/features/chat/ui/transcript/chat_message_view.dart b/app/lib/features/chat/ui/transcript/chat_message_view.dart index 1c318e12..953da8b4 100644 --- a/app/lib/features/chat/ui/transcript/chat_message_view.dart +++ b/app/lib/features/chat/ui/transcript/chat_message_view.dart @@ -11,7 +11,7 @@ import 'native_disclosure.dart'; typedef ChatMessageTextBuilder = Widget Function(BuildContext, String); /// One `transcriptRows` row: a user message or one folded agent turn. Parts keep -/// order; reasoning/tool bodies are native disclosures and unknown parts keep raw JSON. +/// order for agent turns; native disclosures retain unknown parts as raw JSON. class ChatMessageView extends StatelessWidget { const ChatMessageView({super.key, required this.row, this.textBuilder}); @@ -56,10 +56,7 @@ class ChatMessageView extends StatelessWidget { (cupertino ? CupertinoTheme.of(context).textTheme.textStyle : Theme.of(context).textTheme.labelLarge) - ?.copyWith( - fontWeight: FontWeight.w600, - color: _secondaryColor(context, cupertino), - ); + ?.copyWith(color: _secondaryColor(context, cupertino)); Color _secondaryColor(BuildContext context, bool cupertino) => cupertino ? CupertinoColors.secondaryLabel.resolveFrom(context) @@ -80,6 +77,11 @@ class ChatMessageView extends StatelessWidget { final widgets = [ if (text.trim().isNotEmpty) SelectableText(text), for (final part in parts.where(_isFile)) _attachment(context, part), + for (final part in parts) + if (part['type'] != 'text' && + !_isFile(part) && + !(part['type'] == null && part['text'] is String)) + _unrecognised(part), ]; final client = '${message['client'] ?? ''}'.trim(); if (client.isNotEmpty) { diff --git a/app/notes/C2-message.md b/app/notes/C2-message.md index 18f7d3f9..515b6c9f 100644 --- a/app/notes/C2-message.md +++ b/app/notes/C2-message.md @@ -1,5 +1,11 @@ # C2 message — one native transcript row +Manager integration follow-up: role labels keep the host's own weight rather +than forcing w600. Unknown user parts now also retain a native raw disclosure; +they are not silently dropped while assistant unknown parts remain available. +The added focused regression checks native label weight and exact unknown user +data after opening its disclosure. Full conversation integration remains separate. + The first transcript slice renders one row already produced by `transcriptRows` (`lib/features/chat/domain/chat_transcript.dart`). It is a pure widget with no gateway, history, network, composer, shell or chat-screen wiring. diff --git a/app/test/features/chat/ui/transcript/chat_unknown_user_part_test.dart b/app/test/features/chat/ui/transcript/chat_unknown_user_part_test.dart new file mode 100644 index 00000000..4b66bdd1 --- /dev/null +++ b/app/test/features/chat/ui/transcript/chat_unknown_user_part_test.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/chat/ui/transcript/chat_message_view.dart'; + +void main() { + testWidgets( + 'unknown user parts remain available without overriding native label weight', + (tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: ChatMessageView( + row: { + 'kind': 'user', + 'message': { + 'role': 'user', + 'parts': [ + {'type': 'text', 'text': 'Recorded user text'}, + { + 'type': 'future-content', + 'future_value': 'preserved exactly', + }, + ], + }, + }, + ), + ), + ), + ); + final label = tester.widget(find.text('User')); + expect( + label.style!.fontWeight, + Theme.of( + tester.element(find.byType(ChatMessageView)), + ).textTheme.labelLarge!.fontWeight, + ); + expect(find.text('Recorded user text'), findsOneWidget); + await tester.tap(find.text('Unrecognised part: future-content')); + await tester.pumpAndSettle(); + expect(find.textContaining('preserved exactly'), findsOneWidget); + }, + ); +}