import React, { useState, useRef, useEffect } from 'react'; import { useNexus } from '@nexus/shared'; import styles from './NexusConsole.module.css'; interface NexusConsoleProps { initialTicket?: any; } const FORENSIC_STEPS = [ { time:"10:42:01", node:"vision", label:"Vision", detail:"No attachments found. Skipped visual scan.", status:"skip" }, { time:"10:42:02", node:"input_guard", label:"Input Guard", detail:"No injection patterns detected. Cleared.", status:"ok" }, { time:"10:42:02", node:"router", label:"Intent Router", detail:"Intent: DIAGNOSE_TICKET. Tools selected: SQL + KB.", status:"ok" }, { time:"10:42:03", node:"executor", label:"Tool Executor", detail:"Parallel: SQL query (12ms) + KB vector search (31ms).", status:"ok" }, { time:"10:42:04", node:"responder", label:"Responder", detail:"Generated structured diagnosis with code block.", status:"ok" }, { time:"10:42:05", node:"approval", label:"HITL Approval", detail:"Write action detected. Paused for staff approval.", status:"wait" }, ]; export const NexusConsole: React.FC = ({ initialTicket }) => { const { messages, loading, query } = useNexus(initialTicket?.id); const [input, setInput] = useState(""); const [approvalState, setApprovalState] = useState<"pending" | "approved" | "rejected">("pending"); const bottomRef = useRef(null); useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: "smooth" }); }, [messages, loading]); const handleSend = () => { if (!input.trim() || loading) return; query(input); setInput(""); }; const renderMessageContent = (content: string) => { const parts = content.split(/(```[\s\S]*?```|\*\*[^*]+\*\*)/g); return parts.map((p, j) => { if (p.startsWith("```")) { const code = p.replace(/```\w*\n?/, "").replace(/```$/, ""); return
{code}
; } if (p.startsWith("**")) { return {p.replace(/\*\*/g, "")}; } return {p}; }); }; return (
{/* Chat Column */}
{/* Ticket Context Bar */} {initialTicket && (
{initialTicket.id?.slice(0, 8).toUpperCase()} {initialTicket.title}
{initialTicket.priority || 'MEDIUM'}
)}
{messages.map((msg, i) => (
{msg.role === 'assistant' && (
N
)}
{msg.role === 'assistant' && (
Nexus
Nexus Knowledge Base
)}
{renderMessageContent(msg.content)}
))} {loading && (
N
)} {/* Simulated Approval Action */} {initialTicket && messages.length > 2 && approvalState === 'pending' && (
⚑ Action requires approval HITL PAUSE
ACTION PATCH_TENANT_CONFIG
TENANT {initialTicket.user_id || 'acme-corp-t84'}
FIELD oauth_redirect_uri
RISK Low

Update OAuth redirect URI for tenant to resolve SSO login loop.

)}