Show a chat turn's changed files as a chip that opens its diff

The answer footer shows '3 files changed +9 -2'; tapping opens the turn's
files in the sheet (wide) or a full-screen page (narrow), and a file opens
the run Changes diff viewer. Patches load through the chat's own gateway.
This commit is contained in:
2026-11-09 16:08:35 +00:00
parent 0696ab849a
commit 3374bea2ef
15 changed files with 1155 additions and 36 deletions
@@ -13,16 +13,22 @@ class ChatTurnChip extends StatelessWidget {
required this.label,
required this.color,
required this.semanticsLabel,
required this.sheet,
this.sheet,
this.open,
this.ellipsizeLabel = false,
});
}) : assert(sheet != null || open != null);
final Key chipKey;
final Widget leading;
final String label;
final Color color;
final String semanticsLabel;
final Widget sheet;
/// The native sheet the chip opens, unless [open] presents it instead.
final Widget? sheet;
/// A custom presentation (a full-screen route on a narrow window).
final Future<void> Function(BuildContext context, bool cupertino)? open;
/// Shrink a long label to one ellipsized line. Only for a chip whose parent
/// bounds its width (a turn footer's Wrap, an aligned row).
@@ -89,18 +95,29 @@ class ChatTurnChip extends StatelessWidget {
);
Future<void> _open(BuildContext context, bool cupertino) {
if (cupertino) {
return showCupertinoModalPopup<void>(
context: context,
builder: (_) => CupertinoPopupSurface(child: SafeArea(child: sheet)),
);
}
return showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
showDragHandle: true,
useSafeArea: true,
builder: (_) => sheet,
);
if (open case final open?) return open(context, cupertino);
return showChatTurnSheet(context, cupertino, sheet!);
}
}
/// The native sheet a turn chip opens: a Cupertino popup surface or a
/// Material modal bottom sheet.
Future<void> showChatTurnSheet(
BuildContext context,
bool cupertino,
Widget sheet,
) {
if (cupertino) {
return showCupertinoModalPopup<void>(
context: context,
builder: (_) => CupertinoPopupSurface(child: SafeArea(child: sheet)),
);
}
return showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
showDragHandle: true,
useSafeArea: true,
builder: (_) => sheet,
);
}