Skip to content

Commit 9844fed

Browse files
committed
chore: Linting
1 parent e38c455 commit 9844fed

File tree

3 files changed

+37
-28
lines changed

3 files changed

+37
-28
lines changed

tools/server/webui/src/lib/components/app/chat/ChatSidebar/ChatSidebarActions.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,13 @@
8282
<Button
8383
class="w-full justify-start text-sm"
8484
onclick={() => {
85-
importConversations().catch(err => {
85+
importConversations().catch((err) => {
8686
console.error('Import failed:', err);
8787
// Optional: show toast or dialog
8888
});
8989
}}
9090
variant="ghost"
9191
>
92-
9392
<div class="flex items-center gap-2">
9493
<Upload class="h-4 w-4" />
9594
Import conversations

tools/server/webui/src/lib/stores/chat.svelte.ts

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -958,27 +958,27 @@ class ChatStore {
958958
* @param convId - The conversation ID to download
959959
*/
960960
async downloadConversation(convId: string): Promise<void> {
961-
if (!this.activeConversation || this.activeConversation.id !== convId) {
962-
// Load the conversation if not currently active
963-
const conversation = await DatabaseStore.getConversation(convId);
964-
if (!conversation) return;
965-
966-
const messages = await DatabaseStore.getConversationMessages(convId);
967-
const conversationData = {
968-
conv: conversation,
969-
messages
970-
};
961+
if (!this.activeConversation || this.activeConversation.id !== convId) {
962+
// Load the conversation if not currently active
963+
const conversation = await DatabaseStore.getConversation(convId);
964+
if (!conversation) return;
971965

972-
this.triggerDownload(conversationData);
973-
} else {
974-
// Use current active conversation data
975-
const conversationData: ExportedConversations = {
976-
conv: this.activeConversation!,
977-
messages: this.activeMessages
978-
};
966+
const messages = await DatabaseStore.getConversationMessages(convId);
967+
const conversationData = {
968+
conv: conversation,
969+
messages
970+
};
979971

980-
this.triggerDownload(conversationData);
981-
}
972+
this.triggerDownload(conversationData);
973+
} else {
974+
// Use current active conversation data
975+
const conversationData: ExportedConversations = {
976+
conv: this.activeConversation!,
977+
messages: this.activeMessages
978+
};
979+
980+
this.triggerDownload(conversationData);
981+
}
982982
}
983983

984984
/**
@@ -987,20 +987,24 @@ class ChatStore {
987987
* @param filename - Optional filename
988988
*/
989989
private triggerDownload(data: ExportedConversations, filename?: string): void {
990-
const conversation = 'conv' in data ? data.conv : (Array.isArray(data) ? data[0]?.conv : undefined);
990+
const conversation =
991+
'conv' in data ? data.conv : Array.isArray(data) ? data[0]?.conv : undefined;
991992
if (!conversation) {
992993
console.error('Invalid data: missing conversation');
993994
return;
994995
}
995996
const conversationName = conversation.name ? conversation.name.trim() : '';
996997
const convId = conversation.id || 'unknown';
997-
const truncatedSuffix = conversationName.toLowerCase()
998-
.replace(/[^a-z0-9]/gi, '_').replace(/_+/g, '_').substring(0, 20);
998+
const truncatedSuffix = conversationName
999+
.toLowerCase()
1000+
.replace(/[^a-z0-9]/gi, '_')
1001+
.replace(/_+/g, '_')
1002+
.substring(0, 20);
9991003
const downloadFilename = filename || `conversation_${convId}_${truncatedSuffix}.json`;
10001004

10011005
const conversationJson = JSON.stringify(data, null, 2);
10021006
const blob = new Blob([conversationJson], {
1003-
type: 'application/json',
1007+
type: 'application/json'
10041008
});
10051009
const url = URL.createObjectURL(blob);
10061010
const a = document.createElement('a');
@@ -1073,11 +1077,18 @@ class ChatStore {
10731077

10741078
if (Array.isArray(parsedData)) {
10751079
importedData = parsedData;
1076-
} else if (parsedData && typeof parsedData === 'object' && 'conv' in parsedData && 'messages' in parsedData) {
1080+
} else if (
1081+
parsedData &&
1082+
typeof parsedData === 'object' &&
1083+
'conv' in parsedData &&
1084+
'messages' in parsedData
1085+
) {
10771086
// Single conversation object
10781087
importedData = [parsedData];
10791088
} else {
1080-
throw new Error('Invalid file format: expected array of conversations or single conversation object');
1089+
throw new Error(
1090+
'Invalid file format: expected array of conversations or single conversation object'
1091+
);
10811092
}
10821093

10831094
const result = await DatabaseStore.importConversations(importedData);

tools/server/webui/src/lib/stores/database.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,5 +381,4 @@ export class DatabaseStore {
381381
return { imported: importedCount, skipped: skippedCount };
382382
});
383383
}
384-
385384
}

0 commit comments

Comments
 (0)