mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
merge in from upstream and resolve conflicts
This commit is contained in:
commit
669bbb8a1f
42 files changed
+1681
-669
No files matched your search
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
<meta property="og:title" content="Shakespeare - AI-Powered Nostr Development">
|
<meta property="og:title" content="Shakespeare - AI-Powered Nostr Development">
|
||||||
<meta property="og:description" content="Build custom Nostr websites with AI assistance using Shakespeare, an AI-powered development environment">
|
<meta property="og:description" content="Build custom Nostr websites with AI assistance using Shakespeare, an AI-powered development environment">
|
||||||
<meta http-equiv="content-security-policy" content="default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src 'self' https:; font-src 'self'; base-uri 'self'; manifest-src 'self'; connect-src 'self' blob: https: http: wss: ws:; img-src 'self' data: blob: https:; media-src 'self' https:">
|
<meta http-equiv="content-security-policy" content="default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src 'self' https:; font-src 'self'; base-uri 'self'; manifest-src 'self'; connect-src 'self' blob: https: http: wss: ws:; img-src 'self' data: blob: https:; media-src 'self' https:">
|
||||||
<link rel="icon" type="image/png" href="/favicon.png">
|
<link rel="icon" type="image/png" href="/shakespeare.png">
|
||||||
<link rel="manifest" href="/manifest.webmanifest">
|
<link rel="manifest" href="/manifest.webmanifest">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
"theme_color": "#000000",
|
"theme_color": "#000000",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "/favicon.png",
|
"src": "/shakespeare.png",
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "/favicon.png",
|
"src": "/shakespeare.png",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
}
|
}
|
||||||
|
|||||||
File renamed without changes.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 25.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="レイヤー_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
|
||||||
|
y="0px" viewBox="0 0 128 128" style="enable-background:new 0 0 128 128;" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path style="fill:#F45125;" d="M110.28,61.32l2.63,8.84c0,0,7.24-1.6,7.62,3.2c0.38,4.8-6.77,8-6.77,8l2.26,10.63
|
||||||
|
c0,0,7.9-6.4,8-15.61c0,0,0.66-11.29-6.11-13.92C113.67,60.85,110.28,61.32,110.28,61.32z"/>
|
||||||
|
<path style="fill:#F45125;" d="M68.71,94.99c0,0-11.1-4.7-16.46,1.98c-0.75,0.94-1.41,1.88-2.16,2.82
|
||||||
|
c-0.56,0.75-1.13,1.5-1.69,2.16c-0.47,0.56-1.03,1.13-1.69,1.5c-0.66,0.38-1.32,0.66-2.07,0.85c-0.94,0.19-1.88,0.19-2.82,0.09
|
||||||
|
c-1.32-0.09-2.63-0.38-3.95-0.66c-0.47-0.09-0.85-0.19-1.22-0.28c-0.09,0-0.19-0.09-0.28-0.09s-0.19-0.09-0.28-0.09
|
||||||
|
c-0.38,0.09,0.19,0.75,0.38,0.94c0.28,0.28,0.56,0.66,0.85,0.94c0.85,0.75,1.69,1.5,2.73,1.98c1.32,0.66,2.73,1.03,4.14,1.13
|
||||||
|
c0.09,0,0.38,0,0.47,0.09c0.19,0.19-0.28,0.47-0.47,0.56c-0.28,0.19-0.47,0.28-0.75,0.38c-0.85,0.38-1.79,0.56-2.63,0.75
|
||||||
|
c-0.85,0.19-1.69,0.28-2.45,0.28c-0.47,0-0.85,0.09-1.22,0.09c-0.28,0-0.56-0.09-0.85,0s0.09,0.47,0.28,0.56
|
||||||
|
c0.38,0.19,0.75,0.47,1.13,0.66c1.13,0.56,2.26,1.03,3.39,1.32c1.5,0.38,3.1,0.56,4.61,0.38c1.32-0.19,2.63-0.56,3.86-1.03
|
||||||
|
c6.77-3.1,6.21-9.59,12.42-10.16c4.61-0.38,11.1,2.07,11.1,2.07L68.71,94.99z"/>
|
||||||
|
<path style="fill:#F45125;" d="M19.79,38.28c0,0-12.13,1.98-15.24,12.79C0.61,64.9,20.26,69.5,20.26,69.5l1.22-9.41
|
||||||
|
c0,0-13.07-1.32-12.32-6.3c0.94-6.21,11.85-5.64,11.85-5.64L19.79,38.28z"/>
|
||||||
|
<path style="fill:#F45125;" d="M20.73,70.92c0,0-1.88,0.56-4.61,2.54c-1.88,1.32-4.42,3.01-6.87,5.93
|
||||||
|
c-1.22,1.41-2.16,3.1-2.82,4.89c-0.47,1.22-0.66,2.45-0.66,3.76c0,0.28,0,0.56,0,0.85c0,0.09,0,0.85,0.28,0.66
|
||||||
|
c0.09-0.09,0.19-0.38,0.28-0.47c0.19-0.47,0.47-0.85,0.75-1.22c0.85-1.13,1.88-2.16,3.01-3.01c0.38-0.28,0.75-0.47,1.13-0.66
|
||||||
|
c0.28-0.28,0.75-0.66,0.94-0.28c0.09,0.19-0.09,0.47-0.19,0.66c-0.09,0.28-0.19,0.66-0.19,0.94c-0.38,1.5-0.56,3.01-0.75,4.51
|
||||||
|
c-0.09,0.85-0.09,1.69,0,2.45c0,0.38,0.09,0.85,0.09,1.22c0,0.19,0.09,0.38,0.09,0.56c0,0.19,0.19,0.47,0.38,0.19
|
||||||
|
c0.09-0.09,0.09-0.19,0.19-0.38c0.19-0.28,0.28-0.66,0.47-0.94c0.47-0.85,0.94-1.69,1.5-2.63c0.66-1.13,1.41-2.16,2.16-3.1
|
||||||
|
c0.85-1.13,1.88-2.26,2.92-3.2c1.13-1.03,2.35-2.07,3.67-2.92c0.75-0.47,1.6-0.94,2.45-1.32L20.73,70.92z"/>
|
||||||
|
<g>
|
||||||
|
<path style="fill:#FCC21B;" d="M116.4,79.29c-1.13-5.55-2.73-11.01-4.51-16.46c-1.5-4.61-3.1-9.31-5.83-13.36
|
||||||
|
c-1.22-1.79-3.01-3.01-5.27-3.86c-4.33-1.69-9.97-1.98-13.73-1.98c-5.64,0-11.48,1.22-16.74,3.67
|
||||||
|
c-1.88,5.64-7.05,19.94-14.86,26.34c0.47,2.63,1.03,5.36,1.79,8c1.32,4.61,3.01,9.22,4.61,13.83c1.5,4.42,3.29,8.84,6.58,12.23
|
||||||
|
c0.85,0.94,1.88,1.69,2.82,2.45c2.26,1.88,4.99,3.01,7.71,3.95c2.54,0.85,5.17,1.5,7.81,2.07c4.7,1.03,11.48,2.82,16.08,0.66
|
||||||
|
c2.54-1.13,4.61-2.92,6.3-5.08c1.79-2.26,3.2-4.8,4.42-7.43c1.88-3.95,3.86-8.37,4.14-12.89
|
||||||
|
C117.99,87.38,117.24,83.24,116.4,79.29z"/>
|
||||||
|
<path style="fill:#429ADF;" d="M77.64,33.57c-0.28-1.03-1.03-2.07-1.6-3.01c-6.3-11.01-20.04-16.27-32.26-15.52
|
||||||
|
c-3.76,0.28-9.31,0.85-13.54,2.73c-2.07,0.94-3.86,2.35-4.99,4.14c-2.54,4.23-3.76,8.94-5.08,13.64
|
||||||
|
C18.67,41,17.35,46.55,16.5,52.2c-0.75,4.89-1.41,10.25-0.09,15.14c1.03,3.86,3.29,9.22,5.74,12.32
|
||||||
|
c2.73,3.39,6.58,7.34,10.72,8.84c0.75,0.28,1.6,0.47,2.45,0.66c1.6,0.28,3.29,0.47,4.89,0.19c0.94-0.19,1.98-0.28,2.92-0.56
|
||||||
|
c1.88-0.47,3.67-1.13,5.46-1.79c7.52-3.01,13.64-7.43,17.68-14.58c1.69-3.1,3.1-6.4,4.42-9.69c0.09-0.19,0.19-0.38,0.19-0.56
|
||||||
|
c1.98-5.46,3.29-11.19,4.61-16.84c0.66-2.73,1.41-5.55,1.79-8.37C77.55,35.92,77.92,34.7,77.64,33.57z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<path style="fill:#193D51;" d="M23.09,40.53c1.69-3.1,5.74-5.55,9.31-5.08c0.56,0.09,1.22,0.19,1.79,0.47
|
||||||
|
c3.57,1.5,5.74,4.99,4.89,8.56c-0.19,0.75-0.66,0.85-1.22,0.38c-1.98-1.69-3.57-3.01-6.21-3.67c-2.16-0.56-4.61-0.28-6.68,0.28
|
||||||
|
c-0.47,0.09-1.22,0.56-1.69,0.38C22.61,41.57,22.9,40.91,23.09,40.53z"/>
|
||||||
|
<path style="fill:#193D51;" d="M62.21,64.9c-1.03,1.6-2.45,3.01-3.86,4.33c-0.38,0.28-0.66,0.66-1.03,0.94
|
||||||
|
c-5.64,4.7-13.26,7.05-20.51,5.27c-1.98-0.47-4.14-1.5-5.74-2.73c-1.22-0.94-2.45-2.16-3.48-3.39c-1.88-2.26-3.29-4.89-4.23-7.62
|
||||||
|
c-0.47-1.41-0.75-2.73-0.94-4.23c0-0.47-0.66-5.46,0.85-4.8c0.38,0.19,0.66,0.47,0.94,0.75c0.28,0.38,0.47,0.75,0.75,1.03
|
||||||
|
c0.66,0.85,1.32,1.69,2.07,2.45c2.35,2.73,5.27,4.89,8.56,6.4c2.26,1.03,4.7,1.6,7.15,1.79c1.41,0.09,2.73,0.19,4.14,0.09
|
||||||
|
c5.08-0.28,10.25-1.79,14.86-3.76c0.38-0.19,0.85-0.47,1.32-0.47C64.66,61.04,62.5,64.52,62.21,64.9z"/>
|
||||||
|
<path style="fill:#193D51;" d="M67.58,51.16c0,0.47-0.19,1.13-0.75,1.03c-0.47-0.09-0.85-0.94-1.13-1.22
|
||||||
|
c-1.32-1.69-3.86-3.57-6.4-4.14c-3.01-0.75-5.27,0.56-8.28,0.85c-0.85,0.09-1.32-0.28-0.94-1.03c1.6-3.48,5.83-6.21,10.25-5.46
|
||||||
|
c0.75,0.09,1.41,0.28,2.07,0.56C66.26,43.36,67.86,47.59,67.58,51.16z"/>
|
||||||
|
<path style="fill:#9B7515;" d="M91.84,63.86c4.23,2.73,9.69,3.48,14.58,3.2c1.41-0.09,2.26,0.09,1.88,1.69
|
||||||
|
c-0.75,3.29-3.86,5.17-6.87,5.83c-0.75,0.19-1.5,0.19-2.26,0.19c-1.41-0.09-2.82-0.66-4.04-1.5c-2.63-1.79-4.61-4.89-5.17-8
|
||||||
|
C89.68,63.67,90.25,62.83,91.84,63.86z"/>
|
||||||
|
<path style="fill:#9B7515;" d="M65.22,80.79C64,79.57,64.66,79,65.98,78.25c4.51-2.35,9.03-5.93,11.38-10.63
|
||||||
|
c0.85-1.79,1.79-1.41,2.45,0.28c1.13,3.1,1.03,6.87-0.38,9.88c-0.66,1.41-1.6,2.63-2.82,3.57c-0.66,0.47-1.32,0.75-2.07,1.03
|
||||||
|
C71.43,83.33,67.58,83.24,65.22,80.79z"/>
|
||||||
|
<path style="fill:#9B7515;" d="M110,96.41c-0.38,0-0.94-0.38-1.41-0.66c-0.47-0.28-0.94-0.66-1.22-0.85
|
||||||
|
c-1.13-0.56-2.45-1.13-3.67-1.5c-3.76-1.22-7.9-1.22-11.57,0c-2.63,0.85-5.17,2.45-7.24,4.33c-2.26,2.16-3.95,4.8-6.11,7.05
|
||||||
|
c-0.28,0.28-0.56,0.56-0.85,0.75c-0.56,0.28-1.13-0.09-1.32-0.66c-0.94-3.95,1.69-9.5,3.67-12.89c2.26-3.76,5.55-6.77,9.78-8
|
||||||
|
c2.07-0.66,4.33-0.66,6.49-0.38c6.3,0.94,12.79,5.93,14.02,11.66C110.56,95.75,110.47,96.5,110,96.41z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 5.8 KiB |
+1
-1
@@ -38,7 +38,7 @@ const queryClient = new QueryClient({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const defaultConfig: AppConfig = {
|
const defaultConfig: AppConfig = {
|
||||||
theme: "light",
|
theme: "system",
|
||||||
relayUrl: "wss://relay.primal.net",
|
relayUrl: "wss://relay.primal.net",
|
||||||
deployServer: "shakespeare.wtf",
|
deployServer: "shakespeare.wtf",
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-2
@@ -11,7 +11,7 @@ import AISettings from "./pages/AISettings";
|
|||||||
import GitSettings from "./pages/GitSettings";
|
import GitSettings from "./pages/GitSettings";
|
||||||
import DataSettings from "./pages/DataSettings";
|
import DataSettings from "./pages/DataSettings";
|
||||||
import AboutSettings from "./pages/AboutSettings";
|
import AboutSettings from "./pages/AboutSettings";
|
||||||
import EmailSettings from "./pages/EmailSettings";
|
|
||||||
import GitHubOAuth from "./pages/GitHubOAuth";
|
import GitHubOAuth from "./pages/GitHubOAuth";
|
||||||
import { NIP19Page } from "./pages/NIP19Page";
|
import { NIP19Page } from "./pages/NIP19Page";
|
||||||
import NotFound from "./pages/NotFound";
|
import NotFound from "./pages/NotFound";
|
||||||
@@ -34,7 +34,6 @@ export function AppRouter() {
|
|||||||
<Route path="ai" element={<AISettings />} />
|
<Route path="ai" element={<AISettings />} />
|
||||||
<Route path="git" element={<GitSettings />} />
|
<Route path="git" element={<GitSettings />} />
|
||||||
<Route path="data" element={<DataSettings />} />
|
<Route path="data" element={<DataSettings />} />
|
||||||
<Route path="email" element={<EmailSettings />} />
|
|
||||||
<Route path="about" element={<AboutSettings />} />
|
<Route path="about" element={<AboutSettings />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/project/:projectId" element={<ProjectView />} />
|
<Route path="/project/:projectId" element={<ProjectView />} />
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ interface AppLayoutProps {
|
|||||||
export function AppLayout({
|
export function AppLayout({
|
||||||
children,
|
children,
|
||||||
selectedProject = null,
|
selectedProject = null,
|
||||||
title = "Shakespeare",
|
|
||||||
showSidebar = true,
|
showSidebar = true,
|
||||||
headerContent
|
headerContent
|
||||||
}: AppLayoutProps) {
|
}: AppLayoutProps) {
|
||||||
@@ -85,9 +84,6 @@ export function AppLayout({
|
|||||||
<Menu className="h-4 w-4" />
|
<Menu className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<h1 className="text-lg font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
|
||||||
{title}
|
|
||||||
</h1>
|
|
||||||
</div>
|
</div>
|
||||||
{headerContent}
|
{headerContent}
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ export function CreditsDialog({ open, onOpenChange, provider }: CreditsDialogPro
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent className="max-w-lg w-full max-h-[75vh] overflow-hidden flex flex-col sm:max-w-lg sm:max-h-[75vh] max-sm:w-full max-sm:h-full max-sm:max-w-none max-sm:max-h-none max-sm:m-0 max-sm:rounded-none">
|
<DialogContent onOpenAutoFocus={(e) => e.preventDefault()} className="max-w-lg w-full max-h-[75vh] overflow-hidden flex flex-col sm:max-w-lg sm:max-h-[75vh] max-sm:w-full max-sm:h-full max-sm:max-w-none max-sm:max-h-none max-sm:m-0 max-sm:rounded-none">
|
||||||
<DialogHeader className="flex-shrink-0">
|
<DialogHeader className="flex-shrink-0">
|
||||||
<DialogTitle className="flex items-center gap-2 text-lg">
|
<DialogTitle className="flex items-center gap-2 text-lg">
|
||||||
{lightningInvoice ? (
|
{lightningInvoice ? (
|
||||||
|
|||||||
@@ -0,0 +1,204 @@
|
|||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
import { Mail, CheckCircle } from 'lucide-react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
|
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||||
|
import { useToast } from '@/hooks/useToast';
|
||||||
|
import { nip19 } from 'nostr-tools';
|
||||||
|
|
||||||
|
export function EmailSubscription() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { user } = useCurrentUser();
|
||||||
|
const { toast } = useToast();
|
||||||
|
|
||||||
|
const [email, setEmail] = useState('');
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
const [isSubmitted, setIsSubmitted] = useState(false);
|
||||||
|
|
||||||
|
const url = new URL('https://pub.us7.list-manage.com/subscribe/post?u=f1f718a93795f42a604d558d8&id=f7271442a0&f_id=00ffa3e4f0');
|
||||||
|
const honeypot = `b_${url.searchParams.get('u')}_${url.searchParams.get('id')}`;
|
||||||
|
const tag = '8982396';
|
||||||
|
|
||||||
|
// Check localStorage on component mount
|
||||||
|
useEffect(() => {
|
||||||
|
const hasSubscribed = localStorage.getItem('shakespeare-email-subscribed');
|
||||||
|
if (hasSubscribed === 'true') {
|
||||||
|
setIsSubmitted(true);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (!email.trim()) {
|
||||||
|
toast({
|
||||||
|
title: "Email required",
|
||||||
|
description: "Please enter your email address",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Basic email validation
|
||||||
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
if (!emailRegex.test(email)) {
|
||||||
|
toast({
|
||||||
|
title: "Invalid email",
|
||||||
|
description: "Please enter a valid email address",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSubmitting(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Submit to Mailchimp
|
||||||
|
const form = document.createElement('form');
|
||||||
|
form.method = 'POST';
|
||||||
|
form.action = url.href;
|
||||||
|
form.target = '_blank'; // Open in new tab
|
||||||
|
form.style.display = 'none';
|
||||||
|
|
||||||
|
// Add email field
|
||||||
|
const emailInput = document.createElement('input');
|
||||||
|
emailInput.type = 'email';
|
||||||
|
emailInput.name = 'EMAIL';
|
||||||
|
emailInput.value = email.trim();
|
||||||
|
form.appendChild(emailInput);
|
||||||
|
|
||||||
|
// Add tag field with the new Shakespeare tag ID
|
||||||
|
const tagInput = document.createElement('input');
|
||||||
|
tagInput.type = 'hidden';
|
||||||
|
tagInput.name = 'tags';
|
||||||
|
tagInput.value = tag;
|
||||||
|
form.appendChild(tagInput);
|
||||||
|
|
||||||
|
// Add npub if available
|
||||||
|
if (user?.pubkey) {
|
||||||
|
const npubInput = document.createElement('input');
|
||||||
|
npubInput.type = 'text';
|
||||||
|
npubInput.name = 'NPUB';
|
||||||
|
npubInput.value = nip19.npubEncode(user.pubkey);
|
||||||
|
npubInput.style.display = 'none';
|
||||||
|
form.appendChild(npubInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add honeypot field
|
||||||
|
const honeypotInput = document.createElement('input');
|
||||||
|
honeypotInput.type = 'text';
|
||||||
|
honeypotInput.name = honeypot;
|
||||||
|
honeypotInput.tabIndex = -1;
|
||||||
|
honeypotInput.style.position = 'absolute';
|
||||||
|
honeypotInput.style.left = '-5000px';
|
||||||
|
form.appendChild(honeypotInput);
|
||||||
|
|
||||||
|
// Add form to document and submit
|
||||||
|
document.body.appendChild(form);
|
||||||
|
form.submit();
|
||||||
|
|
||||||
|
// Clean up after a short delay
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(form);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
// Save subscription status to localStorage
|
||||||
|
localStorage.setItem('shakespeare-email-subscribed', 'true');
|
||||||
|
|
||||||
|
setIsSubmitted(true);
|
||||||
|
toast({
|
||||||
|
title: "Successfully subscribed!",
|
||||||
|
description: "You'll receive Shakespeare updates and resources occasionally.",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Email signup error:', error);
|
||||||
|
toast({
|
||||||
|
title: "Subscription failed",
|
||||||
|
description: "There was an error subscribing you to updates. Please try again.",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isSubmitted) {
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<CardContent className="pt-6">
|
||||||
|
<div className="text-center space-y-4">
|
||||||
|
<CheckCircle className="h-12 w-12 mx-auto text-green-500" />
|
||||||
|
<div className="space-y-2">
|
||||||
|
<h3 className="text-lg font-semibold">
|
||||||
|
Thanks for subscribing!
|
||||||
|
</h3>
|
||||||
|
<p className="text-muted-foreground text-sm">
|
||||||
|
You can opt out at any time using the unsubscribe link in our emails.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
localStorage.removeItem('shakespeare-email-subscribed');
|
||||||
|
setIsSubmitted(false);
|
||||||
|
setEmail('');
|
||||||
|
}}
|
||||||
|
variant="outline"
|
||||||
|
className="w-full text-xs"
|
||||||
|
>
|
||||||
|
Subscribe with different email
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle className="text-lg flex items-center gap-2">
|
||||||
|
<Mail className="h-5 w-5 text-primary" />
|
||||||
|
{t('emailUpdates')}
|
||||||
|
</CardTitle>
|
||||||
|
<CardDescription>
|
||||||
|
{t('emailUpdatesDescription')}
|
||||||
|
</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="email">
|
||||||
|
Email Address
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
id="email"
|
||||||
|
type="email"
|
||||||
|
placeholder="[email protected]"
|
||||||
|
value={email}
|
||||||
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-3">
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="w-full"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{isSubmitting ? 'Subscribing...' : 'Subscribe to Updates'}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<p className="text-xs text-muted-foreground text-center">
|
||||||
|
You can opt out at any time using the unsubscribe link in our emails.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -47,7 +47,7 @@ import { cn } from '@/lib/utils';
|
|||||||
import { findCredentialsForRepo } from '@/lib/gitCredentials';
|
import { findCredentialsForRepo } from '@/lib/gitCredentials';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
|
|
||||||
const GRASP_SERVERS = ["git.shakespeare.diy", "relay.ngit.dev", "gitnostr.com"];
|
const GRASP_SERVERS = ["git.shakespeare.diy", "relay.ngit.dev"];
|
||||||
|
|
||||||
interface GitDialogProps {
|
interface GitDialogProps {
|
||||||
projectId: string;
|
projectId: string;
|
||||||
@@ -62,6 +62,7 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
|
|||||||
const [isPushingToNostr, setIsPushingToNostr] = useState(false);
|
const [isPushingToNostr, setIsPushingToNostr] = useState(false);
|
||||||
const [originUrl, setOriginUrl] = useState('');
|
const [originUrl, setOriginUrl] = useState('');
|
||||||
const [isSavingOrigin, setIsSavingOrigin] = useState(false);
|
const [isSavingOrigin, setIsSavingOrigin] = useState(false);
|
||||||
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { data: gitStatus, refetch: refetchGitStatus } = useGitStatus(projectId);
|
const { data: gitStatus, refetch: refetchGitStatus } = useGitStatus(projectId);
|
||||||
@@ -334,6 +335,7 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
|
|||||||
title: "Push to Nostr failed",
|
title: "Push to Nostr failed",
|
||||||
description: errorMessage,
|
description: errorMessage,
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
|
duration: Infinity,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setIsPushingToNostr(false);
|
setIsPushingToNostr(false);
|
||||||
@@ -395,6 +397,7 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
|
|||||||
title: "Push failed",
|
title: "Push failed",
|
||||||
description: errorMessage,
|
description: errorMessage,
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
|
duration: Infinity,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setIsPushing(false);
|
setIsPushing(false);
|
||||||
@@ -425,6 +428,12 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
|
|||||||
try {
|
try {
|
||||||
const remote = gitStatus.remotes[0]; // Use first remote (usually 'origin')
|
const remote = gitStatus.remotes[0]; // Use first remote (usually 'origin')
|
||||||
|
|
||||||
|
// Get the current HEAD commit before pulling
|
||||||
|
const beforeCommit = await git.resolveRef({
|
||||||
|
dir: projectPath,
|
||||||
|
ref: 'HEAD',
|
||||||
|
});
|
||||||
|
|
||||||
await git.pull({
|
await git.pull({
|
||||||
dir: projectPath,
|
dir: projectPath,
|
||||||
ref: gitStatus.currentBranch,
|
ref: gitStatus.currentBranch,
|
||||||
@@ -436,20 +445,38 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
|
|||||||
onAuth: (url) => findCredentialsForRepo(url, settings.credentials),
|
onAuth: (url) => findCredentialsForRepo(url, settings.credentials),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get the current HEAD commit after pulling
|
||||||
|
const afterCommit = await git.resolveRef({
|
||||||
|
dir: projectPath,
|
||||||
|
ref: 'HEAD',
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if the repository actually changed
|
||||||
|
const repoChanged = beforeCommit !== afterCommit;
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: "Pull successful",
|
title: "Pull successful",
|
||||||
description: `Latest changes pulled from ${remote.name}/${gitStatus.currentBranch}`,
|
description: repoChanged
|
||||||
|
? `Latest changes pulled from ${remote.name}/${gitStatus.currentBranch}`
|
||||||
|
: `Already up to date with ${remote.name}/${gitStatus.currentBranch}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Refresh git status after pull
|
// Refresh git status after pull
|
||||||
await refetchGitStatus();
|
await refetchGitStatus();
|
||||||
|
|
||||||
|
// Only trigger build if the repository actually changed
|
||||||
|
if (repoChanged) {
|
||||||
|
const newSearchParams = new URLSearchParams(searchParams);
|
||||||
|
newSearchParams.set('build', '');
|
||||||
|
setSearchParams(newSearchParams);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
||||||
toast({
|
toast({
|
||||||
title: "Pull failed",
|
title: "Pull failed",
|
||||||
description: errorMessage,
|
description: errorMessage,
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
|
duration: Infinity,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setIsPulling(false);
|
setIsPulling(false);
|
||||||
|
|||||||
@@ -168,7 +168,9 @@ export function ModelSelector({
|
|||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="w-96 p-0" align="end">
|
<PopoverContent className="w-96 p-0" align="end">
|
||||||
<Command>
|
<Command>
|
||||||
{isConfigured && <CommandInput placeholder={t('searchModels')} className="h-9" />}
|
{(isConfigured && models.length >= 5) && (
|
||||||
|
<CommandInput placeholder={t('searchModels')} className="h-9" />
|
||||||
|
)}
|
||||||
<CommandList className="max-h-[300px]">
|
<CommandList className="max-h-[300px]">
|
||||||
<CommandEmpty>
|
<CommandEmpty>
|
||||||
<div className="py-6 text-center text-sm text-muted-foreground">
|
<div className="py-6 text-center text-sm text-muted-foreground">
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ const GIT_KINDS = [
|
|||||||
const GIT_RELAYS = [
|
const GIT_RELAYS = [
|
||||||
'wss://git.shakespeare.diy/',
|
'wss://git.shakespeare.diy/',
|
||||||
'wss://relay.ngit.dev/',
|
'wss://relay.ngit.dev/',
|
||||||
'wss://gitnostr.com/',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const NostrProvider: React.FC<NostrProviderProps> = (props) => {
|
const NostrProvider: React.FC<NostrProviderProps> = (props) => {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ describe('OnboardingDialog', () => {
|
|||||||
</TestApp>
|
</TestApp>
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getAllByText('Welcome to Shakespeare!')).toHaveLength(2); // Title and heading
|
expect(screen.getByText('Welcome to Shakespeare!')).toBeInTheDocument(); // Only in dialog title now
|
||||||
expect(screen.getByText(/Your AI-powered development assistant/)).toBeInTheDocument();
|
expect(screen.getByText(/Your AI-powered development assistant/)).toBeInTheDocument();
|
||||||
expect(screen.getByRole('button', { name: /Get Started/i })).toBeInTheDocument();
|
expect(screen.getByRole('button', { name: /Get Started/i })).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ import { Button } from '@/components/ui/button';
|
|||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
|
||||||
import { useAISettings } from '@/hooks/useAISettings';
|
import { useAISettings } from '@/hooks/useAISettings';
|
||||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||||
import { useLoginActions } from '@/hooks/useLoginActions';
|
import { useLoginActions } from '@/hooks/useLoginActions';
|
||||||
import { useProviderModels } from '@/hooks/useProviderModels';
|
import { useProviderModels } from '@/hooks/useProviderModels';
|
||||||
import { CreditsDialog } from '@/components/CreditsDialog';
|
import { CreditsDialog } from '@/components/CreditsDialog';
|
||||||
|
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
|
||||||
|
|
||||||
interface OnboardingDialogProps {
|
interface OnboardingDialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
@@ -119,8 +120,8 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent className="max-w-2xl max-h-[80vh] overflow-hidden">
|
<DialogContent className="max-w-2xl max-h-[90vh] sm:max-h-[80vh] flex flex-col">
|
||||||
<DialogHeader>
|
<DialogHeader className="flex-shrink-0">
|
||||||
<DialogTitle className="flex items-center gap-2">
|
<DialogTitle className="flex items-center gap-2">
|
||||||
{step === 'model-selection' && (
|
{step === 'model-selection' && (
|
||||||
<Button
|
<Button
|
||||||
@@ -132,18 +133,28 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
|
|||||||
<ArrowLeft className="h-4 w-4" />
|
<ArrowLeft className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{step === 'conclusion' && (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => setStep('model-selection')}
|
||||||
|
className="mr-2 p-1 h-auto"
|
||||||
|
>
|
||||||
|
<ArrowLeft className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<span className="text-xl">
|
<span className="text-xl">
|
||||||
{step === 'welcome' && 'Welcome to Shakespeare!'}
|
|
||||||
{step === 'model-selection' && 'Choose Your AI Model'}
|
{step === 'model-selection' && 'Choose Your AI Model'}
|
||||||
{step === 'conclusion' && "You're All Set!"}
|
|
||||||
</span>
|
</span>
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<div className="flex-1 overflow-hidden">
|
<div className="flex-1 overflow-y-auto min-h-0">
|
||||||
{step === 'welcome' && (
|
{step === 'welcome' && (
|
||||||
<div className="text-center space-y-6 py-4">
|
<div className="text-center space-y-6 py-4">
|
||||||
<div className="text-6xl mb-4">🎭</div>
|
<div className="mb-4">
|
||||||
|
<ShakespeareLogo className="w-16 h-16 mx-auto" />
|
||||||
|
</div>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<h2 className="text-2xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
<h2 className="text-2xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||||
Welcome to Shakespeare!
|
Welcome to Shakespeare!
|
||||||
@@ -191,15 +202,8 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{step === 'model-selection' && (
|
{step === 'model-selection' && (
|
||||||
<div className="space-y-4">
|
<div className="flex flex-col h-full">
|
||||||
<div className="text-center space-y-2">
|
<div className="flex-1 overflow-y-auto min-h-0 my-4">
|
||||||
<p className="text-muted-foreground">
|
|
||||||
Choose an AI model to power your development experience.
|
|
||||||
Different models offer various capabilities and pricing.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ScrollArea className="h-96">
|
|
||||||
<div className="space-y-3 p-1">
|
<div className="space-y-3 p-1">
|
||||||
{isLoadingModels ? (
|
{isLoadingModels ? (
|
||||||
<>
|
<>
|
||||||
@@ -232,6 +236,7 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
|
|||||||
shakespeareModels.map((model) => {
|
shakespeareModels.map((model) => {
|
||||||
const isSelected = selectedModel === model.fullId;
|
const isSelected = selectedModel === model.fullId;
|
||||||
const isFree = model.pricing?.prompt.equals(0) && model.pricing?.completion.equals(0);
|
const isFree = model.pricing?.prompt.equals(0) && model.pricing?.completion.equals(0);
|
||||||
|
const isPremium = !isFree;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
@@ -244,12 +249,12 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
|
|||||||
<CardHeader className="pb-3">
|
<CardHeader className="pb-3">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<CardTitle className="text-base font-semibold">
|
<CardTitle className={`text-xl font-semibold ${isPremium ? 'bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent' : ''}`}>
|
||||||
{model.description || model.name || model.id}
|
{ model.name || model.description || model.id}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
{model.description && (
|
{model.description && (
|
||||||
<p className="text-sm text-muted-foreground mt-1">
|
<p className="text-sm text-muted-foreground mt-1">
|
||||||
{model.name || model.id}
|
{model.description || model.id}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -259,6 +264,11 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
|
|||||||
Free
|
Free
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
|
{isPremium && (
|
||||||
|
<Badge className="text-xs bg-primary text-white border-0">
|
||||||
|
Premium
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
{isSelected && (
|
{isSelected && (
|
||||||
<div className="h-5 w-5 rounded-full bg-primary flex items-center justify-center">
|
<div className="h-5 w-5 rounded-full bg-primary flex items-center justify-center">
|
||||||
<Check className="h-3 w-3 text-primary-foreground" />
|
<Check className="h-3 w-3 text-primary-foreground" />
|
||||||
@@ -268,12 +278,12 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
|
|||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="pt-0">
|
<CardContent className="pt-0">
|
||||||
<div className="flex items-center gap-4 text-xs text-muted-foreground">
|
<div className="flex items-end justify-end gap-4 text-xs text-muted-foreground">
|
||||||
{model.pricing && (
|
{model.pricing && (
|
||||||
<>
|
<div className="text-right">
|
||||||
<span>Input: {formatPrice(model.pricing.prompt)}</span>
|
<div>Input: {formatPrice(model.pricing.prompt)}</div>
|
||||||
<span>Output: {formatPrice(model.pricing.completion)}</span>
|
<div>Output: {formatPrice(model.pricing.completion)}</div>
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
{model.contextLength && (
|
{model.contextLength && (
|
||||||
<span>Context: {model.contextLength.toLocaleString()} tokens</span>
|
<span>Context: {model.contextLength.toLocaleString()} tokens</span>
|
||||||
@@ -285,9 +295,9 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
|
|||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-end gap-2 pt-4 border-t">
|
<div className="flex justify-end gap-2 pt-4 border-t flex-shrink-0">
|
||||||
<Button
|
<Button
|
||||||
onClick={handleContinue}
|
onClick={handleContinue}
|
||||||
disabled={!selectedModel}
|
disabled={!selectedModel}
|
||||||
@@ -310,11 +320,6 @@ export function OnboardingDialog({ open, onOpenChange }: OnboardingDialogProps)
|
|||||||
Just enter your prompt to start building amazing Nostr applications.
|
Just enter your prompt to start building amazing Nostr applications.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-muted/50 rounded-lg p-4 max-w-md mx-auto">
|
|
||||||
<p className="text-sm text-muted-foreground italic">
|
|
||||||
"Create a farming equipment marketplace for local farmers to buy and sell tractors, tools, and supplies..."
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<Button onClick={handleFinish} size="lg" className="gap-2">
|
<Button onClick={handleFinish} size="lg" className="gap-2">
|
||||||
<Sparkles className="h-4 w-4" />
|
<Sparkles className="h-4 w-4" />
|
||||||
Start Building
|
Start Building
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ describe('ProjectSidebar', () => {
|
|||||||
</TestApp>
|
</TestApp>
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByText('🎭')).toBeInTheDocument();
|
expect(screen.getByAltText('Shakespeare')).toBeInTheDocument();
|
||||||
expect(screen.getByText('Shakespeare')).toBeInTheDocument();
|
expect(screen.getByText('Shakespeare')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X, Settings, HelpCircle, FileArchive } from 'lucide-react';
|
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X, Settings, HelpCircle } from 'lucide-react';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
||||||
@@ -9,12 +9,10 @@ import { useProjects } from '@/hooks/useProjects';
|
|||||||
import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus';
|
import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus';
|
||||||
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
import { useLocalStorage } from '@/hooks/useLocalStorage';
|
||||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||||
import { ProjectImportDialog } from '@/components/ProjectImportDialog';
|
|
||||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
|
||||||
import { useToast } from '@/hooks/useToast';
|
|
||||||
import type { Project } from '@/lib/ProjectsManager';
|
import type { Project } from '@/lib/ProjectsManager';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
|
||||||
|
|
||||||
interface ProjectItemProps {
|
interface ProjectItemProps {
|
||||||
project: Project;
|
project: Project;
|
||||||
@@ -95,9 +93,6 @@ export function ProjectSidebar({
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { data: projects = [], isLoading, error } = useProjects();
|
const { data: projects = [], isLoading, error } = useProjects();
|
||||||
const [favorites] = useLocalStorage<string[]>('project-favorites', []);
|
const [favorites] = useLocalStorage<string[]>('project-favorites', []);
|
||||||
const projectsManager = useProjectsManager();
|
|
||||||
const { toast } = useToast();
|
|
||||||
const [isZipDialogOpen, setIsZipDialogOpen] = useState(false);
|
|
||||||
|
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -123,37 +118,6 @@ export function ProjectSidebar({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleImportZip = async (data: { file: File; projectId?: string } | { projects: { id: string; files: { [path: string]: Uint8Array } }[] }, overwrite: boolean) => {
|
|
||||||
try {
|
|
||||||
let project;
|
|
||||||
|
|
||||||
if ('file' in data) {
|
|
||||||
// Single project import
|
|
||||||
project = await projectsManager.importProject(data.file, { projectId: data.projectId, overwrite });
|
|
||||||
|
|
||||||
// Show success toast
|
|
||||||
toast({
|
|
||||||
title: overwrite ? "Project Overwritten Successfully" : "Project Imported Successfully",
|
|
||||||
description: `"${project.name}" has been ${overwrite ? 'overwritten' : 'imported'} and is ready to use.`,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Bulk import - this shouldn't happen in sidebar mode, but handle gracefully
|
|
||||||
throw new Error('Bulk import not supported in sidebar');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close dialog before navigation to prevent reopening
|
|
||||||
setIsZipDialogOpen(false);
|
|
||||||
|
|
||||||
// Navigate to the imported project
|
|
||||||
if (project) {
|
|
||||||
navigate(`/project/${project.id}`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to import project:', error);
|
|
||||||
throw error; // Re-throw to let the dialog handle the error display
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['projects'] });
|
queryClient.invalidateQueries({ queryKey: ['projects'] });
|
||||||
}, [favorites, queryClient]);
|
}, [favorites, queryClient]);
|
||||||
@@ -171,7 +135,7 @@ export function ProjectSidebar({
|
|||||||
onClick={() => navigateAndClose('/')}
|
onClick={() => navigateAndClose('/')}
|
||||||
className="flex items-center gap-3 hover:opacity-80 transition-opacity text-left"
|
className="flex items-center gap-3 hover:opacity-80 transition-opacity text-left"
|
||||||
>
|
>
|
||||||
<span className="text-2xl">🎭</span>
|
<ShakespeareLogo className="w-6 h-6" />
|
||||||
<h1 className="text-xl font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
<h1 className="text-xl font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||||
Shakespeare
|
Shakespeare
|
||||||
</h1>
|
</h1>
|
||||||
@@ -223,13 +187,6 @@ export function ProjectSidebar({
|
|||||||
<GitBranch className="h-4 w-4" />
|
<GitBranch className="h-4 w-4" />
|
||||||
{t('importRepository')}
|
{t('importRepository')}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem
|
|
||||||
onClick={() => setIsZipDialogOpen(true)}
|
|
||||||
className="flex items-center gap-2 w-full"
|
|
||||||
>
|
|
||||||
<FileArchive className="h-4 w-4" />
|
|
||||||
Import ZIP File
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
@@ -292,14 +249,6 @@ export function ProjectSidebar({
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* ZIP Import Dialog */}
|
|
||||||
<ProjectImportDialog
|
|
||||||
mode="single"
|
|
||||||
onImport={handleImportZip}
|
|
||||||
open={isZipDialogOpen}
|
|
||||||
onOpenChange={setIsZipDialogOpen}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ import { useNavigate, useLocation, Outlet } from 'react-router-dom';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||||
import { Menu, Bot, GitBranch, Database, Wifi, Settings2, Info, Mail } from 'lucide-react';
|
import { Menu, Bot, GitBranch, Database, Wifi, Settings2, Info } from 'lucide-react';
|
||||||
import { ProjectSidebar } from '@/components/ProjectSidebar';
|
import { ProjectSidebar } from '@/components/ProjectSidebar';
|
||||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||||
@@ -56,13 +56,6 @@ const getSettingsItems = (t: (key: string) => string): SettingsItem[] => [
|
|||||||
icon: Database,
|
icon: Database,
|
||||||
href: '/settings/data',
|
href: '/settings/data',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'email',
|
|
||||||
title: t('emailUpdates'),
|
|
||||||
description: t('emailUpdatesDescription'),
|
|
||||||
icon: Mail,
|
|
||||||
href: '/settings/email',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'about',
|
id: 'about',
|
||||||
title: t('aboutShakespeare'),
|
title: t('aboutShakespeare'),
|
||||||
|
|||||||
@@ -34,13 +34,14 @@ import { NostrReadNipsIndexTool } from '@/lib/tools/NostrReadNipsIndexTool';
|
|||||||
import { NostrGenerateKindTool } from '@/lib/tools/NostrGenerateKindTool';
|
import { NostrGenerateKindTool } from '@/lib/tools/NostrGenerateKindTool';
|
||||||
import { ShellTool } from '@/lib/tools/ShellTool';
|
import { ShellTool } from '@/lib/tools/ShellTool';
|
||||||
import { TypecheckTool } from '@/lib/tools/TypecheckTool';
|
import { TypecheckTool } from '@/lib/tools/TypecheckTool';
|
||||||
import { ReadConsoleMessagesTool, ProjectPreviewConsoleError, addErrorListener, removeErrorListener } from '@/lib/tools/ReadConsoleMessagesTool';
|
import { ReadConsoleMessagesTool, ProjectPreviewConsoleError } from '@/lib/tools/ReadConsoleMessagesTool';
|
||||||
import { toolToOpenAI } from '@/lib/tools/openai-adapter';
|
import { toolToOpenAI } from '@/lib/tools/openai-adapter';
|
||||||
import { Tool } from '@/lib/tools/Tool';
|
import { Tool } from '@/lib/tools/Tool';
|
||||||
import OpenAI from 'openai';
|
import OpenAI from 'openai';
|
||||||
import { saveFileToTmp } from '@/lib/fileUtils';
|
import { saveFileToTmp } from '@/lib/fileUtils';
|
||||||
import { useGit } from '@/hooks/useGit';
|
import { useGit } from '@/hooks/useGit';
|
||||||
import { Quilly } from '@/components/Quilly';
|
import { Quilly } from '@/components/Quilly';
|
||||||
|
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
|
||||||
|
|
||||||
// Clean interfaces now handled by proper hooks
|
// Clean interfaces now handled by proper hooks
|
||||||
|
|
||||||
@@ -51,6 +52,8 @@ interface ChatPaneProps {
|
|||||||
onLoadingChange?: (isLoading: boolean) => void;
|
onLoadingChange?: (isLoading: boolean) => void;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
isBuildLoading?: boolean;
|
isBuildLoading?: boolean;
|
||||||
|
consoleError?: ProjectPreviewConsoleError | null;
|
||||||
|
onDismissConsoleError?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChatPaneRef {
|
export interface ChatPaneRef {
|
||||||
@@ -64,6 +67,8 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
onLoadingChange,
|
onLoadingChange,
|
||||||
isLoading: externalIsLoading,
|
isLoading: externalIsLoading,
|
||||||
isBuildLoading: externalIsBuildLoading,
|
isBuildLoading: externalIsBuildLoading,
|
||||||
|
consoleError,
|
||||||
|
onDismissConsoleError,
|
||||||
}, ref) => {
|
}, ref) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
@@ -80,18 +85,8 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
const [isStuck, setIsStuck] = useState(false);
|
const [isStuck, setIsStuck] = useState(false);
|
||||||
const [aiError, setAIError] = useState<Error | null>(null);
|
const [aiError, setAIError] = useState<Error | null>(null);
|
||||||
|
|
||||||
// Console error handling
|
// Determine which error to show - console error takes priority over AI errors
|
||||||
useEffect(() => {
|
const displayError = consoleError || aiError;
|
||||||
const handleConsoleError = (error: ProjectPreviewConsoleError) => {
|
|
||||||
// Only show console errors if there's no existing AI error
|
|
||||||
if (!aiError) {
|
|
||||||
setAIError(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
addErrorListener(handleConsoleError);
|
|
||||||
return () => removeErrorListener(handleConsoleError);
|
|
||||||
}, [aiError]);
|
|
||||||
|
|
||||||
// Use external state if provided, otherwise default to false
|
// Use external state if provided, otherwise default to false
|
||||||
const isBuildLoading = externalIsBuildLoading || false;
|
const isBuildLoading = externalIsBuildLoading || false;
|
||||||
@@ -185,7 +180,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
artist: `Working on ${projectId}...`,
|
artist: `Working on ${projectId}...`,
|
||||||
artwork: [
|
artwork: [
|
||||||
{
|
{
|
||||||
src: '/favicon.png',
|
src: '/shakespeare.png',
|
||||||
sizes: '512x512',
|
sizes: '512x512',
|
||||||
type: 'image/png'
|
type: 'image/png'
|
||||||
}
|
}
|
||||||
@@ -225,6 +220,15 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
sendMessage('Read the console messages and fix any errors present.', providerModel);
|
sendMessage('Read the console messages and fix any errors present.', providerModel);
|
||||||
}, [sendMessage, providerModel]);
|
}, [sendMessage, providerModel]);
|
||||||
|
|
||||||
|
// Handle error dismissal
|
||||||
|
const handleErrorDismiss = useCallback(() => {
|
||||||
|
if (consoleError && onDismissConsoleError) {
|
||||||
|
onDismissConsoleError();
|
||||||
|
} else {
|
||||||
|
setAIError(null);
|
||||||
|
}
|
||||||
|
}, [consoleError, onDismissConsoleError]);
|
||||||
|
|
||||||
// Use external loading state if provided, otherwise use internal state
|
// Use external loading state if provided, otherwise use internal state
|
||||||
const isLoading = externalIsLoading !== undefined ? externalIsLoading : internalIsLoading;
|
const isLoading = externalIsLoading !== undefined ? externalIsLoading : internalIsLoading;
|
||||||
|
|
||||||
@@ -525,7 +529,9 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
{messages.length === 0 && !streamingMessage && !isLoading && (
|
{messages.length === 0 && !streamingMessage && !isLoading && (
|
||||||
<div className="flex-1 flex items-center justify-center min-h-[400px]">
|
<div className="flex-1 flex items-center justify-center min-h-[400px]">
|
||||||
<div className="text-center space-y-4 max-w-md mx-auto">
|
<div className="text-center space-y-4 max-w-md mx-auto">
|
||||||
<div className="text-6xl mb-6">🎭</div>
|
<div className="mb-6">
|
||||||
|
<ShakespeareLogo className="w-16 h-16 mx-auto" />
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 className="text-xl font-semibold mb-2 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
<h3 className="text-xl font-semibold mb-2 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||||
{t('welcomeToShakespeare')}
|
{t('welcomeToShakespeare')}
|
||||||
@@ -608,11 +614,11 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* AI Error Alert */}
|
{/* Error Alert (Console or AI) */}
|
||||||
{aiError && (
|
{displayError && (
|
||||||
<Quilly
|
<Quilly
|
||||||
error={aiError}
|
error={displayError}
|
||||||
onDismiss={() => setAIError(null)}
|
onDismiss={handleErrorDismiss}
|
||||||
onNewChat={onNewChat}
|
onNewChat={onNewChat}
|
||||||
onOpenModelSelector={openModelSelector}
|
onOpenModelSelector={openModelSelector}
|
||||||
onRequestConsoleErrorHelp={handleConsoleErrorHelp}
|
onRequestConsoleErrorHelp={handleConsoleErrorHelp}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { useBuildProject } from '@/hooks/useBuildProject';
|
|||||||
import { Tabs, TabsContent } from '@/components/ui/tabs';
|
import { Tabs, TabsContent } from '@/components/ui/tabs';
|
||||||
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { FolderOpen, ArrowLeft, Bug, Copy, Check, Play, Loader2, MenuIcon, Code, CloudUpload, X } from 'lucide-react';
|
import { FolderOpen, ArrowLeft, Bug, Copy, Check, Play, Loader2, MenuIcon, Code, CloudUpload, X, Terminal } from 'lucide-react';
|
||||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||||
import { GitStatusIndicator } from '@/components/GitStatusIndicator';
|
import { GitStatusIndicator } from '@/components/GitStatusIndicator';
|
||||||
import { BrowserAddressBar } from '@/components/ui/browser-address-bar';
|
import { BrowserAddressBar } from '@/components/ui/browser-address-bar';
|
||||||
@@ -27,6 +27,7 @@ import { cn } from '@/lib/utils';
|
|||||||
import { FileTree } from './FileTree';
|
import { FileTree } from './FileTree';
|
||||||
import { FileEditor } from './FileEditor';
|
import { FileEditor } from './FileEditor';
|
||||||
import { DeployDialog } from '@/components/DeployDialog';
|
import { DeployDialog } from '@/components/DeployDialog';
|
||||||
|
import { Terminal as TerminalComponent } from '@/components/Terminal';
|
||||||
import { useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
// Get iframe domain from environment variable
|
// Get iframe domain from environment variable
|
||||||
@@ -76,7 +77,8 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
|||||||
const [selectedFile, setSelectedFile] = useState<string | null>(null);
|
const [selectedFile, setSelectedFile] = useState<string | null>(null);
|
||||||
const [fileContent, setFileContent] = useState<string>('');
|
const [fileContent, setFileContent] = useState<string>('');
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [mobileCodeView, setMobileCodeView] = useState<'explorer' | 'editor'>('explorer');
|
const [mobileCodeView, setMobileCodeView] = useState<'explorer' | 'editor' | 'terminal'>('explorer');
|
||||||
|
const [desktopCodeView, setDesktopCodeView] = useState<'files' | 'terminal'>('files');
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const [hasBuiltProject, setHasBuiltProject] = useState(false);
|
const [hasBuiltProject, setHasBuiltProject] = useState(false);
|
||||||
const [currentPath, setCurrentPath] = useState('/');
|
const [currentPath, setCurrentPath] = useState('/');
|
||||||
@@ -455,6 +457,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
|||||||
setSelectedFile(null);
|
setSelectedFile(null);
|
||||||
setFileContent('');
|
setFileContent('');
|
||||||
setMobileCodeView('explorer');
|
setMobileCodeView('explorer');
|
||||||
|
setDesktopCodeView('files');
|
||||||
|
|
||||||
// Reset navigation history and state
|
// Reset navigation history and state
|
||||||
setCurrentPath('/');
|
setCurrentPath('/');
|
||||||
@@ -729,18 +732,48 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
|||||||
|
|
||||||
<TabsContent value="code" className="h-full mt-0">
|
<TabsContent value="code" className="h-full mt-0">
|
||||||
{isMobile ? (
|
{isMobile ? (
|
||||||
<div className="h-full flex flex-col">
|
<div className="h-full flex flex-col min-h-0">
|
||||||
{mobileCodeView === 'explorer' ? (
|
{mobileCodeView === 'explorer' ? (
|
||||||
<ScrollArea className="flex-1">
|
<div className="flex-1 relative min-h-0">
|
||||||
<ScrollBar orientation="horizontal" />
|
<ScrollArea className="h-full">
|
||||||
<div className="min-w-max">
|
<ScrollBar orientation="horizontal" />
|
||||||
<FileTree
|
<div className="min-w-max">
|
||||||
projectId={projectId}
|
<FileTree
|
||||||
onFileSelect={handleFileSelect}
|
projectId={projectId}
|
||||||
selectedFile={selectedFile}
|
onFileSelect={handleFileSelect}
|
||||||
/>
|
selectedFile={selectedFile}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</ScrollArea>
|
||||||
|
{/* Floating Terminal Button */}
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => setMobileCodeView('terminal')}
|
||||||
|
className="fixed right-4 bottom-safe-nav z-20 h-12 w-12 p-0 rounded-full shadow-lg bg-background border-2"
|
||||||
|
>
|
||||||
|
<Terminal className="h-6 w-6" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
) : mobileCodeView === 'terminal' ? (
|
||||||
|
<>
|
||||||
|
<div className="h-12 px-3 flex items-center gap-2 bg-black text-purple-400 flex-shrink-0">
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => setMobileCodeView('explorer')}
|
||||||
|
className="p-1 hover:bg-transparent hover:text-white"
|
||||||
|
>
|
||||||
|
<ArrowLeft className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
<h3 className="font-semibold">
|
||||||
|
Terminal
|
||||||
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
<div className="flex-1 min-h-0">
|
||||||
|
<TerminalComponent projectId={projectId} />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="p-3 border-b bg-gradient-to-r from-primary/5 to-accent/5 flex items-center gap-2">
|
<div className="p-3 border-b bg-gradient-to-r from-primary/5 to-accent/5 flex items-center gap-2">
|
||||||
@@ -803,50 +836,73 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
|||||||
{t('backToPreview')}
|
{t('backToPreview')}
|
||||||
</Button>
|
</Button>
|
||||||
<div className="flex-1" />
|
<div className="flex-1" />
|
||||||
<GitStatusIndicator projectId={projectId} />
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => setDesktopCodeView(desktopCodeView === 'terminal' ? 'files' : 'terminal')}
|
||||||
|
className="gap-2 text-muted-foreground hover:text-foreground"
|
||||||
|
>
|
||||||
|
<Terminal className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{/* Code view header without back button for non-previewable projects */}
|
{/* Code view header without back button for non-previewable projects */}
|
||||||
{!isMobile && !isPreviewable && (
|
{!isMobile && !isPreviewable && (
|
||||||
<div className="h-12 px-4 border-b flex items-center bg-gradient-to-r from-muted/20 to-background">
|
<div className="h-12 px-4 border-b flex items-center bg-gradient-to-r from-muted/20 to-background">
|
||||||
<div className="flex-1" />
|
<div className="flex-1" />
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => setDesktopCodeView(desktopCodeView === 'terminal' ? 'files' : 'terminal')}
|
||||||
|
className="gap-2 text-muted-foreground hover:text-foreground"
|
||||||
|
>
|
||||||
|
<Terminal className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
<GitStatusIndicator projectId={projectId} />
|
<GitStatusIndicator projectId={projectId} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex-1 flex min-h-0">
|
<div className="flex-1 flex min-h-0">
|
||||||
<div className="w-1/3 border-r flex flex-col">
|
{desktopCodeView === 'terminal' ? (
|
||||||
<ScrollArea className="flex-1">
|
<div className="flex-1">
|
||||||
<ScrollBar orientation="horizontal" />
|
<TerminalComponent projectId={projectId} />
|
||||||
<div className="min-w-max">
|
</div>
|
||||||
<FileTree
|
) : (
|
||||||
projectId={projectId}
|
<>
|
||||||
onFileSelect={handleFileSelect}
|
<div className="w-1/3 border-r flex flex-col">
|
||||||
selectedFile={selectedFile}
|
<ScrollArea className="flex-1">
|
||||||
/>
|
<ScrollBar orientation="horizontal" />
|
||||||
|
<div className="min-w-max">
|
||||||
|
<FileTree
|
||||||
|
projectId={projectId}
|
||||||
|
onFileSelect={handleFileSelect}
|
||||||
|
selectedFile={selectedFile}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</ScrollArea>
|
||||||
</div>
|
</div>
|
||||||
</ScrollArea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
{selectedFile ? (
|
{selectedFile ? (
|
||||||
<FileEditor
|
<FileEditor
|
||||||
filePath={selectedFile}
|
filePath={selectedFile}
|
||||||
content={fileContent}
|
content={fileContent}
|
||||||
onSave={handleFileSave}
|
onSave={handleFileSave}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="h-full flex items-center justify-center">
|
<div className="h-full flex items-center justify-center">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
{t('selectFileFromExplorer')}
|
{t('selectFileFromExplorer')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
</>
|
||||||
</div>
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
export interface ShakespeareLogoProps {
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ShakespeareLogo({ className }: ShakespeareLogoProps) {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
src="/shakespeare.svg"
|
||||||
|
alt="Shakespeare"
|
||||||
|
className={className}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
||||||
|
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Copy } from 'lucide-react';
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import { ShellTool } from '@/lib/tools/ShellTool';
|
||||||
|
import { useFS } from '@/hooks/useFS';
|
||||||
|
import { useGit } from '@/hooks/useGit';
|
||||||
|
|
||||||
|
interface TerminalProps {
|
||||||
|
projectId: string;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TerminalLine {
|
||||||
|
id: string;
|
||||||
|
type: 'input' | 'output' | 'error';
|
||||||
|
content: string;
|
||||||
|
timestamp: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Terminal({ projectId, className }: TerminalProps) {
|
||||||
|
const [lines, setLines] = useState<TerminalLine[]>([]);
|
||||||
|
const [currentInput, setCurrentInput] = useState('');
|
||||||
|
const [isExecuting, setIsExecuting] = useState(false);
|
||||||
|
const [commandHistory, setCommandHistory] = useState<string[]>([]);
|
||||||
|
const [historyIndex, setHistoryIndex] = useState(-1);
|
||||||
|
|
||||||
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
|
const shellToolRef = useRef<ShellTool | null>(null);
|
||||||
|
|
||||||
|
const { fs } = useFS();
|
||||||
|
const { git } = useGit();
|
||||||
|
|
||||||
|
// Initialize ShellTool
|
||||||
|
useEffect(() => {
|
||||||
|
shellToolRef.current = new ShellTool(fs, `/projects/${projectId}`, git);
|
||||||
|
|
||||||
|
// Add welcome message
|
||||||
|
setLines([{
|
||||||
|
id: Date.now().toString(),
|
||||||
|
type: 'output',
|
||||||
|
content: `Welcome to Shakespeare Terminal\nType 'help' to see available commands.`,
|
||||||
|
timestamp: new Date()
|
||||||
|
}]);
|
||||||
|
}, [projectId, fs, git]);
|
||||||
|
|
||||||
|
// Auto-scroll to bottom when new lines are added or execution state changes
|
||||||
|
useEffect(() => {
|
||||||
|
if (scrollRef.current) {
|
||||||
|
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
||||||
|
}
|
||||||
|
}, [lines, isExecuting]);
|
||||||
|
|
||||||
|
// Focus input when component mounts
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
inputRef.current.focus();
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Refocus input after command execution
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isExecuting && inputRef.current) {
|
||||||
|
inputRef.current.focus();
|
||||||
|
}
|
||||||
|
}, [isExecuting]);
|
||||||
|
|
||||||
|
const addLine = useCallback((type: TerminalLine['type'], content: string) => {
|
||||||
|
const newLine: TerminalLine = {
|
||||||
|
id: Date.now().toString() + Math.random(),
|
||||||
|
type,
|
||||||
|
content,
|
||||||
|
timestamp: new Date()
|
||||||
|
};
|
||||||
|
setLines(prev => [...prev, newLine]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const executeCommand = useCallback(async (command: string) => {
|
||||||
|
if (!shellToolRef.current || !command.trim()) return;
|
||||||
|
|
||||||
|
// Add command to history
|
||||||
|
if (command.trim() && !commandHistory.includes(command.trim())) {
|
||||||
|
setCommandHistory(prev => [...prev, command.trim()]);
|
||||||
|
}
|
||||||
|
setHistoryIndex(-1);
|
||||||
|
|
||||||
|
// Add input line
|
||||||
|
addLine('input', command);
|
||||||
|
|
||||||
|
setIsExecuting(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Handle special help command
|
||||||
|
if (command.trim() === 'help') {
|
||||||
|
const availableCommands = shellToolRef.current.getAvailableCommands();
|
||||||
|
const helpText = `Available commands:\n\n${availableCommands.map(cmd =>
|
||||||
|
`${cmd.name.padEnd(12)} - ${cmd.description}`
|
||||||
|
).join('\n')}\n\nUse 'which <command>' for more details about a specific command.`;
|
||||||
|
addLine('output', helpText);
|
||||||
|
} else if (command.trim() === 'clear') {
|
||||||
|
setLines([]);
|
||||||
|
} else {
|
||||||
|
const result = await shellToolRef.current.execute({ command });
|
||||||
|
|
||||||
|
// Add output
|
||||||
|
if (result && result.trim()) {
|
||||||
|
addLine('output', result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
addLine('error', `Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
||||||
|
} finally {
|
||||||
|
setIsExecuting(false);
|
||||||
|
}
|
||||||
|
}, [addLine, commandHistory]);
|
||||||
|
|
||||||
|
const handleSubmit = useCallback((e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (currentInput.trim() && !isExecuting) {
|
||||||
|
executeCommand(currentInput);
|
||||||
|
setCurrentInput('');
|
||||||
|
}
|
||||||
|
}, [currentInput, isExecuting, executeCommand]);
|
||||||
|
|
||||||
|
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
|
||||||
|
if (e.key === 'ArrowUp') {
|
||||||
|
e.preventDefault();
|
||||||
|
if (commandHistory.length > 0) {
|
||||||
|
const newIndex = historyIndex === -1 ? commandHistory.length - 1 : Math.max(0, historyIndex - 1);
|
||||||
|
setHistoryIndex(newIndex);
|
||||||
|
setCurrentInput(commandHistory[newIndex]);
|
||||||
|
}
|
||||||
|
} else if (e.key === 'ArrowDown') {
|
||||||
|
e.preventDefault();
|
||||||
|
if (historyIndex >= 0) {
|
||||||
|
const newIndex = historyIndex + 1;
|
||||||
|
if (newIndex >= commandHistory.length) {
|
||||||
|
setHistoryIndex(-1);
|
||||||
|
setCurrentInput('');
|
||||||
|
} else {
|
||||||
|
setHistoryIndex(newIndex);
|
||||||
|
setCurrentInput(commandHistory[newIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (e.key === 'Tab') {
|
||||||
|
e.preventDefault();
|
||||||
|
// Basic tab completion could be added here
|
||||||
|
}
|
||||||
|
}, [commandHistory, historyIndex]);
|
||||||
|
|
||||||
|
const copyToClipboard = useCallback(async (content: string) => {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(content);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to copy to clipboard:', error);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Focus input when clicking anywhere in the terminal
|
||||||
|
const handleTerminalClick = useCallback(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
inputRef.current.focus();
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={cn("h-full flex flex-col bg-black text-slate-300 font-mono text-sm", className)}>
|
||||||
|
{/* Terminal Content */}
|
||||||
|
<div className="flex-1 flex flex-col min-h-0" onClick={handleTerminalClick}>
|
||||||
|
<ScrollArea className="flex-1" ref={scrollRef}>
|
||||||
|
<div className="p-2 space-y-1">
|
||||||
|
{lines.map((line) => (
|
||||||
|
<div
|
||||||
|
key={line.id}
|
||||||
|
className={cn(
|
||||||
|
"group relative",
|
||||||
|
line.type === 'input' && "text-white",
|
||||||
|
line.type === 'error' && "text-red-400",
|
||||||
|
line.type === 'output' && "text-slate-300"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<pre className="whitespace-pre-wrap break-words font-mono leading-relaxed">
|
||||||
|
{line.type === 'input' ? (
|
||||||
|
<span className="text-purple-400 font-mono whitespace-nowrap">
|
||||||
|
${' '}
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
{line.content}
|
||||||
|
</pre>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
copyToClipboard(line.content);
|
||||||
|
}}
|
||||||
|
className="absolute right-0 top-0 h-4 w-4 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-gray-500 hover:text-white hover:bg-gray-700"
|
||||||
|
>
|
||||||
|
<Copy className="h-2 w-2" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{/* Current Command Input - inline with content */}
|
||||||
|
{!isExecuting && (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span className="text-purple-400 font-mono whitespace-nowrap">
|
||||||
|
$
|
||||||
|
</span>
|
||||||
|
<form onSubmit={handleSubmit} className="flex-1 relative">
|
||||||
|
<input
|
||||||
|
ref={inputRef}
|
||||||
|
type="text"
|
||||||
|
value={currentInput}
|
||||||
|
onChange={(e) => setCurrentInput(e.target.value)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
|
disabled={isExecuting}
|
||||||
|
className="w-full bg-transparent border-none outline-none text-white font-mono placeholder-gray-500 caret-white leading-relaxed"
|
||||||
|
placeholder=""
|
||||||
|
autoComplete="off"
|
||||||
|
spellCheck="false"
|
||||||
|
autoCapitalize="off"
|
||||||
|
autoCorrect="off"
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ScrollArea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
+12
-4
@@ -110,11 +110,13 @@
|
|||||||
|
|
||||||
@layer base {
|
@layer base {
|
||||||
* {
|
* {
|
||||||
@apply border-border;
|
border-color: hsl(var(--border));
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@apply bg-background text-foreground font-sans;
|
background-color: hsl(var(--background));
|
||||||
|
color: hsl(var(--foreground));
|
||||||
|
font-family: 'Inter Variable', 'Inter', 'system-ui', 'sans-serif';
|
||||||
font-feature-settings: "rlig" 1, "calt" 1;
|
font-feature-settings: "rlig" 1, "calt" 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,8 +140,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GitHub-style focus rings */
|
/* GitHub-style focus rings */
|
||||||
.focus-ring {
|
.focus-ring:focus-visible {
|
||||||
@apply focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2;
|
outline: none;
|
||||||
|
box-shadow: 0 0 0 2px hsl(var(--ring));
|
||||||
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Smooth transitions for theme switching */
|
/* Smooth transitions for theme switching */
|
||||||
@@ -256,6 +260,10 @@
|
|||||||
padding-top: env(safe-area-inset-top);
|
padding-top: env(safe-area-inset-top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bottom-safe-nav {
|
||||||
|
bottom: calc(env(safe-area-inset-bottom) + 3.75rem);
|
||||||
|
}
|
||||||
|
|
||||||
/* Mobile navigation button styles - text/icon highlighting only */
|
/* Mobile navigation button styles - text/icon highlighting only */
|
||||||
.mobile-nav-button,
|
.mobile-nav-button,
|
||||||
.mobile-nav-button:hover,
|
.mobile-nav-button:hover,
|
||||||
|
|||||||
@@ -250,7 +250,6 @@ export class SessionManager {
|
|||||||
model,
|
model,
|
||||||
messages,
|
messages,
|
||||||
tools: session.tools && Object.keys(session.tools).length > 0 ? Object.values(session.tools) : undefined,
|
tools: session.tools && Object.keys(session.tools).length > 0 ? Object.values(session.tools) : undefined,
|
||||||
tool_choice: session.tools && Object.keys(session.tools).length > 0 ? 'auto' : undefined,
|
|
||||||
stream: true,
|
stream: true,
|
||||||
stream_options: {
|
stream_options: {
|
||||||
include_usage: true,
|
include_usage: true,
|
||||||
@@ -301,9 +300,9 @@ export class SessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (delta?.tool_calls) {
|
if (delta?.tool_calls) {
|
||||||
for (const toolCallDelta of delta.tool_calls) {
|
for (let i = 0; i < delta.tool_calls.length; i++) {
|
||||||
const index = toolCallDelta.index;
|
const toolCallDelta = delta.tool_calls[i];
|
||||||
if (index === undefined) continue;
|
const index = toolCallDelta.index ?? i; // Fix for Gemini models
|
||||||
|
|
||||||
accumulatedToolCalls[index] ??= {
|
accumulatedToolCalls[index] ??= {
|
||||||
id: '',
|
id: '',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ interface PackageLock {
|
|||||||
[key: string]: {
|
[key: string]: {
|
||||||
name?: string;
|
name?: string;
|
||||||
version: string;
|
version: string;
|
||||||
|
peerDependencies?: { [key: string]: string };
|
||||||
} | undefined;
|
} | undefined;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -61,6 +62,14 @@ export function esmPlugin(packageLock: PackageLock, target?: string): Plugin {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Legacy (Internet Explorer) "behavior" syntax
|
||||||
|
build.onResolve({ filter: /^#default#/, namespace: "esm" }, (args) => {
|
||||||
|
return {
|
||||||
|
path: args.path,
|
||||||
|
external: true,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// Handle bare imports like "react"
|
// Handle bare imports like "react"
|
||||||
build.onResolve({ filter: /^[^./].*/ }, (args) => {
|
build.onResolve({ filter: /^[^./].*/ }, (args) => {
|
||||||
const packageName = args.path.startsWith("@")
|
const packageName = args.path.startsWith("@")
|
||||||
@@ -69,8 +78,13 @@ export function esmPlugin(packageLock: PackageLock, target?: string): Plugin {
|
|||||||
|
|
||||||
// Handle transitive dependency versions
|
// Handle transitive dependency versions
|
||||||
const keys: string[] = [];
|
const keys: string[] = [];
|
||||||
|
let importerPackage: string | undefined;
|
||||||
try {
|
try {
|
||||||
const importerPackage = extractPackageName(args.importer);
|
const { pathname } = new URL(args.importer);
|
||||||
|
if (/\.css$/.test(pathname)) {
|
||||||
|
return; // CSS imports don't have external dependencies
|
||||||
|
}
|
||||||
|
importerPackage = extractPackageName(args.importer);
|
||||||
keys.push(
|
keys.push(
|
||||||
`node_modules/${importerPackage}/node_modules/${packageName}`,
|
`node_modules/${importerPackage}/node_modules/${packageName}`,
|
||||||
);
|
);
|
||||||
@@ -89,12 +103,13 @@ export function esmPlugin(packageLock: PackageLock, target?: string): Plugin {
|
|||||||
.find((info) => info);
|
.find((info) => info);
|
||||||
|
|
||||||
const packagePath = args.path.slice(packageName.length);
|
const packagePath = args.path.slice(packageName.length);
|
||||||
const version = packageInfo?.version;
|
const version = packageInfo?.version
|
||||||
|
|| packageLock.packages[`node_modules/${importerPackage}`]?.peerDependencies?.[packageName];
|
||||||
|
|
||||||
if (!version) return;
|
const name = packageInfo?.name ?? packageName;
|
||||||
|
const specifier = version
|
||||||
const name = packageInfo.name ?? packageName;
|
? `${name}@${version}${packagePath}`
|
||||||
const specifier = `${name}@${version}${packagePath}`;
|
: `${name}${packagePath}`;
|
||||||
|
|
||||||
const url = new URL(`https://esm.sh/*${specifier}`);
|
const url = new URL(`https://esm.sh/*${specifier}`);
|
||||||
|
|
||||||
@@ -131,6 +146,14 @@ export function esmPlugin(packageLock: PackageLock, target?: string): Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip static assets
|
||||||
|
if (/\.(woff2?|ttf|otf|eot)$/.test(fullURL.pathname)) {
|
||||||
|
return {
|
||||||
|
path: fullURL.toString(),
|
||||||
|
external: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
path: fullURL.toString(),
|
path: fullURL.toString(),
|
||||||
namespace: "esm",
|
namespace: "esm",
|
||||||
|
|||||||
+31
-10
@@ -1,4 +1,4 @@
|
|||||||
import path from "path-browserify";
|
import { join, dirname, extname } from "path-browserify";
|
||||||
|
|
||||||
import type { Loader, Plugin } from "esbuild-wasm";
|
import type { Loader, Plugin } from "esbuild-wasm";
|
||||||
import type { JSRuntimeFS } from '@/lib/JSRuntime';
|
import type { JSRuntimeFS } from '@/lib/JSRuntime';
|
||||||
@@ -8,27 +8,37 @@ export function fsPlugin(fs: JSRuntimeFS, cwd: string): Plugin {
|
|||||||
name: "fs",
|
name: "fs",
|
||||||
|
|
||||||
setup(build) {
|
setup(build) {
|
||||||
|
build.onResolve({ filter: /^data:/ }, (args) => {
|
||||||
|
return {
|
||||||
|
path: args.path,
|
||||||
|
external: true,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
build.onResolve({ filter: /.*/ }, async (args) => {
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
||||||
let resolved: string;
|
let resolved: string;
|
||||||
|
|
||||||
if (args.path.startsWith("@/")) {
|
if (args.path.startsWith("@/")) {
|
||||||
resolved = path.join(cwd, args.path.slice(2));
|
resolved = join(cwd, args.path.slice(2));
|
||||||
} else if (args.kind === "entry-point") {
|
} else if (args.kind === "entry-point") {
|
||||||
resolved = path.join(cwd, args.path);
|
resolved = join(cwd, args.path);
|
||||||
} else if (args.importer) {
|
} else if (args.importer) {
|
||||||
resolved = path.join(path.dirname(args.importer), args.path);
|
resolved = join(dirname(args.importer), args.path);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Vite query parameters https://vite.dev/guide/assets
|
||||||
|
const [cleaned, query] = resolved.split("?");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resolved = await tryFileVariants(fs, resolved);
|
resolved = await tryFileVariants(fs, cleaned);
|
||||||
} catch {
|
} catch {
|
||||||
return; // Let other plugins handle this
|
return; // Let other plugins handle this
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
path: resolved,
|
path: resolved + (typeof query === "string" ? "?" + query : ""),
|
||||||
namespace: "fs",
|
namespace: "fs",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -36,14 +46,25 @@ export function fsPlugin(fs: JSRuntimeFS, cwd: string): Plugin {
|
|||||||
build.onLoad(
|
build.onLoad(
|
||||||
{ filter: /.*/, namespace: "fs" },
|
{ filter: /.*/, namespace: "fs" },
|
||||||
async (args) => {
|
async (args) => {
|
||||||
const ext = path.extname(args.path).slice(1);
|
const [path, query] = args.path.split("?");
|
||||||
|
const params = new URLSearchParams(query);
|
||||||
|
|
||||||
if (!["ts", "tsx", "js", "jsx", "css"].includes(ext)) {
|
// https://vite.dev/guide/assets.html#importing-asset-as-string
|
||||||
|
if (params.has("raw")) {
|
||||||
|
return {
|
||||||
|
contents: await fs.readFile(path, "utf8"),
|
||||||
|
loader: "text",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const ext = extname(path).slice(1);
|
||||||
|
|
||||||
|
if (!["ts", "tsx", "js", "jsx", "css", "json"].includes(ext)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
contents: await fs.readFile(args.path, "utf8"),
|
contents: await fs.readFile(path, "utf8"),
|
||||||
loader: ext as Loader,
|
loader: ext as Loader,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -67,7 +88,7 @@ async function tryFileVariants(
|
|||||||
// If it's a directory, try index files
|
// If it's a directory, try index files
|
||||||
if (stat.isDirectory()) {
|
if (stat.isDirectory()) {
|
||||||
for (const ext of extensions) {
|
for (const ext of extensions) {
|
||||||
const indexFile = path.join(basePath, "index" + ext);
|
const indexFile = join(basePath, "index" + ext);
|
||||||
const indexStat = await statSafe(fs, indexFile);
|
const indexStat = await statSafe(fs, indexFile);
|
||||||
if (indexStat.isFile()) {
|
if (indexStat.isFile()) {
|
||||||
return indexFile;
|
return indexFile;
|
||||||
|
|||||||
+11
-6
@@ -1,6 +1,7 @@
|
|||||||
import { getEsbuild } from "@/lib/esbuild";
|
import { getEsbuild } from "@/lib/esbuild";
|
||||||
import { copyFiles } from "@/lib/copyFiles";
|
import { copyFiles } from "@/lib/copyFiles";
|
||||||
|
|
||||||
|
import { shakespearePlugin } from "./shakespearePlugin";
|
||||||
import { esmPlugin } from "./esmPlugin";
|
import { esmPlugin } from "./esmPlugin";
|
||||||
import { fsPlugin } from "./fsPlugin";
|
import { fsPlugin } from "./fsPlugin";
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ async function bundle(
|
|||||||
outdir: "/",
|
outdir: "/",
|
||||||
jsx: "automatic",
|
jsx: "automatic",
|
||||||
plugins: [
|
plugins: [
|
||||||
|
shakespearePlugin(), // Takes precedence over esmPlugin
|
||||||
fsPlugin(fs, `${projectPath}/src`),
|
fsPlugin(fs, `${projectPath}/src`),
|
||||||
esmPlugin(JSON.parse(packageLockText), target),
|
esmPlugin(JSON.parse(packageLockText), target),
|
||||||
],
|
],
|
||||||
@@ -71,7 +73,7 @@ async function bundle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update index.html with proper script and link tags
|
// Update index.html with proper script and link tags
|
||||||
updateIndexHtml(doc);
|
updateIndexHtml(doc, dist);
|
||||||
|
|
||||||
const updatedHtml = "<!DOCTYPE html>\n" + doc.documentElement.outerHTML;
|
const updatedHtml = "<!DOCTYPE html>\n" + doc.documentElement.outerHTML;
|
||||||
dist["index.html"] = new TextEncoder().encode(updatedHtml);
|
dist["index.html"] = new TextEncoder().encode(updatedHtml);
|
||||||
@@ -154,7 +156,7 @@ export async function buildProject(options: BuildProjectOptions): Promise<{
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateIndexHtml(doc: Document): void {
|
function updateIndexHtml(doc: Document, dist: Record<string, Uint8Array>): void {
|
||||||
const entrypoint = doc.querySelector('script[src="/src/main.tsx"]');
|
const entrypoint = doc.querySelector('script[src="/src/main.tsx"]');
|
||||||
|
|
||||||
if (!entrypoint) {
|
if (!entrypoint) {
|
||||||
@@ -163,8 +165,11 @@ function updateIndexHtml(doc: Document): void {
|
|||||||
|
|
||||||
entrypoint.setAttribute("src", "/main.js");
|
entrypoint.setAttribute("src", "/main.js");
|
||||||
|
|
||||||
const style = doc.createElement("link");
|
const css = dist["main.css"];
|
||||||
style.setAttribute("rel", "stylesheet");
|
if (css) {
|
||||||
style.setAttribute("href", "/main.css");
|
const style = doc.createElement("style");
|
||||||
doc.head.appendChild(style);
|
style.setAttribute("type", "text/tailwindcss");
|
||||||
|
style.textContent = new TextDecoder().decode(css);
|
||||||
|
doc.head.appendChild(style);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
import type { Plugin } from "esbuild-wasm";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shakespeare plugin for dependency polyfills and workarounds.
|
||||||
|
* This plugin handles specific dependencies that need custom implementations
|
||||||
|
* or dummy APIs to work correctly in the browser environment.
|
||||||
|
*/
|
||||||
|
export function shakespearePlugin(): Plugin {
|
||||||
|
return {
|
||||||
|
name: "shakespeare",
|
||||||
|
|
||||||
|
setup(build) {
|
||||||
|
// Handle "sonner" imports with a dummy API
|
||||||
|
build.onResolve({ filter: /^sonner$/ }, (args) => {
|
||||||
|
return {
|
||||||
|
path: args.path,
|
||||||
|
namespace: "shakespeare-sonner",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Provide dummy sonner implementation
|
||||||
|
build.onLoad({ filter: /.*/, namespace: "shakespeare-sonner" }, () => {
|
||||||
|
return {
|
||||||
|
contents: `
|
||||||
|
// Dummy implementation of sonner toast library
|
||||||
|
|
||||||
|
// Toast function that does nothing
|
||||||
|
const toast = (message, options) => {
|
||||||
|
console.log('[Shakespeare Sonner Mock]:', message, options);
|
||||||
|
return { id: Math.random().toString(36) };
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add common toast methods
|
||||||
|
toast.success = (message, options) => {
|
||||||
|
console.log('[Shakespeare Sonner Mock] Success:', message, options);
|
||||||
|
return { id: Math.random().toString(36) };
|
||||||
|
};
|
||||||
|
|
||||||
|
toast.error = (message, options) => {
|
||||||
|
console.log('[Shakespeare Sonner Mock] Error:', message, options);
|
||||||
|
return { id: Math.random().toString(36) };
|
||||||
|
};
|
||||||
|
|
||||||
|
toast.info = (message, options) => {
|
||||||
|
console.log('[Shakespeare Sonner Mock] Info:', message, options);
|
||||||
|
return { id: Math.random().toString(36) };
|
||||||
|
};
|
||||||
|
|
||||||
|
toast.warning = (message, options) => {
|
||||||
|
console.log('[Shakespeare Sonner Mock] Warning:', message, options);
|
||||||
|
return { id: Math.random().toString(36) };
|
||||||
|
};
|
||||||
|
|
||||||
|
toast.loading = (message, options) => {
|
||||||
|
console.log('[Shakespeare Sonner Mock] Loading:', message, options);
|
||||||
|
return { id: Math.random().toString(36) };
|
||||||
|
};
|
||||||
|
|
||||||
|
toast.promise = (promise, options) => {
|
||||||
|
console.log('[Shakespeare Sonner Mock] Promise:', promise, options);
|
||||||
|
return promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
toast.dismiss = (id) => {
|
||||||
|
console.log('[Shakespeare Sonner Mock] Dismiss:', id);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Toaster component (dummy React component)
|
||||||
|
const Toaster = (props) => {
|
||||||
|
console.log('[Shakespeare Sonner Mock] Toaster component rendered:', props);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Export both named and default exports to match sonner API
|
||||||
|
export { toast, Toaster };
|
||||||
|
export default toast;
|
||||||
|
`,
|
||||||
|
loader: "js",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle "next-themes" imports with a dummy API
|
||||||
|
build.onResolve({ filter: /^next-themes$/ }, (args) => {
|
||||||
|
return {
|
||||||
|
path: args.path,
|
||||||
|
namespace: "shakespeare-next-themes",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Provide dummy next-themes implementation
|
||||||
|
build.onLoad({ filter: /.*/, namespace: "shakespeare-next-themes" }, () => {
|
||||||
|
return {
|
||||||
|
contents: `
|
||||||
|
// Dummy implementation of next-themes
|
||||||
|
|
||||||
|
// useTheme hook that returns system theme
|
||||||
|
const useTheme = () => {
|
||||||
|
return { theme: "system" };
|
||||||
|
};
|
||||||
|
|
||||||
|
// ThemeProvider component (dummy React component)
|
||||||
|
const ThemeProvider = ({ children, ...props }) => {
|
||||||
|
console.log('[Shakespeare next-themes Mock] ThemeProvider rendered:', props);
|
||||||
|
return children;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Export both named and default exports to match next-themes API
|
||||||
|
export { useTheme, ThemeProvider };
|
||||||
|
`,
|
||||||
|
loader: "js",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle "virtual:pwa-register/react" imports with a dummy API
|
||||||
|
build.onResolve({ filter: /^virtual:pwa-register\/react$/ }, (args) => {
|
||||||
|
return {
|
||||||
|
path: args.path,
|
||||||
|
namespace: "shakespeare-pwa-register",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Provide dummy PWA register implementation
|
||||||
|
build.onLoad({ filter: /.*/, namespace: "shakespeare-pwa-register" }, () => {
|
||||||
|
return {
|
||||||
|
contents: `
|
||||||
|
// Dummy implementation of virtual:pwa-register/react
|
||||||
|
|
||||||
|
// useRegisterSW hook that returns dummy functions
|
||||||
|
const useRegisterSW = (options = {}) => {
|
||||||
|
console.log('[Shakespeare PWA Mock] useRegisterSW called:', options);
|
||||||
|
|
||||||
|
return {
|
||||||
|
needRefresh: [false, () => {}],
|
||||||
|
offlineReady: [false, () => {}],
|
||||||
|
updateServiceWorker: (reloadPage) => {
|
||||||
|
console.log('[Shakespeare PWA Mock] updateServiceWorker called:', reloadPage);
|
||||||
|
if (reloadPage) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Export the hook
|
||||||
|
export { useRegisterSW };
|
||||||
|
`,
|
||||||
|
loader: "js",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add more dependency polyfills here as needed
|
||||||
|
// Example structure for future dependencies:
|
||||||
|
// build.onResolve({ filter: /^some-other-package$/ }, (args) => {
|
||||||
|
// return {
|
||||||
|
// path: args.path,
|
||||||
|
// namespace: "shakespeare-other-package",
|
||||||
|
// };
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// build.onLoad({ filter: /.*/, namespace: "shakespeare-other-package" }, () => {
|
||||||
|
// return {
|
||||||
|
// contents: `// Custom implementation for some-other-package`,
|
||||||
|
// loader: "js",
|
||||||
|
// };
|
||||||
|
// });
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,275 @@
|
|||||||
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||||
|
import { GitAddCommand } from './add';
|
||||||
|
import type { JSRuntimeFS } from '../../JSRuntime';
|
||||||
|
import type { Git } from '../../git';
|
||||||
|
|
||||||
|
// Mock filesystem
|
||||||
|
const createMockFS = (): JSRuntimeFS => ({
|
||||||
|
readFile: vi.fn().mockResolvedValue('mock content'),
|
||||||
|
writeFile: vi.fn().mockResolvedValue(undefined),
|
||||||
|
readdir: vi.fn().mockResolvedValue([]),
|
||||||
|
mkdir: vi.fn().mockResolvedValue(undefined),
|
||||||
|
stat: vi.fn().mockImplementation((path: string) => {
|
||||||
|
if (path.endsWith('/.git')) {
|
||||||
|
return Promise.resolve({
|
||||||
|
isDirectory: () => true,
|
||||||
|
isFile: () => false,
|
||||||
|
size: 0,
|
||||||
|
mtimeMs: Date.now(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Promise.resolve({
|
||||||
|
isDirectory: () => false,
|
||||||
|
isFile: () => true,
|
||||||
|
size: 100,
|
||||||
|
mtimeMs: Date.now(),
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
lstat: vi.fn().mockResolvedValue({
|
||||||
|
isDirectory: () => false,
|
||||||
|
isFile: () => true,
|
||||||
|
size: 100,
|
||||||
|
mtimeMs: Date.now(),
|
||||||
|
}),
|
||||||
|
unlink: vi.fn().mockResolvedValue(undefined),
|
||||||
|
rmdir: vi.fn().mockResolvedValue(undefined),
|
||||||
|
rename: vi.fn().mockResolvedValue(undefined),
|
||||||
|
readlink: vi.fn().mockResolvedValue('mock link'),
|
||||||
|
symlink: vi.fn().mockResolvedValue(undefined),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mock Git
|
||||||
|
const createMockGit = (): Git => ({
|
||||||
|
statusMatrix: vi.fn(),
|
||||||
|
add: vi.fn(),
|
||||||
|
remove: vi.fn(),
|
||||||
|
} as unknown as Git);
|
||||||
|
|
||||||
|
describe('GitAddCommand', () => {
|
||||||
|
let addCommand: GitAddCommand;
|
||||||
|
let mockFS: JSRuntimeFS;
|
||||||
|
let mockGit: Git;
|
||||||
|
const testCwd = '/test';
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mockFS = createMockFS();
|
||||||
|
mockGit = createMockGit();
|
||||||
|
addCommand = new GitAddCommand({
|
||||||
|
git: mockGit,
|
||||||
|
fs: mockFS,
|
||||||
|
pwd: testCwd,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have correct command properties', () => {
|
||||||
|
expect(addCommand.name).toBe('add');
|
||||||
|
expect(addCommand.description).toBe('Add file contents to the index');
|
||||||
|
expect(addCommand.usage).toBe('git add [--all | -A] [--] [<pathspec>...]');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return error when not in a git repository', async () => {
|
||||||
|
// Mock stat to throw error for .git directory
|
||||||
|
vi.mocked(mockFS.stat).mockRejectedValueOnce(new Error('ENOENT'));
|
||||||
|
|
||||||
|
const result = await addCommand.execute(['file.txt']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.stderr).toContain('fatal: not a git repository');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return error when no files specified', async () => {
|
||||||
|
const result = await addCommand.execute([]);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.stderr).toContain('Nothing specified, nothing added');
|
||||||
|
expect(result.stderr).toContain('Maybe you wanted to say \'git add .\'?');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add all modified files with --all flag', async () => {
|
||||||
|
// Mock status matrix with modified and untracked files
|
||||||
|
// [filepath, headStatus, workdirStatus, stageStatus]
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['modified.txt', 1, 2, 1], // Modified file (not staged)
|
||||||
|
['untracked.txt', 0, 2, 0], // Untracked file
|
||||||
|
['unchanged.txt', 1, 1, 1], // Unchanged file
|
||||||
|
['staged.txt', 1, 2, 2], // Already staged file
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await addCommand.execute(['--all']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toBe(''); // Git add is silent on success
|
||||||
|
|
||||||
|
// Should add modified and untracked files, but not unchanged or already staged
|
||||||
|
expect(mockGit.add).toHaveBeenCalledWith({
|
||||||
|
dir: testCwd,
|
||||||
|
filepath: 'modified.txt',
|
||||||
|
});
|
||||||
|
expect(mockGit.add).toHaveBeenCalledWith({
|
||||||
|
dir: testCwd,
|
||||||
|
filepath: 'untracked.txt',
|
||||||
|
});
|
||||||
|
expect(mockGit.add).toHaveBeenCalledTimes(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle deleted files with --all flag', async () => {
|
||||||
|
// Mock status matrix with deleted file
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['deleted.txt', 1, 0, 1], // Deleted file (not staged)
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await addCommand.execute(['--all']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toBe('');
|
||||||
|
|
||||||
|
// Should remove the deleted file
|
||||||
|
expect(mockGit.remove).toHaveBeenCalledWith({
|
||||||
|
dir: testCwd,
|
||||||
|
filepath: 'deleted.txt',
|
||||||
|
});
|
||||||
|
expect(mockGit.remove).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add specific file', async () => {
|
||||||
|
const result = await addCommand.execute(['file.txt']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toBe('');
|
||||||
|
|
||||||
|
expect(mockGit.add).toHaveBeenCalledWith({
|
||||||
|
dir: testCwd,
|
||||||
|
filepath: 'file.txt',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle git add . (current directory)', async () => {
|
||||||
|
// Mock status matrix with various files
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['file1.txt', 1, 2, 1], // Modified file
|
||||||
|
['file2.txt', 0, 2, 0], // Untracked file
|
||||||
|
['deleted.txt', 1, 0, 1], // Deleted file
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await addCommand.execute(['.']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toBe('');
|
||||||
|
|
||||||
|
// Should add modified and untracked files
|
||||||
|
expect(mockGit.add).toHaveBeenCalledWith({
|
||||||
|
dir: testCwd,
|
||||||
|
filepath: 'file1.txt',
|
||||||
|
});
|
||||||
|
expect(mockGit.add).toHaveBeenCalledWith({
|
||||||
|
dir: testCwd,
|
||||||
|
filepath: 'file2.txt',
|
||||||
|
});
|
||||||
|
|
||||||
|
// Should remove deleted file
|
||||||
|
expect(mockGit.remove).toHaveBeenCalledWith({
|
||||||
|
dir: testCwd,
|
||||||
|
filepath: 'deleted.txt',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject absolute paths', async () => {
|
||||||
|
const result = await addCommand.execute(['/absolute/path/file.txt']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.stderr).toContain('absolute paths are not supported');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle non-existent files', async () => {
|
||||||
|
// Mock stat to throw error for non-existent file
|
||||||
|
vi.mocked(mockFS.stat).mockImplementation((path: string) => {
|
||||||
|
if (path.endsWith('/.git')) {
|
||||||
|
return Promise.resolve({
|
||||||
|
isDirectory: () => true,
|
||||||
|
isFile: () => false,
|
||||||
|
size: 0,
|
||||||
|
mtimeMs: Date.now(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (path.includes('nonexistent')) {
|
||||||
|
throw new Error('ENOENT');
|
||||||
|
}
|
||||||
|
return Promise.resolve({
|
||||||
|
isDirectory: () => false,
|
||||||
|
isFile: () => true,
|
||||||
|
size: 100,
|
||||||
|
mtimeMs: Date.now(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mock git.remove to also throw error (file doesn't exist in git either)
|
||||||
|
vi.mocked(mockGit.remove).mockRejectedValueOnce(new Error('File not found'));
|
||||||
|
|
||||||
|
const result = await addCommand.execute(['nonexistent.txt']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.stderr).toContain('pathspec \'nonexistent.txt\' did not match any files');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle -A flag (same as --all)', async () => {
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['modified.txt', 1, 2, 1], // Modified file
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await addCommand.execute(['-A']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toBe('');
|
||||||
|
|
||||||
|
expect(mockGit.add).toHaveBeenCalledWith({
|
||||||
|
dir: testCwd,
|
||||||
|
filepath: 'modified.txt',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle mixed options and paths', async () => {
|
||||||
|
// Mock status matrix for --all to work
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['modified.txt', 1, 2, 1], // Modified file
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await addCommand.execute(['--all', 'specific.txt']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
|
||||||
|
// When --all is specified, it should ignore specific paths and add all files
|
||||||
|
expect(mockGit.statusMatrix).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle double dash separator', async () => {
|
||||||
|
const result = await addCommand.execute(['--', 'file.txt']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toBe('');
|
||||||
|
|
||||||
|
expect(mockGit.add).toHaveBeenCalledWith({
|
||||||
|
dir: testCwd,
|
||||||
|
filepath: 'file.txt',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should continue with other files if one fails', async () => {
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['good.txt', 1, 2, 1], // This should succeed
|
||||||
|
['bad.txt', 1, 2, 1], // This will fail
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Mock git.add to fail for bad.txt but succeed for good.txt
|
||||||
|
vi.mocked(mockGit.add).mockImplementation(({ filepath }) => {
|
||||||
|
if (filepath === 'bad.txt') {
|
||||||
|
throw new Error('Permission denied');
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await addCommand.execute(['--all']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0); // Should still succeed overall
|
||||||
|
expect(mockGit.add).toHaveBeenCalledTimes(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
+20
-39
@@ -77,27 +77,22 @@ export class GitAddCommand implements GitSubcommand {
|
|||||||
dir: this.pwd,
|
dir: this.pwd,
|
||||||
});
|
});
|
||||||
|
|
||||||
let addedCount = 0;
|
for (const [filepath, headStatus, workdirStatus, stageStatus] of statusMatrix) {
|
||||||
let removedCount = 0;
|
|
||||||
|
|
||||||
for (const [filepath, headStatus, workdirStatus] of statusMatrix) {
|
|
||||||
try {
|
try {
|
||||||
if (workdirStatus === 0 && headStatus === 1) {
|
if (workdirStatus === 0 && headStatus === 1) {
|
||||||
// File was deleted
|
// File was deleted in working directory
|
||||||
await this.git.remove({
|
await this.git.remove({
|
||||||
|
|
||||||
dir: this.pwd,
|
dir: this.pwd,
|
||||||
filepath,
|
filepath,
|
||||||
});
|
});
|
||||||
removedCount++;
|
} else if (workdirStatus === 2 && stageStatus !== 2) {
|
||||||
} else if (workdirStatus === 1) {
|
// File exists and has changes that aren't staged yet
|
||||||
// File exists (new or modified)
|
|
||||||
await this.git.add({
|
await this.git.add({
|
||||||
|
|
||||||
dir: this.pwd,
|
dir: this.pwd,
|
||||||
filepath,
|
filepath,
|
||||||
});
|
});
|
||||||
addedCount++;
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Continue with other files if one fails
|
// Continue with other files if one fails
|
||||||
@@ -105,19 +100,8 @@ export class GitAddCommand implements GitSubcommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const messages: string[] = [];
|
// Git add is typically silent on success, like real git
|
||||||
if (addedCount > 0) {
|
return createSuccessResult('');
|
||||||
messages.push(`Added ${addedCount} file${addedCount !== 1 ? 's' : ''}`);
|
|
||||||
}
|
|
||||||
if (removedCount > 0) {
|
|
||||||
messages.push(`Removed ${removedCount} file${removedCount !== 1 ? 's' : ''}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messages.length === 0) {
|
|
||||||
return createSuccessResult('');
|
|
||||||
}
|
|
||||||
|
|
||||||
return createSuccessResult(messages.join(', ') + '\n');
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return createErrorResult(`Failed to add all files: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
return createErrorResult(`Failed to add all files: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
||||||
@@ -133,24 +117,24 @@ export class GitAddCommand implements GitSubcommand {
|
|||||||
if (path === '.') {
|
if (path === '.') {
|
||||||
// Add current directory (all files in it)
|
// Add current directory (all files in it)
|
||||||
const statusMatrix = await this.git.statusMatrix({
|
const statusMatrix = await this.git.statusMatrix({
|
||||||
|
|
||||||
dir: this.pwd,
|
dir: this.pwd,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const [filepath, headStatus, workdirStatus] of statusMatrix) {
|
for (const [filepath, headStatus, workdirStatus, stageStatus] of statusMatrix) {
|
||||||
try {
|
try {
|
||||||
if (workdirStatus === 0 && headStatus === 1) {
|
if (workdirStatus === 0 && headStatus === 1) {
|
||||||
// File was deleted
|
// File was deleted in working directory
|
||||||
await this.git.remove({
|
await this.git.remove({
|
||||||
|
|
||||||
dir: this.pwd,
|
dir: this.pwd,
|
||||||
filepath,
|
filepath,
|
||||||
});
|
});
|
||||||
addedFiles.push(filepath);
|
addedFiles.push(filepath);
|
||||||
} else if (workdirStatus === 1) {
|
} else if (workdirStatus === 2 && stageStatus !== 2) {
|
||||||
// File exists
|
// File exists and has changes that aren't staged yet
|
||||||
await this.git.add({
|
await this.git.add({
|
||||||
|
|
||||||
dir: this.pwd,
|
dir: this.pwd,
|
||||||
filepath,
|
filepath,
|
||||||
});
|
});
|
||||||
@@ -179,7 +163,7 @@ export class GitAddCommand implements GitSubcommand {
|
|||||||
} else {
|
} else {
|
||||||
// Add single file
|
// Add single file
|
||||||
await this.git.add({
|
await this.git.add({
|
||||||
|
|
||||||
dir: this.pwd,
|
dir: this.pwd,
|
||||||
filepath: path,
|
filepath: path,
|
||||||
});
|
});
|
||||||
@@ -189,7 +173,7 @@ export class GitAddCommand implements GitSubcommand {
|
|||||||
// Check if it's a deleted file
|
// Check if it's a deleted file
|
||||||
try {
|
try {
|
||||||
await this.git.remove({
|
await this.git.remove({
|
||||||
|
|
||||||
dir: this.pwd,
|
dir: this.pwd,
|
||||||
filepath: path,
|
filepath: path,
|
||||||
});
|
});
|
||||||
@@ -208,11 +192,8 @@ export class GitAddCommand implements GitSubcommand {
|
|||||||
return createErrorResult(errors.join('\n'));
|
return createErrorResult(errors.join('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addedFiles.length === 0) {
|
// Git add is typically silent on success, like real git
|
||||||
return createSuccessResult('');
|
return createSuccessResult('');
|
||||||
}
|
|
||||||
|
|
||||||
return createSuccessResult(`Added ${addedFiles.length} file${addedFiles.length !== 1 ? 's' : ''}\n`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async addDirectory(dirPath: string, addedFiles: string[]): Promise<void> {
|
private async addDirectory(dirPath: string, addedFiles: string[]): Promise<void> {
|
||||||
@@ -231,7 +212,7 @@ export class GitAddCommand implements GitSubcommand {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
await this.git.add({
|
await this.git.add({
|
||||||
|
|
||||||
dir: this.pwd,
|
dir: this.pwd,
|
||||||
filepath: entryPath,
|
filepath: entryPath,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,218 @@
|
|||||||
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||||
|
import { GitStatusCommand } from './status';
|
||||||
|
import type { JSRuntimeFS } from '../../JSRuntime';
|
||||||
|
import type { Git } from '../../git';
|
||||||
|
|
||||||
|
// Mock filesystem
|
||||||
|
const createMockFS = (): JSRuntimeFS => ({
|
||||||
|
readFile: vi.fn().mockResolvedValue('mock content'),
|
||||||
|
writeFile: vi.fn().mockResolvedValue(undefined),
|
||||||
|
readdir: vi.fn().mockResolvedValue([]),
|
||||||
|
mkdir: vi.fn().mockResolvedValue(undefined),
|
||||||
|
stat: vi.fn().mockImplementation((path: string) => {
|
||||||
|
if (path.endsWith('/.git')) {
|
||||||
|
return Promise.resolve({
|
||||||
|
isDirectory: () => true,
|
||||||
|
isFile: () => false,
|
||||||
|
size: 0,
|
||||||
|
mtimeMs: Date.now(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
throw new Error('ENOENT: no such file or directory');
|
||||||
|
}),
|
||||||
|
lstat: vi.fn().mockResolvedValue({
|
||||||
|
isDirectory: () => true,
|
||||||
|
isFile: () => false,
|
||||||
|
size: 0,
|
||||||
|
mtimeMs: Date.now(),
|
||||||
|
}),
|
||||||
|
unlink: vi.fn().mockResolvedValue(undefined),
|
||||||
|
rmdir: vi.fn().mockResolvedValue(undefined),
|
||||||
|
rename: vi.fn().mockResolvedValue(undefined),
|
||||||
|
readlink: vi.fn().mockResolvedValue('mock link'),
|
||||||
|
symlink: vi.fn().mockResolvedValue(undefined),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mock Git
|
||||||
|
const createMockGit = (): Git => ({
|
||||||
|
statusMatrix: vi.fn(),
|
||||||
|
currentBranch: vi.fn(),
|
||||||
|
stat: vi.fn(),
|
||||||
|
} as unknown as Git);
|
||||||
|
|
||||||
|
describe('GitStatusCommand', () => {
|
||||||
|
let statusCommand: GitStatusCommand;
|
||||||
|
let mockFS: JSRuntimeFS;
|
||||||
|
let mockGit: Git;
|
||||||
|
const testCwd = '/test';
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
mockFS = createMockFS();
|
||||||
|
mockGit = createMockGit();
|
||||||
|
statusCommand = new GitStatusCommand({
|
||||||
|
git: mockGit,
|
||||||
|
fs: mockFS,
|
||||||
|
pwd: testCwd,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have correct command properties', () => {
|
||||||
|
expect(statusCommand.name).toBe('status');
|
||||||
|
expect(statusCommand.description).toBe('Show the working tree status');
|
||||||
|
expect(statusCommand.usage).toBe('git status [--porcelain] [--short]');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return error when not in a git repository', async () => {
|
||||||
|
// Mock stat to throw error for .git directory
|
||||||
|
vi.mocked(mockFS.stat).mockRejectedValueOnce(new Error('ENOENT'));
|
||||||
|
|
||||||
|
const result = await statusCommand.execute([]);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.stderr).toContain('fatal: not a git repository');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show clean status when no changes', async () => {
|
||||||
|
// Mock git status matrix with no changes
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([]);
|
||||||
|
vi.mocked(mockGit.currentBranch).mockResolvedValue('main');
|
||||||
|
|
||||||
|
const result = await statusCommand.execute([]);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toContain('On branch main');
|
||||||
|
expect(result.stdout).toContain('nothing to commit, working tree clean');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show untracked files correctly', async () => {
|
||||||
|
// Mock git status matrix with untracked file
|
||||||
|
// [filepath, headStatus, workdirStatus, stageStatus]
|
||||||
|
// Untracked: headStatus=0, stageStatus=0, workdirStatus=2
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['newfile.txt', 0, 2, 0]
|
||||||
|
]);
|
||||||
|
vi.mocked(mockGit.currentBranch).mockResolvedValue('main');
|
||||||
|
|
||||||
|
const result = await statusCommand.execute([]);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toContain('On branch main');
|
||||||
|
expect(result.stdout).toContain('Untracked files:');
|
||||||
|
expect(result.stdout).toContain('newfile.txt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show staged files correctly', async () => {
|
||||||
|
// Mock git status matrix with staged file
|
||||||
|
// Staged new file: headStatus=0, stageStatus=2, workdirStatus=2
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['newfile.txt', 0, 2, 2]
|
||||||
|
]);
|
||||||
|
vi.mocked(mockGit.currentBranch).mockResolvedValue('main');
|
||||||
|
|
||||||
|
const result = await statusCommand.execute([]);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toContain('On branch main');
|
||||||
|
expect(result.stdout).toContain('Changes to be committed:');
|
||||||
|
expect(result.stdout).toContain('new file: newfile.txt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show modified files correctly', async () => {
|
||||||
|
// Mock git status matrix with modified file
|
||||||
|
// Modified file: headStatus=1, stageStatus=1, workdirStatus=2
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['existing.txt', 1, 2, 1]
|
||||||
|
]);
|
||||||
|
vi.mocked(mockGit.currentBranch).mockResolvedValue('main');
|
||||||
|
|
||||||
|
const result = await statusCommand.execute([]);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toContain('On branch main');
|
||||||
|
expect(result.stdout).toContain('Changes not staged for commit:');
|
||||||
|
expect(result.stdout).toContain('modified: existing.txt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show deleted files correctly', async () => {
|
||||||
|
// Mock git status matrix with deleted file
|
||||||
|
// Deleted file: headStatus=1, stageStatus=1, workdirStatus=0
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['deleted.txt', 1, 0, 1]
|
||||||
|
]);
|
||||||
|
vi.mocked(mockGit.currentBranch).mockResolvedValue('main');
|
||||||
|
|
||||||
|
const result = await statusCommand.execute([]);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toContain('On branch main');
|
||||||
|
expect(result.stdout).toContain('Changes not staged for commit:');
|
||||||
|
expect(result.stdout).toContain('deleted: deleted.txt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should format porcelain output correctly', async () => {
|
||||||
|
// Mock git status matrix with various changes
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['untracked.txt', 0, 2, 0], // Untracked
|
||||||
|
['staged.txt', 0, 2, 2], // Staged new file
|
||||||
|
['modified.txt', 1, 2, 1], // Modified
|
||||||
|
['deleted.txt', 1, 0, 1], // Deleted
|
||||||
|
]);
|
||||||
|
vi.mocked(mockGit.currentBranch).mockResolvedValue('main');
|
||||||
|
|
||||||
|
const result = await statusCommand.execute(['--porcelain']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toContain('?? untracked.txt');
|
||||||
|
expect(result.stdout).toContain('A staged.txt');
|
||||||
|
expect(result.stdout).toContain(' M modified.txt');
|
||||||
|
expect(result.stdout).toContain(' D deleted.txt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle short format', async () => {
|
||||||
|
// Mock git status matrix with changes
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['untracked.txt', 0, 2, 0], // Untracked
|
||||||
|
]);
|
||||||
|
vi.mocked(mockGit.currentBranch).mockResolvedValue('main');
|
||||||
|
|
||||||
|
const result = await statusCommand.execute(['--short']);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toContain('?? untracked.txt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle complex status matrix correctly', async () => {
|
||||||
|
// Mock git status matrix with a complex scenario
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([
|
||||||
|
['file1.txt', 1, 2, 2], // Modified and staged
|
||||||
|
['file2.txt', 0, 2, 0], // Untracked
|
||||||
|
['file3.txt', 1, 0, 0], // Deleted (staged)
|
||||||
|
['file4.txt', 1, 2, 1], // Modified (not staged)
|
||||||
|
]);
|
||||||
|
vi.mocked(mockGit.currentBranch).mockResolvedValue('feature-branch');
|
||||||
|
|
||||||
|
const result = await statusCommand.execute([]);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toContain('On branch feature-branch');
|
||||||
|
expect(result.stdout).toContain('Changes to be committed:');
|
||||||
|
expect(result.stdout).toContain('modified: file1.txt');
|
||||||
|
expect(result.stdout).toContain('deleted: file3.txt');
|
||||||
|
expect(result.stdout).toContain('Untracked files:');
|
||||||
|
expect(result.stdout).toContain('file2.txt');
|
||||||
|
expect(result.stdout).toContain('Changes not staged for commit:');
|
||||||
|
expect(result.stdout).toContain('modified: file4.txt');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle detached HEAD state', async () => {
|
||||||
|
// Mock git status matrix with no current branch
|
||||||
|
vi.mocked(mockGit.statusMatrix).mockResolvedValue([]);
|
||||||
|
vi.mocked(mockGit.currentBranch).mockResolvedValue(undefined);
|
||||||
|
|
||||||
|
const result = await statusCommand.execute([]);
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stdout).toContain('HEAD detached at unknown');
|
||||||
|
expect(result.stdout).toContain('nothing to commit, working tree clean');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -39,7 +39,6 @@ export class GitStatusCommand implements GitSubcommand {
|
|||||||
let currentBranch: string | null = null;
|
let currentBranch: string | null = null;
|
||||||
try {
|
try {
|
||||||
currentBranch = await this.git.currentBranch({
|
currentBranch = await this.git.currentBranch({
|
||||||
|
|
||||||
dir: this.pwd,
|
dir: this.pwd,
|
||||||
}) || null;
|
}) || null;
|
||||||
} catch {
|
} catch {
|
||||||
@@ -78,22 +77,26 @@ export class GitStatusCommand implements GitSubcommand {
|
|||||||
let indexStatus = ' ';
|
let indexStatus = ' ';
|
||||||
let workingStatus = ' ';
|
let workingStatus = ' ';
|
||||||
|
|
||||||
// Determine index status (staged changes)
|
// Determine index status (staged changes - comparing HEAD to stage)
|
||||||
if (headStatus === 0 && stageStatus === 1) {
|
if (headStatus === 0 && stageStatus === 2) {
|
||||||
indexStatus = 'A'; // Added
|
indexStatus = 'A'; // Added to stage
|
||||||
} else if (headStatus === 1 && stageStatus === 0) {
|
} else if (headStatus === 1 && stageStatus === 0) {
|
||||||
indexStatus = 'D'; // Deleted
|
indexStatus = 'D'; // Deleted from stage
|
||||||
} else if (headStatus === 1 && stageStatus === 1 && headStatus !== stageStatus) {
|
} else if (headStatus === 1 && stageStatus === 2) {
|
||||||
indexStatus = 'M'; // Modified
|
indexStatus = 'M'; // Modified in stage
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine working directory status
|
// Determine working directory status (comparing stage to working dir)
|
||||||
if (headStatus === 0 && stageStatus === 0 && workdirStatus === 1) {
|
if (headStatus === 0 && stageStatus === 0 && workdirStatus === 2) {
|
||||||
workingStatus = '?'; // Untracked
|
// Untracked files show as ?? in porcelain format
|
||||||
|
indexStatus = '?';
|
||||||
|
workingStatus = '?';
|
||||||
|
} else if (stageStatus === 2 && workdirStatus === 0) {
|
||||||
|
workingStatus = 'D'; // Deleted in working dir
|
||||||
} else if (stageStatus === 1 && workdirStatus === 0) {
|
} else if (stageStatus === 1 && workdirStatus === 0) {
|
||||||
workingStatus = 'D'; // Deleted
|
workingStatus = 'D'; // Deleted in working dir (was same as HEAD)
|
||||||
} else if (stageStatus !== workdirStatus) {
|
} else if (stageStatus !== workdirStatus && workdirStatus === 2) {
|
||||||
workingStatus = 'M'; // Modified
|
workingStatus = 'M'; // Modified in working dir
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only show files with changes
|
// Only show files with changes
|
||||||
@@ -112,7 +115,7 @@ export class GitStatusCommand implements GitSubcommand {
|
|||||||
if (currentBranch) {
|
if (currentBranch) {
|
||||||
lines.push(`On branch ${currentBranch}`);
|
lines.push(`On branch ${currentBranch}`);
|
||||||
} else {
|
} else {
|
||||||
lines.push('On branch main');
|
lines.push('HEAD detached at unknown');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Categorize changes
|
// Categorize changes
|
||||||
@@ -122,24 +125,26 @@ export class GitStatusCommand implements GitSubcommand {
|
|||||||
const deleted: string[] = [];
|
const deleted: string[] = [];
|
||||||
|
|
||||||
for (const [filepath, headStatus, workdirStatus, stageStatus] of statusMatrix) {
|
for (const [filepath, headStatus, workdirStatus, stageStatus] of statusMatrix) {
|
||||||
// Staged changes (index differs from HEAD)
|
// Staged changes (stage differs from HEAD)
|
||||||
if (headStatus === 0 && stageStatus === 1) {
|
if (headStatus === 0 && stageStatus === 2) {
|
||||||
staged.push(`\tnew file: ${filepath}`);
|
staged.push(`\tnew file: ${filepath}`);
|
||||||
} else if (headStatus === 1 && stageStatus === 0) {
|
} else if (headStatus === 1 && stageStatus === 0) {
|
||||||
staged.push(`\tdeleted: ${filepath}`);
|
staged.push(`\tdeleted: ${filepath}`);
|
||||||
} else if (headStatus !== stageStatus && headStatus === 1 && stageStatus === 1) {
|
} else if (headStatus === 1 && stageStatus === 2) {
|
||||||
staged.push(`\tmodified: ${filepath}`);
|
staged.push(`\tmodified: ${filepath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Working directory changes (working dir differs from index)
|
// Working directory changes (working dir differs from stage)
|
||||||
if (stageStatus === 1 && workdirStatus === 0) {
|
if (stageStatus === 2 && workdirStatus === 0) {
|
||||||
deleted.push(`\tdeleted: ${filepath}`);
|
deleted.push(`\tdeleted: ${filepath}`);
|
||||||
} else if (stageStatus !== workdirStatus && stageStatus === 1 && workdirStatus === 1) {
|
} else if (stageStatus === 1 && workdirStatus === 0) {
|
||||||
|
deleted.push(`\tdeleted: ${filepath}`);
|
||||||
|
} else if (stageStatus !== workdirStatus && workdirStatus === 2) {
|
||||||
modified.push(`\tmodified: ${filepath}`);
|
modified.push(`\tmodified: ${filepath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Untracked files
|
// Untracked files (not in HEAD, not in stage, but in working dir)
|
||||||
if (headStatus === 0 && stageStatus === 0 && workdirStatus === 1) {
|
if (headStatus === 0 && stageStatus === 0 && workdirStatus === 2) {
|
||||||
untracked.push(`\t${filepath}`);
|
untracked.push(`\t${filepath}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,7 +153,7 @@ export class GitStatusCommand implements GitSubcommand {
|
|||||||
if (staged.length > 0) {
|
if (staged.length > 0) {
|
||||||
lines.push('');
|
lines.push('');
|
||||||
lines.push('Changes to be committed:');
|
lines.push('Changes to be committed:');
|
||||||
lines.push(' (use "git reset HEAD <file>..." to unstage)');
|
lines.push(' (use "git restore --staged <file>..." to unstage)');
|
||||||
lines.push('');
|
lines.push('');
|
||||||
lines.push(...staged);
|
lines.push(...staged);
|
||||||
}
|
}
|
||||||
@@ -158,7 +163,7 @@ export class GitStatusCommand implements GitSubcommand {
|
|||||||
lines.push('');
|
lines.push('');
|
||||||
lines.push('Changes not staged for commit:');
|
lines.push('Changes not staged for commit:');
|
||||||
lines.push(' (use "git add <file>..." to update what will be committed)');
|
lines.push(' (use "git add <file>..." to update what will be committed)');
|
||||||
lines.push(' (use "git checkout -- <file>..." to discard changes in working directory)');
|
lines.push(' (use "git restore <file>..." to discard changes in working directory)');
|
||||||
lines.push('');
|
lines.push('');
|
||||||
lines.push(...modified);
|
lines.push(...modified);
|
||||||
lines.push(...deleted);
|
lines.push(...deleted);
|
||||||
|
|||||||
+1
-2
@@ -911,7 +911,6 @@ export class Git {
|
|||||||
const gitRelays = new Set<string>([
|
const gitRelays = new Set<string>([
|
||||||
'wss://git.shakespeare.diy/',
|
'wss://git.shakespeare.diy/',
|
||||||
'wss://relay.ngit.dev/',
|
'wss://relay.ngit.dev/',
|
||||||
'wss://gitnostr.com/',
|
|
||||||
'wss://relay.nostr.band/', // General purpose relay as fallback
|
'wss://relay.nostr.band/', // General purpose relay as fallback
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -1313,6 +1312,7 @@ export class Git {
|
|||||||
dir: options.dir,
|
dir: options.dir,
|
||||||
ref: `refs/heads/${currentBranch}`,
|
ref: `refs/heads/${currentBranch}`,
|
||||||
value: upstreamCommit,
|
value: upstreamCommit,
|
||||||
|
force: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the working directory
|
// Update the working directory
|
||||||
@@ -1395,7 +1395,6 @@ export class Git {
|
|||||||
relayUrls.push(
|
relayUrls.push(
|
||||||
'wss://git.shakespeare.diy/',
|
'wss://git.shakespeare.diy/',
|
||||||
'wss://relay.ngit.dev/',
|
'wss://relay.ngit.dev/',
|
||||||
'wss://gitnostr.com/',
|
|
||||||
'wss://relay.nostr.band/'
|
'wss://relay.nostr.band/'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,9 +81,6 @@ const resources = {
|
|||||||
dataSettingsDescription: 'Export files and manage local data',
|
dataSettingsDescription: 'Export files and manage local data',
|
||||||
emailUpdates: 'Email Updates',
|
emailUpdates: 'Email Updates',
|
||||||
emailUpdatesDescription: 'Subscribe to Shakespeare updates and resources',
|
emailUpdatesDescription: 'Subscribe to Shakespeare updates and resources',
|
||||||
emailUpdatesDescriptionLong: 'Stay updated with the latest Shakespeare features, tutorials, and resources.',
|
|
||||||
aboutShakespeareSettings: 'About Shakespeare',
|
|
||||||
aboutShakespeareSettingsDescription: 'Information about Shakespeare',
|
|
||||||
|
|
||||||
// Project Sidebar
|
// Project Sidebar
|
||||||
newProject: 'New Project',
|
newProject: 'New Project',
|
||||||
@@ -207,7 +204,6 @@ const resources = {
|
|||||||
aboutShakespeare: 'About Shakespeare',
|
aboutShakespeare: 'About Shakespeare',
|
||||||
aboutShakespeareDescription: 'Information about Shakespeare',
|
aboutShakespeareDescription: 'Information about Shakespeare',
|
||||||
sourceCode: 'Source Code',
|
sourceCode: 'Source Code',
|
||||||
viewOnGitLab: 'View on GitLab',
|
|
||||||
description: 'Description',
|
description: 'Description',
|
||||||
license: 'License',
|
license: 'License',
|
||||||
loadingLicense: 'Loading license...',
|
loadingLicense: 'Loading license...',
|
||||||
@@ -396,9 +392,6 @@ const resources = {
|
|||||||
dataSettingsDescription: 'Exporte arquivos e gerencie dados locais',
|
dataSettingsDescription: 'Exporte arquivos e gerencie dados locais',
|
||||||
emailUpdates: 'Atualizações por Email',
|
emailUpdates: 'Atualizações por Email',
|
||||||
emailUpdatesDescription: 'Inscreva-se para receber atualizações e recursos do Shakespeare',
|
emailUpdatesDescription: 'Inscreva-se para receber atualizações e recursos do Shakespeare',
|
||||||
emailUpdatesDescriptionLong: 'Mantenha-se atualizado com os recursos mais recentes do Shakespeare, tutoriais e recursos. Enviamos apenas atualizações ocasionais e você pode cancelar a inscrição a qualquer momento.',
|
|
||||||
aboutShakespeareSettings: 'Sobre o Shakespeare',
|
|
||||||
aboutShakespeareSettingsDescription: 'Informações sobre o Shakespeare',
|
|
||||||
|
|
||||||
// Project Sidebar
|
// Project Sidebar
|
||||||
newProject: 'Novo Projeto',
|
newProject: 'Novo Projeto',
|
||||||
@@ -565,7 +558,6 @@ const resources = {
|
|||||||
aboutShakespeare: 'Sobre o Shakespeare',
|
aboutShakespeare: 'Sobre o Shakespeare',
|
||||||
aboutShakespeareDescription: 'Informações sobre o Shakespeare.',
|
aboutShakespeareDescription: 'Informações sobre o Shakespeare.',
|
||||||
sourceCode: 'Código-fonte',
|
sourceCode: 'Código-fonte',
|
||||||
viewOnGitLab: 'Ver no GitLab',
|
|
||||||
description: 'Descrição',
|
description: 'Descrição',
|
||||||
license: 'Licença',
|
license: 'Licença',
|
||||||
loadingLicense: 'Carregando licença...',
|
loadingLicense: 'Carregando licença...',
|
||||||
@@ -711,9 +703,6 @@ const resources = {
|
|||||||
dataSettingsDescription: '导出文件和管理本地数据',
|
dataSettingsDescription: '导出文件和管理本地数据',
|
||||||
emailUpdates: '邮件更新',
|
emailUpdates: '邮件更新',
|
||||||
emailUpdatesDescription: '订阅Shakespeare更新和资源',
|
emailUpdatesDescription: '订阅Shakespeare更新和资源',
|
||||||
emailUpdatesDescriptionLong: '及时了解最新的Shakespeare功能、教程和资源。我们只会偶尔发送更新,您可以随时取消订阅。',
|
|
||||||
aboutShakespeareSettings: '关于Shakespeare',
|
|
||||||
aboutShakespeareSettingsDescription: '关于Shakespeare的信息',
|
|
||||||
|
|
||||||
// Project Sidebar
|
// Project Sidebar
|
||||||
newProject: '新项目',
|
newProject: '新项目',
|
||||||
@@ -880,7 +869,6 @@ const resources = {
|
|||||||
aboutShakespeare: '关于Shakespeare',
|
aboutShakespeare: '关于Shakespeare',
|
||||||
aboutShakespeareDescription: '关于Shakespeare的信息。',
|
aboutShakespeareDescription: '关于Shakespeare的信息。',
|
||||||
sourceCode: '源代码',
|
sourceCode: '源代码',
|
||||||
viewOnGitLab: '在GitLab上查看',
|
|
||||||
description: '描述',
|
description: '描述',
|
||||||
license: '许可证',
|
license: '许可证',
|
||||||
loadingLicense: '加载许可证中...',
|
loadingLicense: '加载许可证中...',
|
||||||
@@ -1026,9 +1014,6 @@ const resources = {
|
|||||||
dataSettingsDescription: 'Fitar da fayiloli da sarrafa bayanan gida',
|
dataSettingsDescription: 'Fitar da fayiloli da sarrafa bayanan gida',
|
||||||
emailUpdates: 'Sabuntawar Imel',
|
emailUpdates: 'Sabuntawar Imel',
|
||||||
emailUpdatesDescription: 'Yi rajista don karbar sabuntawar Shakespeare da albarkatu',
|
emailUpdatesDescription: 'Yi rajista don karbar sabuntawar Shakespeare da albarkatu',
|
||||||
emailUpdatesDescriptionLong: 'Kasance da sabuntawa game da sabbin fasalolin Shakespeare, koyarwa, da albarkatu. Muna aika sabuntawa lokaci-lokaci kawai kuma kuna iya dakatar da rajista koyaushe.',
|
|
||||||
aboutShakespeareSettings: 'Game da Shakespeare',
|
|
||||||
aboutShakespeareSettingsDescription: 'Bayani game da Shakespeare',
|
|
||||||
|
|
||||||
// Project Sidebar
|
// Project Sidebar
|
||||||
newProject: 'Sabon Aikin',
|
newProject: 'Sabon Aikin',
|
||||||
@@ -1194,7 +1179,6 @@ const resources = {
|
|||||||
aboutShakespeare: 'Game da Shakespeare',
|
aboutShakespeare: 'Game da Shakespeare',
|
||||||
aboutShakespeareDescription: 'Bayani game da Shakespeare.',
|
aboutShakespeareDescription: 'Bayani game da Shakespeare.',
|
||||||
sourceCode: 'Lambar Tushe',
|
sourceCode: 'Lambar Tushe',
|
||||||
viewOnGitLab: 'Duba akan GitLab',
|
|
||||||
description: 'Bayanin',
|
description: 'Bayanin',
|
||||||
license: 'Lasisi',
|
license: 'Lasisi',
|
||||||
loadingLicense: 'Ana lodin lasisi...',
|
loadingLicense: 'Ana lodin lasisi...',
|
||||||
@@ -1340,9 +1324,6 @@ const resources = {
|
|||||||
dataSettingsDescription: 'Gbe awọn faili jade ati ṣakoso data agbegbe',
|
dataSettingsDescription: 'Gbe awọn faili jade ati ṣakoso data agbegbe',
|
||||||
emailUpdates: 'Awọn Imudojuiwọn Imeeli',
|
emailUpdates: 'Awọn Imudojuiwọn Imeeli',
|
||||||
emailUpdatesDescription: 'Forukọsilẹ fun awọn imudojuiwọn Shakespeare ati awọn ohun elo',
|
emailUpdatesDescription: 'Forukọsilẹ fun awọn imudojuiwọn Shakespeare ati awọn ohun elo',
|
||||||
emailUpdatesDescriptionLong: 'Wa pẹlu imudojuiwọn pẹlu awọn ẹya Shakespeare tuntun, awọn ikẹkọ, ati awọn ohun elo. A nfi awọn imudojuiwọn lọọrọọ nikan ranṣẹ ati pe o le da forukọsilẹ duro nigbakugba.',
|
|
||||||
aboutShakespeareSettings: 'Nipa Shakespeare',
|
|
||||||
aboutShakespeareSettingsDescription: 'Alaye nipa Shakespeare',
|
|
||||||
|
|
||||||
// Project Sidebar
|
// Project Sidebar
|
||||||
newProject: 'Iṣẹ akanṣe Tuntun',
|
newProject: 'Iṣẹ akanṣe Tuntun',
|
||||||
@@ -1508,7 +1489,6 @@ const resources = {
|
|||||||
aboutShakespeare: 'Nipa Shakespeare',
|
aboutShakespeare: 'Nipa Shakespeare',
|
||||||
aboutShakespeareDescription: 'Alaye nipa Shakespeare.',
|
aboutShakespeareDescription: 'Alaye nipa Shakespeare.',
|
||||||
sourceCode: 'Koodu Orisun',
|
sourceCode: 'Koodu Orisun',
|
||||||
viewOnGitLab: 'Wo lori GitLab',
|
|
||||||
description: 'Apejuwe',
|
description: 'Apejuwe',
|
||||||
license: 'Iwe-aṣẹ',
|
license: 'Iwe-aṣẹ',
|
||||||
loadingLicense: 'N gbe iwe-aṣẹ...',
|
loadingLicense: 'N gbe iwe-aṣẹ...',
|
||||||
@@ -1649,9 +1629,6 @@ const resources = {
|
|||||||
dataSettingsDescription: 'Bupụta faịlụ na jikwaa data mpaghara',
|
dataSettingsDescription: 'Bupụta faịlụ na jikwaa data mpaghara',
|
||||||
emailUpdates: 'Nmelite Email',
|
emailUpdates: 'Nmelite Email',
|
||||||
emailUpdatesDescription: 'Debanye aha maka nmelite Shakespeare na akụrụngwa',
|
emailUpdatesDescription: 'Debanye aha maka nmelite Shakespeare na akụrụngwa',
|
||||||
emailUpdatesDescriptionLong: 'Nọrọ na-emelite na atụmatụ Shakespeare ọhụrụ, nkuzi, na akụrụngwa. Anyị na-eziga naanị nmelite mgbe ụfọdụ ma ị nwere ike ịkwụsị ndebanye aha mgbe ọ bụla.',
|
|
||||||
aboutShakespeareSettings: 'Gbasara Shakespeare',
|
|
||||||
aboutShakespeareSettingsDescription: 'Ozi gbasara Shakespeare',
|
|
||||||
|
|
||||||
// Project Sidebar
|
// Project Sidebar
|
||||||
newProject: 'Ọrụ Ọhụrụ',
|
newProject: 'Ọrụ Ọhụrụ',
|
||||||
@@ -1817,7 +1794,6 @@ const resources = {
|
|||||||
aboutShakespeare: 'Gbasara Shakespeare',
|
aboutShakespeare: 'Gbasara Shakespeare',
|
||||||
aboutShakespeareDescription: 'Ozi gbasara Shakespeare.',
|
aboutShakespeareDescription: 'Ozi gbasara Shakespeare.',
|
||||||
sourceCode: 'Koodu Isi',
|
sourceCode: 'Koodu Isi',
|
||||||
viewOnGitLab: 'Lee na GitLab',
|
|
||||||
description: 'Nkọwa',
|
description: 'Nkọwa',
|
||||||
license: 'Ikike',
|
license: 'Ikike',
|
||||||
loadingLicense: 'Na-ebu ikike...',
|
loadingLicense: 'Na-ebu ikike...',
|
||||||
|
|||||||
@@ -195,6 +195,25 @@ describe('NpmAddPackageTool', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vi.mocked(mockFS.readFile).mockResolvedValue(JSON.stringify(packageJson, null, 2));
|
||||||
|
|
||||||
|
const result = await tool.execute({ name: 'lodash' });
|
||||||
|
|
||||||
|
// Should not fetch from registry when no version specified and package already installed
|
||||||
|
expect(mockFetch).not.toHaveBeenCalled();
|
||||||
|
expect(mockFS.writeFile).not.toHaveBeenCalled();
|
||||||
|
expect(result).toContain('ℹ️ Package lodash is already installed in dependencies with version ^4.17.21.');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle package already installed with specific version', async () => {
|
||||||
|
const packageJson = {
|
||||||
|
name: 'test-project',
|
||||||
|
version: '1.0.0',
|
||||||
|
dependencies: {
|
||||||
|
'lodash': '^4.17.21'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
vi.mocked(mockFS.readFile).mockResolvedValue(JSON.stringify(packageJson, null, 2));
|
vi.mocked(mockFS.readFile).mockResolvedValue(JSON.stringify(packageJson, null, 2));
|
||||||
mockFetch.mockResolvedValue({
|
mockFetch.mockResolvedValue({
|
||||||
ok: true,
|
ok: true,
|
||||||
@@ -208,10 +227,10 @@ describe('NpmAddPackageTool', () => {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await tool.execute({ name: 'lodash' });
|
const result = await tool.execute({ name: 'lodash', version: '4.17.21' });
|
||||||
|
|
||||||
expect(mockFS.writeFile).not.toHaveBeenCalled();
|
expect(mockFS.writeFile).not.toHaveBeenCalled();
|
||||||
expect(result).toContain('ℹ️ Package [email protected] is already installed');
|
expect(result).toContain('ℹ️ Package [email protected] is already installed in dependencies.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle missing package.json', async () => {
|
it('should handle missing package.json', async () => {
|
||||||
|
|||||||
@@ -88,6 +88,16 @@ export class NpmAddPackageTool implements Tool<NpmAddPackageParams> {
|
|||||||
throw new Error(`❌ Invalid package.json format. Could not parse JSON.`);
|
throw new Error(`❌ Invalid package.json format. Could not parse JSON.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if package already exists
|
||||||
|
const dependencyKey = dev ? 'devDependencies' : 'dependencies';
|
||||||
|
const otherKey = dev ? 'dependencies' : 'devDependencies';
|
||||||
|
|
||||||
|
// If no version is specified and package is already installed, it's a no-op
|
||||||
|
if (!version && packageJson[dependencyKey]?.[name]) {
|
||||||
|
const currentVersion = packageJson[dependencyKey][name];
|
||||||
|
return `ℹ️ Package ${name} is already installed in ${dependencyKey} with version ${currentVersion}.`;
|
||||||
|
}
|
||||||
|
|
||||||
// Determine version to use and fetch package metadata
|
// Determine version to use and fetch package metadata
|
||||||
let targetVersion = version;
|
let targetVersion = version;
|
||||||
let packageMetadata: NpmRegistryResponse;
|
let packageMetadata: NpmRegistryResponse;
|
||||||
@@ -107,10 +117,7 @@ export class NpmAddPackageTool implements Tool<NpmAddPackageParams> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if package already exists
|
// Check if package already exists with the specific version
|
||||||
const dependencyKey = dev ? 'devDependencies' : 'dependencies';
|
|
||||||
const otherKey = dev ? 'dependencies' : 'devDependencies';
|
|
||||||
|
|
||||||
if (packageJson[dependencyKey]?.[name]) {
|
if (packageJson[dependencyKey]?.[name]) {
|
||||||
const currentVersion = packageJson[dependencyKey][name];
|
const currentVersion = packageJson[dependencyKey][name];
|
||||||
if (currentVersion === `^${targetVersion}`) {
|
if (currentVersion === `^${targetVersion}`) {
|
||||||
|
|||||||
+50
-58
@@ -1,12 +1,12 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Info, ExternalLink, Loader2, AlertTriangle, ArrowLeft } from 'lucide-react';
|
import { Info, ExternalLink, Loader2, AlertTriangle, ArrowLeft, Code } from 'lucide-react';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
||||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||||
|
import { EmailSubscription } from '@/components/EmailSubscription';
|
||||||
|
|
||||||
export function AboutSettings() {
|
export function AboutSettings() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -78,64 +78,56 @@ export function AboutSettings() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-6 max-w-xl">
|
||||||
{/* Project Information */}
|
{/* Email Updates */}
|
||||||
<Card>
|
<EmailSubscription />
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="flex items-center gap-2">
|
|
||||||
<Info className="h-5 w-5" />
|
|
||||||
{t('sourceCode')}
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent className="space-y-4">
|
|
||||||
<div>
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
asChild
|
|
||||||
className="w-full sm:w-auto"
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="https://gitlab.com/soapbox-pub/act2"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="flex items-center gap-2"
|
|
||||||
>
|
|
||||||
<ExternalLink className="h-4 w-4" />
|
|
||||||
{t('viewOnGitLab')}
|
|
||||||
</a>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
{/* License */}
|
<div className="space-y-3">
|
||||||
<Accordion type="single" collapsible className="w-full">
|
{/* Project Information */}
|
||||||
<AccordionItem value="license-text" className="border rounded-lg">
|
<Button
|
||||||
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
variant="outline"
|
||||||
<div className="flex items-center gap-2">
|
className="w-full h-12 flex items-center gap-2 justify-start text-base"
|
||||||
<Info className="h-5 w-5" />
|
asChild
|
||||||
{t('license')}
|
>
|
||||||
</div>
|
<a href="https://gitlab.com/soapbox-pub/shakespeare" target="_blank">
|
||||||
</AccordionTrigger>
|
<Code className="!size-5" />
|
||||||
<AccordionContent className="px-4 pb-4">
|
{t('sourceCode')}
|
||||||
{isLoading ? (
|
<ExternalLink className="ml-auto" />
|
||||||
<div className="flex items-center gap-2 text-muted-foreground py-4">
|
</a>
|
||||||
<Loader2 className="h-4 w-4 animate-spin" />
|
</Button>
|
||||||
<span className="text-sm">{t('loadingLicense')}</span>
|
|
||||||
|
{/* License */}
|
||||||
|
<Accordion type="single" collapsible className="w-full">
|
||||||
|
<AccordionItem value="license-text" className="border rounded-lg">
|
||||||
|
<AccordionTrigger className="px-4 py-3 hover:no-underline">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Info className="h-5 w-5" />
|
||||||
|
{t('license')}
|
||||||
</div>
|
</div>
|
||||||
) : error ? (
|
</AccordionTrigger>
|
||||||
<Alert variant="destructive">
|
<AccordionContent className="px-4 pb-4">
|
||||||
<AlertTriangle className="h-4 w-4" />
|
{isLoading ? (
|
||||||
<AlertDescription>
|
<div className="flex items-center gap-2 text-muted-foreground py-4">
|
||||||
{t('failedToLoadLicense')}: {error}
|
<Loader2 className="h-4 w-4 animate-spin" />
|
||||||
</AlertDescription>
|
<span className="text-sm">{t('loadingLicense')}</span>
|
||||||
</Alert>
|
</div>
|
||||||
) : license ? (
|
) : error ? (
|
||||||
<div className="prose text-sm" dangerouslySetInnerHTML={{ __html: license }} />
|
<Alert variant="destructive">
|
||||||
) : null}
|
<AlertTriangle className="h-4 w-4" />
|
||||||
</AccordionContent>
|
<AlertDescription>
|
||||||
</AccordionItem>
|
{t('failedToLoadLicense')}: {error}
|
||||||
</Accordion>
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
) : license ? (
|
||||||
|
<div
|
||||||
|
className="prose text-sm dark:prose-invert mx-auto"
|
||||||
|
dangerouslySetInnerHTML={{ __html: license }}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</AccordionContent>
|
||||||
|
</AccordionItem>
|
||||||
|
</Accordion>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+51
-2
@@ -4,11 +4,12 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { AppLayout } from '@/components/AppLayout';
|
import { AppLayout } from '@/components/AppLayout';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { GitBranch, Loader2, AlertCircle } from 'lucide-react';
|
import { GitBranch, Loader2, AlertCircle, FileArchive, MoreHorizontal } from 'lucide-react';
|
||||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||||
import { useToast } from '@/hooks/useToast';
|
import { useToast } from '@/hooks/useToast';
|
||||||
|
import { ZipImportDialog } from '@/components/ZipImportDialog';
|
||||||
import { useSeoMeta } from '@unhead/react';
|
import { useSeoMeta } from '@unhead/react';
|
||||||
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/dropdown-menu';
|
||||||
|
|
||||||
export default function Clone() {
|
export default function Clone() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -20,6 +21,7 @@ export default function Clone() {
|
|||||||
const projectsManager = useProjectsManager();
|
const projectsManager = useProjectsManager();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const autoCloneInitiatedRef = useRef(false);
|
const autoCloneInitiatedRef = useRef(false);
|
||||||
|
const [isZipDialogOpen, setIsZipDialogOpen] = useState(false);
|
||||||
|
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
title: `${t('importRepository')} - Shakespeare`,
|
title: `${t('importRepository')} - Shakespeare`,
|
||||||
@@ -171,6 +173,25 @@ export default function Clone() {
|
|||||||
}
|
}
|
||||||
}, [handleClone, searchParams]);
|
}, [handleClone, searchParams]);
|
||||||
|
|
||||||
|
const handleImportZip = async (file: File, overwrite = false, projectId?: string) => {
|
||||||
|
try {
|
||||||
|
// Import project from zip file
|
||||||
|
const project = await projectsManager.importProjectFromZip(file, projectId, overwrite);
|
||||||
|
|
||||||
|
// Show success toast
|
||||||
|
toast({
|
||||||
|
title: overwrite ? "Project Overwritten Successfully" : "Project Imported Successfully",
|
||||||
|
description: `"${project.name}" has been ${overwrite ? 'overwritten' : 'imported'} and is ready to use.`,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Navigate to the imported project
|
||||||
|
navigate(`/project/${project.id}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to import project:', error);
|
||||||
|
throw error; // Re-throw to let the dialog handle the error display
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppLayout title={t('importRepository')}>
|
<AppLayout title={t('importRepository')}>
|
||||||
<div className="max-w-2xl mx-auto">
|
<div className="max-w-2xl mx-auto">
|
||||||
@@ -226,7 +247,35 @@ export default function Clone() {
|
|||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Import ZIP File Link */}
|
||||||
|
<div className="mt-8 text-center">
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button variant="ghost" size="icon" className="text-muted-foreground hover:text-primary hover:bg-transparent">
|
||||||
|
<MoreHorizontal className="h-5 w-5" />
|
||||||
|
<span className="sr-only">More options</span>
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="center">
|
||||||
|
<DropdownMenuItem
|
||||||
|
className="flex items-center gap-2 w-full"
|
||||||
|
onClick={() => setIsZipDialogOpen(true)}
|
||||||
|
>
|
||||||
|
<FileArchive className="h-4 w-4" />
|
||||||
|
Import ZIP File
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* ZIP Import Dialog */}
|
||||||
|
<ZipImportDialog
|
||||||
|
onImport={handleImportZip}
|
||||||
|
open={isZipDialogOpen}
|
||||||
|
onOpenChange={setIsZipDialogOpen}
|
||||||
|
/>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,292 +0,0 @@
|
|||||||
import { useState, useEffect } from 'react';
|
|
||||||
import { ArrowLeft, Mail, CheckCircle } from 'lucide-react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import { Input } from '@/components/ui/input';
|
|
||||||
import { Label } from '@/components/ui/label';
|
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
||||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
|
||||||
import { useToast } from '@/hooks/useToast';
|
|
||||||
import { nip19 } from 'nostr-tools';
|
|
||||||
|
|
||||||
export function EmailSettings() {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const isMobile = useIsMobile();
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const { user } = useCurrentUser();
|
|
||||||
const { toast } = useToast();
|
|
||||||
|
|
||||||
const [email, setEmail] = useState('');
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
||||||
const [isSubmitted, setIsSubmitted] = useState(false);
|
|
||||||
|
|
||||||
const url = new URL('https://pub.us7.list-manage.com/subscribe/post?u=f1f718a93795f42a604d558d8&id=f7271442a0&f_id=00ffa3e4f0');
|
|
||||||
const honeypot = `b_${url.searchParams.get('u')}_${url.searchParams.get('id')}`;
|
|
||||||
const tag = '8982396';
|
|
||||||
|
|
||||||
// Check localStorage on component mount
|
|
||||||
useEffect(() => {
|
|
||||||
const hasSubscribed = localStorage.getItem('shakespeare-email-subscribed');
|
|
||||||
if (hasSubscribed === 'true') {
|
|
||||||
setIsSubmitted(true);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (!email.trim()) {
|
|
||||||
toast({
|
|
||||||
title: "Email required",
|
|
||||||
description: "Please enter your email address",
|
|
||||||
variant: "destructive",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Basic email validation
|
|
||||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
||||||
if (!emailRegex.test(email)) {
|
|
||||||
toast({
|
|
||||||
title: "Invalid email",
|
|
||||||
description: "Please enter a valid email address",
|
|
||||||
variant: "destructive",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsSubmitting(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Submit to Mailchimp
|
|
||||||
const form = document.createElement('form');
|
|
||||||
form.method = 'POST';
|
|
||||||
form.action = url.href;
|
|
||||||
form.target = '_blank'; // Open in new tab
|
|
||||||
form.style.display = 'none';
|
|
||||||
|
|
||||||
// Add email field
|
|
||||||
const emailInput = document.createElement('input');
|
|
||||||
emailInput.type = 'email';
|
|
||||||
emailInput.name = 'EMAIL';
|
|
||||||
emailInput.value = email.trim();
|
|
||||||
form.appendChild(emailInput);
|
|
||||||
|
|
||||||
// Add tag field with the new Shakespeare tag ID
|
|
||||||
const tagInput = document.createElement('input');
|
|
||||||
tagInput.type = 'hidden';
|
|
||||||
tagInput.name = 'tags';
|
|
||||||
tagInput.value = tag;
|
|
||||||
form.appendChild(tagInput);
|
|
||||||
|
|
||||||
// Add npub if available
|
|
||||||
if (user?.pubkey) {
|
|
||||||
const npubInput = document.createElement('input');
|
|
||||||
npubInput.type = 'text';
|
|
||||||
npubInput.name = 'NPUB';
|
|
||||||
npubInput.value = nip19.npubEncode(user.pubkey);
|
|
||||||
npubInput.style.display = 'none';
|
|
||||||
form.appendChild(npubInput);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add honeypot field
|
|
||||||
const honeypotInput = document.createElement('input');
|
|
||||||
honeypotInput.type = 'text';
|
|
||||||
honeypotInput.name = honeypot;
|
|
||||||
honeypotInput.tabIndex = -1;
|
|
||||||
honeypotInput.style.position = 'absolute';
|
|
||||||
honeypotInput.style.left = '-5000px';
|
|
||||||
form.appendChild(honeypotInput);
|
|
||||||
|
|
||||||
// Add form to document and submit
|
|
||||||
document.body.appendChild(form);
|
|
||||||
form.submit();
|
|
||||||
|
|
||||||
// Clean up after a short delay
|
|
||||||
setTimeout(() => {
|
|
||||||
document.body.removeChild(form);
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
// Save subscription status to localStorage
|
|
||||||
localStorage.setItem('shakespeare-email-subscribed', 'true');
|
|
||||||
|
|
||||||
setIsSubmitted(true);
|
|
||||||
toast({
|
|
||||||
title: "Successfully subscribed!",
|
|
||||||
description: "You'll receive Shakespeare updates and resources occasionally.",
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Email signup error:', error);
|
|
||||||
toast({
|
|
||||||
title: "Subscription failed",
|
|
||||||
description: "There was an error subscribing you to updates. Please try again.",
|
|
||||||
variant: "destructive",
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setIsSubmitting(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (isSubmitted) {
|
|
||||||
return (
|
|
||||||
<div className="p-6 space-y-6">
|
|
||||||
{isMobile && (
|
|
||||||
<div className="space-y-3">
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => navigate('/settings')}
|
|
||||||
className="h-8 w-auto px-2 -ml-2"
|
|
||||||
>
|
|
||||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
|
||||||
{t('backToSettings')}
|
|
||||||
</Button>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
|
||||||
<Mail className="h-6 w-6 text-primary" />
|
|
||||||
{t('emailUpdates')}
|
|
||||||
</h1>
|
|
||||||
<p className="text-muted-foreground">
|
|
||||||
{t('emailUpdatesDescriptionLong')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isMobile && (
|
|
||||||
<div className="space-y-2">
|
|
||||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
|
||||||
<Mail className="h-6 w-6 text-primary" />
|
|
||||||
{t('emailUpdates')}
|
|
||||||
</h1>
|
|
||||||
<p className="text-muted-foreground">
|
|
||||||
{t('emailUpdatesDescriptionLong')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="max-w-md">
|
|
||||||
<Card>
|
|
||||||
<CardContent className="pt-6">
|
|
||||||
<div className="text-center space-y-4">
|
|
||||||
<CheckCircle className="h-12 w-12 mx-auto text-green-500" />
|
|
||||||
<div className="space-y-2">
|
|
||||||
<h3 className="text-lg font-semibold">
|
|
||||||
Thanks for subscribing!
|
|
||||||
</h3>
|
|
||||||
<p className="text-muted-foreground text-sm">
|
|
||||||
You can opt out at any time using the unsubscribe link in our emails.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Button
|
|
||||||
onClick={() => navigate('/settings')}
|
|
||||||
className="w-full"
|
|
||||||
>
|
|
||||||
Back to Settings
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
localStorage.removeItem('shakespeare-email-subscribed');
|
|
||||||
setIsSubmitted(false);
|
|
||||||
setEmail('');
|
|
||||||
}}
|
|
||||||
variant="outline"
|
|
||||||
className="w-full text-xs"
|
|
||||||
>
|
|
||||||
Subscribe with different email
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="p-6 space-y-6">
|
|
||||||
{isMobile && (
|
|
||||||
<div className="space-y-3">
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => navigate('/settings')}
|
|
||||||
className="h-8 w-auto px-2 -ml-2"
|
|
||||||
>
|
|
||||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
|
||||||
{t('backToSettings')}
|
|
||||||
</Button>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
|
||||||
<Mail className="h-6 w-6 text-primary" />
|
|
||||||
{t('emailUpdates')}
|
|
||||||
</h1>
|
|
||||||
<p className="text-muted-foreground">
|
|
||||||
{t('emailUpdatesDescriptionLong')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isMobile && (
|
|
||||||
<div className="space-y-2">
|
|
||||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
|
||||||
<Mail className="h-6 w-6 text-primary" />
|
|
||||||
{t('emailUpdates')}
|
|
||||||
</h1>
|
|
||||||
<p className="text-muted-foreground">
|
|
||||||
{t('emailUpdatesDescriptionLong')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="max-w-md">
|
|
||||||
<Card>
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="text-lg">
|
|
||||||
Stay Updated with Shakespeare
|
|
||||||
</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label htmlFor="email">
|
|
||||||
Email Address
|
|
||||||
</Label>
|
|
||||||
<Input
|
|
||||||
id="email"
|
|
||||||
type="email"
|
|
||||||
placeholder="[email protected]"
|
|
||||||
value={email}
|
|
||||||
onChange={(e) => setEmail(e.target.value)}
|
|
||||||
disabled={isSubmitting}
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-3">
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
className="w-full"
|
|
||||||
disabled={isSubmitting}
|
|
||||||
>
|
|
||||||
{isSubmitting ? 'Subscribing...' : 'Subscribe to Updates'}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<p className="text-xs text-muted-foreground text-center">
|
|
||||||
You can opt out at any time using the unsubscribe link in our emails.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default EmailSettings;
|
|
||||||
+4
-1
@@ -21,6 +21,7 @@ import { ModelSelector } from '@/components/ModelSelector';
|
|||||||
import { FileAttachment } from '@/components/ui/file-attachment';
|
import { FileAttachment } from '@/components/ui/file-attachment';
|
||||||
import { Plus } from 'lucide-react';
|
import { Plus } from 'lucide-react';
|
||||||
import { useSeoMeta } from '@unhead/react';
|
import { useSeoMeta } from '@unhead/react';
|
||||||
|
import { ShakespeareLogo } from '@/components/ShakespeareLogo';
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -267,7 +268,9 @@ export default function Index() {
|
|||||||
<AppLayout headerContent={headerContent}>
|
<AppLayout headerContent={headerContent}>
|
||||||
<div className="max-w-4xl mx-auto">
|
<div className="max-w-4xl mx-auto">
|
||||||
<div className="text-center mb-8 md:mb-12">
|
<div className="text-center mb-8 md:mb-12">
|
||||||
<div className="text-4xl md:text-6xl mb-4 md:mb-6">🎭</div>
|
<div className="mb-4 md:mb-6">
|
||||||
|
<ShakespeareLogo className="w-20 h-20 md:w-24 md:h-24 mx-auto" />
|
||||||
|
</div>
|
||||||
<h1 className="text-3xl md:text-4xl font-bold mb-3 md:mb-4 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
<h1 className="text-3xl md:text-4xl font-bold mb-3 md:mb-4 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||||
{t('buildNostrApps')}
|
{t('buildNostrApps')}
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
@@ -92,15 +92,13 @@ export function NostrSettings() {
|
|||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="border rounded-lg overflow-hidden">
|
<div className="border rounded-lg overflow-hidden">
|
||||||
{/* Loading skeleton for accounts */}
|
{/* Loading skeleton for accounts */}
|
||||||
{[...Array(2)].map((_, i) => (
|
<div className="flex items-center gap-3 p-3 border-b last:border-b-0">
|
||||||
<div key={i} className="flex items-center gap-3 p-3 border-b last:border-b-0">
|
<Skeleton className="h-10 w-10 rounded-full" />
|
||||||
<Skeleton className="h-10 w-10 rounded-full" />
|
<div className="flex-1 space-y-1">
|
||||||
<div className="flex-1 space-y-1">
|
<Skeleton className="h-4 w-32" />
|
||||||
<Skeleton className="h-4 w-32" />
|
|
||||||
</div>
|
|
||||||
<Skeleton className="h-8 w-8 rounded" />
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
<Skeleton className="h-8 w-8 rounded" />
|
||||||
|
</div>
|
||||||
{/* Add account button skeleton */}
|
{/* Add account button skeleton */}
|
||||||
<div className="flex items-center gap-3 p-3">
|
<div className="flex items-center gap-3 p-3">
|
||||||
<Skeleton className="h-10 w-10 rounded-full" />
|
<Skeleton className="h-10 w-10 rounded-full" />
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { GitStatusIndicator } from '@/components/GitStatusIndicator';
|
|||||||
import { StarButton } from '@/components/StarButton';
|
import { StarButton } from '@/components/StarButton';
|
||||||
import { useBuildProject } from '@/hooks/useBuildProject';
|
import { useBuildProject } from '@/hooks/useBuildProject';
|
||||||
import { useIsProjectPreviewable } from '@/hooks/useIsProjectPreviewable';
|
import { useIsProjectPreviewable } from '@/hooks/useIsProjectPreviewable';
|
||||||
import { clearConsoleMessages } from '@/lib/tools/ReadConsoleMessagesTool';
|
import { clearConsoleMessages, ProjectPreviewConsoleError, addErrorListener, removeErrorListener } from '@/lib/tools/ReadConsoleMessagesTool';
|
||||||
|
|
||||||
export function ProjectView() {
|
export function ProjectView() {
|
||||||
const { projectId } = useParams<{ projectId: string }>();
|
const { projectId } = useParams<{ projectId: string }>();
|
||||||
@@ -29,6 +29,7 @@ export function ProjectView() {
|
|||||||
const [mobileView, setMobileView] = useState<'chat' | 'preview' | 'code'>('chat');
|
const [mobileView, setMobileView] = useState<'chat' | 'preview' | 'code'>('chat');
|
||||||
const [isAILoading, setIsAILoading] = useState(false);
|
const [isAILoading, setIsAILoading] = useState(false);
|
||||||
const [isProjectDetailsOpen, setIsProjectDetailsOpen] = useState(false);
|
const [isProjectDetailsOpen, setIsProjectDetailsOpen] = useState(false);
|
||||||
|
const [consoleError, setConsoleError] = useState<ProjectPreviewConsoleError | null>(null);
|
||||||
|
|
||||||
const projectsManager = useProjectsManager();
|
const projectsManager = useProjectsManager();
|
||||||
const chatPaneRef = useRef<ChatPaneRef>(null);
|
const chatPaneRef = useRef<ChatPaneRef>(null);
|
||||||
@@ -46,8 +47,9 @@ export function ProjectView() {
|
|||||||
try {
|
try {
|
||||||
const projectData = await projectsManager.getProject(projectId);
|
const projectData = await projectsManager.getProject(projectId);
|
||||||
setProject(projectData);
|
setProject(projectData);
|
||||||
// Clear console messages when switching projects
|
// Clear console messages and error state when switching projects
|
||||||
clearConsoleMessages();
|
clearConsoleMessages();
|
||||||
|
setConsoleError(null);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to load project:', error);
|
console.error('Failed to load project:', error);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -79,6 +81,16 @@ export function ProjectView() {
|
|||||||
}
|
}
|
||||||
}, [isPreviewable, mobileView, activeTab]);
|
}, [isPreviewable, mobileView, activeTab]);
|
||||||
|
|
||||||
|
// Global console error listener (always active regardless of current tab)
|
||||||
|
useEffect(() => {
|
||||||
|
const handleConsoleError = (error: ProjectPreviewConsoleError) => {
|
||||||
|
setConsoleError(error);
|
||||||
|
};
|
||||||
|
|
||||||
|
addErrorListener(handleConsoleError);
|
||||||
|
return () => removeErrorListener(handleConsoleError);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleNewChat = () => {
|
const handleNewChat = () => {
|
||||||
// Reset to chat view on mobile when starting new chat
|
// Reset to chat view on mobile when starting new chat
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
@@ -100,6 +112,10 @@ export function ProjectView() {
|
|||||||
// when isAILoading becomes true after user interaction
|
// when isAILoading becomes true after user interaction
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDismissConsoleError = () => {
|
||||||
|
setConsoleError(null);
|
||||||
|
};
|
||||||
|
|
||||||
const handleProjectDeleted = async () => {
|
const handleProjectDeleted = async () => {
|
||||||
setProject(null);
|
setProject(null);
|
||||||
navigate('/');
|
navigate('/');
|
||||||
@@ -212,6 +228,8 @@ export function ProjectView() {
|
|||||||
onLoadingChange={handleAILoadingChange}
|
onLoadingChange={handleAILoadingChange}
|
||||||
isLoading={isAILoading}
|
isLoading={isAILoading}
|
||||||
isBuildLoading={build.isPending}
|
isBuildLoading={build.isPending}
|
||||||
|
consoleError={consoleError}
|
||||||
|
onDismissConsoleError={handleDismissConsoleError}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="h-full p-4 space-y-4">
|
<div className="h-full p-4 space-y-4">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Bot, GitBranch, Database, Wifi, Settings2, Info, Mail } from 'lucide-react';
|
import { Bot, GitBranch, Database, Wifi, Settings2, Info } from 'lucide-react';
|
||||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||||
|
|
||||||
interface SettingsItem {
|
interface SettingsItem {
|
||||||
@@ -48,13 +48,6 @@ const getSettingsItems = (t: (key: string) => string): SettingsItem[] => [
|
|||||||
icon: Database,
|
icon: Database,
|
||||||
href: '/settings/data',
|
href: '/settings/data',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'email',
|
|
||||||
title: t('emailUpdates'),
|
|
||||||
description: t('emailUpdatesDescription'),
|
|
||||||
icon: Mail,
|
|
||||||
href: '/settings/email',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'about',
|
id: 'about',
|
||||||
title: t('aboutShakespeare'),
|
title: t('aboutShakespeare'),
|
||||||
|
|||||||
Reference in new issue
Block a user