feat: refactor names
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
|||||||
MenubarCheckboxItem,
|
MenubarCheckboxItem,
|
||||||
} from '@/components/ui/menubar'
|
} from '@/components/ui/menubar'
|
||||||
import { Kbd, KbdGroup } from '@/components/ui/kbd'
|
import { Kbd, KbdGroup } from '@/components/ui/kbd'
|
||||||
import { usePlatform } from '@/app/platform/platformContext'
|
import { usePlatform } from '@/app/kosmos/KosmosContext'
|
||||||
import { ArrowLeft, ClipboardPaste, Copy, CopyPlus, Download, FolderOpen, Pencil, Redo2, Undo2 } from 'lucide-react'
|
import { ArrowLeft, ClipboardPaste, Copy, CopyPlus, Download, FolderOpen, Pencil, Redo2, Undo2 } from 'lucide-react'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import {
|
|||||||
import { AnimatedEdge } from '@/components/base/AnimatedEdge'
|
import { AnimatedEdge } from '@/components/base/AnimatedEdge'
|
||||||
import FlowContext from '@/lib/flowContext'
|
import FlowContext from '@/lib/flowContext'
|
||||||
import { useTheme } from '@/lib/themeContext'
|
import { useTheme } from '@/lib/themeContext'
|
||||||
import { usePlatform } from '@/app/platform/platformContext'
|
import { usePlatform } from '@/app/kosmos/KosmosContext'
|
||||||
import { useGraphStateWithHistory } from '@/hooks/useGraphStateWithHistory'
|
import { useGraphStateWithHistory } from '@/hooks/useGraphStateWithHistory'
|
||||||
import {
|
import {
|
||||||
ContextMenu,
|
ContextMenu,
|
||||||
@@ -67,7 +67,7 @@ import {
|
|||||||
saveGraphToStorage,
|
saveGraphToStorage,
|
||||||
PROJECT_FILE_EXT,
|
PROJECT_FILE_EXT,
|
||||||
PROJECT_VERSION,
|
PROJECT_VERSION,
|
||||||
} from '@/app/platform/projectGraphStorage'
|
} from '@/app/pleroma/projectGraphStorage'
|
||||||
|
|
||||||
const SNAP_GRID: [number, number] = [15, 15]
|
const SNAP_GRID: [number, number] = [15, 15]
|
||||||
const DUPLICATE_OFFSET = { x: 30, y: 30 }
|
const DUPLICATE_OFFSET = { x: 30, y: 30 }
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import { useParams } from 'react-router-dom'
|
import { useParams } from 'react-router-dom'
|
||||||
import { CanvasPage } from '../canvas/CanvasPage'
|
import { CanvasPage } from './CanvasPage'
|
||||||
import { usePlatform } from './platformContext'
|
import { usePlatform } from '../kosmos/KosmosContext'
|
||||||
|
|
||||||
export function CanvasRoute() {
|
export function CanvasRoute() {
|
||||||
const { projectId } = useParams<{ projectId: string }>()
|
const { projectId } = useParams<{ projectId: string }>()
|
||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
import React, { createContext, useCallback, useContext, useMemo, useState } from 'react'
|
import React, { createContext, useCallback, useContext, useMemo, useState } from 'react'
|
||||||
import type { Project } from './types'
|
import type { Project } from './types'
|
||||||
import { saveGraphToStorage } from './projectGraphStorage'
|
import { saveGraphToStorage } from '../pleroma/projectGraphStorage'
|
||||||
import { PROJECT_VERSION } from './projectGraphStorage'
|
import { PROJECT_VERSION } from '../pleroma/projectGraphStorage'
|
||||||
|
|
||||||
const STORAGE_KEY = 'zui_platform_projects'
|
const STORAGE_KEY = 'zui_platform_projects'
|
||||||
const ORDER_STORAGE_KEY = 'zui_platform_project_order'
|
const ORDER_STORAGE_KEY = 'zui_platform_project_order'
|
||||||
@@ -149,7 +149,7 @@ export function sortProjectsByOrder(projects: Project[], order: string[]): Proje
|
|||||||
return [...ordered, ...rest]
|
return [...ordered, ...rest]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PlatformContextValue = {
|
export type KosmosContextValue = {
|
||||||
projects: Project[]
|
projects: Project[]
|
||||||
projectOrder: string[]
|
projectOrder: string[]
|
||||||
/** Projects in display order (sidebar order, then lastEditedAt) */
|
/** Projects in display order (sidebar order, then lastEditedAt) */
|
||||||
@@ -172,9 +172,9 @@ export type PlatformContextValue = {
|
|||||||
setAiConnection: (value: AiConnection) => void
|
setAiConnection: (value: AiConnection) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const PlatformContext = createContext<PlatformContextValue | null>(null)
|
const KosmosContext = createContext<KosmosContextValue | null>(null)
|
||||||
|
|
||||||
export function PlatformProvider({ children }: { children: React.ReactNode }) {
|
export function KosmosProvider({ children }: { children: React.ReactNode }) {
|
||||||
const [projects, setProjects] = useState<Project[]>(loadProjects)
|
const [projects, setProjects] = useState<Project[]>(loadProjects)
|
||||||
const [projectOrder, setProjectOrder] = useState<string[]>(loadOrder)
|
const [projectOrder, setProjectOrder] = useState<string[]>(loadOrder)
|
||||||
const [recentProjectIds, setRecentProjectIds] = useState<string[]>(loadRecentIds)
|
const [recentProjectIds, setRecentProjectIds] = useState<string[]>(loadRecentIds)
|
||||||
@@ -281,7 +281,7 @@ export function PlatformProvider({ children }: { children: React.ReactNode }) {
|
|||||||
[projects, projectOrder]
|
[projects, projectOrder]
|
||||||
)
|
)
|
||||||
|
|
||||||
const value: PlatformContextValue = useMemo(
|
const value: KosmosContextValue = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
projects,
|
projects,
|
||||||
projectOrder,
|
projectOrder,
|
||||||
@@ -320,11 +320,11 @@ export function PlatformProvider({ children }: { children: React.ReactNode }) {
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
return <PlatformContext.Provider value={value}>{children}</PlatformContext.Provider>
|
return <KosmosContext.Provider value={value}>{children}</KosmosContext.Provider>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function usePlatform() {
|
export function usePlatform() {
|
||||||
const ctx = useContext(PlatformContext)
|
const ctx = useContext(KosmosContext)
|
||||||
if (!ctx) throw new Error('usePlatform must be used within PlatformProvider')
|
if (!ctx) throw new Error('usePlatform must be used within PlatformProvider')
|
||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,10 @@
|
|||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { Outlet, useParams } from 'react-router-dom'
|
import { Outlet, useParams } from 'react-router-dom'
|
||||||
import { SidebarProvider } from '@/components/ui/sidebar'
|
import { SidebarProvider } from '@/components/ui/sidebar'
|
||||||
import { PlatformProvider, usePlatform } from './platformContext'
|
import { KosmosProvider, usePlatform } from './KosmosContext'
|
||||||
import { AppSidebar } from './AppSidebar'
|
import { KosmosSidebar } from './KosmosSidebar'
|
||||||
|
|
||||||
function PlatformLayoutInner() {
|
function KosmosLayoutInner() {
|
||||||
const { projectId } = useParams<{ projectId: string }>()
|
const { projectId } = useParams<{ projectId: string }>()
|
||||||
const { recordProjectAccess } = usePlatform()
|
const { recordProjectAccess } = usePlatform()
|
||||||
const [sidebarOpen, setSidebarOpen] = useState(true)
|
const [sidebarOpen, setSidebarOpen] = useState(true)
|
||||||
@@ -19,7 +19,7 @@ function PlatformLayoutInner() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarProvider open={sidebarOpen} onOpenChange={setSidebarOpen}>
|
<SidebarProvider open={sidebarOpen} onOpenChange={setSidebarOpen}>
|
||||||
<AppSidebar />
|
<KosmosSidebar />
|
||||||
<div className="relative flex h-dvh min-h-0 w-full flex-1 flex-col overflow-hidden bg-background">
|
<div className="relative flex h-dvh min-h-0 w-full flex-1 flex-col overflow-hidden bg-background">
|
||||||
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
@@ -29,10 +29,10 @@ function PlatformLayoutInner() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PlatformPage() {
|
export function KosmosPage() {
|
||||||
return (
|
return (
|
||||||
<PlatformProvider>
|
<KosmosProvider>
|
||||||
<PlatformLayoutInner />
|
<KosmosLayoutInner />
|
||||||
</PlatformProvider>
|
</KosmosProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -20,13 +20,13 @@ import {
|
|||||||
import { Plus, Settings, Triangle } from 'lucide-react'
|
import { Plus, Settings, Triangle } from 'lucide-react'
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
||||||
import { useSidebar } from '@/components/ui/sidebar'
|
import { useSidebar } from '@/components/ui/sidebar'
|
||||||
import { usePlatform } from './platformContext'
|
import { usePlatform } from './KosmosContext'
|
||||||
import { getProjectIcon } from '../../lib/iconMap'
|
import { getProjectIcon } from '../../lib/iconMap'
|
||||||
import { NewProjectDialog } from './NewProjectDialog'
|
import { NewProjectDialog } from './NewProjectDialog'
|
||||||
import { SettingsDialog } from './SettingsDialog'
|
import { SettingsDialog } from './SettingsDialog'
|
||||||
import type { Project } from './types'
|
import type { Project } from './types'
|
||||||
|
|
||||||
export function AppSidebar() {
|
export function KosmosSidebar() {
|
||||||
const { state, setOpen } = useSidebar()
|
const { state, setOpen } = useSidebar()
|
||||||
const isCollapsed = state === 'collapsed'
|
const isCollapsed = state === 'collapsed'
|
||||||
const { orderedProjects, createProject, recentProjectIds } = usePlatform()
|
const { orderedProjects, createProject, recentProjectIds } = usePlatform()
|
||||||
@@ -22,8 +22,8 @@ import { Switch } from '@/components/ui/switch'
|
|||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
import { useTheme } from '@/lib/themeContext'
|
import { useTheme } from '@/lib/themeContext'
|
||||||
import type { Theme } from '@/lib/themeContext'
|
import type { Theme } from '@/lib/themeContext'
|
||||||
import { usePlatform } from './platformContext'
|
import { usePlatform } from './KosmosContext'
|
||||||
import type { AiConnection, AiConnectionProvider } from './platformContext'
|
import type { AiConnection, AiConnectionProvider } from './KosmosContext'
|
||||||
import { Sun, Sparkles } from 'lucide-react'
|
import { Sun, Sparkles } from 'lucide-react'
|
||||||
|
|
||||||
type SettingsSection = 'appearance' | 'ai'
|
type SettingsSection = 'appearance' | 'ai'
|
||||||
@@ -55,7 +55,7 @@ import {
|
|||||||
Copy,
|
Copy,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { Checkbox } from '@/components/ui/checkbox'
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
import { usePlatform } from './platformContext'
|
import { usePlatform } from '../kosmos/KosmosContext'
|
||||||
import { getProjectIcon } from '../../lib/iconMap'
|
import { getProjectIcon } from '../../lib/iconMap'
|
||||||
import {
|
import {
|
||||||
loadGraphFromStorage,
|
loadGraphFromStorage,
|
||||||
@@ -65,9 +65,9 @@ import {
|
|||||||
PROJECT_VERSION,
|
PROJECT_VERSION,
|
||||||
} from './projectGraphStorage'
|
} from './projectGraphStorage'
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
import { NewProjectDialog } from './NewProjectDialog'
|
import { NewProjectDialog } from '../kosmos/NewProjectDialog'
|
||||||
import { ProjectsPageBackground } from './ProjectsPageBackground'
|
import { ProjectsPageBackground } from './ProjectsPageBackground'
|
||||||
import type { Project } from './types'
|
import type { Project } from '../kosmos/types'
|
||||||
|
|
||||||
const PAGE_SIZE_OPTIONS = [10, 25, 50] as const
|
const PAGE_SIZE_OPTIONS = [10, 25, 50] as const
|
||||||
type SortKey = 'lastEdited' | 'name' | 'created'
|
type SortKey = 'lastEdited' | 'name' | 'created'
|
||||||
@@ -16,7 +16,7 @@ import { NodeFooterEdgeIndicators } from '@/components/base/NodeFooterEdgeIndica
|
|||||||
import { NodeHeaderTitle } from '@/components/base/NodeHeaderTitle'
|
import { NodeHeaderTitle } from '@/components/base/NodeHeaderTitle'
|
||||||
import { InputHandle, OutputHandle } from '@/components/base/NodeHandles'
|
import { InputHandle, OutputHandle } from '@/components/base/NodeHandles'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { usePlatform } from '@/app/platform/platformContext'
|
import { usePlatform } from '@/app/kosmos/KosmosContext'
|
||||||
import { Bot, Play, Loader2 } from 'lucide-react'
|
import { Bot, Play, Loader2 } from 'lucide-react'
|
||||||
|
|
||||||
export type AgentNodeData = {
|
export type AgentNodeData = {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
Turtle,
|
Turtle,
|
||||||
type LucideIcon,
|
type LucideIcon,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import type { ProjectIconId } from '../app/platform/types'
|
import type { ProjectIconId } from '../app/kosmos/types'
|
||||||
|
|
||||||
export const PROJECT_ICON_MAP: Record<ProjectIconId, LucideIcon> = {
|
export const PROJECT_ICON_MAP: Record<ProjectIconId, LucideIcon> = {
|
||||||
bird: Bird,
|
bird: Bird,
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'
|
|||||||
import { Toaster } from 'sonner'
|
import { Toaster } from 'sonner'
|
||||||
import { ThemeProvider } from './lib/themeContext'
|
import { ThemeProvider } from './lib/themeContext'
|
||||||
import { registerBuiltinNodes } from './lib/registerBuiltinNodes'
|
import { registerBuiltinNodes } from './lib/registerBuiltinNodes'
|
||||||
import { PlatformPage } from './app/platform/PlatformPage'
|
import { KosmosPage } from './app/kosmos/KosmosPage'
|
||||||
import { ProjectsPage } from './app/platform/ProjectsPage'
|
import { ProjectsPage } from './app/pleroma/PleromaPage'
|
||||||
import { KeromaPage } from './app/platform/KeromaPage'
|
import { KeromaPage } from './app/keroma/KeromaPage'
|
||||||
import { CanvasRoute } from './app/platform/CanvasRoute'
|
import { CanvasRoute } from './app/canvas/CanvasRoute'
|
||||||
import './styles.css'
|
import './styles.css'
|
||||||
import '@xyflow/react/dist/style.css'
|
import '@xyflow/react/dist/style.css'
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ createRoot(document.getElementById('root')!).render(
|
|||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<PlatformPage />}>
|
<Route path="/" element={<KosmosPage />}>
|
||||||
<Route index element={<Navigate to="/projects" replace />} />
|
<Route index element={<Navigate to="/projects" replace />} />
|
||||||
<Route path="projects" element={<ProjectsPage />} />
|
<Route path="projects" element={<ProjectsPage />} />
|
||||||
<Route path="projects/:projectId" element={<CanvasRoute />} />
|
<Route path="projects/:projectId" element={<CanvasRoute />} />
|
||||||
|
|||||||
Reference in New Issue
Block a user