Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
71 lines
2.1 KiB
Dart
71 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:cutdex_ui/theme.dart';
|
|
|
|
import '../../l10n/l10n.dart';
|
|
import 'chat_controller.dart';
|
|
import 'chat_state.dart';
|
|
|
|
/// Streaming output observes its conversation independently of history/composer.
|
|
class AgentReplyRegion extends ConsumerWidget {
|
|
const AgentReplyRegion({
|
|
super.key,
|
|
required this.projectId,
|
|
this.conversationId,
|
|
this.draftKey,
|
|
});
|
|
|
|
final String? projectId;
|
|
final String? conversationId;
|
|
final String? draftKey;
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
if (projectId == null) return const SizedBox.shrink();
|
|
final provider =
|
|
chatControllerProvider(
|
|
projectId!,
|
|
conversationId: conversationId,
|
|
draftKey: draftKey,
|
|
).select(
|
|
(state) => (
|
|
state.busy,
|
|
state.partialResponse,
|
|
state.stopping,
|
|
state.activity,
|
|
),
|
|
);
|
|
final state = TickerMode.valuesOf(context).enabled
|
|
? ref.watch(provider)
|
|
: ref.read(provider);
|
|
if (!state.$1) return const SizedBox.shrink();
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
if (state.$2.isNotEmpty)
|
|
SelectionArea(
|
|
child: Text(
|
|
state.$2,
|
|
style: AppTheme.chatMessageTextStyle(context),
|
|
),
|
|
),
|
|
Text(
|
|
state.$3
|
|
? context.l10n.stopping
|
|
: switch (state.$4) {
|
|
AgentChatActivity.compacting => context.l10n.agentCompacting,
|
|
AgentChatActivity.editing => context.l10n.agentEditing,
|
|
AgentChatActivity.verifying => context.l10n.agentVerifying,
|
|
AgentChatActivity.replying => context.l10n.replying,
|
|
},
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Stable chrome/history snapshot; each streamed token belongs to reply region.
|
|
ChatState chatChrome(ChatState state) =>
|
|
state.copyWith(partialResponse: '', activity: AgentChatActivity.replying);
|