Skip to content

Commit

Permalink
feat: enhance chat import with multi-format support (stackblitz-labs#936
Browse files Browse the repository at this point in the history
)

* feat: enhance chat import with multi-format support

- Add support for importing chats from different formats:
  - Standard Bolt format
  - Chrome extension format
  - History array format
  - Bolt export format
- Add Import Chats button to Data Management
- Add proper error handling and logging
- Update README with backup/restore feature

* refactor: simplify chat import formats

- Remove multi-format support from DataTab
- Keep only standard Bolt export formats
- Simplify ImportButtons to handle standard format only
  • Loading branch information
sidbetatester authored and apple committed Jan 13, 2025
1 parent dd7499f commit 9770eb3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/components/chat/chatExportAndImport/ImportButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ type ChatData = {
description?: string; // Optional description
};

type ChatData = {
messages?: Message[]; // Standard Bolt format
description?: string; // Optional description
};

export function ImportButtons(importChat: ((description: string, messages: Message[]) => Promise<void>) | undefined) {
return (
<div className="flex flex-col items-center justify-center w-auto">
Expand All @@ -26,12 +31,12 @@ export function ImportButtons(importChat: ((description: string, messages: Messa
try {
const content = e.target?.result as string;
const data = JSON.parse(content) as ChatData;
const data = JSON.parse(content) as ChatData;

// Standard format
if (Array.isArray(data.messages)) {
await importChat(data.description || 'Imported Chat', data.messages);
toast.success('Chat imported successfully');

return;
}

Expand Down

0 comments on commit 9770eb3

Please sign in to comment.