import React, { useState, useMemo } from 'react'; import { Terminal, Copy, Check, UploadCloud, FileText, GitBranch, ShieldCheck, ArrowRight, BookOpen, Sparkles, ExternalLink, Code2, CheckCircle2, Globe, Layers, Cpu, Info, Search, Filter, Sliders, History, Activity, UserCheck, CheckSquare } from 'lucide-react'; export default function WorkspaceEmptyState({ workspace, currentUser, onUploadDocument, onRefresh, onDismissEmptyState }) { const [copiedId, setCopiedId] = useState(null); const [uploading, setUploading] = useState(false); const [activeTab, setActiveTab] = useState('workflow'); // 'workflow' | 'all_commands' const [commandCategory, setCommandCategory] = useState('all'); const [searchFilter, setSearchFilter] = useState(''); // Human-readable workspace name (unique identifier) const wsName = workspace?.name || 'my-workspace'; const copyToClipboard = (text, id) => { navigator.clipboard.writeText(text); setCopiedId(id); setTimeout(() => setCopiedId(null), 2000); }; const handleFileDrop = async (e) => { e.preventDefault(); const files = e.dataTransfer ? e.dataTransfer.files : e.target.files; if (!files || files.length === 0) return; setUploading(true); try { for (let i = 0; i < files.length; i++) { await onUploadDocument(files[i]); } if (onRefresh) onRefresh(); } catch (err) { console.error(err); } finally { setUploading(false); } }; // 1. Core Onboarding 7-Step Workflow const onboardingSteps = [ { id: 'step_install', stepNum: '1', title: 'Install DiffWeave CLI', desc: 'Installs the dw command-line utility globally on your workstation via pip. Compatible across Windows, macOS, Linux, and automated CI/CD runners.', command: 'pip install git+https://github.com/AdhiShak3008/DiffWeave.git', details: 'Registers the dw binary in your system PATH with full support for semantic diffs, staging, and policy rules.' }, { id: 'step_auth', stepNum: '2', title: 'Authenticate CLI Session', desc: 'Stores an authenticated session in ~/.diffweave/credentials.json. You can copy your personal API token anytime from the visible "Copy API Key" button in the Studio header.', command: 'dw login --token ', details: 'Alternatively, sign in with your email and password via: dw login --email developer@example.com' }, { id: 'step_dir', stepNum: '3', title: 'Create & Enter Local Document Directory', desc: 'Create a local folder on your filesystem to organize the specifications, policy files, or markdown documentation you want to track.', command: 'mkdir my-docs && cd my-docs', details: 'Navigating into a dedicated directory ensures DiffWeave tracks only the intended documentation files.' }, { id: 'step_init', stepNum: '4', title: 'Initialize Workspace by Name', desc: `Binds your current directory to the "${wsName}" workspace by its unique name. No database UUIDs required.`, command: `dw init --workspace "${wsName}"`, details: 'Generates a local .diffweave/ configuration file binding this repository to the remote cloud workspace.' }, { id: 'step_stage', stepNum: '5', title: 'Stage Documents for Parsing & Extraction', desc: 'Ingests your local documents into the deterministic parsing engine to extract verifiable facts, claims, and semantic relationships.', command: 'dw add ./sample_policy.txt', details: 'Supports PDF, DOCX, Markdown, and TXT files. The extraction pipeline automatically isolates facts and creates knowledge proposals.' }, { id: 'step_diff', stepNum: '6', title: 'Inspect Semantic Fact Diff', desc: 'Computes a semantic delta comparing extracted claims against the Master Knowledge Register to detect additions, conflicts, and policy violations.', command: 'dw diff', details: 'Displays high-confidence facts, confidence scores, and potential contradictions with your current committed baseline.' }, { id: 'step_push', stepNum: '7', title: 'Push Verified Knowledge to Cloud', desc: 'Commits approved knowledge proposals to the cloud Master Truth register, updating your Knowledge Graph and Studio in real time.', command: 'dw push', details: 'Synchronizes your local review state with the remote register, creating an immutable audit trail entry.' } ]; // 2. Complete Reference of all 20 CLI Commands const allCommands = [ // Lifecycle & Workspace { name: 'dw init', category: 'workspace', categoryLabel: 'Workspace & Setup', command: `dw init --workspace "${wsName}"`, desc: 'Initializes a local .diffweave/ project configuration and binds it to a workspace by name or UUID.', flags: '--workspace , --create ' }, { name: 'dw status', category: 'workspace', categoryLabel: 'Workspace & Setup', command: 'dw status', desc: 'Displays the local directory staging state, bound workspace details, and counts of pending review proposals.', flags: '--json' }, { name: 'dw doctor', category: 'workspace', categoryLabel: 'Workspace & Setup', command: 'dw doctor', desc: 'Runs automated diagnostic health checks on FastMCP bridge connectivity, local configuration, and backend services.', flags: 'None' }, { name: 'dw version', category: 'workspace', categoryLabel: 'Workspace & Setup', command: 'dw version', desc: 'Prints the currently installed version of the DiffWeave CLI tool.', flags: 'None' }, // Authentication { name: 'dw login (token)', category: 'auth', categoryLabel: 'Authentication', command: 'dw login --token ', desc: 'Authenticates a CLI session using your DiffWeave API bearer token and stores credentials in ~/.diffweave/credentials.json.', flags: '--token , --url ' }, { name: 'dw login (email)', category: 'auth', categoryLabel: 'Authentication', command: 'dw login --email developer@example.com', desc: 'Authenticates with email and password interactively.', flags: '--email , --password ' }, { name: 'dw whoami', category: 'auth', categoryLabel: 'Authentication', command: 'dw whoami', desc: 'Displays current authenticated user username, email address, role, and the active workspace binding.', flags: '--json' }, { name: 'dw logout', category: 'auth', categoryLabel: 'Authentication', command: 'dw logout', desc: 'Logs out of the current session and securely removes saved tokens from your local machine.', flags: 'None' }, // Ingestion & Staging { name: 'dw add', category: 'ingestion', categoryLabel: 'Ingestion & Staging', command: 'dw add ./specifications/system-architecture.pdf', desc: 'Stages local documentation files (PDF, DOCX, Markdown, TXT) and triggers deterministic claim extraction.', flags: '--workspace , --wait / --no-wait, --json' }, { name: 'dw proposals', category: 'ingestion', categoryLabel: 'Ingestion & Staging', command: 'dw proposals', desc: 'Lists and inspects all extracted knowledge proposals (PRs) pending review for the current workspace.', flags: '--status , --json' }, { name: 'dw diff', category: 'ingestion', categoryLabel: 'Ingestion & Staging', command: 'dw diff', desc: 'Computes a semantic fact delta comparing staged document claims against the committed Master Truth Register.', flags: '--workspace , --json' }, // Validation & Review { name: 'dw validate', category: 'validation', categoryLabel: 'Validation & CI/CD', command: 'dw validate --strict', desc: 'CI/CD policy compliance linter. Validates proposals against workspace policy rules; exits with code 1 on violations.', flags: '--strict / --no-strict, --proposal , --json' }, { name: 'dw review', category: 'validation', categoryLabel: 'Validation & CI/CD', command: 'dw review', desc: 'Launches an interactive terminal review wizard to inspect, approve, reject, or comment on pending fact proposals.', flags: '--proposal ' }, { name: 'dw commit', category: 'validation', categoryLabel: 'Validation & CI/CD', command: 'dw commit -m "Approved Q3 regulatory compliance baseline"', desc: 'Commits approved knowledge proposals into the active workspace register with an audit message.', flags: '-m , --proposal , --all-approved, --json' }, { name: 'dw push', category: 'validation', categoryLabel: 'Validation & CI/CD', command: 'dw push', desc: 'Publishes and synchronizes all staged and approved knowledge proposals to the cloud Master Truth register in real time.', flags: '-m , --workspace , --json' }, // Knowledge Search & Audit { name: 'dw search', category: 'search', categoryLabel: 'Search & Audit', command: 'dw search "data retention policy 90 days"', desc: 'Performs hybrid lexical and vector semantic search across all verified facts and documents in the workspace.', flags: '--workspace , --limit , --json' }, { name: 'dw log', category: 'search', categoryLabel: 'Search & Audit', command: 'dw log', desc: 'Displays the chronological, tamper-evident audit trail showing who staged, modified, or approved each claim.', flags: '--limit , --json' }, // Policy Rules Management { name: 'dw rules list', category: 'rules', categoryLabel: 'Policy Rules', command: 'dw rules list', desc: 'Lists all active and inactive policy rules, conditions, and enforcement levels configured for this workspace.', flags: '--json' }, { name: 'dw rules add', category: 'rules', categoryLabel: 'Policy Rules', command: 'dw rules add --name "Require ISO Citation" --operator "must_contain" --condition "ISO-27001"', desc: 'Creates a new compliance lint rule to automatically check incoming document claims before merging.', flags: '--name , --operator , --condition , --blocking' }, { name: 'dw rules enable', category: 'rules', categoryLabel: 'Policy Rules', command: 'dw rules enable ', desc: 'Activates an existing policy rule for strict evaluation during dw validate.', flags: '' }, { name: 'dw rules disable', category: 'rules', categoryLabel: 'Policy Rules', command: 'dw rules disable ', desc: 'Temporarily disables an active policy rule without deleting it from the registry.', flags: '' } ]; // Filter commands by category and search keyword const filteredCommands = useMemo(() => { return allCommands.filter((cmd) => { const matchesCategory = commandCategory === 'all' || cmd.category === commandCategory; const matchesSearch = searchFilter.trim() === '' || cmd.name.toLowerCase().includes(searchFilter.toLowerCase()) || cmd.desc.toLowerCase().includes(searchFilter.toLowerCase()) || cmd.command.toLowerCase().includes(searchFilter.toLowerCase()); return matchesCategory && matchesSearch; }); }, [allCommands, commandCategory, searchFilter]); return (
{/* GitHub-style Quick Setup Header Card */}

CLI Developer Workspace Setup

Initialize this workspace in your local terminal using the steps below, or drag and drop files directly in the browser.

Workspace: {wsName}
{/* Professional Enterprise Client Notice */}

Cross-Platform Terminal Client

CLI • MCP • Studio

Install and run the DiffWeave CLI across any developer workstation, local environment, or CI/CD runner to stage documentation, inspect semantic diffs, and synchronize verified knowledge with the cloud register.

{/* View Mode Tabs: Workflow vs Full Reference */}
{/* VIEW 1: Onboarding 7-Step Workflow */} {activeTab === 'workflow' && (

Standard Ingestion & Review Workflow

{onboardingSteps.map((step) => { const isCopied = copiedId === step.id; return (
Step {step.stepNum}
{step.title}

{step.desc}

{/* Dedicated Individual Copy Button */}
{/* Code Snippet Box */}
{step.command}
{/* Deep Feature Details */}
{step.details}
); })}
)} {/* VIEW 2: Complete CLI Command Reference (All 20 Commands) */} {activeTab === 'all_commands' && (
{/* Category Filter Pills & Search */}
{[ { id: 'all', label: 'All Commands' }, { id: 'workspace', label: 'Workspace' }, { id: 'auth', label: 'Authentication' }, { id: 'ingestion', label: 'Ingestion' }, { id: 'validation', label: 'Validation & CI' }, { id: 'search', label: 'Search & Audit' }, { id: 'rules', label: 'Policy Rules' } ].map((cat) => ( ))}
setSearchFilter(e.target.value)} className="w-full pl-8 pr-3 py-1.5 rounded-lg bg-[#0D1117] border border-[#30363D] text-xs text-white placeholder-slate-500 focus:outline-none focus:border-emerald-500" />
{/* Grid of All Commands */}
{filteredCommands.map((cmd, idx) => { const isCopied = copiedId === `all_${idx}`; return (
{cmd.name} {cmd.categoryLabel}

{cmd.desc}

{/* Dedicated Individual Copy Button */}
{/* Code Snippet Box */}
{cmd.command}
{cmd.flags && cmd.flags !== 'None' && (
Options: {cmd.flags}
)}
); })} {filteredCommands.length === 0 && (
No commands matching "{searchFilter}" in this category.
)}
)}
or upload directly via browser
{/* Browser Drag and Drop Upload */}
e.preventDefault()} onDrop={handleFileDrop} className="border-2 border-dashed border-[#30363D] hover:border-emerald-500/50 rounded-xl p-8 text-center bg-[#0D1117]/50 hover:bg-[#0D1117] transition cursor-pointer" >
{/* Footer Dismiss / Continue Bar */}
Need diagnostic information? Run dw doctor in your terminal {onDismissEmptyState && ( )}
); }