/* ═══════════════════════════════════════════════════════════════
LandingPage — Hero section with GitHub URL input & code paste
═══════════════════════════════════════════════════════════════ */
import { useState } from 'react';
import { useScan } from '../context/ScanContext';
import ParticleBackground from './ParticleBackground';
import './LandingPage.css';
export default function LandingPage() {
const { startScan } = useScan();
const [inputMode, setInputMode] = useState('url'); // 'url' or 'code'
const [githubUrl, setGithubUrl] = useState('');
const [codeInput, setCodeInput] = useState('');
const [language, setLanguage] = useState('javascript');
const [isStarting, setIsStarting] = useState(false);
const canScan = inputMode === 'url' ? githubUrl.trim().length > 0 : codeInput.trim().length > 0;
const handleScan = async () => {
if (!canScan || isStarting) return;
// Request Notification permission on user gesture
if ('Notification' in window && Notification.permission === 'default') {
Notification.requestPermission();
}
setIsStarting(true);
const sessionId = `cs-${Math.random().toString(36).substring(2, 11)}-${Date.now()}`;
let sourceType = 'github';
if (inputMode === 'url') {
if (githubUrl.includes('huggingface.co')) {
sourceType = 'huggingface';
}
} else {
sourceType = 'code';
}
const payload = inputMode === 'url'
? {
source_type: sourceType,
source: githubUrl.trim(),
session_id: sessionId
}
: {
source_type: sourceType,
source: codeInput.trim(),
session_id: sessionId
};
await startScan(payload);
};
const handleKeyDown = (e) => {
if (e.key === 'Enter' && !e.shiftKey && inputMode === 'url') {
e.preventDefault();
handleScan();
}
};
return (
{/* Header */}
{/* Hero */}
AI-Powered Security Intelligence
Secure Your Code
Before It Ships
3 AI agents analyze your codebase in real-time — detecting vulnerabilities,
finding performance issues, and generating fixes. All locally, all privately.
{/* Privacy Banner */}
🔒
Your code never leaves this machine — 100% local inference, zero data retention
{/* Input Section */}
{/* Mode Tabs */}
setInputMode('url')}
>
🐙/🤗 Repo URL
setInputMode('code')}
>
📋 Paste Code
{/* Input Area */}
{inputMode === 'url' ? (
) : (
setLanguage(e.target.value)}
>
JavaScript
Python
TypeScript
Java
Go
Rust
C++
C#
{codeInput.split('\n').filter(l => l.trim()).length} lines
)}
{/* Scan Button */}
{isStarting ? (
<>
⟳
Initializing Agents...
>
) : (
<>
⚡
Launch Security Scan
>
)}
{/* Feature Cards */}
🔍
Security Agent
OWASP vulnerabilities, prompt injection, hardcoded secrets, auth weaknesses
⚡
Performance Agent
Memory leaks, N+1 queries, GPU inefficiencies, tensor optimization
🔧
Fix Agent
AI-generated patches, before/after diffs, secure code suggestions
{/* Footer */}
);
}