This commit is contained in:
@@ -58,6 +58,37 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
||||
_inputFocusNode.requestFocus();
|
||||
}
|
||||
|
||||
Future<void> _createPlanFromMessage(
|
||||
ChatController controller,
|
||||
String content,
|
||||
) async {
|
||||
// Simple progress dialog — extraction is a second LLM round-trip.
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => const Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
try {
|
||||
final name = await controller.createPlanFromText(content);
|
||||
if (!mounted) return;
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Plan "$name" created — find it under Trainings.'),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Could not create a plan: $e'),
|
||||
backgroundColor: AppColors.surfaceContainerHigh,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _formatTimestamp(String timestamp) {
|
||||
try {
|
||||
final dt = DateTime.parse(timestamp);
|
||||
@@ -306,6 +337,9 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
||||
return MessageBubble(
|
||||
message: msg,
|
||||
formattedTime: _formatTimestamp(msg.createdAt),
|
||||
onCreatePlan: msg.isUser
|
||||
? null
|
||||
: () => _createPlanFromMessage(controller, msg.content),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user