diff --git a/src/components/ActionsMenu.tsx b/src/components/ActionsMenu.tsx
index 040fcd4d..77015443 100644
--- a/src/components/ActionsMenu.tsx
+++ b/src/components/ActionsMenu.tsx
@@ -1,4 +1,5 @@
import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
import { Button } from '@/components/ui/button';
import {
DropdownMenu,
@@ -13,10 +14,12 @@ import {
History,
Folder,
Rocket,
+ Copy,
} from 'lucide-react';
import { GitHistoryDialog } from '@/components/ai/GitHistoryDialog';
import { GitDialog } from '@/components/GitDialog';
import { DeployDialog } from '@/components/DeployDialog';
+import { DuplicateProjectDialog } from '@/components/DuplicateProjectDialog';
interface ActionsMenuProps {
projectId: string;
@@ -39,9 +42,11 @@ export function ActionsMenu({
disabled = false,
onFirstInteraction: _onFirstInteraction,
}: ActionsMenuProps) {
+ const { t } = useTranslation();
const [gitHistoryOpen, setGitHistoryOpen] = useState(false);
const [gitDialogOpen, setGitDialogOpen] = useState(false);
const [deployDialogOpen, setDeployDialogOpen] = useState(false);
+ const [duplicateDialogOpen, setDuplicateDialogOpen] = useState(false);
const isAnyLoading = isLoading || isBuildLoading;
@@ -98,6 +103,15 @@ export function ActionsMenu({
Deploy
+ setDuplicateDialogOpen(true)}
+ disabled={isAnyLoading}
+ className="gap-2"
+ >
+
+ {t('duplicateProject')}
+
+
+
+
>
);
}
\ No newline at end of file
diff --git a/src/components/DuplicateProjectDialog.test.tsx b/src/components/DuplicateProjectDialog.test.tsx
new file mode 100644
index 00000000..aaab0c9d
--- /dev/null
+++ b/src/components/DuplicateProjectDialog.test.tsx
@@ -0,0 +1,137 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { DuplicateProjectDialog } from './DuplicateProjectDialog';
+import { TestApp } from '@/test/TestApp';
+
+// Mock the navigate function
+const mockNavigate = vi.fn();
+vi.mock('react-router-dom', async () => {
+ const actual = await vi.importActual('react-router-dom');
+ return {
+ ...actual,
+ useNavigate: () => mockNavigate,
+ };
+});
+
+describe('DuplicateProjectDialog', () => {
+ beforeEach(() => {
+ mockNavigate.mockClear();
+ });
+
+ it('renders dialog when open', () => {
+ render(
+
+ {}}
+ />
+
+ );
+
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
+ expect(screen.getByRole('heading', { name: 'Duplicate Project' })).toBeInTheDocument();
+ expect(screen.getByText('Create a copy of this project with a new name')).toBeInTheDocument();
+ });
+
+ it('does not render dialog when closed', () => {
+ render(
+
+ {}}
+ />
+
+ );
+
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
+ });
+
+ it('shows default project name with -copy suffix', () => {
+ render(
+
+ {}}
+ />
+
+ );
+
+ const input = screen.getByLabelText('New Project Name');
+ expect(input).toHaveValue('Test Project-copy');
+ });
+
+ it('allows changing the project name', async () => {
+ const user = userEvent.setup();
+
+ render(
+
+ {}}
+ />
+
+ );
+
+ const input = screen.getByLabelText('New Project Name');
+ await user.clear(input);
+ await user.type(input, 'My New Project');
+
+ expect(input).toHaveValue('My New Project');
+ });
+
+ it('disables duplicate button when name is empty', async () => {
+ const user = userEvent.setup();
+
+ render(
+
+ {}}
+ />
+
+ );
+
+ const input = screen.getByLabelText('New Project Name');
+ const duplicateButton = screen.getByRole('button', { name: /Duplicate Project/i });
+
+ // Clear the input
+ await user.clear(input);
+
+ // Button should be disabled when input is empty
+ expect(duplicateButton).toBeDisabled();
+ });
+
+ it('closes dialog when cancel button is clicked', async () => {
+ const user = userEvent.setup();
+ const onOpenChange = vi.fn();
+
+ render(
+
+
+
+ );
+
+ const cancelButton = screen.getByRole('button', { name: /Cancel/i });
+ await user.click(cancelButton);
+
+ await waitFor(() => {
+ expect(onOpenChange).toHaveBeenCalledWith(false);
+ });
+ });
+});
diff --git a/src/components/DuplicateProjectDialog.tsx b/src/components/DuplicateProjectDialog.tsx
new file mode 100644
index 00000000..1fb56331
--- /dev/null
+++ b/src/components/DuplicateProjectDialog.tsx
@@ -0,0 +1,119 @@
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { useNavigate } from 'react-router-dom';
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { useProjectsManager } from '@/hooks/useProjectsManager';
+import { useToast } from '@/hooks/useToast';
+import { useQueryClient } from '@tanstack/react-query';
+
+interface DuplicateProjectDialogProps {
+ projectId: string;
+ projectName: string;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+}
+
+export function DuplicateProjectDialog({
+ projectId,
+ projectName,
+ open,
+ onOpenChange,
+}: DuplicateProjectDialogProps) {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+ const { toast } = useToast();
+ const projectsManager = useProjectsManager();
+ const queryClient = useQueryClient();
+ const [newName, setNewName] = useState(`${projectName}-copy`);
+ const [isLoading, setIsLoading] = useState(false);
+
+ const handleDuplicate = async () => {
+ if (!newName.trim()) {
+ return;
+ }
+
+ setIsLoading(true);
+
+ try {
+ const duplicatedProject = await projectsManager.duplicateProject(projectId, newName);
+
+ // Invalidate projects query to refresh the list
+ await queryClient.invalidateQueries({ queryKey: ['projects'] });
+
+ toast({
+ title: t('projectDuplicated'),
+ description: t('projectDuplicatedDescription'),
+ });
+
+ // Close dialog
+ onOpenChange(false);
+
+ // Navigate to the new project
+ navigate(`/project/${duplicatedProject.id}`);
+ } catch (error) {
+ console.error('Failed to duplicate project:', error);
+ toast({
+ title: t('failedToDuplicateProject'),
+ description: error instanceof Error ? error.message : String(error),
+ variant: 'destructive',
+ });
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ return (
+
+ );
+}
diff --git a/src/components/Shakespeare/PreviewPane.tsx b/src/components/Shakespeare/PreviewPane.tsx
index a24e9115..8434a701 100644
--- a/src/components/Shakespeare/PreviewPane.tsx
+++ b/src/components/Shakespeare/PreviewPane.tsx
@@ -708,6 +708,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o