Merge branch 'main' into drag-and-drop

This commit is contained in:
filemon committed 2025-09-18 18:58:33 -03:00
commit 3fe03007d2
11 files changed
+189 -817

No files matched your search

+72 -795
View File
File diff suppressed because it is too large. Load diff
+1 -4
View File
@@ -44,7 +44,6 @@
"@radix-ui/react-toggle": "^1.1.0",
"@radix-ui/react-toggle-group": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.4",
"@soapbox.pub/streamdown": "^1.0.11",
"@std/encoding": "npm:@jsr/std__encoding@^1.0.10",
"@std/path": "npm:@jsr/std__path@^1.1.1",
"@tanstack/react-query": "^5.56.2",
@@ -73,10 +72,9 @@
"react-markdown": "^10.1.0",
"react-resizable-panels": "^3.0.3",
"react-router-dom": "^6.26.2",
"react-syntax-highlighter": "^15.6.1",
"recharts": "^2.12.7",
"remark-gfm": "^4.0.1",
"streamdown": "^1.0.12",
"streamdown": "~1.0.0",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7",
"turndown": "^7.2.1",
@@ -98,7 +96,6 @@
"@types/path-browserify": "^1.0.3",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.1",
"@types/react-syntax-highlighter": "^15.5.13",
"@types/turndown": "^5.0.5",
"@vitejs/plugin-react-swc": "^3.5.0",
"autoprefixer": "^10.4.20",
+1
View File
@@ -108,6 +108,7 @@ export function AppLayout({
setIsSidebarVisible(false); // Always collapse sidebar on mobile navigation
handleProjectSelect(project);
}}
onClose={() => setIsSidebarVisible(false)}
/>
</div>
</div>
+33 -9
View File
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2 } from 'lucide-react';
import { Plus, Folder, GitBranch, Loader2, ChevronDown, Star, Columns2, X } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
@@ -8,6 +8,7 @@ import { LoginArea } from '@/components/auth/LoginArea';
import { useProjects } from '@/hooks/useProjects';
import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus';
import { useLocalStorage } from '@/hooks/useLocalStorage';
import { useIsMobile } from '@/hooks/useIsMobile';
import type { Project } from '@/lib/ProjectsManager';
import { cn } from '@/lib/utils';
import { useQueryClient } from '@tanstack/react-query';
@@ -77,23 +78,42 @@ interface ProjectSidebarProps {
onSelectProject: (project: Project | null) => void;
className?: string;
onToggleSidebar?: () => void;
onClose?: () => void;
}
export function ProjectSidebar({
selectedProject,
onSelectProject,
className,
onToggleSidebar
onToggleSidebar,
onClose
}: ProjectSidebarProps) {
const queryClient = useQueryClient();
const { data: projects = [], isLoading, error } = useProjects();
const [favorites] = useLocalStorage<string[]>('project-favorites', []);
const isMobile = useIsMobile();
const navigate = useNavigate();
// Custom navigate function that closes sidebar on mobile
const navigateAndClose = (path: string) => {
navigate(path);
if (isMobile && onClose) {
onClose();
}
};
const handleNewProject = () => {
onSelectProject(null);
navigate('/');
navigateAndClose('/');
};
const handleToggleSidebar = () => {
if (onToggleSidebar) {
onToggleSidebar();
} else if (onClose && isMobile) {
onClose();
}
};
useEffect(() => {
@@ -110,7 +130,7 @@ export function ProjectSidebar({
<div className="flex px-4 h-12 border-b border-sidebar-border bg-gradient-to-r from-primary/10 via-accent/5 to-primary/10">
<div className="flex items-center justify-between w-full">
<button
onClick={() => navigate('/')}
onClick={() => navigateAndClose('/')}
className="flex items-center gap-3 hover:opacity-80 transition-opacity text-left"
>
<span className="text-2xl">🎭</span>
@@ -118,16 +138,20 @@ export function ProjectSidebar({
Shakespeare
</h1>
</button>
{onToggleSidebar && (
{(onToggleSidebar || (onClose && isMobile)) && (
<div className="flex items-center gap-1">
<Button
variant="ghost"
size="sm"
className="h-8 w-8 p-0 hover:bg-primary/10 -mr-2"
onClick={onToggleSidebar}
aria-label="Collapse sidebar"
onClick={handleToggleSidebar}
aria-label={(onClose && isMobile) ? "Close sidebar" : "Collapse sidebar"}
>
<Columns2 className="h-4 w-4 text-primary/60 hover:text-primary" />
{(onClose && isMobile) ? (
<X className="h-4 w-4 text-primary/60 hover:text-primary" />
) : (
<Columns2 className="h-4 w-4 text-primary/60 hover:text-primary" />
)}
</Button>
</div>
)}
@@ -155,7 +179,7 @@ export function ProjectSidebar({
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-48">
<DropdownMenuItem
onClick={() => navigate('/clone')}
onClick={() => navigateAndClose('/clone')}
className="flex items-center gap-2 w-full"
>
<GitBranch className="h-4 w-4" />
+1
View File
@@ -125,6 +125,7 @@ export function SettingsLayout() {
setIsSidebarVisible(false);
handleProjectSelect(project);
}}
onClose={() => setIsSidebarVisible(false)}
/>
</div>
</div>
+49
View File
@@ -0,0 +1,49 @@
import * as React from "react"
import { Eye, EyeOff } from "lucide-react"
import { cn } from "@/lib/utils"
const PasswordInput = React.forwardRef<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>(
({ className, ...props }, ref) => {
const [showPassword, setShowPassword] = React.useState(false)
const [isFocused, setIsFocused] = React.useState(false)
return (
<div className="relative">
<input
type={showPassword ? "text" : "password"}
className={cn(
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
isFocused && "ring-2 ring-ring ring-offset-2",
className
)}
ref={ref}
onFocus={(e) => {
setIsFocused(true)
props.onFocus?.(e)
}}
onBlur={(e) => {
setIsFocused(false)
props.onBlur?.(e)
}}
{...props}
/>
<button
type="button"
onClick={() => setShowPassword(!showPassword)}
className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded-sm disabled:cursor-not-allowed disabled:opacity-50"
disabled={props.disabled}
aria-label={showPassword ? "Hide password" : "Show password"}
>
{showPassword ? (
<EyeOff className="h-4 w-4" />
) : (
<Eye className="h-4 w-4" />
)}
</button>
</div>
)
}
)
PasswordInput.displayName = "PasswordInput"
export { PasswordInput }
+6 -2
View File
@@ -3,6 +3,10 @@ import { renderHook, act } from '@testing-library/react';
import { useGitHubOAuth } from './useGitHubOAuth';
import { TestApp } from '@/test/TestApp';
// Mock environment variables for testing
vi.stubEnv('VITE_GITHUB_OAUTH_CLIENT_ID', '********************');
vi.stubEnv('VITE_GITHUB_OAUTH_CLIENT_SECRET', '****************************************');
// Mock crypto.subtle for PKCE testing
const mockCryptoSubtle = {
digest: vi.fn(),
@@ -57,7 +61,7 @@ describe('useGitHubOAuth PKCE', () => {
wrapper: TestApp,
});
// Mock fetch for token exchange and user info
// Mock fetch for token exchange and user info (using corsproxy.io URLs)
const mockFetch = vi.fn()
.mockResolvedValueOnce({
ok: true,
@@ -143,7 +147,7 @@ describe('useGitHubOAuth PKCE', () => {
// Check that the token request includes the code verifier
expect(mockFetch).toHaveBeenCalledWith(
expect.stringContaining('github.com/login/oauth/access_token'),
expect.stringContaining('corsproxy.io/?url=https://github.com/login/oauth/access_token'),
expect.objectContaining({
method: 'POST',
body: expect.stringContaining('"code_verifier":"test-verifier"'),
+21
View File
@@ -44,6 +44,23 @@ export function esmPlugin(packageLock: PackageLock, target?: string): Plugin {
};
});
// node built-in modules
build.onResolve({ filter: /^node:/ }, (args) => {
const moduleName = args.path.slice(5);
switch (moduleName) {
case "buffer":
return {
path: `https://esm.sh/${moduleName}?target=${target ?? "esnext"}`,
namespace: "esm",
};
default:
return {
errors: [{ text: `Module not found: ${args.path}` }],
};
}
});
// Handle bare imports like "react"
build.onResolve({ filter: /^[^./].*/ }, (args) => {
const packageName = args.path.startsWith("@")
@@ -61,6 +78,10 @@ export function esmPlugin(packageLock: PackageLock, target?: string): Plugin {
// fallthrough
}
if (packageName.startsWith("@jsr/")) {
keys.push(`node_modules/@${packageName.slice(5).replace("__", "/")}`);
}
keys.push(`node_modules/${packageName}`);
const packageInfo = keys
-1
View File
@@ -73,7 +73,6 @@ async function tryFileVariants(
return indexFile;
}
}
throw new Error("Directory without index file");
}
// Try direct file with extensions
+4 -6
View File
@@ -2,6 +2,7 @@ import { useState } from 'react';
import { Check, Bot, ArrowLeft, Trash2 } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { PasswordInput } from '@/components/ui/password-input';
import { Label } from '@/components/ui/label';
import { Separator } from '@/components/ui/separator';
import { Badge } from '@/components/ui/badge';
@@ -245,9 +246,8 @@ export function AISettings() {
{!provider?.nostr && (
<div className="grid gap-2">
<Label htmlFor={`${providerId}-apiKey`}>API Key</Label>
<Input
<PasswordInput
id={`${providerId}-apiKey`}
type="password"
placeholder="Enter your API key"
value={provider?.apiKey || ''}
onChange={(e) => handleUpdateProvider(providerId, { apiKey: e.target.value })}
@@ -286,9 +286,8 @@ export function AISettings() {
</div>
<div className="flex gap-2">
{!preset.nostr && (
<Input
<PasswordInput
placeholder={preset.id === "routstr" ? "Enter a Cashu token" : "Enter your API key"}
type="password"
className="flex-1"
value={presetApiKeys[preset.id] || ''}
onChange={(e) => setPresetApiKeys(prev => ({
@@ -368,9 +367,8 @@ export function AISettings() {
{customAuthMethod === 'api-key' && (
<div className="grid gap-2">
<Label htmlFor="custom-apikey">API Key</Label>
<Input
<PasswordInput
id="custom-apikey"
type="password"
placeholder="Enter your API key (optional)"
value={customApiKey}
onChange={(e) => setCustomApiKey(e.target.value)}
+1
View File
@@ -263,6 +263,7 @@ export function ProjectView() {
navigate('/');
}
}}
onClose={() => setIsSidebarVisible(false)}
/>
</div>
</div>