diff --git a/app/components/chat/chatExportAndImport/ExportChatButton.tsx b/app/components/chat/chatExportAndImport/ExportChatButton.tsx index 8d1ef2c..5ac0224 100644 --- a/app/components/chat/chatExportAndImport/ExportChatButton.tsx +++ b/app/components/chat/chatExportAndImport/ExportChatButton.tsx @@ -4,7 +4,7 @@ import { classNames } from '~/utils/classNames'; export const ExportChatButton = ({ exportChat }: { exportChat?: () => void }) => { return ( -
+
Export diff --git a/app/components/header/HeaderActionButtons.client.tsx b/app/components/header/HeaderActionButtons.client.tsx index b3a5fcf..41d6354 100644 --- a/app/components/header/HeaderActionButtons.client.tsx +++ b/app/components/header/HeaderActionButtons.client.tsx @@ -1,88 +1,21 @@ +import { useState } from 'react'; import { useStore } from '@nanostores/react'; import { workbenchStore } from '~/lib/stores/workbench'; -import { useState, useCallback } from 'react'; -import { streamingState } from '~/lib/stores/streaming'; -import { ExportChatButton } from '~/components/chat/chatExportAndImport/ExportChatButton'; -import { useChatHistory } from '~/lib/persistence'; import { DeployButton } from '~/components/deploy/DeployButton'; -import { toast } from 'react-toastify'; -import { classNames } from '~/utils/classNames'; -import * as DropdownMenu from '@radix-ui/react-dropdown-menu'; interface HeaderActionButtonsProps { chatStarted: boolean; } -export function HeaderActionButtons({ chatStarted }: HeaderActionButtonsProps) { +export function HeaderActionButtons({ chatStarted: _chatStarted }: HeaderActionButtonsProps) { const [activePreviewIndex] = useState(0); const previews = useStore(workbenchStore.previews); const activePreview = previews[activePreviewIndex]; - const isStreaming = useStore(streamingState); - const { exportChat } = useChatHistory(); - const [isSyncing, setIsSyncing] = useState(false); - const shouldShowButtons = !isStreaming && activePreview; - - const handleSyncFiles = useCallback(async () => { - setIsSyncing(true); - - try { - const directoryHandle = await window.showDirectoryPicker(); - await workbenchStore.syncFiles(directoryHandle); - toast.success('Files synced successfully'); - } catch (error) { - console.error('Error syncing files:', error); - toast.error('Failed to sync files'); - } finally { - setIsSyncing(false); - } - }, []); + const shouldShowButtons = activePreview; return (
- {/* Export Chat Button */} - {chatStarted && shouldShowButtons && } - - {/* Sync Button */} - {shouldShowButtons && ( -
- - - {isSyncing ? 'Syncing...' : 'Sync'} - - - - -
- {isSyncing ?
:
} - {isSyncing ? 'Syncing...' : 'Sync Files'} -
- - - -
- )} - {/* Deploy Button */} {shouldShowButtons && } diff --git a/app/components/workbench/Workbench.client.tsx b/app/components/workbench/Workbench.client.tsx index 52194fc..3661c49 100644 --- a/app/components/workbench/Workbench.client.tsx +++ b/app/components/workbench/Workbench.client.tsx @@ -13,7 +13,6 @@ import { type OnScrollCallback as OnEditorScroll, } from '~/components/editor/codemirror/CodeMirrorEditor'; import { IconButton } from '~/components/ui/IconButton'; -import { PanelHeaderButton } from '~/components/ui/PanelHeaderButton'; import { Slider, type SliderOptions } from '~/components/ui/Slider'; import { workbenchStore, type WorkbenchViewType } from '~/lib/stores/workbench'; import { classNames } from '~/utils/classNames'; @@ -26,6 +25,10 @@ import useViewport from '~/lib/hooks'; import { usePreviewStore } from '~/lib/stores/previews'; import { chatStore } from '~/lib/stores/chat'; import type { ElementInfo } from './Inspector'; +import { ExportChatButton } from '~/components/chat/chatExportAndImport/ExportChatButton'; +import { useChatHistory } from '~/lib/persistence'; +import { streamingState } from '~/lib/stores/streaming'; +import * as DropdownMenu from '@radix-ui/react-dropdown-menu'; interface WorkspaceProps { chatStarted?: boolean; @@ -302,6 +305,9 @@ export const Workbench = memo( const canHideChat = showWorkbench || !showChat; const isSmallViewport = useViewport(1024); + const streaming = useStore(streamingState); + const { exportChat } = useChatHistory(); + const [isSyncing, setIsSyncing] = useState(false); const setSelectedView = (view: WorkbenchViewType) => { workbenchStore.currentView.set(view); @@ -351,6 +357,21 @@ export const Workbench = memo( workbenchStore.currentView.set('diff'); }, []); + const handleSyncFiles = useCallback(async () => { + setIsSyncing(true); + + try { + const directoryHandle = await window.showDirectoryPicker(); + await workbenchStore.syncFiles(directoryHandle); + toast.success('Files synced successfully'); + } catch (error) { + console.error('Error syncing files:', error); + toast.error('Failed to sync files'); + } finally { + setIsSyncing(false); + } + }, []); + return ( chatStarted && ( {selectedView === 'code' && (
- { - workbenchStore.toggleTerminal(!workbenchStore.showTerminal.get()); - }} - > -
- Toggle Terminal - + {/* Export Chat Button */} + + + {/* Sync Button */} +
+ + + {isSyncing ? 'Syncing...' : 'Sync'} + + + + +
+ {isSyncing ? ( +
+ ) : ( +
+ )} + {isSyncing ? 'Syncing...' : 'Sync Files'} +
+ + + +
+ + {/* Toggle Terminal Button */} +
+ +
)}