fix: range error on chat drawer
This commit is contained in:
@@ -442,8 +442,11 @@ final conversationsProvider = FutureProvider<List<Conversation>>((ref) async {
|
|||||||
conversationMap[conversation.id] = conversation.copyWith(
|
conversationMap[conversation.id] = conversation.copyWith(
|
||||||
folderId: folderIdToUse,
|
folderId: folderIdToUse,
|
||||||
);
|
);
|
||||||
|
final _idPreview = conversation.id.length > 8
|
||||||
|
? conversation.id.substring(0, 8)
|
||||||
|
: conversation.id;
|
||||||
foundation.debugPrint(
|
foundation.debugPrint(
|
||||||
'DEBUG: Updated conversation ${conversation.id.substring(0, 8)} with folderId: $folderIdToUse (explicit: ${explicitFolderId != null})',
|
'DEBUG: Updated conversation $_idPreview with folderId: $folderIdToUse (explicit: ${explicitFolderId != null})',
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
conversationMap[conversation.id] = conversation;
|
conversationMap[conversation.id] = conversation;
|
||||||
@@ -505,8 +508,11 @@ final conversationsProvider = FutureProvider<List<Conversation>>((ref) async {
|
|||||||
// Use map to prevent duplicates - this will overwrite if ID already exists
|
// Use map to prevent duplicates - this will overwrite if ID already exists
|
||||||
conversationMap[toAdd.id] = toAdd;
|
conversationMap[toAdd.id] = toAdd;
|
||||||
existingIds.add(toAdd.id);
|
existingIds.add(toAdd.id);
|
||||||
|
final _idPreview = toAdd.id.length > 8
|
||||||
|
? toAdd.id.substring(0, 8)
|
||||||
|
: toAdd.id;
|
||||||
foundation.debugPrint(
|
foundation.debugPrint(
|
||||||
'DEBUG: Added missing conversation from folder fetch: ${toAdd.id.substring(0, 8)} -> folder ${folder.id}',
|
'DEBUG: Added missing conversation from folder fetch: $_idPreview -> folder ${folder.id}',
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Create a minimal placeholder if not returned by folder API
|
// Create a minimal placeholder if not returned by folder API
|
||||||
@@ -521,8 +527,11 @@ final conversationsProvider = FutureProvider<List<Conversation>>((ref) async {
|
|||||||
// Use map to prevent duplicates
|
// Use map to prevent duplicates
|
||||||
conversationMap[convId] = placeholder;
|
conversationMap[convId] = placeholder;
|
||||||
existingIds.add(convId);
|
existingIds.add(convId);
|
||||||
|
final _idPreview = convId.length > 8
|
||||||
|
? convId.substring(0, 8)
|
||||||
|
: convId;
|
||||||
foundation.debugPrint(
|
foundation.debugPrint(
|
||||||
'DEBUG: Added placeholder conversation for missing ID: ${convId.substring(0, 8)} -> folder ${folder.id}',
|
'DEBUG: Added placeholder conversation for missing ID: $_idPreview -> folder ${folder.id}',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -417,9 +417,11 @@ class ApiService {
|
|||||||
debugPrint(
|
debugPrint(
|
||||||
'🔍 DEBUG: Sample chat data fields: ${chatData.keys.toList()}',
|
'🔍 DEBUG: Sample chat data fields: ${chatData.keys.toList()}',
|
||||||
);
|
);
|
||||||
debugPrint(
|
final _sampleStr = chatData.toString();
|
||||||
'🔍 DEBUG: Sample chat data: ${chatData.toString().substring(0, 200)}...',
|
final _preview = _sampleStr.length > 200
|
||||||
);
|
? _sampleStr.substring(0, 200)
|
||||||
|
: _sampleStr;
|
||||||
|
debugPrint('🔍 DEBUG: Sample chat data: $_preview...');
|
||||||
}
|
}
|
||||||
|
|
||||||
final conversation = _parseOpenWebUIChat(chatData);
|
final conversation = _parseOpenWebUIChat(chatData);
|
||||||
@@ -498,9 +500,8 @@ class ApiService {
|
|||||||
|
|
||||||
// Debug logging for folder assignment
|
// Debug logging for folder assignment
|
||||||
if (folderId != null) {
|
if (folderId != null) {
|
||||||
debugPrint(
|
final _idPreview = id.length > 8 ? id.substring(0, 8) : id;
|
||||||
'🔍 DEBUG: Conversation ${id.substring(0, 8)} has folderId: $folderId',
|
debugPrint('🔍 DEBUG: Conversation $_idPreview has folderId: $folderId');
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint(
|
debugPrint(
|
||||||
@@ -3020,9 +3021,11 @@ class ApiService {
|
|||||||
} else if (response.data is Map) {
|
} else if (response.data is Map) {
|
||||||
DebugLogger.log(' Object keys: ${(response.data as Map).keys}');
|
DebugLogger.log(' Object keys: ${(response.data as Map).keys}');
|
||||||
}
|
}
|
||||||
DebugLogger.log(
|
final _dataStr = response.data.toString();
|
||||||
' Sample data: ${response.data.toString().substring(0, 200)}...',
|
final _dataPreview = _dataStr.length > 200
|
||||||
);
|
? _dataStr.substring(0, 200)
|
||||||
|
: _dataStr;
|
||||||
|
DebugLogger.log(' Sample data: $_dataPreview...');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('❌ $endpoint - Error: $e');
|
debugPrint('❌ $endpoint - Error: $e');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,23 +198,32 @@ class _ChatsDrawerState extends ConsumerState<ChatsDrawer> {
|
|||||||
|
|
||||||
// Build sections
|
// Build sections
|
||||||
final pinned = list.where((c) => c.pinned == true).toList();
|
final pinned = list.where((c) => c.pinned == true).toList();
|
||||||
final regular = list
|
|
||||||
.where(
|
// Determine which folder IDs actually exist from the API
|
||||||
(c) =>
|
final foldersState = ref.watch(foldersProvider);
|
||||||
c.pinned != true &&
|
final availableFolderIds = foldersState.maybeWhen(
|
||||||
c.archived != true &&
|
data: (folders) => folders.map((f) => f.id).toSet(),
|
||||||
(c.folderId == null || c.folderId!.isEmpty),
|
orElse: () => <String>{},
|
||||||
)
|
);
|
||||||
.toList();
|
|
||||||
final foldered = list
|
// Conversations that reference a non-existent/unknown folder should not disappear.
|
||||||
.where(
|
// Treat those as regular until the folders list is available and contains the ID.
|
||||||
(c) =>
|
final regular = list.where((c) {
|
||||||
c.pinned != true &&
|
final hasFolder = (c.folderId != null && c.folderId!.isNotEmpty);
|
||||||
c.archived != true &&
|
final folderKnown = hasFolder && availableFolderIds.contains(c.folderId);
|
||||||
c.folderId != null &&
|
return c.pinned != true &&
|
||||||
c.folderId!.isNotEmpty,
|
c.archived != true &&
|
||||||
)
|
(!hasFolder || !folderKnown);
|
||||||
.toList();
|
}).toList();
|
||||||
|
|
||||||
|
final foldered = list.where((c) {
|
||||||
|
final hasFolder = (c.folderId != null && c.folderId!.isNotEmpty);
|
||||||
|
return c.pinned != true &&
|
||||||
|
c.archived != true &&
|
||||||
|
hasFolder &&
|
||||||
|
availableFolderIds.contains(c.folderId);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
final archived = list.where((c) => c.archived == true).toList();
|
final archived = list.where((c) => c.archived == true).toList();
|
||||||
|
|
||||||
return Scrollbar(
|
return Scrollbar(
|
||||||
@@ -342,23 +351,30 @@ class _ChatsDrawerState extends ConsumerState<ChatsDrawer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final pinned = list.where((c) => c.pinned == true).toList();
|
final pinned = list.where((c) => c.pinned == true).toList();
|
||||||
final regular = list
|
|
||||||
.where(
|
// For search results, apply the same folder safety logic
|
||||||
(c) =>
|
final foldersState = ref.watch(foldersProvider);
|
||||||
c.pinned != true &&
|
final availableFolderIds = foldersState.maybeWhen(
|
||||||
c.archived != true &&
|
data: (folders) => folders.map((f) => f.id).toSet(),
|
||||||
(c.folderId == null || c.folderId!.isEmpty),
|
orElse: () => <String>{},
|
||||||
)
|
);
|
||||||
.toList();
|
|
||||||
final foldered = list
|
final regular = list.where((c) {
|
||||||
.where(
|
final hasFolder = (c.folderId != null && c.folderId!.isNotEmpty);
|
||||||
(c) =>
|
final folderKnown = hasFolder && availableFolderIds.contains(c.folderId);
|
||||||
c.pinned != true &&
|
return c.pinned != true &&
|
||||||
c.archived != true &&
|
c.archived != true &&
|
||||||
c.folderId != null &&
|
(!hasFolder || !folderKnown);
|
||||||
c.folderId!.isNotEmpty,
|
}).toList();
|
||||||
)
|
|
||||||
.toList();
|
final foldered = list.where((c) {
|
||||||
|
final hasFolder = (c.folderId != null && c.folderId!.isNotEmpty);
|
||||||
|
return c.pinned != true &&
|
||||||
|
c.archived != true &&
|
||||||
|
hasFolder &&
|
||||||
|
availableFolderIds.contains(c.folderId);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
final archived = list.where((c) => c.archived == true).toList();
|
final archived = list.where((c) => c.archived == true).toList();
|
||||||
|
|
||||||
return Scrollbar(
|
return Scrollbar(
|
||||||
|
|||||||
1
vendor/open-webui
vendored
Submodule
1
vendor/open-webui
vendored
Submodule
Submodule vendor/open-webui added at 2407d9b905
Reference in New Issue
Block a user