import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../sessions/chat_adaptive.dart'; import 'native_disclosure.dart'; /// Only reasoning actually supplied by the backend. Keeping its body in the /// transcript (rather than a modal snapshot) lets an open disclosure rebuild /// with every delta, even while answer text is also arriving. class ChatReasoningDisclosure extends StatelessWidget { const ChatReasoningDisclosure({ super.key, required this.steps, required this.streaming, }); final List steps; final bool streaming; @override Widget build(BuildContext context) { final cupertino = chatControlsStyleOf(context) == ChatControlsStyle.cupertino; final label = steps.length == 1 ? 'Reasoning' : 'Reasoning ยท ${steps.length} steps'; final disclosure = NativeDisclosure( key: const Key('chat-reasoning-disclosure'), label: label, initiallyExpanded: streaming, childBuilder: (_) => Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ for (final (index, step) in steps.indexed) Padding( padding: EdgeInsets.only(top: index == 0 ? 0 : 12, bottom: 8), child: SelectableText(step), ), ], ), ); // Material's native ExpansionTile needs a surface; Cupertino must not // acquire a Material dependency just to show its own disclosure button. return DefaultTextStyle.merge( style: cupertino ? CupertinoTheme.of(context).textTheme.textStyle : Theme.of(context).textTheme.bodyMedium, child: cupertino ? disclosure : Material(color: Colors.transparent, child: disclosure), ); } }