Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
feat(ui): add Grok-style Virtual Machine and live browser split pane
Oleksandr Ivanchenko05ddd18acf22
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex 98b47bc0..31b86d90 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -33,6 +33,14 @@ export const App: React.FC = () => {const [isNewTeamOpen, setIsNewTeamOpen] = useState(false);const [editingTeam, setEditingTeam] = useState<Team | null>(null);+ // Virtual Machine & Live Browser state+ const [isVmPaneOpen, setIsVmPaneOpen] = useState(false);+ const [activeUrl, setActiveUrl] = useState('');+ const [pageTitle, setPageTitle] = useState('');+ const [screenshotBase64, setScreenshotBase64] = useState<string | null>(null);+ const [isVmRunning, setIsVmRunning] = useState(true);+ const [terminalLogs, setTerminalLogs] = useState<Array<{ command: string; output: string; timestamp?: string }>>([]);+// Load initial Kwants, Channels, and TeamsuseEffect(() => {async function loadInitialData() {@@ -187,6 +195,41 @@ export const App: React.FC = () => {setIsStreaming(false);}break;+ case 'browser_navigated':+ case 'BrowserNavigated': {+ if (event.data?.url) setActiveUrl(event.data.url);+ if (event.data?.title) setPageTitle(event.data.title);+ setIsVmPaneOpen(true);+ playSfx('blip');+ break;+ }+ case 'browser_screenshot':+ case 'BrowserScreenshot': {+ if (event.data?.image_base64) setScreenshotBase64(event.data.image_base64);+ if (event.data?.url) setActiveUrl(event.data.url);+ setIsVmPaneOpen(true);+ playSfx('blip');+ break;+ }+ case 'sandbox_status':+ case 'SandboxStatusChanged': {+ if (typeof event.data?.is_running === 'boolean') {+ setIsVmRunning(event.data.is_running);+ }+ break;+ }+ case 'ToolCallCompleted': {+ const result = event.data?.result;+ if (result && typeof result === 'object' && ('command' in result || 'stdout' in result)) {+ const cmd = result.command || 'bash';+ const output = result.stdout || result.stderr || JSON.stringify(result);+ setTerminalLogs((prev) => [+ ...prev,+ { command: cmd, output, timestamp: new Date().toLocaleTimeString() },+ ]);+ }+ break;+ }case 'Error':discussionInProgressRef.current = false;setDiscussionState({ inProgress: false });@@ -524,6 +567,62 @@ export const App: React.FC = () => {? `${currentKwant?.title || 'Specialist'} [Laya Auto-Fleet]`: currentTeam?.description || currentChannel?.description || 'Team collaboration room';+ // Load container status for active team+ useEffect(() => {+ const tid = currentTeam?.id || selectedTeamId;+ if (!tid) return;+ fetch(`/api/teams/${tid}/sandbox`)+ .then((r) => (r.ok ? r.json() : null))+ .then((data) => {+ if (data && typeof data.is_running === 'boolean') {+ setIsVmRunning(data.is_running);+ }+ })+ .catch(() => {});+ }, [currentTeam?.id, selectedTeamId]);++ const handleRefreshVm = async () => {+ const tid = currentTeam?.id || selectedTeamId;+ if (!tid) return;+ try {+ const res = await fetch(`/api/teams/${tid}/browser/screenshot`);+ if (res.ok) {+ const data = await res.json();+ if (data.image_base64 || data.screenshot) {+ setScreenshotBase64(data.image_base64 || data.screenshot);+ }+ if (data.url) {+ setActiveUrl(data.url);+ }+ }+ } catch (err) {+ console.error('Failed refreshing VM screenshot:', err);+ }+ };++ const handleRestartVm = async () => {+ const tid = currentTeam?.id || selectedTeamId;+ if (!tid) return;+ try {+ const res = await fetch(`/api/teams/${tid}/sandbox/restart`, {+ method: 'POST',+ });+ if (res.ok) {+ setIsVmRunning(false);+ setTerminalLogs((prev) => [+ ...prev,+ {+ command: 'docker restart sandbox',+ output: 'Sandbox container stopped and reset.',+ timestamp: new Date().toLocaleTimeString(),+ },+ ]);+ }+ } catch (err) {+ console.error('Failed restarting VM:', err);+ }+ };+return (<div className="h-screen w-screen flex flex-col bg-zinc-950 text-zinc-100 overflow-hidden font-sans">{/* Modern App Header */}@@ -585,6 +684,15 @@ export const App: React.FC = () => {}: undefined}+ isVmPaneOpen={isVmPaneOpen}+ onToggleVmPane={() => setIsVmPaneOpen((prev) => !prev)}+ activeUrl={activeUrl}+ pageTitle={pageTitle}+ screenshotBase64={screenshotBase64}+ isRunning={isVmRunning}+ terminalLogs={terminalLogs}+ onRefreshVm={handleRefreshVm}+ onRestartVm={handleRestartVm}/></div>diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsxindex e117d585..4519479b 100644--- a/frontend/src/components/ChatView.tsx+++ b/frontend/src/components/ChatView.tsx@@ -4,6 +4,7 @@ import { ModernAvatar } from './ModernAvatar';import { ModernApprovalCard, PendingApproval } from './ModernApprovalCard';import { MentionPopover, MentionItem } from './MentionPopover';import { MarkdownRenderer } from './MarkdownRenderer';+import { VirtualMachinePane, TerminalLogEntry } from './VirtualMachinePane';import { playSfx } from '../audio/chiptune';export interface ChatMessage {@@ -43,6 +44,16 @@ export interface ChatViewProps {workspacePath?: string;repoUrl?: string;onManageTeam?: () => void;+ // Grok-style Sandbox VM Pane props+ isVmPaneOpen?: boolean;+ onToggleVmPane?: () => void;+ activeUrl?: string;+ pageTitle?: string;+ screenshotBase64?: string | null;+ isRunning?: boolean;+ terminalLogs?: TerminalLogEntry[];+ onRefreshVm?: () => void;+ onRestartVm?: () => void;}export const renderFormattedText = (text: string): React.ReactNode => {@@ -82,7 +93,20 @@ export const ChatView: React.FC<ChatViewProps> = ({workspacePath,repoUrl,onManageTeam,+ isVmPaneOpen,+ onToggleVmPane,+ activeUrl,+ pageTitle,+ screenshotBase64,+ isRunning = true,+ terminalLogs = [],+ onRefreshVm,+ onRestartVm,}) => {+ const [internalIsVmPaneOpen, setInternalIsVmPaneOpen] = useState(false);+ const vmOpen = isVmPaneOpen !== undefined ? isVmPaneOpen : internalIsVmPaneOpen;+ const toggleVm = onToggleVmPane || (() => setInternalIsVmPaneOpen((prev) => !prev));+const [inputVal, setInputVal] = useState('');const [openThoughts, setOpenThoughts] = useState<Record<string, boolean>>({});const [copiedId, setCopiedId] = useState<string | null>(null);@@ -347,6 +371,24 @@ export const ChatView: React.FC<ChatViewProps> = ({<span>Stop</span></button>)}+ {/* Sandbox VM & Live Browser Toggle Button */}+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ toggleVm();+ }}+ className={`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors border shadow-sm cursor-pointer ${+ vmOpen+ ? 'text-sky-300 bg-sky-500/20 border-sky-500/40'+ : 'text-zinc-300 bg-zinc-900 hover:bg-zinc-800 border-zinc-700/60 hover:text-zinc-100'+ }`}+ title="Toggle Sandbox VM & Live Browser Pane"+ >+ <span className="text-xs">🖥️</span>+ <span>Sandbox VM</span>+ </button>+<div className="flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium text-sky-400 bg-sky-500/10 border border-sky-500/20 shadow-sm"><Cpu size={13} /><span>Laya Auto-Fleet</span>@@ -378,8 +420,11 @@ export const ChatView: React.FC<ChatViewProps> = ({</div>)}- {/* Messages Stream */}- <div ref={scrollRef} className="flex-1 overflow-y-auto p-6 space-y-6">+ {/* Main Split Layout: Messages/Input on Left + Virtual Machine Side Drawer on Right */}+ <div className="flex-1 flex overflow-hidden min-h-0">+ <div className="flex-1 flex flex-col h-full overflow-hidden min-w-0">+ {/* Messages Stream */}+ <div ref={scrollRef} className="flex-1 overflow-y-auto p-6 space-y-6">{messages.map((msg) => {const isUser = msg.sender_role === 'user';const isThoughtOpen = !!openThoughts[msg.id];@@ -627,5 +672,27 @@ export const ChatView: React.FC<ChatViewProps> = ({</form></div></div>++ {/* Live Grok-style Virtual Machine / Browser Side Pane */}+ <VirtualMachinePane+ isOpen={vmOpen}+ onClose={() => {+ if (onToggleVmPane) {+ onToggleVmPane();+ } else {+ setInternalIsVmPaneOpen(false);+ }+ }}+ teamName={teamName}+ activeUrl={activeUrl}+ pageTitle={pageTitle}+ screenshotBase64={screenshotBase64}+ isRunning={isRunning}+ terminalLogs={terminalLogs}+ onRefresh={onRefreshVm}+ onRestartVm={onRestartVm}+ />+ </div>+</div>);};diff --git a/frontend/src/components/VirtualMachinePane.tsx b/frontend/src/components/VirtualMachinePane.tsxnew file mode 100644index 00000000..7c10a970--- /dev/null+++ b/frontend/src/components/VirtualMachinePane.tsx@@ -0,0 +1,219 @@+import React, { useState } from 'react';+import { X, Globe, Terminal, RefreshCw, ExternalLink, Cpu } from 'lucide-react';+import { playSfx } from '../audio/chiptune';++export interface TerminalLogEntry {+ command: string;+ output: string;+ timestamp?: string;+}++export interface VirtualMachinePaneProps {+ isOpen: boolean;+ onClose: () => void;+ teamName?: string;+ activeUrl?: string;+ pageTitle?: string;+ screenshotBase64?: string | null;+ isRunning?: boolean;+ terminalLogs?: TerminalLogEntry[];+ onRefresh?: () => void;+ onRestartVm?: () => void;+}++export const VirtualMachinePane: React.FC<VirtualMachinePaneProps> = ({+ isOpen,+ onClose,+ teamName = 'Team',+ activeUrl = '',+ pageTitle = '',+ screenshotBase64,+ isRunning = true,+ terminalLogs = [],+ onRefresh,+ onRestartVm,+}) => {+ const [activeTab, setActiveTab] = useState<'browser' | 'terminal'>('browser');++ if (!isOpen) return null;++ return (+ <div className="w-96 border-l border-zinc-800 bg-zinc-950 flex flex-col h-full shadow-2xl z-30 select-none animate-in slide-in-from-right duration-200">+ {/* Top Header */}+ <div className="h-14 border-b border-zinc-800 px-4 flex items-center justify-between bg-zinc-900/60">+ <div className="flex items-center gap-2">+ <div className={`w-2.5 h-2.5 rounded-full ${isRunning ? 'bg-emerald-400 animate-pulse' : 'bg-zinc-500'}`} />+ <div>+ <div className="text-xs font-semibold text-zinc-100 flex items-center gap-1.5">+ <span>Sandbox VM</span>+ <span className="text-[10px] font-mono text-zinc-400">(@{teamName})</span>+ </div>+ <p className="text-[10px] text-zinc-400">Debian 12 • Chromium CDP</p>+ </div>+ </div>++ <div className="flex items-center gap-1">+ {onRefresh && (+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ onRefresh();+ }}+ title="Refresh Screenshot"+ className="p-1 rounded-md text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800 transition-colors cursor-pointer"+ >+ <RefreshCw size={13} />+ </button>+ )}+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ onClose();+ }}+ title="Close VM Pane"+ className="p-1 rounded-md text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800 transition-colors cursor-pointer"+ >+ <X size={15} />+ </button>+ </div>+ </div>++ {/* Tabs */}+ <div className="flex border-b border-zinc-800 bg-zinc-900/30 text-xs font-medium">+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ setActiveTab('browser');+ }}+ className={`flex-1 py-2 flex items-center justify-center gap-1.5 transition-colors border-b-2 cursor-pointer ${+ activeTab === 'browser'+ ? 'border-sky-500 text-sky-400 bg-sky-500/10'+ : 'border-transparent text-zinc-400 hover:text-zinc-200'+ }`}+ >+ <Globe size={13} />+ <span>Browser</span>+ </button>+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ setActiveTab('terminal');+ }}+ className={`flex-1 py-2 flex items-center justify-center gap-1.5 transition-colors border-b-2 cursor-pointer ${+ activeTab === 'terminal'+ ? 'border-sky-500 text-sky-400 bg-sky-500/10'+ : 'border-transparent text-zinc-400 hover:text-zinc-200'+ }`}+ >+ <Terminal size={13} />+ <span>Terminal Logs</span>+ </button>+ </div>++ {/* Content Area */}+ <div className="flex-1 overflow-hidden flex flex-col">+ {activeTab === 'browser' ? (+ <div className="flex-1 flex flex-col p-3 gap-2 overflow-hidden">+ {/* Browser Address Bar */}+ <div className="flex items-center gap-2 p-1.5 bg-zinc-900 border border-zinc-800 rounded-lg text-xs">+ <Globe size={13} className="text-zinc-400 flex-shrink-0" />+ <input+ type="text"+ readOnly+ value={activeUrl || 'about:blank'}+ className="flex-1 bg-transparent text-zinc-200 font-mono text-[11px] truncate focus:outline-none"+ />+ {activeUrl && activeUrl !== 'about:blank' && (+ <a+ href={activeUrl}+ target="_blank"+ rel="noopener noreferrer"+ className="text-zinc-400 hover:text-sky-400 p-0.5"+ title="Open in new window"+ >+ <ExternalLink size={12} />+ </a>+ )}+ </div>++ {pageTitle && (+ <div className="text-[11px] text-zinc-400 truncate px-1 font-medium">+ {pageTitle}+ </div>+ )}++ {/* Viewport Frame */}+ <div className="flex-1 border border-zinc-800 rounded-xl bg-zinc-950 overflow-hidden flex items-center justify-center relative shadow-inner">+ {screenshotBase64 ? (+ <img+ src={+ screenshotBase64.startsWith('data:')+ ? screenshotBase64+ : `data:image/jpeg;base64,${screenshotBase64}`+ }+ alt="Browser Viewport"+ className="w-full h-full object-contain"+ />+ ) : (+ <div className="text-center p-6 text-zinc-600 text-xs">+ <Globe size={32} className="mx-auto mb-2 opacity-40 text-zinc-500" />+ <p>Browser idle</p>+ <p className="text-[10px] text-zinc-500 mt-1">Bot will navigate here when needed</p>+ </div>+ )}+ </div>+ </div>+ ) : (+ /* Terminal Tab */+ <div className="flex-1 p-3 overflow-y-auto font-mono text-xs text-zinc-300 space-y-2 bg-zinc-950">+ {terminalLogs.length === 0 ? (+ <div className="text-center text-zinc-600 text-xs py-8">+ <Terminal size={24} className="mx-auto mb-1 opacity-40" />+ <span>No commands executed in container yet</span>+ </div>+ ) : (+ terminalLogs.map((log, index) => (+ <div key={index} className="p-2 bg-zinc-900/60 border border-zinc-800/80 rounded-lg">+ <div className="flex items-center justify-between text-sky-400 font-semibold text-[11px]">+ <span>$ {log.command}</span>+ {log.timestamp && (+ <span className="text-[9px] text-zinc-500 font-normal">+ {log.timestamp.includes('T') ? log.timestamp.split('T')[1].split('.')[0] : log.timestamp}+ </span>+ )}+ </div>+ <pre className="text-[10px] text-zinc-300 mt-1 whitespace-pre-wrap font-mono leading-relaxed">{log.output}</pre>+ </div>+ ))+ )}+ </div>+ )}+ </div>++ {/* Footer Status */}+ <div className="p-2.5 border-t border-zinc-800 bg-zinc-900/60 flex items-center justify-between text-[11px] text-zinc-400">+ <div className="flex items-center gap-1.5">+ <Cpu size={12} className={isRunning ? 'text-emerald-400' : 'text-zinc-500'} />+ <span>{isRunning ? 'Container Active' : 'Container Inactive'}</span>+ </div>+ {onRestartVm && (+ <button+ type="button"+ onClick={() => {+ playSfx('click');+ onRestartVm();+ }}+ className="hover:text-zinc-200 text-zinc-400 flex items-center gap-1 transition-colors cursor-pointer"+ >+ <RefreshCw size={11} />+ <span>Restart VM</span>+ </button>+ )}+ </div>+ </div>+ );+};