refactor: action buttons and scroll to bottom ui/ux
This commit is contained in:
@@ -115,7 +115,19 @@ abstract class OutboundTask with _$OutboundTask {
|
||||
factory OutboundTask.fromJson(Map<String, dynamic> json) =>
|
||||
_$OutboundTaskFromJson(json);
|
||||
|
||||
String get threadKey => (conversationId == null || conversationId!.isEmpty)
|
||||
? 'new'
|
||||
: conversationId!;
|
||||
// Provide a unified nullable conversationId across variants
|
||||
String? get maybeConversationId => map(
|
||||
sendTextMessage: (t) => t.conversationId,
|
||||
uploadMedia: (t) => t.conversationId,
|
||||
executeToolCall: (t) => t.conversationId,
|
||||
generateImage: (t) => t.conversationId,
|
||||
saveConversation: (t) => t.conversationId,
|
||||
generateTitle: (t) => t.conversationId,
|
||||
imageToDataUrl: (t) => t.conversationId,
|
||||
);
|
||||
|
||||
String get threadKey =>
|
||||
(maybeConversationId == null || maybeConversationId!.isEmpty)
|
||||
? 'new'
|
||||
: maybeConversationId!;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class TaskQueueNotifier extends StateNotifier<List<OutboundTask>> {
|
||||
Future<void> cancelByConversation(String conversationId) async {
|
||||
state = [
|
||||
for (final t in state)
|
||||
if ((t.conversationId ?? '') == conversationId &&
|
||||
if ((t.maybeConversationId ?? '') == conversationId &&
|
||||
(t.status == TaskStatus.queued || t.status == TaskStatus.running))
|
||||
t.copyWith(
|
||||
status: TaskStatus.cancelled,
|
||||
|
||||
@@ -343,9 +343,13 @@ class TaskWorker {
|
||||
final b64 = base64Encode(bytes);
|
||||
final ext = path.extension(task.fileName).toLowerCase();
|
||||
String mime = 'image/png';
|
||||
if (ext == '.jpg' || ext == '.jpeg') mime = 'image/jpeg';
|
||||
else if (ext == '.gif') mime = 'image/gif';
|
||||
else if (ext == '.webp') mime = 'image/webp';
|
||||
if (ext == '.jpg' || ext == '.jpeg') {
|
||||
mime = 'image/jpeg';
|
||||
} else if (ext == '.gif') {
|
||||
mime = 'image/gif';
|
||||
} else if (ext == '.webp') {
|
||||
mime = 'image/webp';
|
||||
}
|
||||
final dataUrl = 'data:$mime;base64,$b64';
|
||||
|
||||
// Mark as completed with data URL as fileId
|
||||
|
||||
Reference in New Issue
Block a user