mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Fix linter errors
This commit is contained in:
15 files changed
+92
-69
No files matched your search
+2
-2
@@ -13,8 +13,8 @@ import { TooltipProvider } from "@/components/ui/tooltip";
|
|||||||
import { NostrLoginProvider } from '@nostrify/react/login';
|
import { NostrLoginProvider } from '@nostrify/react/login';
|
||||||
import { AppProvider } from '@/components/AppProvider';
|
import { AppProvider } from '@/components/AppProvider';
|
||||||
import { AppConfig } from '@/contexts/AppContext';
|
import { AppConfig } from '@/contexts/AppContext';
|
||||||
import { AISettingsProvider } from '@/contexts/AISettingsContext';
|
import { AISettingsProvider } from '@/components/AISettingsProvider';
|
||||||
import { FSProvider } from '@/contexts/FSContext';
|
import { FSProvider } from '@/components/FSProvider';
|
||||||
import AppRouter from './AppRouter';
|
import AppRouter from './AppRouter';
|
||||||
|
|
||||||
const head = createHead({
|
const head = createHead({
|
||||||
|
|||||||
@@ -1,19 +1,10 @@
|
|||||||
import { createContext, useContext, useState, useEffect, ReactNode } from 'react';
|
import { ReactNode, useState, useEffect } from 'react';
|
||||||
|
import { AISettingsContext, type AISettings, type AISettingsContextType } from '@/contexts/AISettingsContext';
|
||||||
|
|
||||||
export interface AISettings {
|
interface AISettingsProviderProps {
|
||||||
apiKey: string;
|
children: ReactNode;
|
||||||
baseUrl: string;
|
|
||||||
model: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AISettingsContextType {
|
|
||||||
settings: AISettings;
|
|
||||||
updateSettings: (settings: Partial<AISettings>) => void;
|
|
||||||
isConfigured: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const AISettingsContext = createContext<AISettingsContextType | undefined>(undefined);
|
|
||||||
|
|
||||||
const DEFAULT_SETTINGS: AISettings = {
|
const DEFAULT_SETTINGS: AISettings = {
|
||||||
apiKey: '',
|
apiKey: '',
|
||||||
baseUrl: 'https://openrouter.ai/api/v1',
|
baseUrl: 'https://openrouter.ai/api/v1',
|
||||||
@@ -22,7 +13,7 @@ const DEFAULT_SETTINGS: AISettings = {
|
|||||||
|
|
||||||
const STORAGE_KEY = 'ai-settings';
|
const STORAGE_KEY = 'ai-settings';
|
||||||
|
|
||||||
export function AISettingsProvider({ children }: { children: ReactNode }) {
|
export function AISettingsProvider({ children }: AISettingsProviderProps) {
|
||||||
const [settings, setSettings] = useState<AISettings>(() => {
|
const [settings, setSettings] = useState<AISettings>(() => {
|
||||||
const stored = localStorage.getItem(STORAGE_KEY);
|
const stored = localStorage.getItem(STORAGE_KEY);
|
||||||
if (stored) {
|
if (stored) {
|
||||||
@@ -45,18 +36,15 @@ export function AISettingsProvider({ children }: { children: ReactNode }) {
|
|||||||
|
|
||||||
const isConfigured = Boolean(settings.apiKey);
|
const isConfigured = Boolean(settings.apiKey);
|
||||||
|
|
||||||
|
const contextValue: AISettingsContextType = {
|
||||||
|
settings,
|
||||||
|
updateSettings,
|
||||||
|
isConfigured,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AISettingsContext.Provider value={{ settings, updateSettings, isConfigured }}>
|
<AISettingsContext.Provider value={contextValue}>
|
||||||
{children}
|
{children}
|
||||||
</AISettingsContext.Provider>
|
</AISettingsContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function useAISettings() {
|
|
||||||
const context = useContext(AISettingsContext);
|
|
||||||
if (!context) {
|
|
||||||
throw new Error('useAISettings must be used within AISettingsProvider');
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
@@ -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 { Card } from '@/components/ui/card';
|
||||||
import { Send, Bot, User, Settings, Play } from 'lucide-react';
|
import { Send, Bot, User, Settings, Play } from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { useAISettings } from '@/contexts/AISettingsContext';
|
import { useAISettings } from '@/hooks/useAISettings';
|
||||||
import { FsToolSet } from '@/lib/FsToolSet';
|
import { FsToolSet } from '@/lib/FsToolSet';
|
||||||
import { useFS } from '@/hooks/useFS';
|
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 { ProjectsManager } from '@/lib/fs';
|
||||||
import { useFS } from '@/hooks/useFS';
|
import { useFS } from '@/hooks/useFS';
|
||||||
import { ChevronRight, ChevronDown, File, Folder } from 'lucide-react';
|
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 [tree, setTree] = useState<FileNode[]>([]);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const { fs } = useFS();
|
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 buildFileTree = useCallback(async (projectId: string, dirPath: string): Promise<FileNode[]> => {
|
||||||
const items = await projectsManager.listFiles(projectId, dirPath);
|
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 { ProjectsManager } from '@/lib/fs';
|
||||||
import { useFS } from '@/hooks/useFS';
|
import { useFS } from '@/hooks/useFS';
|
||||||
import { Tabs, TabsContent } from '@/components/ui/tabs';
|
import { Tabs, TabsContent } from '@/components/ui/tabs';
|
||||||
@@ -51,7 +51,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
|||||||
const [hasBuiltProject, setHasBuiltProject] = useState(false);
|
const [hasBuiltProject, setHasBuiltProject] = useState(false);
|
||||||
const iframeRef = useRef<HTMLIFrameElement>(null);
|
const iframeRef = useRef<HTMLIFrameElement>(null);
|
||||||
const { fs } = useFS();
|
const { fs } = useFS();
|
||||||
const projectsManager = new ProjectsManager(fs);
|
const projectsManager = useMemo(() => new ProjectsManager(fs), [fs]);
|
||||||
|
|
||||||
const loadFileContent = useCallback(async (filePath: string) => {
|
const loadFileContent = useCallback(async (filePath: string) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Button } from '@/components/ui/button';
|
|||||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { useAISettings } from '@/contexts/AISettingsContext';
|
import { useAISettings } from '@/hooks/useAISettings';
|
||||||
|
|
||||||
export function AISettingsDialog() {
|
export function AISettingsDialog() {
|
||||||
const { settings, updateSettings, isConfigured } = useAISettings();
|
const { settings, updateSettings, isConfigured } = useAISettings();
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { createContext } from 'react';
|
||||||
|
|
||||||
|
export interface AISettings {
|
||||||
|
apiKey: string;
|
||||||
|
baseUrl: string;
|
||||||
|
model: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AISettingsContextType {
|
||||||
|
settings: AISettings;
|
||||||
|
updateSettings: (settings: Partial<AISettings>) => void;
|
||||||
|
isConfigured: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const AISettingsContext = createContext<AISettingsContextType | undefined>(undefined);
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { createContext } from 'react';
|
||||||
|
import type LightningFS from '@isomorphic-git/lightning-fs';
|
||||||
|
|
||||||
|
export interface FSContextType {
|
||||||
|
fs: LightningFS.PromisifiedFS;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FSContext = createContext<FSContextType | undefined>(undefined);
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import { createContext, useContext, type ReactNode } from 'react';
|
|
||||||
import LightningFS from '@isomorphic-git/lightning-fs';
|
|
||||||
|
|
||||||
interface FSContextType {
|
|
||||||
fs: LightningFS.PromisifiedFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
const FSContext = createContext<FSContextType | undefined>(undefined);
|
|
||||||
|
|
||||||
interface FSProviderProps {
|
|
||||||
children: ReactNode;
|
|
||||||
fs: LightningFS.PromisifiedFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function FSProvider({ children, fs }: FSProviderProps) {
|
|
||||||
return (
|
|
||||||
<FSContext.Provider value={{ fs }}>
|
|
||||||
{children}
|
|
||||||
</FSContext.Provider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useFS(): FSContextType {
|
|
||||||
const context = useContext(FSContext);
|
|
||||||
if (context === undefined) {
|
|
||||||
throw new Error('useFS must be used within a FSProvider');
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { useContext } from 'react';
|
||||||
|
import { AISettingsContext, type AISettingsContextType } from '@/contexts/AISettingsContext';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook to access and update AI settings
|
||||||
|
* @returns AI settings context with settings and update methods
|
||||||
|
*/
|
||||||
|
export function useAISettings(): AISettingsContextType {
|
||||||
|
const context = useContext(AISettingsContext);
|
||||||
|
if (!context) {
|
||||||
|
throw new Error('useAISettings must be used within AISettingsProvider');
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
+12
-3
@@ -1,5 +1,14 @@
|
|||||||
import { useFS as useInternalFS } from '@/contexts/FSContext';
|
import { useContext } from 'react';
|
||||||
|
import { FSContext, type FSContextType } from '@/contexts/FSContext';
|
||||||
|
|
||||||
export function useFS() {
|
/**
|
||||||
return useInternalFS();
|
* Hook to access the filesystem
|
||||||
|
* @returns Filesystem context with fs instance
|
||||||
|
*/
|
||||||
|
export function useFS(): FSContextType {
|
||||||
|
const context = useContext(FSContext);
|
||||||
|
if (context === undefined) {
|
||||||
|
throw new Error('useFS must be used within a FSProvider');
|
||||||
|
}
|
||||||
|
return context;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useEffect, useCallback } from 'react';
|
import { useState, useEffect, useCallback, useMemo } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { ProjectsManager, type Project } from '@/lib/fs';
|
import { ProjectsManager, type Project } from '@/lib/fs';
|
||||||
import { useFS } from '@/hooks/useFS';
|
import { useFS } from '@/hooks/useFS';
|
||||||
@@ -15,7 +15,7 @@ export function ProjectView() {
|
|||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [activeTab, setActiveTab] = useState<'preview' | 'code'>('preview');
|
const [activeTab, setActiveTab] = useState<'preview' | 'code'>('preview');
|
||||||
const { fs } = useFS();
|
const { fs } = useFS();
|
||||||
const projectsManager = new ProjectsManager(fs);
|
const projectsManager = useMemo(() => new ProjectsManager(fs), [fs]);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const loadProject = useCallback(async () => {
|
const loadProject = useCallback(async () => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useEffect, useCallback } from 'react';
|
import { useState, useEffect, useCallback, useMemo } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { ProjectsManager, type Project } from '@/lib/fs';
|
import { ProjectsManager, type Project } from '@/lib/fs';
|
||||||
import { useFS } from '@/hooks/useFS';
|
import { useFS } from '@/hooks/useFS';
|
||||||
@@ -15,7 +15,7 @@ export function ShakespeareHome() {
|
|||||||
const [isCreating, setIsCreating] = useState(false);
|
const [isCreating, setIsCreating] = useState(false);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { fs } = useFS();
|
const { fs } = useFS();
|
||||||
const projectsManager = new ProjectsManager(fs);
|
const projectsManager = useMemo(() => new ProjectsManager(fs), [fs]);
|
||||||
|
|
||||||
const loadProjects = useCallback(async () => {
|
const loadProjects = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { NostrLoginProvider } from '@nostrify/react/login';
|
|||||||
import NostrProvider from '@/components/NostrProvider';
|
import NostrProvider from '@/components/NostrProvider';
|
||||||
import { AppProvider } from '@/components/AppProvider';
|
import { AppProvider } from '@/components/AppProvider';
|
||||||
import { AppConfig } from '@/contexts/AppContext';
|
import { AppConfig } from '@/contexts/AppContext';
|
||||||
import { FSProvider } from '@/contexts/FSContext';
|
import { FSProvider } from '@/components/FSProvider';
|
||||||
|
|
||||||
interface TestAppProps {
|
interface TestAppProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
Reference in new issue
Block a user