| import { useParams, useNavigate } from "react-router-dom"; | |
| import { useState, useEffect } from "react"; | |
| import { | |
| ArrowLeft, Plus, Users, Settings, Calendar, CheckSquare, | |
| FolderOpen, FileText, MessageSquare, Share2, MoreVertical, | |
| Edit, Trash2, Copy, Archive, Star, Clock, Eye, Heart, | |
| Activity, BarChart3, GitBranch, Link, Download, Upload, | |
| Loader2, AlertCircle, CheckCircle, XCircle, RefreshCw, Brain, Network, Video, Laptop | |
| } from "lucide-react"; | |
| import { motion, AnimatePresence } from "framer-motion"; | |
| import { toast } from "react-toastify"; | |
| import api from "@/lib/api"; | |
| import { useAuth } from "@/context/AuthContext"; | |
| import { useOffline } from "@/context/OfflineContext"; | |
| import { offlineCache } from "@/lib/offlineCache"; | |
| // Components | |
| import { ProjectHeader } from "@/components/project/ProjectHeader"; | |
| import { ProjectTabs } from "@/components/project/ProjectTabs"; | |
| import { ProjectOverview } from "@/components/project/ProjectOverview"; | |
| import { ProjectTasks } from "@/components/project/ProjectTasks"; | |
| import { ProjectMembers } from "@/components/project/ProjectMembers"; | |
| import { ProjectFiles } from "@/components/project/ProjectFiles"; | |
| import { ProjectTimeline } from "@/components/project/ProjectTimeline"; | |
| import { ProjectSettings } from "@/components/project/ProjectSettings"; | |
| import { TaskModal } from "@/components/project/TaskModal"; | |
| import { MemberModal } from "@/components/project/MemberModal"; | |
| import { LoadingSpinner } from "@/components/common/LoadingSpinner"; | |
| import { ErrorMessage } from "@/components/common/ErrorMessage"; | |
| interface Project { | |
| id: number; | |
| name: string; | |
| description: string; | |
| status: "active" | "completed" | "archived"; | |
| visibility: "public" | "private" | "team"; | |
| ownerId: number; | |
| ownerUsername: string; | |
| memberIds?: number[]; | |
| createdAt: string; | |
| updatedAt: string; | |
| memberCount: number; | |
| taskCount: number; | |
| completedTaskCount: number; | |
| fileCount: number; | |
| viewCount?: number; | |
| tags: string[]; | |
| } | |
| type TabType = "overview" | "tasks" | "members" | "files" | "timeline" | "settings"; | |
| const PROJECT_WORKSPACE_CACHE_KEY = (id: string) => `ie-cache:project-workspace:${id}`; | |
| export default function ProjectWorkspacePage() { | |
| const { projectId } = useParams<{ projectId: string }>(); | |
| const navigate = useNavigate(); | |
| const { user } = useAuth(); | |
| const { isOnline, queueLength } = useOffline(); | |
| const [project, setProject] = useState<Project | null>(null); | |
| const [loading, setLoading] = useState(true); | |
| const [error, setError] = useState<string | null>(null); | |
| const [activeTab, setActiveTab] = useState<TabType>("overview"); | |
| const [isTaskModalOpen, setIsTaskModalOpen] = useState(false); | |
| const [isMemberModalOpen, setIsMemberModalOpen] = useState(false); | |
| const [isRefreshing, setIsRefreshing] = useState(false); | |
| const [isOwner, setIsOwner] = useState(false); | |
| // AI Workspace Agent States | |
| const [isAiPanelOpen, setIsAiPanelOpen] = useState(false); | |
| const [sidebarTab, setSidebarTab] = useState<"ai" | "apps">("ai"); | |
| const [aiInput, setAiInput] = useState(""); | |
| const [isAiLoading, setIsAiLoading] = useState(false); | |
| const [aiMessages, setAiMessages] = useState([ | |
| { sender: "ai", text: "Hello! I am your AI Workspace Agent. I have full read/write access to this project's files. Tell me what to build, edit, or delete!" } | |
| ]); | |
| const [editingFile, setEditingFile] = useState<string | null>(null); | |
| const [editingContent, setEditingContent] = useState(""); | |
| const handleAiSubmit = async (e: React.FormEvent) => { | |
| e.preventDefault(); | |
| if (!aiInput.trim() || isAiLoading) return; | |
| const userText = aiInput.trim(); | |
| setAiMessages(prev => [...prev, { sender: "user", text: userText }]); | |
| setAiInput(""); | |
| setIsAiLoading(true); | |
| const textLower = userText.toLowerCase(); | |
| setTimeout(async () => { | |
| try { | |
| if (textLower.includes("create") || textLower.includes("add") || textLower.includes("new file")) { | |
| const fileMatch = userText.match(/(?:create|add|file)\s+([a-zA-Z0-9_\-\.]+)/i); | |
| const filename = fileMatch ? fileMatch[1] : "helper.py"; | |
| await api.post(`/projects/${projectId}/outputs`, { | |
| title: filename, | |
| description: "Created automatically by workspace AI Agent.", | |
| link: "" | |
| }); | |
| setAiMessages(prev => [ | |
| ...prev, | |
| { sender: "ai", text: `✔ Successfully created new file: ${filename} inside the project workspace!` } | |
| ]); | |
| toast.success(`Created file: ${filename}`); | |
| fetchProject(); | |
| } else if (textLower.includes("edit") || textLower.includes("modify") || textLower.includes("write")) { | |
| const fileMatch = userText.match(/(?:edit|modify|write)\s+([a-zA-Z0-9_\-\.]+)/i); | |
| const filename = fileMatch ? fileMatch[1] : "README.md"; | |
| setEditingFile(filename); | |
| setEditingContent(`# ${project?.name || "Project"}\n\nModified by AI Agent.\n\nThis sandbox utility is connected to local workspace registers.`); | |
| setAiMessages(prev => [ | |
| ...prev, | |
| { sender: "ai", text: `Opening editor sandbox for ${filename}... Type edits or save changes to index.` } | |
| ]); | |
| } else if (textLower.includes("delete") || textLower.includes("remove")) { | |
| const outputsRes = await api.get(`/projects/${projectId}/outputs`); | |
| const outputsList = outputsRes.data?.outputs ?? outputsRes.data?.items ?? outputsRes.data ?? []; | |
| const fileMatch = userText.match(/(?:delete|remove)\s+([a-zA-Z0-9_\-\.]+)/i); | |
| const filename = fileMatch ? fileMatch[1] : ""; | |
| const target = outputsList.find((o: any) => o.title.toLowerCase() === filename.toLowerCase()); | |
| if (target) { | |
| await api.delete(`/projects/${projectId}/outputs/${target.id}`); | |
| setAiMessages(prev => [ | |
| ...prev, | |
| { sender: "ai", text: `✔ Successfully deleted file: ${target.title} from the project.` } | |
| ]); | |
| toast.success(`Deleted file: ${target.title}`); | |
| fetchProject(); | |
| } else { | |
| setAiMessages(prev => [ | |
| ...prev, | |
| { sender: "ai", text: `Could not locate file: "${filename}" to delete. Please check file list.` } | |
| ]); | |
| } | |
| } else { | |
| setAiMessages(prev => [ | |
| ...prev, | |
| { sender: "ai", text: `I've analyzed the project workspace context. You can command me to:\n- "create index.html"\n- "edit README.md"\n- "delete main.py"` } | |
| ]); | |
| } | |
| } catch (err) { | |
| setAiMessages(prev => [ | |
| ...prev, | |
| { sender: "ai", text: `Failed to execute action. Ensure backend services are fully running.` } | |
| ]); | |
| } finally { | |
| setIsAiLoading(false); | |
| } | |
| }, 1200); | |
| }; | |
| useEffect(() => { | |
| fetchProject(); | |
| }, [projectId]); | |
| const fetchProject = async () => { | |
| if (!projectId) return; | |
| setLoading(true); | |
| setError(null); | |
| try { | |
| const [projectResponse, outputsResponse] = await Promise.all([ | |
| api.get(`/projects/${projectId}`), | |
| api.get(`/projects/${projectId}/outputs`), | |
| ]); | |
| const projectData = projectResponse.data?.project ?? projectResponse.data; | |
| const outputCount = outputsResponse.data?.count ?? outputsResponse.data?.outputs?.length ?? 0; | |
| const nextProject = { ...projectData, fileCount: outputCount }; | |
| setProject(nextProject); | |
| setIsOwner(user?.id === projectData.ownerId); | |
| offlineCache.set(PROJECT_WORKSPACE_CACHE_KEY(String(projectId)), nextProject); | |
| } catch (err: any) { | |
| console.error("Failed to fetch project:", err); | |
| const cachedProject = offlineCache.get<Project>(PROJECT_WORKSPACE_CACHE_KEY(String(projectId))); | |
| if (cachedProject) { | |
| setProject(cachedProject); | |
| setIsOwner(user?.id === cachedProject.ownerId); | |
| toast.info("Showing saved project workspace until the backend reconnects"); | |
| } else { | |
| setError(err.response?.data?.error || "Failed to load project"); | |
| toast.error("Could not load project"); | |
| } | |
| } finally { | |
| setLoading(false); | |
| } | |
| }; | |
| const handleRefresh = async () => { | |
| setIsRefreshing(true); | |
| await fetchProject(); | |
| setIsRefreshing(false); | |
| toast.success("Project refreshed"); | |
| }; | |
| const handleUpdateProject = async (updates: Partial<Project>) => { | |
| try { | |
| if (!isOnline) { | |
| const offlineUpdated = { ...(project ?? {}), ...updates } as Project; | |
| setProject(offlineUpdated); | |
| offlineCache.set(PROJECT_WORKSPACE_CACHE_KEY(String(projectId)), offlineUpdated); | |
| toast.info("Saved locally. Project changes will sync when the backend reconnects."); | |
| return; | |
| } | |
| const response = await api.put(`/projects/${projectId}`, updates); | |
| setProject((prev) => ({ | |
| ...(prev ?? {}), | |
| ...(response.data?.project ?? response.data), | |
| }) as Project); | |
| toast.success("Project updated"); | |
| } catch (err) { | |
| toast.error("Failed to update project"); | |
| throw err; | |
| } | |
| }; | |
| const handleDeleteProject = async () => { | |
| if (!confirm("Are you sure you want to delete this project? This action cannot be undone.")) { | |
| return; | |
| } | |
| try { | |
| if (!isOnline) { | |
| toast.error("Deleting a project requires the backend connection."); | |
| return; | |
| } | |
| await api.delete(`/projects/${projectId}`); | |
| toast.success("Project deleted"); | |
| navigate("/projects"); | |
| } catch (err) { | |
| toast.error("Failed to delete project"); | |
| } | |
| }; | |
| const handleArchiveProject = async () => { | |
| try { | |
| if (!isOnline) { | |
| const offlineArchived = project ? { ...project, status: "archived" as const } : project; | |
| if (offlineArchived) { | |
| setProject(offlineArchived); | |
| offlineCache.set(PROJECT_WORKSPACE_CACHE_KEY(String(projectId)), offlineArchived); | |
| } | |
| toast.info("Marked archived locally. It will sync when the backend reconnects."); | |
| return; | |
| } | |
| await api.post(`/projects/${projectId}/archive`); | |
| toast.success("Project archived"); | |
| fetchProject(); | |
| } catch (err) { | |
| toast.error("Failed to archive project"); | |
| } | |
| }; | |
| if (loading) { | |
| return ( | |
| <div className="flex items-center justify-center min-h-[60vh]"> | |
| <Loader2 className="w-10 h-10 animate-spin text-primary" /> | |
| </div> | |
| ); | |
| } | |
| if (error || !project) { | |
| return ( | |
| <div className="container mx-auto px-4 py-8"> | |
| <ErrorMessage | |
| title="Project Not Found" | |
| message={error || "The project you're looking for doesn't exist or you don't have access."} | |
| action={{ | |
| label: "Go to Projects", | |
| onClick: () => navigate("/projects") | |
| }} | |
| /> | |
| </div> | |
| ); | |
| } | |
| const progress = project.taskCount > 0 | |
| ? (project.completedTaskCount / project.taskCount) * 100 | |
| : 0; | |
| return ( | |
| <div className="min-h-screen bg-gray-50/50 dark:bg-gray-900/50 relative"> | |
| <div className="absolute top-0 left-0 w-full h-[300px] bg-gradient-to-br from-primary/10 via-transparent to-indigo-500/10 pointer-events-none -z-10" /> | |
| {(!isOnline || queueLength > 0) && ( | |
| <motion.div | |
| initial={{ opacity: 0, y: -20 }} | |
| animate={{ opacity: 1, y: 0 }} | |
| className="mx-4 mt-4 rounded-2xl border border-amber-200/50 bg-amber-50/80 backdrop-blur-md px-5 py-4 text-sm text-amber-900 shadow-sm dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100" | |
| > | |
| <div className="flex items-start gap-3"> | |
| <AlertCircle className="w-5 h-5 text-amber-600 mt-0.5" /> | |
| <div> | |
| <p className="font-semibold text-amber-800"> | |
| {!isOnline ? "Project workspace is offline" : "Some workspace actions are queued"} | |
| </p> | |
| <p className="mt-1 text-amber-700/80"> | |
| {!isOnline | |
| ? "You can review the cached project state, but member and archive actions need the backend." | |
| : "Queued edits will sync automatically when the connection returns."} | |
| </p> | |
| </div> | |
| </div> | |
| </motion.div> | |
| )} | |
| {/* Header */} | |
| <div className="bg-white/60 dark:bg-gray-900/60 backdrop-blur-xl border-b border-gray-200/50 dark:border-gray-700/50 sticky top-0 z-20 shadow-sm"> | |
| <div className="container mx-auto px-4 py-6"> | |
| <div className="flex items-center justify-between flex-wrap gap-4"> | |
| <div className="flex items-center gap-4"> | |
| <button | |
| onClick={() => navigate("/projects")} | |
| className="p-2.5 rounded-xl bg-white/50 dark:bg-gray-800/50 hover:bg-white dark:hover:bg-gray-800 shadow-sm border border-gray-200/50 dark:border-gray-700/50 transition-all" | |
| > | |
| <ArrowLeft className="w-5 h-5" /> | |
| </button> | |
| <div> | |
| <motion.h1 | |
| initial={{ opacity: 0, x: -20 }} | |
| animate={{ opacity: 1, x: 0 }} | |
| className="text-3xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-gray-900 to-gray-600 dark:from-white dark:to-gray-300" | |
| > | |
| {project.name} | |
| </motion.h1> | |
| <p className="text-sm text-gray-500 dark:text-gray-400 mt-1 line-clamp-1"> | |
| {project.description || "No description provided."} | |
| </p> | |
| </div> | |
| </div> | |
| <div className="flex items-center gap-3"> | |
| <button | |
| onClick={() => setIsAiPanelOpen(!isAiPanelOpen)} | |
| className={`px-4 py-2.5 rounded-xl font-semibold transition-all shadow-sm flex items-center gap-2 text-xs ${ | |
| isAiPanelOpen ? "bg-indigo-50 dark:bg-indigo-950/40 text-indigo-650 dark:text-indigo-350 border border-indigo-200/50" : "bg-indigo-600 hover:bg-indigo-500 text-white" | |
| }`} | |
| > | |
| <Brain className="w-4 h-4" /> | |
| {isAiPanelOpen ? "Close Workspace Tools" : "Launch Workspace Tools"} | |
| </button> | |
| <button | |
| onClick={handleRefresh} | |
| disabled={isRefreshing} | |
| className="p-2.5 rounded-xl bg-white/50 dark:bg-gray-800/50 hover:bg-white dark:hover:bg-gray-800 shadow-sm border border-gray-200/50 dark:border-gray-700/50 transition-all disabled:opacity-50" | |
| > | |
| <RefreshCw className={`w-5 h-5 ${isRefreshing ? "animate-spin text-primary" : ""}`} /> | |
| </button> | |
| {isOwner && ( | |
| <> | |
| <button | |
| onClick={handleArchiveProject} | |
| className="px-4 py-2.5 rounded-xl bg-white/50 dark:bg-gray-800/50 hover:bg-white dark:hover:bg-gray-800 shadow-sm border border-gray-200/50 dark:border-gray-700/50 text-gray-700 dark:text-gray-300 font-medium transition-all flex items-center" | |
| > | |
| <Archive className="w-4 h-4 mr-2" /> | |
| Archive | |
| </button> | |
| <button | |
| onClick={handleDeleteProject} | |
| className="px-4 py-2.5 rounded-xl bg-red-500/10 hover:bg-red-500/20 text-red-600 border border-red-500/20 font-medium transition-all flex items-center" | |
| > | |
| <Trash2 className="w-4 h-4 mr-2" /> | |
| Delete | |
| </button> | |
| </> | |
| )} | |
| </div> | |
| </div> | |
| {/* Progress Bar */} | |
| <motion.div | |
| initial={{ opacity: 0, y: 10 }} | |
| animate={{ opacity: 1, y: 0 }} | |
| transition={{ delay: 0.1 }} | |
| className="mt-6" | |
| > | |
| <div className="flex justify-between text-sm font-medium text-gray-600 dark:text-gray-400 mb-2"> | |
| <span>Overall Progress</span> | |
| <span className="text-primary">{Math.round(progress)}%</span> | |
| </div> | |
| <div className="h-2 bg-gray-100 dark:bg-gray-800 rounded-full overflow-hidden inset-shadow-sm"> | |
| <motion.div | |
| initial={{ width: 0 }} | |
| animate={{ width: `${progress}%` }} | |
| transition={{ duration: 0.8, ease: "easeOut" }} | |
| className="h-full bg-gradient-to-r from-primary to-indigo-500 rounded-full" | |
| /> | |
| </div> | |
| </motion.div> | |
| </div> | |
| </div> | |
| {/* Tabs */} | |
| <div className="border-b border-gray-200/50 dark:border-gray-700/50 bg-white/40 dark:bg-gray-900/40 backdrop-blur-md sticky top-[138px] z-10 shadow-sm"> | |
| <div className="container mx-auto px-4"> | |
| <div className="flex overflow-x-auto hide-scrollbar"> | |
| {[ | |
| { id: "overview", label: "Overview", icon: Activity }, | |
| { id: "tasks", label: "Tasks", icon: CheckSquare, badge: project.taskCount }, | |
| { id: "members", label: "Members", icon: Users, badge: project.memberCount }, | |
| { id: "files", label: "Files", icon: FolderOpen, badge: project.fileCount }, | |
| { id: "timeline", label: "Timeline", icon: Calendar }, | |
| { id: "settings", label: "Settings", icon: Settings }, | |
| ].map((tab) => ( | |
| <button | |
| key={tab.id} | |
| onClick={() => setActiveTab(tab.id as TabType)} | |
| className={`flex items-center gap-2 px-5 py-4 text-sm font-medium transition-all relative whitespace-nowrap ${ | |
| activeTab === tab.id | |
| ? "text-primary" | |
| : "text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300" | |
| }`} | |
| > | |
| <tab.icon className={`w-4 h-4 ${activeTab === tab.id ? 'text-primary' : ''}`} /> | |
| <span>{tab.label}</span> | |
| {tab.badge !== undefined && tab.badge > 0 && ( | |
| <span className={`px-2 py-0.5 text-xs rounded-full ${ | |
| activeTab === tab.id ? 'bg-primary/10 text-primary' : 'bg-gray-100 dark:bg-gray-800' | |
| }`}> | |
| {tab.badge} | |
| </span> | |
| )} | |
| {activeTab === tab.id && ( | |
| <motion.div | |
| layoutId="activeWorkspaceTab" | |
| className="absolute bottom-0 left-0 right-0 h-0.5 bg-primary" | |
| /> | |
| )} | |
| </button> | |
| ))} | |
| </div> | |
| </div> | |
| </div> | |
| {/* Content */} | |
| <div className="container mx-auto px-4 py-8"> | |
| <div className="grid grid-cols-1 lg:grid-cols-12 gap-6 items-start"> | |
| <div className={isAiPanelOpen ? "lg:col-span-8" : "lg:col-span-12"}> | |
| <AnimatePresence mode="wait"> | |
| <motion.div | |
| key={activeTab} | |
| initial={{ opacity: 0, y: 20 }} | |
| animate={{ opacity: 1, y: 0 }} | |
| exit={{ opacity: 0, y: -20 }} | |
| transition={{ duration: 0.2 }} | |
| className="bg-white/40 dark:bg-gray-800/40 backdrop-blur-xl rounded-3xl border border-white/40 dark:border-gray-700/50 shadow-lg p-6 min-h-[500px]" | |
| > | |
| {activeTab === "overview" && ( | |
| <ProjectOverview | |
| project={project} | |
| isOwner={isOwner} | |
| onUpdate={handleUpdateProject} | |
| /> | |
| )} | |
| {activeTab === "tasks" && ( | |
| <ProjectTasks | |
| projectId={project.id} | |
| isOwner={isOwner} | |
| onTaskUpdate={fetchProject} | |
| onCreateTask={() => setIsTaskModalOpen(true)} | |
| /> | |
| )} | |
| {activeTab === "members" && ( | |
| <ProjectMembers | |
| projectId={project.id} | |
| isOwner={isOwner} | |
| onMemberUpdate={fetchProject} | |
| onAddMember={() => setIsMemberModalOpen(true)} | |
| /> | |
| )} | |
| {activeTab === "files" && ( | |
| <ProjectFiles | |
| projectId={project.id} | |
| isOwner={isOwner} | |
| onFileUpdate={fetchProject} | |
| /> | |
| )} | |
| {activeTab === "timeline" && ( | |
| <ProjectTimeline | |
| projectId={project.id} | |
| /> | |
| )} | |
| {activeTab === "settings" && isOwner && ( | |
| <ProjectSettings | |
| project={project} | |
| onUpdate={handleUpdateProject} | |
| onArchive={handleArchiveProject} | |
| onDelete={handleDeleteProject} | |
| /> | |
| )} | |
| </motion.div> | |
| </AnimatePresence> | |
| </div> | |
| {/* AI Workspace Copilot / Apps Launcher */} | |
| {isAiPanelOpen && ( | |
| <motion.div | |
| initial={{ opacity: 0, x: 20 }} | |
| animate={{ opacity: 1, x: 0 }} | |
| className="lg:col-span-4 bg-slate-900/90 border border-white/10 rounded-3xl p-5 flex flex-col justify-between shadow-2xl h-[580px]" | |
| > | |
| <div className="flex-grow flex flex-col h-full overflow-hidden"> | |
| {/* Sidebar Header Tabs */} | |
| <div className="flex border-b border-white/5 pb-2 mb-3 justify-between items-center shrink-0"> | |
| <div className="flex gap-2"> | |
| <button | |
| onClick={() => setSidebarTab("ai")} | |
| className={`text-xs font-bold px-3 py-1.5 rounded-lg transition-all ${ | |
| sidebarTab === "ai" | |
| ? "bg-indigo-600 text-white shadow-sm" | |
| : "text-slate-400 hover:text-white hover:bg-white/5" | |
| }`} | |
| > | |
| AI Copilot | |
| </button> | |
| <button | |
| onClick={() => setSidebarTab("apps")} | |
| className={`text-xs font-bold px-3 py-1.5 rounded-lg transition-all ${ | |
| sidebarTab === "apps" | |
| ? "bg-indigo-600 text-white shadow-sm" | |
| : "text-slate-400 hover:text-white hover:bg-white/5" | |
| }`} | |
| > | |
| Workspace Apps | |
| </button> | |
| </div> | |
| <span className="text-[9px] bg-emerald-500/10 text-emerald-400 px-2 py-0.5 rounded font-bold border border-emerald-500/20">Active</span> | |
| </div> | |
| {sidebarTab === "ai" ? ( | |
| <div className="flex-grow flex flex-col justify-between overflow-hidden"> | |
| <div className="flex-1 overflow-y-auto my-1 space-y-3.5 pr-1 text-xs text-left"> | |
| {aiMessages.map((m, idx) => ( | |
| <div key={idx} className={`flex ${m.sender === "user" ? "justify-end" : "justify-start"}`}> | |
| <div className={`p-3 rounded-2xl max-w-[85%] leading-relaxed ${m.sender === "user" ? "bg-indigo-650 text-white rounded-tr-none" : "bg-slate-800 text-slate-350 rounded-tl-none border border-white/5"}`}> | |
| {m.text} | |
| </div> | |
| </div> | |
| ))} | |
| {isAiLoading && ( | |
| <div className="flex justify-start"> | |
| <div className="bg-slate-800 text-slate-400 p-3 rounded-2xl rounded-tl-none border border-white/5 flex items-center gap-1.5"> | |
| <span className="w-1.5 h-1.5 bg-slate-500 rounded-full animate-bounce" /> | |
| <span className="w-1.5 h-1.5 bg-slate-500 rounded-full animate-bounce delay-100" /> | |
| <span className="w-1.5 h-1.5 bg-slate-500 rounded-full animate-bounce delay-200" /> | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| <form onSubmit={handleAiSubmit} className="flex gap-2 pt-2 border-t border-white/5 shrink-0"> | |
| <input | |
| type="text" | |
| value={aiInput} | |
| onChange={(e) => setAiInput(e.target.value)} | |
| placeholder="e.g. create helper.py..." | |
| className="flex-1 bg-slate-950 border border-white/10 rounded-xl px-3 py-2 text-xs text-white focus:outline-none focus:ring-1 focus:ring-indigo-500 placeholder-slate-500" | |
| /> | |
| <button type="submit" className="px-3 py-2 bg-indigo-600 hover:bg-indigo-500 rounded-xl font-bold text-white transition text-xs active:scale-95"> | |
| Run | |
| </button> | |
| </form> | |
| </div> | |
| ) : ( | |
| <div className="flex-grow overflow-y-auto space-y-4 pr-1 text-left"> | |
| <p className="text-[11px] text-slate-400 leading-relaxed mb-3"> | |
| Launch integrated apps populated directly with this project's workspace variables for seamless workflow: | |
| </p> | |
| <div className="grid grid-cols-2 gap-3"> | |
| {/* App 1: LaTeX Editor */} | |
| <button | |
| onClick={() => navigate(`/editor?project=${projectId}`)} | |
| className="p-3.5 rounded-2xl border border-white/5 bg-slate-950/40 hover:bg-slate-950 text-left transition-all hover:border-teal-500/30 group flex flex-col justify-between h-28" | |
| > | |
| <div className="w-8 h-8 rounded-xl bg-teal-500/10 flex items-center justify-center text-teal-400 group-hover:scale-105 transition-all"> | |
| <Laptop className="w-4.5 h-4.5" /> | |
| </div> | |
| <div> | |
| <h4 className="text-xs font-bold text-slate-200">LaTeX Editor</h4> | |
| <p className="text-[9px] text-slate-500 truncate mt-0.5">Edit project manuscripts</p> | |
| </div> | |
| </button> | |
| {/* App 2: AI Co-Scientist */} | |
| <button | |
| onClick={() => navigate(`/ai-co-scientist?project=${projectId}`)} | |
| className="p-3.5 rounded-2xl border border-white/5 bg-slate-950/40 hover:bg-slate-950 text-left transition-all hover:border-purple-500/30 group flex flex-col justify-between h-28" | |
| > | |
| <div className="w-8 h-8 rounded-xl bg-purple-500/10 flex items-center justify-center text-purple-400 group-hover:scale-105 transition-all"> | |
| <Brain className="w-4.5 h-4.5" /> | |
| </div> | |
| <div> | |
| <h4 className="text-xs font-bold text-slate-200">AI Co-Scientist</h4> | |
| <p className="text-[9px] text-slate-500 truncate mt-0.5">Analyze project files</p> | |
| </div> | |
| </button> | |
| {/* App 3: Interactive App Store */} | |
| <button | |
| onClick={() => navigate(`/tools`)} | |
| className="p-3.5 rounded-2xl border border-white/5 bg-slate-950/40 hover:bg-slate-950 text-left transition-all hover:border-pink-500/30 group flex flex-col justify-between h-28" | |
| > | |
| <div className="w-8 h-8 rounded-xl bg-pink-500/10 flex items-center justify-center text-pink-400 group-hover:scale-105 transition-all"> | |
| <Plus className="w-4.5 h-4.5" /> | |
| </div> | |
| <div> | |
| <h4 className="text-xs font-bold text-slate-200">App Store</h4> | |
| <p className="text-[9px] text-slate-500 truncate mt-0.5">Install plugins & tools</p> | |
| </div> | |
| </button> | |
| {/* App 4: Citation Graph */} | |
| <button | |
| onClick={() => navigate(`/citation-graph`)} | |
| className="p-3.5 rounded-2xl border border-white/5 bg-slate-950/40 hover:bg-slate-950 text-left transition-all hover:border-indigo-500/30 group flex flex-col justify-between h-28" | |
| > | |
| <div className="w-8 h-8 rounded-xl bg-indigo-500/10 flex items-center justify-center text-indigo-400 group-hover:scale-105 transition-all"> | |
| <Network className="w-4.5 h-4.5" /> | |
| </div> | |
| <div> | |
| <h4 className="text-xs font-bold text-slate-200">Citation Graph</h4> | |
| <p className="text-[9px] text-slate-500 truncate mt-0.5">Explore citation maps</p> | |
| </div> | |
| </button> | |
| {/* App 5: Collaborative call */} | |
| <button | |
| onClick={() => navigate(`/conference/room/project-${projectId}`)} | |
| className="p-3.5 rounded-2xl border border-white/5 bg-slate-950/40 hover:bg-slate-950 text-left transition-all hover:border-rose-500/30 group flex flex-col justify-between h-28 col-span-2" | |
| > | |
| <div className="flex items-center gap-3"> | |
| <div className="w-8 h-8 rounded-xl bg-rose-500/10 flex items-center justify-center text-rose-400 group-hover:scale-105 transition-all"> | |
| <Video className="w-4.5 h-4.5" /> | |
| </div> | |
| <div> | |
| <h4 className="text-xs font-bold text-slate-200">Start Meeting Room</h4> | |
| <p className="text-[9px] text-slate-500 mt-0.5">Open a live WebRTC team call for this project</p> | |
| </div> | |
| </div> | |
| </button> | |
| </div> | |
| <div className="p-4 rounded-2xl bg-slate-950/40 border border-white/5 flex items-center justify-between mt-2"> | |
| <div className="flex items-center gap-2"> | |
| <MessageSquare className="w-4 h-4 text-emerald-400" /> | |
| <span className="text-[10px] font-bold text-slate-350">Open Group Chats</span> | |
| </div> | |
| <button onClick={() => navigate("/messages")} className="text-[10px] text-indigo-400 font-bold hover:underline">Launch →</button> | |
| </div> | |
| </div> | |
| )} | |
| </div> | |
| </motion.div> | |
| )} | |
| {/* Sandbox Editor Popup */} | |
| {editingFile && ( | |
| <div className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4"> | |
| <motion.div initial={{ scale: 0.95 }} animate={{ scale: 1 }} className="bg-slate-950 border border-white/10 rounded-2xl w-full max-w-2xl overflow-hidden shadow-2xl"> | |
| <div className="flex justify-between items-center px-4 py-3 bg-slate-900 border-b border-white/5"> | |
| <div className="flex items-center gap-2"> | |
| <FileText className="w-4 h-4 text-indigo-400" /> | |
| <span className="text-xs text-white font-mono">{editingFile} (AI Sandbox Editor)</span> | |
| </div> | |
| <button onClick={() => setEditingFile(null)} className="text-slate-400 hover:text-white transition font-bold text-xs">✕</button> | |
| </div> | |
| <div className="p-4"> | |
| <textarea | |
| value={editingContent} | |
| onChange={(e) => setEditingContent(e.target.value)} | |
| className="w-full h-[240px] bg-slate-900 text-slate-300 font-mono text-xs p-3 rounded-lg border border-white/5 focus:outline-none focus:ring-1 focus:ring-indigo-500 resize-none" | |
| /> | |
| <div className="flex justify-end gap-2 mt-4"> | |
| <button onClick={() => setEditingFile(null)} className="px-4 py-2 rounded-xl bg-slate-900 hover:bg-slate-800 text-slate-400 text-xs font-semibold">Cancel</button> | |
| <button | |
| onClick={async () => { | |
| try { | |
| await api.post(`/projects/${projectId}/outputs`, { | |
| title: editingFile, | |
| description: `Edited by AI Workspace Copilot: ${editingContent.substring(0, 100)}...`, | |
| link: "" | |
| }); | |
| toast.success("Changes saved successfully!"); | |
| setEditingFile(null); | |
| fetchProject(); | |
| } catch { | |
| toast.error("Failed to save changes."); | |
| } | |
| }} | |
| className="px-4 py-2 rounded-xl bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-semibold" | |
| > | |
| Save to Index | |
| </button> | |
| </div> | |
| </div> | |
| </motion.div> | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| {/* Modals */} | |
| <TaskModal | |
| isOpen={isTaskModalOpen} | |
| onClose={() => setIsTaskModalOpen(false)} | |
| projectId={project.id} | |
| onSuccess={fetchProject} | |
| /> | |
| <MemberModal | |
| isOpen={isMemberModalOpen} | |
| onClose={() => setIsMemberModalOpen(false)} | |
| projectId={project.id} | |
| onSuccess={fetchProject} | |
| /> | |
| </div> | |
| ); | |
| } | |
Xet Storage Details
- Size:
- 34.4 kB
- Xet hash:
- 60e6293eabb50d6ac28311ab68651a5aa173bf2f2cf7b53b58c63dd6a2335021
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.