Merge remote-tracking branch 'origin/main' into electron

This commit is contained in:
Alex Gleason committed 2025-10-23 15:20:27 -05:00
commit 16cfdb555e
42 files changed
+390 -122

No files matched your search

+6 -4
View File
@@ -2,6 +2,7 @@ import { useQueryClient } from '@tanstack/react-query';
import { ReactNode, useState, useEffect } from 'react';
import { AISettingsContext, type AISettings, type AIProvider, type AISettingsContextType } from '@/contexts/AISettingsContext';
import { useFS } from '@/hooks/useFS';
import { useFSPaths } from '@/hooks/useFSPaths';
import { readAISettings, writeAISettings } from '@/lib/configUtils';
interface AISettingsProviderProps {
@@ -16,6 +17,7 @@ const DEFAULT_SETTINGS: AISettings = {
export function AISettingsProvider({ children }: AISettingsProviderProps) {
const queryClient = useQueryClient();
const { fs } = useFS();
const { configPath } = useFSPaths();
const [settings, setSettings] = useState<AISettings>(DEFAULT_SETTINGS);
const [isInitialized, setIsInitialized] = useState(false);
@@ -23,7 +25,7 @@ export function AISettingsProvider({ children }: AISettingsProviderProps) {
useEffect(() => {
const initializeSettings = async () => {
try {
const settings = await readAISettings(fs);
const settings = await readAISettings(fs, configPath);
setSettings(settings);
} catch (error) {
console.error('Failed to initialize AI settings:', error);
@@ -34,7 +36,7 @@ export function AISettingsProvider({ children }: AISettingsProviderProps) {
};
initializeSettings();
}, [fs]);
}, [fs, configPath]);
// Save settings to VFS whenever they change (but not during initialization)
useEffect(() => {
@@ -42,14 +44,14 @@ export function AISettingsProvider({ children }: AISettingsProviderProps) {
const saveSettings = async () => {
try {
await writeAISettings(fs, settings);
await writeAISettings(fs, settings, configPath);
} catch (error) {
console.error('Failed to save AI settings:', error);
}
};
saveSettings();
}, [fs, settings, isInitialized]);
}, [fs, settings, isInitialized, configPath]);
const updateSettings = (newSettings: Partial<AISettings>) => {
setSettings(prev => ({ ...prev, ...newSettings }));
+3
View File
@@ -27,6 +27,9 @@ const AppConfigSchema = z.object({
showcaseEnabled: z.boolean(),
showcaseModerator: z.string(),
ngitServers: z.array(z.string()),
fsPathProjects: z.string().min(1),
fsPathConfig: z.string().min(1),
fsPathTmp: z.string().min(1),
}) satisfies z.ZodType<AppConfig>;
export function AppProvider(props: AppProviderProps) {
+3 -1
View File
@@ -24,6 +24,7 @@ import { useDeploySettings } from '@/hooks/useDeploySettings';
import { useProjectDeploySettings } from '@/hooks/useProjectDeploySettings';
import { useCurrentUser } from '@/hooks/useCurrentUser';
import { useFS } from '@/hooks/useFS';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useAppContext } from '@/hooks/useAppContext';
import { useNostr } from '@nostrify/react';
import { ShakespeareAdapter, NetlifyAdapter, VercelAdapter, NsiteAdapter, DeployAdapter } from '@/lib/deploy';
@@ -115,6 +116,7 @@ export function DeployDialog({ projectId, projectName, open, onOpenChange }: Dep
const { settings: projectSettings, updateSettings: updateProjectSettings } = useProjectDeploySettings(projectId);
const { user } = useCurrentUser();
const { fs } = useFS();
const { projectsPath } = useFSPaths();
const { config } = useAppContext();
const { nostr } = useNostr();
@@ -165,7 +167,7 @@ export function DeployDialog({ projectId, projectName, open, onOpenChange }: Dep
setDeployResult(null);
try {
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
let adapter: DeployAdapter;
+6 -4
View File
@@ -1,6 +1,7 @@
import { useState, useEffect, useMemo, type ReactNode } from 'react';
import { DeploySettingsContext, type DeploySettings, type DeployProvider } from '@/contexts/DeploySettingsContext';
import { useFS } from '@/hooks/useFS';
import { useFSPaths } from '@/hooks/useFSPaths';
import { readDeploySettings, writeDeploySettings } from '@/lib/configUtils';
const DEFAULT_SETTINGS: DeploySettings = {
@@ -9,6 +10,7 @@ const DEFAULT_SETTINGS: DeploySettings = {
export function DeploySettingsProvider({ children }: { children: ReactNode }) {
const { fs } = useFS();
const { configPath } = useFSPaths();
const [settings, setSettings] = useState<DeploySettings>(DEFAULT_SETTINGS);
const [isInitialized, setIsInitialized] = useState(false);
@@ -16,7 +18,7 @@ export function DeploySettingsProvider({ children }: { children: ReactNode }) {
useEffect(() => {
const initializeSettings = async () => {
try {
const settings = await readDeploySettings(fs);
const settings = await readDeploySettings(fs, configPath);
setSettings(settings);
} catch (error) {
console.error('Failed to initialize deploy settings:', error);
@@ -27,7 +29,7 @@ export function DeploySettingsProvider({ children }: { children: ReactNode }) {
};
initializeSettings();
}, [fs]);
}, [fs, configPath]);
// Save settings to VFS whenever they change (but not during initialization)
useEffect(() => {
@@ -35,14 +37,14 @@ export function DeploySettingsProvider({ children }: { children: ReactNode }) {
const saveSettings = async () => {
try {
await writeDeploySettings(fs, settings);
await writeDeploySettings(fs, settings, configPath);
} catch (error) {
console.error('Failed to save deploy settings:', error);
}
};
saveSettings();
}, [fs, settings, isInitialized]);
}, [fs, settings, isInitialized, configPath]);
const updateSettings = (updates: Partial<DeploySettings>) => {
setSettings(prev => ({ ...prev, ...updates }));
+3 -1
View File
@@ -51,6 +51,7 @@ import {
import { useGitStatus } from '@/hooks/useGitStatus';
import { useGitSettings } from '@/hooks/useGitSettings';
import { useGit } from '@/hooks/useGit';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useToast } from '@/hooks/useToast';
import { useCurrentUser } from '@/hooks/useCurrentUser';
import { useNostr } from '@nostrify/react';
@@ -91,6 +92,7 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
const { data: gitStatus, refetch: refetchGitStatus } = useGitStatus(projectId);
const { settings } = useGitSettings();
const { git } = useGit();
const { projectsPath } = useFSPaths();
const { toast } = useToast();
const { user } = useCurrentUser();
const { nostr } = useNostr();
@@ -98,7 +100,7 @@ export function GitDialog({ projectId, children, open, onOpenChange }: GitDialog
const { data: pullRequests, isLoading: isLoadingPRs } = usePullRequests(originUrl);
const { config } = useAppContext();
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
// Initialize origin URL from git status
useEffect(() => {
+2 -1
View File
@@ -171,7 +171,8 @@ describe('GitSettingsProvider', () => {
password: 'test-token',
}
}
})
}),
'/config' // configPath
);
});
});
+6 -4
View File
@@ -1,6 +1,7 @@
import { ReactNode, useState, useEffect } from 'react';
import { GitSettingsContext, type GitSettings, type GitCredential, type GitHostToken, type GitSettingsContextType } from '@/contexts/GitSettingsContext';
import { useFS } from '@/hooks/useFS';
import { useFSPaths } from '@/hooks/useFSPaths';
import { readGitSettings, writeGitSettings } from '@/lib/configUtils';
interface GitSettingsProviderProps {
@@ -14,6 +15,7 @@ const DEFAULT_SETTINGS: GitSettings = {
export function GitSettingsProvider({ children }: GitSettingsProviderProps) {
const { fs } = useFS();
const { configPath } = useFSPaths();
const [settings, setSettings] = useState<GitSettings>(DEFAULT_SETTINGS);
const [isInitialized, setIsInitialized] = useState(false);
@@ -21,7 +23,7 @@ export function GitSettingsProvider({ children }: GitSettingsProviderProps) {
useEffect(() => {
const initializeSettings = async () => {
try {
const settings = await readGitSettings(fs);
const settings = await readGitSettings(fs, configPath);
setSettings(settings);
} catch (error) {
console.error('Failed to initialize Git settings:', error);
@@ -32,7 +34,7 @@ export function GitSettingsProvider({ children }: GitSettingsProviderProps) {
};
initializeSettings();
}, [fs]);
}, [fs, configPath]);
// Save settings to VFS whenever they change (but not during initialization)
useEffect(() => {
@@ -40,14 +42,14 @@ export function GitSettingsProvider({ children }: GitSettingsProviderProps) {
const saveSettings = async () => {
try {
await writeGitSettings(fs, settings);
await writeGitSettings(fs, settings, configPath);
} catch (error) {
console.error('Failed to save Git settings:', error);
}
};
saveSettings();
}, [fs, settings, isInitialized]);
}, [fs, settings, isInitialized, configPath]);
const updateSettings = (newSettings: Partial<GitSettings>) => {
setSettings(prev => ({ ...prev, ...newSettings }));
+3 -1
View File
@@ -23,6 +23,7 @@ import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { useToast } from '@/hooks/useToast';
import { useFS } from '@/hooks/useFS';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useNavigate } from 'react-router-dom';
import {
@@ -50,6 +51,7 @@ export function ProjectDetailsDialog({ project, open, onOpenChange, onProjectDel
const [newProjectName, setNewProjectName] = useState(project.id);
const { toast } = useToast();
const { fs } = useFS();
const { projectsPath } = useFSPaths();
const projectsManager = useProjectsManager();
const navigate = useNavigate();
const queryClient = useQueryClient();
@@ -143,7 +145,7 @@ export function ProjectDetailsDialog({ project, open, onOpenChange, onProjectDel
setIsExporting(true);
try {
const zip = new JSZip();
const projectPath = `/projects/${project.id}`;
const projectPath = `${projectsPath}/${project.id}`;
// Recursive function to add files and directories to zip from a specific project
const addFolderToZip = async (dirPath: string, zipFolder: JSZip) => {
+4 -2
View File
@@ -2,6 +2,7 @@ import { ReactNode, useMemo, useEffect } from 'react';
import { SessionManagerContext } from '@/contexts/SessionManagerContext';
import { SessionManager } from '@/lib/SessionManager';
import { useFS } from '@/hooks/useFS';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useAISettings } from '@/hooks/useAISettings';
import { useProviderModels } from '@/hooks/useProviderModels';
import { useCurrentUser } from '@/hooks/useCurrentUser';
@@ -16,6 +17,7 @@ interface SessionManagerProviderProps {
*/
export function SessionManagerProvider({ children }: SessionManagerProviderProps) {
const { fs } = useFS();
const { projectsPath } = useFSPaths();
const { settings } = useAISettings();
const { models } = useProviderModels();
const { user, metadata } = useCurrentUser();
@@ -24,8 +26,8 @@ export function SessionManagerProvider({ children }: SessionManagerProviderProps
const sessionManager = useMemo(() => {
const getProviderModels = () => models;
const getCurrentUser = () => ({ user, metadata });
return new SessionManager(fs, settings, getProviderModels, getCurrentUser, config.corsProxy);
}, [fs, settings, models, user, metadata, config.corsProxy]);
return new SessionManager(fs, settings, getProviderModels, getCurrentUser, config.corsProxy, projectsPath);
}, [fs, settings, models, user, metadata, config.corsProxy, projectsPath]);
// Cleanup on unmount
useEffect(() => {
+9 -7
View File
@@ -7,6 +7,7 @@ import { OnboardingDialog } from '@/components/OnboardingDialog';
import { Loader2, ChevronDown } from 'lucide-react';
import { useAISettings } from '@/hooks/useAISettings';
import { useFS } from '@/hooks/useFS';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useCurrentUser } from '@/hooks/useCurrentUser';
import { useKeepAlive } from '@/hooks/useKeepAlive';
import { useAppContext } from '@/hooks/useAppContext';
@@ -75,6 +76,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
const { user } = useCurrentUser();
const { models } = useProviderModels();
const { config } = useAppContext();
const { projectsPath, tmpPath } = useFSPaths();
const [showScrollToBottom, setShowScrollToBottom] = useState(false);
const [isDragOver, setIsDragOver] = useState(false);
const [scrolledProjects] = useState(() => new Set<string>());
@@ -133,14 +135,14 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
}, [projectId, providerModel]);
// Initialize AI chat with tools
const cwd = `/projects/${projectId}`;
const cwd = `${projectsPath}/${projectId}`;
const esmUrlRef = useRef(config.esmUrl);
const customTools = useMemo(() => {
const baseTools = {
git_commit: new GitCommitTool(fs, cwd, git),
text_editor_view: new TextEditorViewTool(fs, cwd),
text_editor_write: new TextEditorWriteTool(fs, cwd),
text_editor_str_replace: new TextEditorStrReplaceTool(fs, cwd),
text_editor_view: new TextEditorViewTool(fs, cwd, { projectsPath }),
text_editor_write: new TextEditorWriteTool(fs, cwd, { projectsPath, tmpPath }),
text_editor_str_replace: new TextEditorStrReplaceTool(fs, cwd, { projectsPath, tmpPath }),
npm_add_package: new NpmAddPackageTool(fs, cwd),
npm_remove_package: new NpmRemovePackageTool(fs, cwd),
build_project: new BuildProjectTool(fs, cwd, esmUrlRef.current),
@@ -165,7 +167,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
}
return baseTools;
}, [fs, git, cwd, user, projectId]);
}, [fs, git, cwd, user, projectId, projectsPath, tmpPath]);
// Convert tools to OpenAI format
const tools = useMemo(() => {
@@ -438,7 +440,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
if (attachedFiles.length > 0) {
const filePromises = attachedFiles.map(async (file) => {
try {
const savedPath = await saveFileToTmp(fs, file);
const savedPath = await saveFileToTmp(fs, file, tmpPath);
return `Added file: ${savedPath}`;
} catch (error) {
console.error('Failed to save file:', error);
@@ -463,7 +465,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
// Send as text parts if we have multiple parts, otherwise send as string for simplicity
const messageContent = contentParts.length === 1 ? contentParts[0].text : contentParts;
await sendMessage(messageContent, modelToUse);
}, [addRecentlyUsedModel, fs, isConfigured, isLoading, providerModel, sendMessage]);
}, [addRecentlyUsedModel, fs, isConfigured, isLoading, providerModel, sendMessage, tmpPath]);
// Handle textarea focus - show onboarding if not configured
const handleTextareaFocus = useCallback(() => {
+3 -1
View File
@@ -3,6 +3,7 @@ import { useState, useEffect, useCallback, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { useProjectsManager } from '@/hooks/useProjectsManager';
import { useFS } from '@/hooks/useFS';
import { useFSPaths } from '@/hooks/useFSPaths';
import { addConsoleMessage, getConsoleMessages, type ConsoleMessage } from '@/lib/consoleMessages';
import { useConsoleError } from '@/hooks/useConsoleError';
import { useBuildProject } from '@/hooks/useBuildProject';
@@ -89,6 +90,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
const [deployDialogOpen, setDeployDialogOpen] = useState(false);
const iframeRef = useRef<HTMLIFrameElement>(null);
const { fs } = useFS();
const { projectsPath } = useFSPaths();
const projectsManager = useProjectsManager();
// Use console error state from provider
@@ -506,7 +508,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
if (!selectedFile) return;
try {
await fs.writeFile(`/projects/${projectId}/${selectedFile}`, content);
await fs.writeFile(`${projectsPath}/${projectId}/${selectedFile}`, content);
setFileContent(content);
// Automatically trigger a rebuild after saving a file
+5 -3
View File
@@ -5,6 +5,7 @@ import { Copy } from 'lucide-react';
import { cn } from '@/lib/utils';
import { ShellTool } from '@/lib/tools/ShellTool';
import { useFS } from '@/hooks/useFS';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useGit } from '@/hooks/useGit';
import { ansiToHtml, containsAnsiCodes } from '@/lib/ansiToHtml';
@@ -32,11 +33,12 @@ export function Terminal({ projectId, className }: TerminalProps) {
const shellToolRef = useRef<ShellTool | null>(null);
const { fs } = useFS();
const { projectsPath } = useFSPaths();
const { git } = useGit();
// Initialize ShellTool
useEffect(() => {
shellToolRef.current = new ShellTool(fs, `/projects/${projectId}`, git);
shellToolRef.current = new ShellTool(fs, `${projectsPath}/${projectId}`, git);
// Add welcome message
setLines([{
@@ -45,7 +47,7 @@ export function Terminal({ projectId, className }: TerminalProps) {
content: `Welcome to Shakespeare Terminal\nType 'help' to see available commands.`,
timestamp: new Date()
}]);
}, [projectId, fs, git]);
}, [projectId, fs, git, projectsPath]);
// Auto-scroll to bottom when new lines are added or execution state changes
useEffect(() => {
@@ -190,7 +192,7 @@ export function Terminal({ projectId, className }: TerminalProps) {
${' '}
</span>
) : null}
{containsAnsiCodes(line.content)
{containsAnsiCodes(line.content)
? <span dangerouslySetInnerHTML={{ __html: ansiToHtml(line.content) }} />
: line.content}
</pre>
+8 -6
View File
@@ -6,6 +6,7 @@ import { Button } from '@/components/ui/button';
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@/components/ui/alert-dialog';
import { History, GitCommit, RotateCcw, AlertTriangle, ChevronDown, ChevronUp } from 'lucide-react';
import { useGit } from '@/hooks/useGit';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useFS } from '@/hooks/useFS';
import { useToast } from '@/hooks/useToast';
import { useGitStatus } from '@/hooks/useGitStatus';
@@ -45,6 +46,7 @@ export function GitHistoryDialog({ projectId, open: controlledOpen, onOpenChange
const [isRollingBack, setIsRollingBack] = useState<string | null>(null);
const [expandedCommits, setExpandedCommits] = useState<Set<string>>(new Set());
const { fs } = useFS();
const { projectsPath } = useFSPaths();
const { git } = useGit();
const { toast } = useToast();
const navigate = useNavigate();
@@ -55,7 +57,7 @@ export function GitHistoryDialog({ projectId, open: controlledOpen, onOpenChange
setError(null);
try {
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
// Check if git repository exists
try {
@@ -78,7 +80,7 @@ export function GitHistoryDialog({ projectId, open: controlledOpen, onOpenChange
} finally {
setIsLoading(false);
}
}, [git, projectId]);
}, [git, projectId, projectsPath]);
const rollbackToCommit = useCallback(async (targetCommit: GitCommit) => {
if (!fs) return;
@@ -86,7 +88,7 @@ export function GitHistoryDialog({ projectId, open: controlledOpen, onOpenChange
setIsRollingBack(targetCommit.oid);
try {
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
// Get the current HEAD commit
const currentCommit = await git.resolveRef({
@@ -227,7 +229,7 @@ ${commitsToRevert.map(c => {
} finally {
setIsRollingBack(null);
}
}, [git, fs, projectId, toast, navigate, setIsOpen]);
}, [git, fs, projectId, toast, navigate, setIsOpen, projectsPath]);
const resetToHead = useCallback(async () => {
if (!fs) return;
@@ -235,7 +237,7 @@ ${commitsToRevert.map(c => {
setIsRollingBack('HEAD');
try {
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
// Get the current HEAD commit
const headCommit = await git.resolveRef({
@@ -326,7 +328,7 @@ ${commitsToRevert.map(c => {
} finally {
setIsRollingBack(null);
}
}, [git, fs, projectId, toast, navigate, setIsOpen]);
}, [git, fs, projectId, toast, navigate, setIsOpen, projectsPath]);
useEffect(() => {
if (isOpen) {
@@ -24,6 +24,7 @@ import {
Megaphone,
} from 'lucide-react';
import { useGit } from '@/hooks/useGit';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useCurrentUser } from '@/hooks/useCurrentUser';
import { useNostr } from '@/hooks/useNostr';
import { useToast } from '@/hooks/useToast';
@@ -59,11 +60,12 @@ export function AnnounceRepositoryDialog({
const [newRelay, setNewRelay] = useState('');
const { git } = useGit();
const { projectsPath } = useFSPaths();
const { user } = useCurrentUser();
const { nostr } = useNostr();
const { toast } = useToast();
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
useEffect(() => {
if (open !== undefined) {
+3 -1
View File
@@ -30,6 +30,7 @@ import {
ArrowUpRight,
} from 'lucide-react';
import { useGit } from '@/hooks/useGit';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useToast } from '@/hooks/useToast';
import { cn } from '@/lib/utils';
@@ -59,8 +60,9 @@ export function BranchManager({ projectId, currentBranch, onBranchChange }: Bran
const [switchingToBranch, setSwitchingToBranch] = useState<string | null>(null);
const { git } = useGit();
const { projectsPath } = useFSPaths();
const { toast } = useToast();
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
const loadBranches = useCallback(async () => {
setIsLoading(true);
+3 -1
View File
@@ -10,6 +10,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { GitCompare, Loader2, GitCommit, FileIcon } from 'lucide-react';
import { useGit } from '@/hooks/useGit';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useToast } from '@/hooks/useToast';
import { DiffViewer } from './DiffViewer';
@@ -38,8 +39,9 @@ export function CompareView({ projectId }: CompareViewProps) {
} | null>(null);
const { git } = useGit();
const { projectsPath } = useFSPaths();
const { toast } = useToast();
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
const loadReferences = useCallback(async () => {
setIsLoading(true);
+3 -1
View File
@@ -15,6 +15,7 @@ import {
Check,
} from 'lucide-react';
import { useGit } from '@/hooks/useGit';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useFS } from '@/hooks/useFS';
import { useToast } from '@/hooks/useToast';
import { cn } from '@/lib/utils';
@@ -57,9 +58,10 @@ export function DiffViewer({ projectId, compareFrom = 'HEAD', compareTo, filepat
const [copiedHunk, setCopiedHunk] = useState<number | null>(null);
const { git } = useGit();
const { projectsPath } = useFSPaths();
const { fs } = useFS();
const { toast } = useToast();
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
const getChangedFilesBetweenRefs = useCallback(async (from: string, to: string): Promise<string[]> => {
// Get list of files from both refs and find differences
+4 -2
View File
@@ -20,8 +20,9 @@ import { DiffViewer } from './DiffViewer';
import { PullRequestForm } from './PullRequestForm';
import { useGitStatus } from '@/hooks/useGitStatus';
import { useGit } from '@/hooks/useGit';
import { useFSPaths } from '@/hooks/useFSPaths';
interface GitManagementDialogProps {
interface GitManagementDialogProps{
projectId: string;
children?: React.ReactNode;
open?: boolean;
@@ -39,7 +40,8 @@ export function GitManagementDialog({
const [activeTab, setActiveTab] = useState(defaultTab);
const [remoteUrl, setRemoteUrl] = useState<string | null>(null);
const { git } = useGit();
const projectPath = `/projects/${projectId}`;
const { projectsPath } = useFSPaths();
const projectPath = `${projectsPath}/${projectId}`;
const { data: gitStatus, refetch: refetchGitStatus } = useGitStatus(projectId);
+3 -1
View File
@@ -29,6 +29,7 @@ import {
AlertTriangle,
} from 'lucide-react';
import { useGit } from '@/hooks/useGit';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useToast } from '@/hooks/useToast';
import { useSearchParams } from 'react-router-dom';
@@ -77,9 +78,10 @@ export function MergeDialog({
const [mergeComplete, setMergeComplete] = useState(false);
const { git } = useGit();
const { projectsPath } = useFSPaths();
const { toast } = useToast();
const [searchParams, setSearchParams] = useSearchParams();
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
useEffect(() => {
if (open !== undefined) {
+3 -1
View File
@@ -32,6 +32,7 @@ import {
GitFork,
} from 'lucide-react';
import { useGit } from '@/hooks/useGit';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useGitSettings } from '@/hooks/useGitSettings';
import { useToast } from '@/hooks/useToast';
import { useCurrentUser } from '@/hooks/useCurrentUser';
@@ -84,12 +85,13 @@ export function PullRequestDialog({
const [error, setError] = useState<string | null>(null);
const { git } = useGit();
const { projectsPath } = useFSPaths();
const { settings } = useGitSettings();
const { toast } = useToast();
const { user } = useCurrentUser();
const { nostr } = useNostr();
const { config } = useAppContext();
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
useEffect(() => {
if (open !== undefined) {
+3 -1
View File
@@ -22,6 +22,7 @@ import {
GitFork,
} from 'lucide-react';
import { useGit } from '@/hooks/useGit';
import { useFSPaths } from '@/hooks/useFSPaths';
import { useGitSettings } from '@/hooks/useGitSettings';
import { useToast } from '@/hooks/useToast';
import { findCredentialsForRepo } from '@/lib/gitCredentials';
@@ -59,9 +60,10 @@ export function PullRequestForm({ projectId, currentBranch, remoteUrl }: PullReq
const [error, setError] = useState<string | null>(null);
const { git } = useGit();
const { projectsPath } = useFSPaths();
const { settings } = useGitSettings();
const { toast } = useToast();
const projectPath = `/projects/${projectId}`;
const projectPath = `${projectsPath}/${projectId}`;
// All the helper functions from PullRequestDialog can be reused here
// (parseRemoteUrl, checkPushPermissions, ensureFork, etc.)