mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix linter errors
This commit is contained in:
1 parent
b832c5c6fd
commit
fcf779fe35
15 files changed
+93
-70
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import { ReactNode, useState, useEffect } from 'react';
|
||||
import { AISettingsContext, type AISettings, type AISettingsContextType } from '@/contexts/AISettingsContext';
|
||||
|
||||
interface AISettingsProviderProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: AISettings = {
|
||||
apiKey: '',
|
||||
baseUrl: 'https://openrouter.ai/api/v1',
|
||||
model: 'anthropic/claude-sonnet-4',
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'ai-settings';
|
||||
|
||||
export function AISettingsProvider({ children }: AISettingsProviderProps) {
|
||||
const [settings, setSettings] = useState<AISettings>(() => {
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
if (stored) {
|
||||
try {
|
||||
return { ...DEFAULT_SETTINGS, ...JSON.parse(stored) };
|
||||
} catch {
|
||||
return DEFAULT_SETTINGS;
|
||||
}
|
||||
}
|
||||
return DEFAULT_SETTINGS;
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));
|
||||
}, [settings]);
|
||||
|
||||
const updateSettings = (newSettings: Partial<AISettings>) => {
|
||||
setSettings(prev => ({ ...prev, ...newSettings }));
|
||||
};
|
||||
|
||||
const isConfigured = Boolean(settings.apiKey);
|
||||
|
||||
const contextValue: AISettingsContextType = {
|
||||
settings,
|
||||
updateSettings,
|
||||
isConfigured,
|
||||
};
|
||||
|
||||
return (
|
||||
<AISettingsContext.Provider value={contextValue}>
|
||||
{children}
|
||||
</AISettingsContext.Provider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { ReactNode } from 'react';
|
||||
import type LightningFS from '@isomorphic-git/lightning-fs';
|
||||
import { FSContext, type FSContextType } from '@/contexts/FSContext';
|
||||
|
||||
interface FSProviderProps {
|
||||
children: ReactNode;
|
||||
fs: LightningFS.PromisifiedFS;
|
||||
}
|
||||
|
||||
export function FSProvider({ children, fs }: FSProviderProps) {
|
||||
const contextValue: FSContextType = { fs };
|
||||
|
||||
return (
|
||||
<FSContext.Provider value={contextValue}>
|
||||
{children}
|
||||
</FSContext.Provider>
|
||||
);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { Send, Bot, User, Settings, Play } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useAISettings } from '@/contexts/AISettingsContext';
|
||||
import { useAISettings } from '@/hooks/useAISettings';
|
||||
import { FsToolSet } from '@/lib/FsToolSet';
|
||||
import { useFS } from '@/hooks/useFS';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useState, useEffect, useCallback, useMemo } from 'react';
|
||||
import { ProjectsManager } from '@/lib/fs';
|
||||
import { useFS } from '@/hooks/useFS';
|
||||
import { ChevronRight, ChevronDown, File, Folder } from 'lucide-react';
|
||||
@@ -22,7 +22,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
|
||||
const [tree, setTree] = useState<FileNode[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const { fs } = useFS();
|
||||
const projectsManager = new ProjectsManager(fs);
|
||||
const projectsManager = useMemo(() => new ProjectsManager(fs), [fs]);
|
||||
|
||||
const buildFileTree = useCallback(async (projectId: string, dirPath: string): Promise<FileNode[]> => {
|
||||
const items = await projectsManager.listFiles(projectId, dirPath);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import { useState, useEffect, useCallback, useRef, useMemo } from 'react';
|
||||
import { ProjectsManager } from '@/lib/fs';
|
||||
import { useFS } from '@/hooks/useFS';
|
||||
import { Tabs, TabsContent } from '@/components/ui/tabs';
|
||||
@@ -51,7 +51,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
const [hasBuiltProject, setHasBuiltProject] = useState(false);
|
||||
const iframeRef = useRef<HTMLIFrameElement>(null);
|
||||
const { fs } = useFS();
|
||||
const projectsManager = new ProjectsManager(fs);
|
||||
const projectsManager = useMemo(() => new ProjectsManager(fs), [fs]);
|
||||
|
||||
const loadFileContent = useCallback(async (filePath: string) => {
|
||||
setIsLoading(true);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { useAISettings } from '@/contexts/AISettingsContext';
|
||||
import { useAISettings } from '@/hooks/useAISettings';
|
||||
|
||||
export function AISettingsDialog() {
|
||||
const { settings, updateSettings, isConfigured } = useAISettings();
|
||||
|
||||
Reference in new issue
Block a user