Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
refactor(playground): split large files for agent-friendly codebase (#1104)
Sarina Lid5d86f5f45f0
diff --git a/libs/typescript/playground/src/components/Playground.tsx b/libs/typescript/playground/src/components/Playground.tsxindex 33d418b182..458cfede34 100644--- a/libs/typescript/playground/src/components/Playground.tsx+++ b/libs/typescript/playground/src/components/Playground.tsx@@ -10,7 +10,7 @@ import { ChatList } from './composed/ChatList';import { ComputerList } from './composed/ComputerList';import { EmptyStateWithInput } from './composed/EmptyState';import { VNCViewer } from './primitives/VNCViewer';-import { AddSandboxModal } from './modals/CustomComputerModal';+import { AddSandboxModal } from './modals/AddSandboxModal';import type { PlaygroundAdapters } from '../adapters/types';import type { Chat } from '../types';import { cn } from '../utils/cn';diff --git a/libs/typescript/playground/src/components/composed/ChatContent.tsx b/libs/typescript/playground/src/components/composed/ChatContent.tsxindex 33487e8942..aec4426f6c 100644--- a/libs/typescript/playground/src/components/composed/ChatContent.tsx+++ b/libs/typescript/playground/src/components/composed/ChatContent.tsx@@ -2,7 +2,7 @@// Adapted from cloud/src/website/app/components/playground/ChatContent.tsximport { motion } from 'motion/react';-import { useEffect, useMemo, useRef } from 'react';+import { useEffect, useRef } from 'react';import { ChatArea } from './ChatArea';import { ChatInput } from '../primitives/ChatInput';import { ExamplePrompts, type ExamplePrompt } from './ExamplePrompts';@@ -13,8 +13,9 @@ import {useIsChatGenerating,} from '../../hooks/usePlayground';import { useAgentRequest } from '../../hooks/useAgentRequest';+import { useComputerMapping } from '../../hooks/useComputerMapping';+import { useSelectedComputer } from '../../hooks/useSelectedComputer';import type { Computer, VM } from '../../types';-import { getComputerId } from '../../types';import { cn } from '../../utils/cn';interface ChatContentProps {@@ -116,25 +117,15 @@ export function ChatContent({const hasMessages = processedMessages.length > 0;// Convert ComputerInfo[] to Computer[] for ChatInput- const computers: Computer[] = state.computers.map((c) => {- const { agentUrl, ...rest } = c;- return {- ...rest,- url: agentUrl,- } as Computer;- });+ const computers = useComputerMapping(state.computers);// Determine selected computer: prefer currentComputerId from playground state, fallback to chat's computer// This ensures the Select stays in sync with the VNC viewer- const selectedComputerForInput = useMemo(() => {- if (state.currentComputerId) {- const currentComputer = computers.find((c) => getComputerId(c) === state.currentComputerId);- if (currentComputer) {- return currentComputer;- }- }- return computer;- }, [state.currentComputerId, computers, computer]);+ const selectedComputerForInput = useSelectedComputer(+ state.currentComputerId,+ computers,+ computer+ );// Handle model changeconst handleModelChange = (modelId: string) => {diff --git a/libs/typescript/playground/src/components/composed/PlaygroundContent.tsx b/libs/typescript/playground/src/components/composed/PlaygroundContent.tsxindex ecbd8334d4..21b4a3e822 100644--- a/libs/typescript/playground/src/components/composed/PlaygroundContent.tsx+++ b/libs/typescript/playground/src/components/composed/PlaygroundContent.tsx@@ -13,7 +13,7 @@ import {usePlayground,} from '../../hooks/usePlayground';import type { Chat, Computer } from '../../types';-import { AddSandboxModal } from '../modals/CustomComputerModal';+import { AddSandboxModal } from '../modals/AddSandboxModal';// Re-export for convenienceexport { EmptyStateWithInput } from './EmptyState';diff --git a/libs/typescript/playground/src/components/modals/AddSandboxModal.tsx b/libs/typescript/playground/src/components/modals/AddSandboxModal.tsxnew file mode 100644index 0000000000..5fee3653d0--- /dev/null+++ b/libs/typescript/playground/src/components/modals/AddSandboxModal.tsx@@ -0,0 +1,297 @@+// Add Sandbox wizard modal+// Supports three paths: Local Docker, Cloud Sandbox, Custom URL+//+// Sub-components live in sibling files:+// SourcePicker.tsx - Step 1: choose source+// PresetGrid.tsx - Step 2a: choose Docker preset+// LocalDockerForm.tsx - Step 2b: configure local Docker+// CustomUrlForm.tsx - Step 2c: configure custom URL++import { useState, useCallback } from 'react';+import { ArrowLeft } from 'lucide-react';+import { usePlayground } from '../../hooks/usePlayground';+import type { ComputerInfo } from '../../adapters/types';+import { cn } from '../../utils/cn';+import { Modal } from '../ui/Modal';+import type { SandboxPreset } from '../../constants/sandboxPresets';++import { SourcePicker, type SandboxSource } from './SourcePicker';+import { PresetGrid } from './PresetGrid';+import { LocalDockerForm } from './LocalDockerForm';+import { CustomUrlForm } from './CustomUrlForm';++type WizardStep = 'source' | 'configure';++export interface AddSandboxModalProps {+ isOpen: boolean;+ onClose: () => void;+ onAdd?: (computer: ComputerInfo) => void;+ /** Render prop for cloud VM creation wizard. Injected by cloud website. */+ renderCloudCreate?: (props: { onCreated: () => void; onCancel: () => void }) => React.ReactNode;+ className?: string;+}++// Backward-compatible alias+export type CustomComputerModalProps = AddSandboxModalProps;++export function AddSandboxModal({+ isOpen,+ onClose,+ onAdd,+ renderCloudCreate,+ className,+}: AddSandboxModalProps) {+ const { adapters, dispatch } = usePlayground();++ const [step, setStep] = useState<WizardStep>('source');+ const [source, setSource] = useState<SandboxSource | null>(null);+ const [selectedPreset, setSelectedPreset] = useState<SandboxPreset | null>(null);++ // Local Docker form state+ const [localName, setLocalName] = useState('');+ const [localHost, setLocalHost] = useState('localhost');++ // Custom URL form state+ const [customName, setCustomName] = useState('');+ const [customAgentUrl, setCustomAgentUrl] = useState('');+ const [customVncUrl, setCustomVncUrl] = useState('');++ // Shared state+ const [isLoading, setIsLoading] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const [testStatus, setTestStatus] = useState<'idle' | 'testing' | 'success' | 'error'>('idle');+ const [copiedCommand, setCopiedCommand] = useState(false);++ const resetState = useCallback(() => {+ setStep('source');+ setSource(null);+ setSelectedPreset(null);+ setLocalName('');+ setLocalHost('localhost');+ setCustomName('');+ setCustomAgentUrl('');+ setCustomVncUrl('');+ setError(null);+ setTestStatus('idle');+ setIsLoading(false);+ setCopiedCommand(false);+ }, []);++ const handleClose = useCallback(() => {+ resetState();+ onClose();+ }, [onClose, resetState]);++ const handleSelectSource = useCallback((s: SandboxSource) => {+ setSource(s);+ setStep('configure');+ setError(null);+ setTestStatus('idle');+ }, []);++ const handleBack = useCallback(() => {+ if (step === 'configure' && source === 'local' && selectedPreset) {+ setSelectedPreset(null);+ setError(null);+ setTestStatus('idle');+ return;+ }+ setStep('source');+ setSource(null);+ setSelectedPreset(null);+ setError(null);+ setTestStatus('idle');+ }, [step, source, selectedPreset]);++ const handleSelectPreset = useCallback((preset: SandboxPreset) => {+ setSelectedPreset(preset);+ setLocalName(preset.name);+ setError(null);+ setTestStatus('idle');+ }, []);++ const handleCopyCommand = useCallback((command: string) => {+ navigator.clipboard.writeText(command).then(() => {+ setCopiedCommand(true);+ setTimeout(() => setCopiedCommand(false), 2000);+ });+ }, []);++ const buildAgentUrl = useCallback((preset: SandboxPreset, host: string) => {+ return `http://${host}:${preset.apiPort}`;+ }, []);++ const buildVncUrl = useCallback((preset: SandboxPreset, host: string) => {+ const base = `http://${host}:${preset.vncPort}`;+ return preset.vncPath ? `${base}${preset.vncPath}` : base;+ }, []);++ const handleTestConnection = useCallback(async (agentUrl: string) => {+ setTestStatus('testing');+ setError(null);+ try {+ const response = await fetch(`${agentUrl}/health`, {+ signal: AbortSignal.timeout(5000),+ });+ if (response.ok) {+ setTestStatus('success');+ } else {+ setTestStatus('error');+ setError(`Health check returned ${response.status}`);+ }+ } catch {+ setTestStatus('error');+ setError('Could not connect. Make sure the container is running.');+ }+ }, []);++ const handleAddComputer = useCallback(+ async (name: string, agentUrl: string, vncUrl: string) => {+ setError(null);++ if (!name.trim()) {+ setError('Please enter a name');+ return;+ }++ try {+ new URL(agentUrl);+ } catch {+ setError('Invalid agent URL');+ return;+ }++ setIsLoading(true);++ try {+ if (adapters.computer.addCustomComputer) {+ const newComputer = await adapters.computer.addCustomComputer({+ name: name.trim(),+ vncUrl,+ agentUrl,+ status: 'running',+ isCustom: true,+ });++ const computers = await adapters.computer.listComputers();+ dispatch({ type: 'SET_COMPUTERS', payload: computers });++ onAdd?.(newComputer);+ handleClose();+ } else {+ setError('Adding custom computers is not supported');+ }+ } catch (err) {+ setError(err instanceof Error ? err.message : 'Failed to add computer');+ } finally {+ setIsLoading(false);+ }+ },+ [adapters, dispatch, onAdd, handleClose]+ );++ const handleCloudCreated = useCallback(async () => {+ try {+ const computers = await adapters.computer.listComputers();+ dispatch({ type: 'SET_COMPUTERS', payload: computers });+ } catch (err) {+ console.error('Failed to refresh computers after cloud creation:', err);+ }+ handleClose();+ }, [adapters, dispatch, handleClose]);++ const showBackButton = step === 'configure';++ const title = (() => {+ if (step === 'source') return 'Add Sandbox';+ if (source === 'local' && !selectedPreset) return 'Choose Sandbox Type';+ if (source === 'local' && selectedPreset) return selectedPreset.name;+ if (source === 'cloud') return 'Create Cloud Sandbox';+ if (source === 'custom') return 'Custom URL';+ return 'Add Sandbox';+ })();++ return (+ <Modal+ isOpen={isOpen}+ onClose={handleClose}+ showCloseButton={!showBackButton}+ contentClassName={cn(+ 'max-w-lg p-0',+ step === 'configure' && source === 'cloud' && 'max-w-2xl',+ className+ )}+ >+ {/* Header */}+ <div className="flex items-center gap-3 border-b border-neutral-200 px-6 py-4 dark:border-neutral-700">+ {showBackButton && (+ <button+ type="button"+ onClick={handleBack}+ className="rounded-md p-1 hover:bg-neutral-100 dark:hover:bg-neutral-700"+ >+ <ArrowLeft className="h-4 w-4 text-neutral-600 dark:text-neutral-400" />+ </button>+ )}+ <h2 className="flex-1 text-lg font-semibold text-neutral-900 dark:text-white">{title}</h2>+ </div>++ {/* Content */}+ <div className="overflow-y-auto px-6 py-4" style={{ maxHeight: '70vh' }}>+ {step === 'source' && (+ <SourcePicker onSelect={handleSelectSource} hasCloud={!!renderCloudCreate} />+ )}++ {step === 'configure' && source === 'local' && !selectedPreset && (+ <PresetGrid onSelect={handleSelectPreset} />+ )}++ {step === 'configure' && source === 'local' && selectedPreset && (+ <LocalDockerForm+ preset={selectedPreset}+ name={localName}+ onNameChange={setLocalName}+ host={localHost}+ onHostChange={setLocalHost}+ onCopyCommand={handleCopyCommand}+ copiedCommand={copiedCommand}+ testStatus={testStatus}+ onTestConnection={() => handleTestConnection(buildAgentUrl(selectedPreset, localHost))}+ onAdd={() =>+ handleAddComputer(+ localName,+ buildAgentUrl(selectedPreset, localHost),+ buildVncUrl(selectedPreset, localHost)+ )+ }+ isLoading={isLoading}+ error={error}+ />+ )}++ {step === 'configure' && source === 'cloud' && renderCloudCreate && (+ <div>{renderCloudCreate({ onCreated: handleCloudCreated, onCancel: handleClose })}</div>+ )}++ {step === 'configure' && source === 'custom' && (+ <CustomUrlForm+ name={customName}+ onNameChange={setCustomName}+ agentUrl={customAgentUrl}+ onAgentUrlChange={setCustomAgentUrl}+ vncUrl={customVncUrl}+ onVncUrlChange={setCustomVncUrl}+ testStatus={testStatus}+ onTestConnection={() => handleTestConnection(customAgentUrl)}+ onAdd={() => handleAddComputer(customName, customAgentUrl, customVncUrl)}+ isLoading={isLoading}+ error={error}+ />+ )}+ </div>+ </Modal>+ );+}++// Backward-compatible export+export const CustomComputerModal = AddSandboxModal;diff --git a/libs/typescript/playground/src/components/modals/CustomComputerModal.tsx b/libs/typescript/playground/src/components/modals/CustomComputerModal.tsxdeleted file mode 100644index 24a57f46f9..0000000000--- a/libs/typescript/playground/src/components/modals/CustomComputerModal.tsx+++ /dev/null@@ -1,673 +0,0 @@-// Add Sandbox wizard modal-// Supports three paths: Local Docker, Cloud Sandbox, Custom URL--import { useState, useCallback } from 'react';-import {- ArrowLeft,- Check,- ChevronRight,- Copy,- Globe,- Loader2,- Monitor,- Server,-} from 'lucide-react';-import { usePlayground } from '../../hooks/usePlayground';-import type { ComputerInfo } from '../../adapters/types';-import { cn } from '../../utils/cn';-import { Modal } from '../ui/Modal';-import { SANDBOX_PRESETS, MACOS_PRESET, type SandboxPreset } from '../../constants/sandboxPresets';--type SandboxSource = 'local' | 'cloud' | 'custom';-type WizardStep = 'source' | 'configure';--export interface AddSandboxModalProps {- isOpen: boolean;- onClose: () => void;- onAdd?: (computer: ComputerInfo) => void;- /** Render prop for cloud VM creation wizard. Injected by cloud website. */- renderCloudCreate?: (props: { onCreated: () => void; onCancel: () => void }) => React.ReactNode;- className?: string;-}--// Backward-compatible alias-export type CustomComputerModalProps = AddSandboxModalProps;--export function AddSandboxModal({- isOpen,- onClose,- onAdd,- renderCloudCreate,- className,-}: AddSandboxModalProps) {- const { adapters, dispatch } = usePlayground();-- const [step, setStep] = useState<WizardStep>('source');- const [source, setSource] = useState<SandboxSource | null>(null);- const [selectedPreset, setSelectedPreset] = useState<SandboxPreset | null>(null);-- // Local Docker form state- const [localName, setLocalName] = useState('');- const [localHost, setLocalHost] = useState('localhost');-- // Custom URL form state- const [customName, setCustomName] = useState('');- const [customAgentUrl, setCustomAgentUrl] = useState('');- const [customVncUrl, setCustomVncUrl] = useState('');-- // Shared state- const [isLoading, setIsLoading] = useState(false);- const [error, setError] = useState<string | null>(null);- const [testStatus, setTestStatus] = useState<'idle' | 'testing' | 'success' | 'error'>('idle');- const [copiedCommand, setCopiedCommand] = useState(false);-- const resetState = useCallback(() => {- setStep('source');- setSource(null);- setSelectedPreset(null);- setLocalName('');- setLocalHost('localhost');- setCustomName('');- setCustomAgentUrl('');- setCustomVncUrl('');- setError(null);- setTestStatus('idle');- setIsLoading(false);- setCopiedCommand(false);- }, []);-- const handleClose = useCallback(() => {- resetState();- onClose();- }, [onClose, resetState]);-- const handleSelectSource = useCallback((s: SandboxSource) => {- setSource(s);- setStep('configure');- setError(null);- setTestStatus('idle');- }, []);-- const handleBack = useCallback(() => {- if (step === 'configure' && source === 'local' && selectedPreset) {- setSelectedPreset(null);- setError(null);- setTestStatus('idle');- return;- }- setStep('source');- setSource(null);- setSelectedPreset(null);- setError(null);- setTestStatus('idle');- }, [step, source, selectedPreset]);-- const handleSelectPreset = useCallback((preset: SandboxPreset) => {- setSelectedPreset(preset);- setLocalName(preset.name);- setError(null);- setTestStatus('idle');- }, []);-- const handleCopyCommand = useCallback((command: string) => {- navigator.clipboard.writeText(command).then(() => {- setCopiedCommand(true);- setTimeout(() => setCopiedCommand(false), 2000);- });- }, []);-- const buildAgentUrl = useCallback((preset: SandboxPreset, host: string) => {- return `http://${host}:${preset.apiPort}`;- }, []);-- const buildVncUrl = useCallback((preset: SandboxPreset, host: string) => {- const base = `http://${host}:${preset.vncPort}`;- return preset.vncPath ? `${base}${preset.vncPath}` : base;- }, []);-- const handleTestConnection = useCallback(async (agentUrl: string) => {- setTestStatus('testing');- setError(null);- try {- const response = await fetch(`${agentUrl}/health`, {- signal: AbortSignal.timeout(5000),- });- if (response.ok) {- setTestStatus('success');- } else {- setTestStatus('error');- setError(`Health check returned ${response.status}`);- }- } catch {- setTestStatus('error');- setError('Could not connect. Make sure the container is running.');- }- }, []);-- const handleAddComputer = useCallback(- async (name: string, agentUrl: string, vncUrl: string) => {- setError(null);-- if (!name.trim()) {- setError('Please enter a name');- return;- }-- try {- new URL(agentUrl);- } catch {- setError('Invalid agent URL');- return;- }-- setIsLoading(true);-- try {- if (adapters.computer.addCustomComputer) {- const newComputer = await adapters.computer.addCustomComputer({- name: name.trim(),- vncUrl,- agentUrl,- status: 'running',- isCustom: true,- });-- const computers = await adapters.computer.listComputers();- dispatch({ type: 'SET_COMPUTERS', payload: computers });-- onAdd?.(newComputer);- handleClose();- } else {- setError('Adding custom computers is not supported');- }- } catch (err) {- setError(err instanceof Error ? err.message : 'Failed to add computer');- } finally {- setIsLoading(false);- }- },- [adapters, dispatch, onAdd, handleClose]- );-- const handleCloudCreated = useCallback(async () => {- try {- const computers = await adapters.computer.listComputers();- dispatch({ type: 'SET_COMPUTERS', payload: computers });- } catch (err) {- console.error('Failed to refresh computers after cloud creation:', err);- }- handleClose();- }, [adapters, dispatch, handleClose]);-- const showBackButton = step === 'configure';-- const title = (() => {- if (step === 'source') return 'Add Sandbox';- if (source === 'local' && !selectedPreset) return 'Choose Sandbox Type';- if (source === 'local' && selectedPreset) return selectedPreset.name;- if (source === 'cloud') return 'Create Cloud Sandbox';- if (source === 'custom') return 'Custom URL';- return 'Add Sandbox';- })();-- return (- <Modal- isOpen={isOpen}- onClose={handleClose}- showCloseButton={!showBackButton}- contentClassName={cn(- 'max-w-lg p-0',- step === 'configure' && source === 'cloud' && 'max-w-2xl',- className- )}- >- {/* Header */}- <div className="flex items-center gap-3 border-b border-neutral-200 px-6 py-4 dark:border-neutral-700">- {showBackButton && (- <button- type="button"- onClick={handleBack}- className="rounded-md p-1 hover:bg-neutral-100 dark:hover:bg-neutral-700"- >- <ArrowLeft className="h-4 w-4 text-neutral-600 dark:text-neutral-400" />- </button>- )}- <h2 className="flex-1 text-lg font-semibold text-neutral-900 dark:text-white">{title}</h2>- </div>-- {/* Content */}- <div className="overflow-y-auto px-6 py-4" style={{ maxHeight: '70vh' }}>- {step === 'source' && (- <SourceStep onSelect={handleSelectSource} hasCloud={!!renderCloudCreate} />- )}-- {step === 'configure' && source === 'local' && !selectedPreset && (- <PresetGrid onSelect={handleSelectPreset} />- )}-- {step === 'configure' && source === 'local' && selectedPreset && (- <LocalDockerForm- preset={selectedPreset}- name={localName}- onNameChange={setLocalName}- host={localHost}- onHostChange={setLocalHost}- onCopyCommand={handleCopyCommand}- copiedCommand={copiedCommand}- testStatus={testStatus}- onTestConnection={() => handleTestConnection(buildAgentUrl(selectedPreset, localHost))}- onAdd={() =>- handleAddComputer(- localName,- buildAgentUrl(selectedPreset, localHost),- buildVncUrl(selectedPreset, localHost)- )- }- isLoading={isLoading}- error={error}- />- )}-- {step === 'configure' && source === 'cloud' && renderCloudCreate && (- <div>{renderCloudCreate({ onCreated: handleCloudCreated, onCancel: handleClose })}</div>- )}-- {step === 'configure' && source === 'custom' && (- <CustomUrlForm- name={customName}- onNameChange={setCustomName}- agentUrl={customAgentUrl}- onAgentUrlChange={setCustomAgentUrl}- vncUrl={customVncUrl}- onVncUrlChange={setCustomVncUrl}- testStatus={testStatus}- onTestConnection={() => handleTestConnection(customAgentUrl)}- onAdd={() => handleAddComputer(customName, customAgentUrl, customVncUrl)}- isLoading={isLoading}- error={error}- />- )}- </div>- </Modal>- );-}--// Backward-compatible export-export const CustomComputerModal = AddSandboxModal;--// ----------------------------------------------------------------------------// Step 1: Source selection-// -----------------------------------------------------------------------------function SourceStep({- onSelect,- hasCloud,-}: {- onSelect: (source: SandboxSource) => void;- hasCloud: boolean;-}) {- const cards: Array<{- source: SandboxSource;- icon: React.ReactNode;- title: string;- description: string;- hidden?: boolean;- }> = [- {- source: 'local',- icon: <Monitor className="h-6 w-6" />,- title: 'Local (Docker)',- description: 'Run a sandbox on your machine using Docker',- },- {- source: 'cloud',- icon: <Server className="h-6 w-6" />,- title: 'Cloud Sandbox',- description: 'Provision a cloud VM',- hidden: !hasCloud,- },- {- source: 'custom',- icon: <Globe className="h-6 w-6" />,- title: 'Custom URL',- description: 'Connect to any computer-server endpoint',- },- ];-- return (- <div className="flex flex-col gap-3">- {cards- .filter((c) => !c.hidden)- .map((card) => (- <button- key={card.source}- type="button"- onClick={() => onSelect(card.source)}- className="flex items-center gap-4 rounded-lg border border-neutral-200 p-4 text-left transition-colors hover:border-blue-400 hover:bg-blue-50/50 dark:border-neutral-600 dark:hover:border-blue-500 dark:hover:bg-blue-950/20"- >- <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-neutral-100 text-neutral-600 dark:bg-neutral-700 dark:text-neutral-300">- {card.icon}- </div>- <div className="flex-1">- <p className="font-medium text-neutral-900 dark:text-white">{card.title}</p>- <p className="text-sm text-neutral-500 dark:text-neutral-400">{card.description}</p>- </div>- <ChevronRight className="h-5 w-5 text-neutral-400" />- </button>- ))}- </div>- );-}--// ----------------------------------------------------------------------------// Step 2a: Preset grid for local Docker-// -----------------------------------------------------------------------------const ICON_MAP: Record<SandboxPreset['icon'], string> = {- linux: '\u{1F427}',- windows: '\u{1FA9F}',- android: '\u{1F4F1}',- macos: '\u{1F34E}',-};--function PresetGrid({ onSelect }: { onSelect: (preset: SandboxPreset) => void }) {- return (- <div className="flex flex-col gap-3">- {SANDBOX_PRESETS.map((preset) => (- <button- key={preset.id}- type="button"- onClick={() => onSelect(preset)}- className="flex items-center gap-4 rounded-lg border border-neutral-200 p-4 text-left transition-colors hover:border-blue-400 hover:bg-blue-50/50 dark:border-neutral-600 dark:hover:border-blue-500 dark:hover:bg-blue-950/20"- >- <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-neutral-100 text-xl dark:bg-neutral-700">- {ICON_MAP[preset.icon]}- </div>- <div className="flex-1">- <p className="font-medium text-neutral-900 dark:text-white">{preset.name}</p>- <p className="text-sm text-neutral-500 dark:text-neutral-400">{preset.description}</p>- </div>- <ChevronRight className="h-5 w-5 text-neutral-400" />- </button>- ))}-- {/* macOS informational card */}- <div className="flex items-center gap-4 rounded-lg border border-dashed border-neutral-300 p-4 dark:border-neutral-600">- <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-neutral-100 text-xl dark:bg-neutral-700">- {ICON_MAP.macos}- </div>- <div className="flex-1">- <p className="font-medium text-neutral-900 dark:text-white">{MACOS_PRESET.name}</p>- <p className="text-sm text-neutral-500 dark:text-neutral-400">{MACOS_PRESET.note}</p>- </div>- </div>- </div>- );-}--// ----------------------------------------------------------------------------// Step 2b: Local Docker configuration form-// -----------------------------------------------------------------------------function LocalDockerForm({- preset,- name,- onNameChange,- host,- onHostChange,- onCopyCommand,- copiedCommand,- testStatus,- onTestConnection,- onAdd,- isLoading,- error,-}: {- preset: SandboxPreset;- name: string;- onNameChange: (v: string) => void;- host: string;- onHostChange: (v: string) => void;- onCopyCommand: (cmd: string) => void;- copiedCommand: boolean;- testStatus: 'idle' | 'testing' | 'success' | 'error';- onTestConnection: () => void;- onAdd: () => void;- isLoading: boolean;- error: string | null;-}) {- return (- <div className="flex flex-col gap-4">- {/* Docker command */}- <div>- <label className="mb-1.5 block text-sm font-medium text-neutral-700 dark:text-neutral-300">- 1. Run this Docker command- </label>- <div className="group relative">- <pre className="overflow-x-auto rounded-md bg-neutral-900 p-3 text-xs text-green-400">- <code>{preset.dockerCommand}</code>- </pre>- <button- type="button"- onClick={() => onCopyCommand(preset.dockerCommand)}- className="absolute right-2 top-2 rounded-md bg-neutral-700 p-1.5 text-neutral-300 opacity-0 transition-opacity hover:bg-neutral-600 group-hover:opacity-100"- title="Copy command"- >- {copiedCommand ? <Check className="h-3.5 w-3.5" /> : <Copy className="h-3.5 w-3.5" />}- </button>- </div>- <p className="mt-1 text-xs text-neutral-500 dark:text-neutral-400">- Prerequisites: {preset.prerequisites}- </p>- </div>-- {/* Name */}- <div>- <label- htmlFor="local-name"- className="mb-1.5 block text-sm font-medium text-neutral-700 dark:text-neutral-300"- >- 2. Configure connection- </label>- <div className="flex flex-col gap-3">- <div>- <label- htmlFor="local-sandbox-name"- className="mb-1 block text-xs text-neutral-500 dark:text-neutral-400"- >- Name- </label>- <input- id="local-sandbox-name"- type="text"- value={name}- onChange={(e) => onNameChange(e.target.value)}- className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-700 dark:text-white"- disabled={isLoading}- />- </div>- <div>- <label- htmlFor="local-sandbox-host"- className="mb-1 block text-xs text-neutral-500 dark:text-neutral-400"- >- Host- </label>- <input- id="local-sandbox-host"- type="text"- value={host}- onChange={(e) => onHostChange(e.target.value)}- placeholder="localhost"- className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-700 dark:text-white"- disabled={isLoading}- />- </div>- </div>- <p className="mt-2 text-xs text-neutral-500 dark:text-neutral-400">- Agent URL:{' '}- <code className="text-neutral-700 dark:text-neutral-300">- http://{host}:{preset.apiPort}- </code>- {' | '}- VNC URL:{' '}- <code className="text-neutral-700 dark:text-neutral-300">- http://{host}:{preset.vncPort}- {preset.vncPath}- </code>- </p>- </div>-- {error && <p className="text-sm text-red-600 dark:text-red-400">{error}</p>}-- {/* Actions */}- <div className="flex items-center justify-end gap-3 border-t border-neutral-200 pt-4 dark:border-neutral-700">- <TestConnectionButton status={testStatus} onClick={onTestConnection} />- <button- type="button"- onClick={onAdd}- disabled={isLoading}- className="rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50"- >- {isLoading ? 'Adding...' : 'Add'}- </button>- </div>- </div>- );-}--// ----------------------------------------------------------------------------// Step 2c: Custom URL form-// -----------------------------------------------------------------------------function CustomUrlForm({- name,- onNameChange,- agentUrl,- onAgentUrlChange,- vncUrl,- onVncUrlChange,- testStatus,- onTestConnection,- onAdd,- isLoading,- error,-}: {- name: string;- onNameChange: (v: string) => void;- agentUrl: string;- onAgentUrlChange: (v: string) => void;- vncUrl: string;- onVncUrlChange: (v: string) => void;- testStatus: 'idle' | 'testing' | 'success' | 'error';- onTestConnection: () => void;- onAdd: () => void;- isLoading: boolean;- error: string | null;-}) {- return (- <div className="flex flex-col gap-4">- <div>- <label- htmlFor="custom-name"- className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300"- >- Name- </label>- <input- id="custom-name"- type="text"- value={name}- onChange={(e) => onNameChange(e.target.value)}- placeholder="My Computer"- className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-700 dark:text-white"- disabled={isLoading}- />- </div>-- <div>- <label- htmlFor="custom-agent-url"- className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300"- >- Agent URL- </label>- <input- id="custom-agent-url"- type="text"- value={agentUrl}- onChange={(e) => onAgentUrlChange(e.target.value)}- placeholder="http://localhost:8000"- className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-700 dark:text-white"- disabled={isLoading}- />- </div>-- <div>- <label- htmlFor="custom-vnc-url"- className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300"- >- VNC URL- </label>- <input- id="custom-vnc-url"- type="text"- value={vncUrl}- onChange={(e) => onVncUrlChange(e.target.value)}- placeholder="http://localhost:6901/vnc.html"- className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-700 dark:text-white"- disabled={isLoading}- />- </div>-- {error && <p className="text-sm text-red-600 dark:text-red-400">{error}</p>}-- <div className="flex items-center justify-end gap-3 border-t border-neutral-200 pt-4 dark:border-neutral-700">- <TestConnectionButton status={testStatus} onClick={onTestConnection} disabled={!agentUrl} />- <button- type="button"- onClick={onAdd}- disabled={isLoading}- className="rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50"- >- {isLoading ? 'Adding...' : 'Add'}- </button>- </div>- </div>- );-}--// ----------------------------------------------------------------------------// Test connection button-// -----------------------------------------------------------------------------function TestConnectionButton({- status,- onClick,- disabled,-}: {- status: 'idle' | 'testing' | 'success' | 'error';- onClick: () => void;- disabled?: boolean;-}) {- return (- <button- type="button"- onClick={onClick}- disabled={disabled || status === 'testing'}- className={cn(- 'flex items-center gap-2 rounded-md border px-4 py-2 text-sm font-medium transition-colors disabled:opacity-50',- status === 'success'- ? 'border-green-300 text-green-700 dark:border-green-700 dark:text-green-400'- : status === 'error'- ? 'border-red-300 text-red-700 dark:border-red-700 dark:text-red-400'- : 'border-neutral-300 text-neutral-700 hover:bg-neutral-50 dark:border-neutral-600 dark:text-neutral-300 dark:hover:bg-neutral-700'- )}- >- {status === 'testing' && <Loader2 className="h-3.5 w-3.5 animate-spin" />}- {status === 'success' && <Check className="h-3.5 w-3.5" />}- {status === 'testing' ? 'Testing...' : status === 'success' ? 'Connected' : 'Test Connection'}- </button>- );-}diff --git a/libs/typescript/playground/src/components/modals/CustomUrlForm.tsx b/libs/typescript/playground/src/components/modals/CustomUrlForm.tsxnew file mode 100644index 0000000000..79153b2834--- /dev/null+++ b/libs/typescript/playground/src/components/modals/CustomUrlForm.tsx@@ -0,0 +1,104 @@+// Step 2c: Custom URL form+// Simple form with name, agent URL, VNC URL fields, test connection, and add button.++import { TestConnectionButton, type TestStatus } from './TestConnectionButton';++export interface CustomUrlFormProps {+ name: string;+ onNameChange: (v: string) => void;+ agentUrl: string;+ onAgentUrlChange: (v: string) => void;+ vncUrl: string;+ onVncUrlChange: (v: string) => void;+ testStatus: TestStatus;+ onTestConnection: () => void;+ onAdd: () => void;+ isLoading: boolean;+ error: string | null;+}++export function CustomUrlForm({+ name,+ onNameChange,+ agentUrl,+ onAgentUrlChange,+ vncUrl,+ onVncUrlChange,+ testStatus,+ onTestConnection,+ onAdd,+ isLoading,+ error,+}: CustomUrlFormProps) {+ return (+ <div className="flex flex-col gap-4">+ <div>+ <label+ htmlFor="custom-name"+ className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300"+ >+ Name+ </label>+ <input+ id="custom-name"+ type="text"+ value={name}+ onChange={(e) => onNameChange(e.target.value)}+ placeholder="My Computer"+ className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-700 dark:text-white"+ disabled={isLoading}+ />+ </div>++ <div>+ <label+ htmlFor="custom-agent-url"+ className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300"+ >+ Agent URL+ </label>+ <input+ id="custom-agent-url"+ type="text"+ value={agentUrl}+ onChange={(e) => onAgentUrlChange(e.target.value)}+ placeholder="http://localhost:8000"+ className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-700 dark:text-white"+ disabled={isLoading}+ />+ </div>++ <div>+ <label+ htmlFor="custom-vnc-url"+ className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300"+ >+ VNC URL+ </label>+ <input+ id="custom-vnc-url"+ type="text"+ value={vncUrl}+ onChange={(e) => onVncUrlChange(e.target.value)}+ placeholder="http://localhost:6901/vnc.html"+ className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-700 dark:text-white"+ disabled={isLoading}+ />+ </div>++ {error && <p className="text-sm text-red-600 dark:text-red-400">{error}</p>}++ <div className="flex items-center justify-end gap-3 border-t border-neutral-200 pt-4 dark:border-neutral-700">+ <TestConnectionButton status={testStatus} onClick={onTestConnection} disabled={!agentUrl} />+ <button+ type="button"+ onClick={onAdd}+ disabled={isLoading}+ className="rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50"+ >+ {isLoading ? 'Adding...' : 'Add'}+ </button>+ </div>+ </div>+ );+}diff --git a/libs/typescript/playground/src/components/modals/LocalDockerForm.tsx b/libs/typescript/playground/src/components/modals/LocalDockerForm.tsxnew file mode 100644index 0000000000..3503a2ee5b--- /dev/null+++ b/libs/typescript/playground/src/components/modals/LocalDockerForm.tsx@@ -0,0 +1,135 @@+// Step 2b: Local Docker configuration form+// Shows docker command, name/host fields, test connection, and add button.++import { Check, Copy } from 'lucide-react';+import type { SandboxPreset } from '../../constants/sandboxPresets';+import { TestConnectionButton, type TestStatus } from './TestConnectionButton';++export interface LocalDockerFormProps {+ preset: SandboxPreset;+ name: string;+ onNameChange: (v: string) => void;+ host: string;+ onHostChange: (v: string) => void;+ onCopyCommand: (cmd: string) => void;+ copiedCommand: boolean;+ testStatus: TestStatus;+ onTestConnection: () => void;+ onAdd: () => void;+ isLoading: boolean;+ error: string | null;+}++export function LocalDockerForm({+ preset,+ name,+ onNameChange,+ host,+ onHostChange,+ onCopyCommand,+ copiedCommand,+ testStatus,+ onTestConnection,+ onAdd,+ isLoading,+ error,+}: LocalDockerFormProps) {+ return (+ <div className="flex flex-col gap-4">+ {/* Docker command */}+ <div>+ <label className="mb-1.5 block text-sm font-medium text-neutral-700 dark:text-neutral-300">+ 1. Run this Docker command+ </label>+ <div className="group relative">+ <pre className="overflow-x-auto rounded-md bg-neutral-900 p-3 text-xs text-green-400">+ <code>{preset.dockerCommand}</code>+ </pre>+ <button+ type="button"+ onClick={() => onCopyCommand(preset.dockerCommand)}+ className="absolute right-2 top-2 rounded-md bg-neutral-700 p-1.5 text-neutral-300 opacity-0 transition-opacity hover:bg-neutral-600 group-hover:opacity-100"+ title="Copy command"+ >+ {copiedCommand ? <Check className="h-3.5 w-3.5" /> : <Copy className="h-3.5 w-3.5" />}+ </button>+ </div>+ <p className="mt-1 text-xs text-neutral-500 dark:text-neutral-400">+ Prerequisites: {preset.prerequisites}+ </p>+ </div>++ {/* Name */}+ <div>+ <label+ htmlFor="local-name"+ className="mb-1.5 block text-sm font-medium text-neutral-700 dark:text-neutral-300"+ >+ 2. Configure connection+ </label>+ <div className="flex flex-col gap-3">+ <div>+ <label+ htmlFor="local-sandbox-name"+ className="mb-1 block text-xs text-neutral-500 dark:text-neutral-400"+ >+ Name+ </label>+ <input+ id="local-sandbox-name"+ type="text"+ value={name}+ onChange={(e) => onNameChange(e.target.value)}+ className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-700 dark:text-white"+ disabled={isLoading}+ />+ </div>+ <div>+ <label+ htmlFor="local-sandbox-host"+ className="mb-1 block text-xs text-neutral-500 dark:text-neutral-400"+ >+ Host+ </label>+ <input+ id="local-sandbox-host"+ type="text"+ value={host}+ onChange={(e) => onHostChange(e.target.value)}+ placeholder="localhost"+ className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm dark:border-neutral-600 dark:bg-neutral-700 dark:text-white"+ disabled={isLoading}+ />+ </div>+ </div>+ <p className="mt-2 text-xs text-neutral-500 dark:text-neutral-400">+ Agent URL:{' '}+ <code className="text-neutral-700 dark:text-neutral-300">+ http://{host}:{preset.apiPort}+ </code>+ {' | '}+ VNC URL:{' '}+ <code className="text-neutral-700 dark:text-neutral-300">+ http://{host}:{preset.vncPort}+ {preset.vncPath}+ </code>+ </p>+ </div>++ {error && <p className="text-sm text-red-600 dark:text-red-400">{error}</p>}++ {/* Actions */}+ <div className="flex items-center justify-end gap-3 border-t border-neutral-200 pt-4 dark:border-neutral-700">+ <TestConnectionButton status={testStatus} onClick={onTestConnection} />+ <button+ type="button"+ onClick={onAdd}+ disabled={isLoading}+ className="rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50"+ >+ {isLoading ? 'Adding...' : 'Add'}+ </button>+ </div>+ </div>+ );+}diff --git a/libs/typescript/playground/src/components/modals/PresetGrid.tsx b/libs/typescript/playground/src/components/modals/PresetGrid.tsxnew file mode 100644index 0000000000..2032abe0a0--- /dev/null+++ b/libs/typescript/playground/src/components/modals/PresetGrid.tsx@@ -0,0 +1,50 @@+// Step 2a: Preset selection grid for local Docker containers++import { ChevronRight } from 'lucide-react';+import { SANDBOX_PRESETS, MACOS_PRESET, type SandboxPreset } from '../../constants/sandboxPresets';++const ICON_MAP: Record<SandboxPreset['icon'], string> = {+ linux: '\u{1F427}',+ windows: '\u{1FA9F}',+ android: '\u{1F4F1}',+ macos: '\u{1F34E}',+};++export interface PresetGridProps {+ onSelect: (preset: SandboxPreset) => void;+}++export function PresetGrid({ onSelect }: PresetGridProps) {+ return (+ <div className="flex flex-col gap-3">+ {SANDBOX_PRESETS.map((preset) => (+ <button+ key={preset.id}+ type="button"+ onClick={() => onSelect(preset)}+ className="flex items-center gap-4 rounded-lg border border-neutral-200 p-4 text-left transition-colors hover:border-blue-400 hover:bg-blue-50/50 dark:border-neutral-600 dark:hover:border-blue-500 dark:hover:bg-blue-950/20"+ >+ <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-neutral-100 text-xl dark:bg-neutral-700">+ {ICON_MAP[preset.icon]}+ </div>+ <div className="flex-1">+ <p className="font-medium text-neutral-900 dark:text-white">{preset.name}</p>+ <p className="text-sm text-neutral-500 dark:text-neutral-400">{preset.description}</p>+ </div>+ <ChevronRight className="h-5 w-5 text-neutral-400" />+ </button>+ ))}++ {/* macOS informational card */}+ <div className="flex items-center gap-4 rounded-lg border border-dashed border-neutral-300 p-4 dark:border-neutral-600">+ <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-neutral-100 text-xl dark:bg-neutral-700">+ {ICON_MAP.macos}+ </div>+ <div className="flex-1">+ <p className="font-medium text-neutral-900 dark:text-white">{MACOS_PRESET.name}</p>+ <p className="text-sm text-neutral-500 dark:text-neutral-400">{MACOS_PRESET.note}</p>+ </div>+ </div>+ </div>+ );+}diff --git a/libs/typescript/playground/src/components/modals/SourcePicker.tsx b/libs/typescript/playground/src/components/modals/SourcePicker.tsxnew file mode 100644index 0000000000..8cfdc0ff9b--- /dev/null+++ b/libs/typescript/playground/src/components/modals/SourcePicker.tsx@@ -0,0 +1,64 @@+// Step 1: Source selection cards (Local Docker, Cloud Sandbox, Custom URL)++import { ChevronRight, Globe, Monitor, Server } from 'lucide-react';++export type SandboxSource = 'local' | 'cloud' | 'custom';++export interface SourcePickerProps {+ onSelect: (source: SandboxSource) => void;+ hasCloud: boolean;+}++export function SourcePicker({ onSelect, hasCloud }: SourcePickerProps) {+ const cards: Array<{+ source: SandboxSource;+ icon: React.ReactNode;+ title: string;+ description: string;+ hidden?: boolean;+ }> = [+ {+ source: 'local',+ icon: <Monitor className="h-6 w-6" />,+ title: 'Local (Docker)',+ description: 'Run a sandbox on your machine using Docker',+ },+ {+ source: 'cloud',+ icon: <Server className="h-6 w-6" />,+ title: 'Cloud Sandbox',+ description: 'Provision a cloud VM',+ hidden: !hasCloud,+ },+ {+ source: 'custom',+ icon: <Globe className="h-6 w-6" />,+ title: 'Custom URL',+ description: 'Connect to any computer-server endpoint',+ },+ ];++ return (+ <div className="flex flex-col gap-3">+ {cards+ .filter((c) => !c.hidden)+ .map((card) => (+ <button+ key={card.source}+ type="button"+ onClick={() => onSelect(card.source)}+ className="flex items-center gap-4 rounded-lg border border-neutral-200 p-4 text-left transition-colors hover:border-blue-400 hover:bg-blue-50/50 dark:border-neutral-600 dark:hover:border-blue-500 dark:hover:bg-blue-950/20"+ >+ <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-neutral-100 text-neutral-600 dark:bg-neutral-700 dark:text-neutral-300">+ {card.icon}+ </div>+ <div className="flex-1">+ <p className="font-medium text-neutral-900 dark:text-white">{card.title}</p>+ <p className="text-sm text-neutral-500 dark:text-neutral-400">{card.description}</p>+ </div>+ <ChevronRight className="h-5 w-5 text-neutral-400" />+ </button>+ ))}+ </div>+ );+}diff --git a/libs/typescript/playground/src/components/modals/TestConnectionButton.tsx b/libs/typescript/playground/src/components/modals/TestConnectionButton.tsxnew file mode 100644index 0000000000..12f7b25264--- /dev/null+++ b/libs/typescript/playground/src/components/modals/TestConnectionButton.tsx@@ -0,0 +1,34 @@+// Shared "Test Connection" button used by LocalDockerForm and CustomUrlForm++import { Check, Loader2 } from 'lucide-react';+import { cn } from '../../utils/cn';++export type TestStatus = 'idle' | 'testing' | 'success' | 'error';++export interface TestConnectionButtonProps {+ status: TestStatus;+ onClick: () => void;+ disabled?: boolean;+}++export function TestConnectionButton({ status, onClick, disabled }: TestConnectionButtonProps) {+ return (+ <button+ type="button"+ onClick={onClick}+ disabled={disabled || status === 'testing'}+ className={cn(+ 'flex items-center gap-2 rounded-md border px-4 py-2 text-sm font-medium transition-colors disabled:opacity-50',+ status === 'success'+ ? 'border-green-300 text-green-700 dark:border-green-700 dark:text-green-400'+ : status === 'error'+ ? 'border-red-300 text-red-700 dark:border-red-700 dark:text-red-400'+ : 'border-neutral-300 text-neutral-700 hover:bg-neutral-50 dark:border-neutral-600 dark:text-neutral-300 dark:hover:bg-neutral-700'+ )}+ >+ {status === 'testing' && <Loader2 className="h-3.5 w-3.5 animate-spin" />}+ {status === 'success' && <Check className="h-3.5 w-3.5" />}+ {status === 'testing' ? 'Testing...' : status === 'success' ? 'Connected' : 'Test Connection'}+ </button>+ );+}diff --git a/libs/typescript/playground/src/components/modals/index.ts b/libs/typescript/playground/src/components/modals/index.tsindex abeb00ad50..f500cc9407 100644--- a/libs/typescript/playground/src/components/modals/index.ts+++ b/libs/typescript/playground/src/components/modals/index.ts@@ -1,6 +1,6 @@// Barrel export for modalsexport { SettingsModal } from './SettingsModal';-export { AddSandboxModal, CustomComputerModal } from './CustomComputerModal';-export type { AddSandboxModalProps } from './CustomComputerModal';+export { AddSandboxModal, CustomComputerModal } from './AddSandboxModal';+export type { AddSandboxModalProps } from './AddSandboxModal';export { default as ExportTrajectoryModal } from './ExportTrajectoryModal';export { default as ReplayTrajectoryModal } from './ReplayTrajectoryModal';diff --git a/libs/typescript/playground/src/components/primitives/ChatInput.tsx b/libs/typescript/playground/src/components/primitives/ChatInput.tsxindex 2b01f2c8ff..dbb40bd188 100644--- a/libs/typescript/playground/src/components/primitives/ChatInput.tsx+++ b/libs/typescript/playground/src/components/primitives/ChatInput.tsx@@ -1,47 +1,18 @@-// Chat input component-// Based on cloud/src/website/app/components/playground/ChatInput.tsx from main+// Chat input component — thin orchestrator+// Sub-components: ComputerSelector, ModelSelector, MobileInputBar-import { Loader2, Monitor, Send, StopCircle } from 'lucide-react';-import { useCallback, useEffect, useMemo, useRef, useState } from 'react';-import {- Select,- SelectContent,- SelectGroup,- SelectItem,- SelectLabel,- SelectSeparator,- SelectTrigger,- SelectValue,-} from '../ui/select';+import { Monitor, Send, StopCircle } from 'lucide-react';+import { useCallback, useEffect, useRef, useState } from 'react';import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip';import type { Computer, Model, ModelProvider, VM } from '../../types';-import { isVM, getComputerId, getComputerName, getComputerStatus } from '../../types';+import { isVM } from '../../types';+import { ComputerSelector } from './ComputerSelector';+import { ModelSelector } from './ModelSelector';+import { MobileInputBar } from './MobileInputBar';-/**- * Groups computers by workspace name, sorted alphabetically with "Custom" at the end.- */-function groupComputersByWorkspace(- computers: Computer[]-): Array<{ workspaceName: string; computers: Computer[] }> {- const groups = new Map<string, Computer[]>();-- for (const computer of computers) {- const wsName = isVM(computer) ? 'Sandboxes' : 'Custom';- if (!groups.has(wsName)) {- groups.set(wsName, []);- }- groups.get(wsName)!.push(computer);- }-- // Sort alphabetically, with "Custom" at the end- return Array.from(groups.entries())- .sort(([a], [b]) => {- if (a === 'Custom') return 1;- if (b === 'Custom') return -1;- return a.localeCompare(b);- })- .map(([workspaceName, computers]) => ({ workspaceName, computers }));-}+// ---------------------------------------------------------------------------+// Ghost typing hook+// ---------------------------------------------------------------------------const GHOST_PROMPTS = ['Describe my screen',@@ -75,27 +46,23 @@ function useGhostTyping(isActive: boolean) {const currentPrompt = GHOST_PROMPTS[promptIndex];if (!isDeleting) {- // Typingif (charIndex < currentPrompt.length) {timeoutRef.current = setTimeout(() => {setGhostText(currentPrompt.slice(0, charIndex + 1));setCharIndex((prev) => prev + 1);}, 50);} else {- // Pause at end before deletingtimeoutRef.current = setTimeout(() => {setIsDeleting(true);}, 2000);}} else {- // Deletingif (charIndex > 0) {timeoutRef.current = setTimeout(() => {setGhostText(currentPrompt.slice(0, charIndex - 1));setCharIndex((prev) => prev - 1);}, 30);} else {- // Move to next promptsetIsDeleting(false);setPromptIndex((prev) => (prev + 1) % GHOST_PROMPTS.length);}@@ -107,7 +74,11 @@ function useGhostTyping(isActive: boolean) {return ghostText;}-interface ChatInputProps {+// ---------------------------------------------------------------------------+// ChatInput props & component+// ---------------------------------------------------------------------------++export interface ChatInputProps {// Core propscurrentInput: string;onInputChange: (value: string) => void;@@ -166,30 +137,14 @@ export function ChatInput({vmVersionInfo = new Map(),hasOrg = true,hasWorkspace = true,- hasCredits = true,- renderLink,onAddComputer,}: ChatInputProps) {// Lock model/computer selection after first message, but only if they're set- // This allows users to still pick if the saved model/computer is unavailableconst isModelLocked = hasMessages && !!selectedModel;const isComputerLocked = hasMessages && !!selectedComputer;- const handleModelChange = (modelId: string) => {- onModelChange(modelId);- };-- const handleComputerChange = (computerId: string) => {- if (computerId === '__add_sandbox__') {- onAddComputer?.();- return;- }- onComputerChange(computerId);- };-const handleInputChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {onInputChange(e.target.value);- // Auto-resize textareae.target.style.height = 'auto';e.target.style.height = `${e.target.scrollHeight}px`;};@@ -215,370 +170,114 @@ export function ChatInput({!currentInput.trim() ||(selectedComputer && isVM(selectedComputer) && (selectedComputer as VM).status !== 'running');- // Group computers by workspace- const groupedComputers = useMemo(() => groupComputersByWorkspace(computers), [computers]);-// Ghost typing - only show when input is empty and no messagesconst showGhostTyping = !currentInput && !hasMessages && !isGenerating;const ghostText = useGhostTyping(showGhostTyping);- // Desktop layout- if (!isMobile) {+ // -------------------------------------------------------------------------+ // Mobile layout+ // -------------------------------------------------------------------------+ if (isMobile) {return (- <div className="flex flex-col rounded-2xl bg-neutral-100 p-2 dark:bg-neutral-800">- {/* Textarea row */}- <div className="relative">- <textarea- value={currentInput}- onChange={handleInputChange}- onKeyDown={handleKeyDown}- placeholder={showGhostTyping ? '' : 'Send a message'}- disabled={isGenerating}- rows={1}- className="w-full resize-none rounded-2xl bg-neutral-100 px-3 pt-2 text-neutral-900 placeholder-neutral-400 focus:outline-none disabled:opacity-50 dark:bg-neutral-800 dark:text-white dark:placeholder-neutral-500"- style={{ minHeight: '44px', maxHeight: '200px' }}- />- {showGhostTyping && ghostText && (- <div- className="pointer-events-none absolute top-0 left-0 px-3 pt-2 text-neutral-400 dark:text-neutral-500"- aria-hidden="true"- >- {ghostText}- <span className="animate-pulse">|</span>- </div>- )}- </div>-- {/* Desktop: Model & Sandbox selectors - button bar row */}- <div className="flex flex-wrap items-center justify-end gap-2">- {/* Computer selector - locked after first message */}- <Select- value={- selectedComputer &&- computers.find((c: Computer) => c.name === selectedComputer.name) !== undefined- ? getComputerId(selectedComputer)- : ''- }- onValueChange={handleComputerChange}- disabled={isComputerLocked}- >- <SelectTrigger- minimal- className="border-0 bg-neutral-100 text-neutral-400 hover:bg-white/60 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-neutral-800 dark:text-neutral-400 dark:hover:bg-neutral-700/60 [&>svg]:rotate-180"- >- <SelectValue placeholder="Sandbox" />- </SelectTrigger>- <SelectContent className="rounded-lg bg-white dark:bg-card">- {computers.length === 0 ? (- <div className="p-2 text-center">- <p className="mb-2 text-muted-foreground text-xs">- {!hasOrg- ? 'Set up an organization first'- : !hasWorkspace- ? 'Create a workspace first'- : 'No sandboxes available'}- </p>- </div>- ) : (- <>- {groupedComputers.map((group) => (- <SelectGroup key={group.workspaceName}>- <SelectLabel>{group.workspaceName}</SelectLabel>- {group.computers.map((c) => {- // Check status for both VMs and custom computers- const computerStatus = getComputerStatus(c);- const isRunning = computerStatus === 'running';- // Only VMs use vmVersionInfo for reachability/outdated checks- const versionInfo = isVM(c) ? vmVersionInfo.get((c as VM).vmId) : undefined;- // Custom computers are never "unreachable" via vmVersionInfo;- // they trust their own status property- const isUnreachable = isVM(c) ? versionInfo?.unreachable : false;- return (- <SelectItem- key={getComputerId(c)}- value={getComputerId(c)}- className="hover:bg-neutral-200 dark:hover:bg-neutral-700"- >- <div className="flex items-center gap-2">- {computerStatus === 'restarting' || computerStatus === 'starting' ? (- <Loader2 className="h-3 w-3 animate-spin text-neutral-500 dark:text-neutral-400" />- ) : (- <div- className={`h-2 w-2 rounded-full ${- isUnreachable- ? 'bg-orange-500'- : isRunning- ? 'bg-green-500'- : 'bg-red-500'- }`}- />- )}- <span>{getComputerName(c)}</span>- {computerStatus === 'starting' ? (- <span className="text-neutral-500 text-xs dark:text-neutral-400">- Starting- </span>- ) : computerStatus === 'restarting' ? (- <span className="text-neutral-500 text-xs dark:text-neutral-400">- Restarting- </span>- ) : isUnreachable ? (- <span className="text-orange-600 text-xs dark:text-orange-400">- Not responding- </span>- ) : (- versionInfo?.isOutdated && (- <span className="text-orange-600 text-xs dark:text-orange-400">- Outdated- </span>- )- )}- </div>- </SelectItem>- );- })}- </SelectGroup>- ))}- </>- )}- {onAddComputer && (- <>- <SelectSeparator />- <SelectItem- value="__add_sandbox__"- className="text-blue-600 hover:bg-neutral-200 dark:text-blue-400 dark:hover:bg-neutral-700"- >- + Add Sandbox...- </SelectItem>- </>- )}- </SelectContent>- </Select>-- {/* Model selector - locked after first message */}- <Select- value={selectedModel?.id || ''}- onValueChange={handleModelChange}- disabled={!!customModelId || isModelLocked}- >- <SelectTrigger- minimal- className="border-0 bg-neutral-100 text-neutral-400 hover:bg-white/60 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-neutral-800 dark:text-neutral-400 dark:hover:bg-neutral-700/60 [&>svg]:rotate-180"- >- <SelectValue placeholder="Model" />- </SelectTrigger>- <SelectContent className="rounded-lg bg-white dark:bg-card">- {customModelId && (- <SelectGroup>- <SelectLabel>Custom</SelectLabel>- <SelectItem- key={customModelId}- value={customModelId}- className="hover:bg-neutral-200 dark:hover:bg-neutral-700"- >- {customModelId}- </SelectItem>- </SelectGroup>- )}- {availableModels.map((provider) => (- <SelectGroup key={provider.name}>- <SelectLabel>- {provider.name.charAt(0).toUpperCase() + provider.name.slice(1)}- </SelectLabel>- {provider.models.map((m) => (- <SelectItem- key={m.id}- value={m.id}- className="hover:bg-neutral-200 dark:hover:bg-neutral-700"- >- <span className="flex items-center gap-2">- {m.name}- {provider.name.toLowerCase() !== 'anthropic' && (- <span className="rounded bg-amber-100 px-1.5 py-0.5 font-medium text-amber-700 text-xs dark:bg-amber-900/30 dark:text-amber-400">- Preview- </span>- )}- </span>- </SelectItem>- ))}- </SelectGroup>- ))}- </SelectContent>- </Select>-- {/* Open VM button */}- {selectedComputer &&- isVM(selectedComputer) &&- ((selectedComputer as VM).vncUrl || customVncUrl) && (- <Tooltip>- <TooltipTrigger asChild>- <button- type="button"- onClick={handleOpenVnc}- className="flex h-8 w-8 items-center justify-center text-neutral-600 transition-colors hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white"- >- <Monitor className="h-4 w-4" />- </button>- </TooltipTrigger>- <TooltipContent>- <p>Open VNC in new tab</p>- </TooltipContent>- </Tooltip>- )}-- {/* Send/Stop button */}- {isGenerating ? (- <button- type="button"- onClick={onStopResponse}- className="flex h-8 w-8 items-center justify-center text-neutral-600 transition-colors hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white"- >- <StopCircle className="h-4 w-4" />- </button>- ) : (- <button- type="button"- onClick={onSendMessage}- disabled={sendDisabled}- className="flex h-8 w-8 items-center justify-center text-neutral-600 transition-colors hover:text-neutral-900 disabled:text-neutral-300 dark:text-neutral-400 dark:disabled:text-neutral-600 dark:hover:text-white"- title={- selectedComputer &&- isVM(selectedComputer) &&- (selectedComputer as VM).status !== 'running'- ? 'Sandbox is not running'- : undefined- }- >- <Send className="h-4 w-4" />- </button>- )}- </div>- </div>+ <MobileInputBar+ currentInput={currentInput}+ onInputChange={handleInputChange}+ onKeyDown={handleKeyDown}+ onSendMessage={onSendMessage}+ onStopResponse={onStopResponse}+ isGenerating={isGenerating}+ sendDisabled={sendDisabled}+ showGhostTyping={showGhostTyping}+ ghostText={ghostText}+ computers={computers}+ selectedComputer={selectedComputer}+ onComputerChange={onComputerChange}+ isComputerLocked={isComputerLocked}+ onAddComputer={onAddComputer}+ availableModels={availableModels}+ selectedModel={selectedModel}+ onModelChange={onModelChange}+ isModelLocked={isModelLocked}+ customModelId={customModelId}+ />);}- // Mobile layout+ // -------------------------------------------------------------------------+ // Desktop layout+ // -------------------------------------------------------------------------return (- <div className="space-y-2">- {/* Mobile selectors row - locked after first message */}- <div className="flex gap-2">- <Select- value={- selectedComputer &&- computers.find((c: Computer) => c.name === selectedComputer.name) !== undefined- ? getComputerId(selectedComputer)- : ''- }- onValueChange={handleComputerChange}- disabled={isComputerLocked}- >- <SelectTrigger- minimal- className="flex-1 border-0 bg-neutral-100 text-neutral-600 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-neutral-800 dark:text-neutral-400"+ <div className="flex flex-col rounded-2xl bg-neutral-100 p-2 dark:bg-neutral-800">+ {/* Textarea row */}+ <div className="relative">+ <textarea+ value={currentInput}+ onChange={handleInputChange}+ onKeyDown={handleKeyDown}+ placeholder={showGhostTyping ? '' : 'Send a message'}+ disabled={isGenerating}+ rows={1}+ className="w-full resize-none rounded-2xl bg-neutral-100 px-3 pt-2 text-neutral-900 placeholder-neutral-400 focus:outline-none disabled:opacity-50 dark:bg-neutral-800 dark:text-white dark:placeholder-neutral-500"+ style={{ minHeight: '44px', maxHeight: '200px' }}+ />+ {showGhostTyping && ghostText && (+ <div+ className="pointer-events-none absolute top-0 left-0 px-3 pt-2 text-neutral-400 dark:text-neutral-500"+ aria-hidden="true">- <SelectValue placeholder="Sandbox" />- </SelectTrigger>- <SelectContent className="z-[100] rounded-lg bg-white dark:bg-card">- {groupedComputers.map((group) => (- <SelectGroup key={group.workspaceName}>- <SelectLabel>{group.workspaceName}</SelectLabel>- {group.computers.map((c: Computer) => (- <SelectItem- key={getComputerId(c)}- value={getComputerId(c)}- className="hover:bg-neutral-200 dark:hover:bg-neutral-700"- >- {getComputerName(c)}- </SelectItem>- ))}- </SelectGroup>- ))}- {onAddComputer && (- <>- <SelectSeparator />- <SelectItem- value="__add_sandbox__"- className="text-blue-600 hover:bg-neutral-200 dark:text-blue-400 dark:hover:bg-neutral-700"- >- + Add Sandbox...- </SelectItem>- </>- )}- </SelectContent>- </Select>-- <Select- value={selectedModel?.id || ''}- onValueChange={handleModelChange}- disabled={!!customModelId || isModelLocked}- >- <SelectTrigger- minimal- className="flex-1 border-0 bg-neutral-100 text-neutral-600 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-neutral-800 dark:text-neutral-400"- >- <SelectValue placeholder="Model" />- </SelectTrigger>- <SelectContent className="z-[100] rounded-lg bg-white dark:bg-card">- {customModelId && (- <SelectGroup>- <SelectLabel>Custom</SelectLabel>- <SelectItem- key={customModelId}- value={customModelId}- className="hover:bg-neutral-200 dark:hover:bg-neutral-700"- >- {customModelId}- </SelectItem>- </SelectGroup>- )}- {availableModels.map((provider) => (- <SelectGroup key={provider.name}>- <SelectLabel>- {provider.name.charAt(0).toUpperCase() + provider.name.slice(1)}- </SelectLabel>- {provider.models.map((m) => (- <SelectItem- key={m.id}- value={m.id}- className="hover:bg-neutral-200 dark:hover:bg-neutral-700"- >- {m.name}- </SelectItem>- ))}- </SelectGroup>- ))}- </SelectContent>- </Select>+ {ghostText}+ <span className="animate-pulse">|</span>+ </div>+ )}</div>- {/* Mobile input row */}- <div className="flex items-end gap-2 rounded-2xl bg-neutral-100 p-2 dark:bg-neutral-800">- <div className="relative flex-1">- <textarea- value={currentInput}- onChange={handleInputChange}- onKeyDown={handleKeyDown}- placeholder={showGhostTyping ? '' : 'Send a message'}- disabled={isGenerating}- rows={1}- className="w-full resize-none bg-transparent px-2 pt-1 text-neutral-900 placeholder-neutral-400 focus:outline-none disabled:opacity-50 dark:text-white dark:placeholder-neutral-500"- style={{ minHeight: '36px', maxHeight: '120px' }}- />- {showGhostTyping && ghostText && (- <div- className="pointer-events-none absolute top-0 left-0 px-2 pt-1 text-neutral-400 dark:text-neutral-500"- aria-hidden="true"- >- {ghostText}- <span className="animate-pulse">|</span>- </div>+ {/* Desktop: Model & Sandbox selectors - button bar row */}+ <div className="flex flex-wrap items-center justify-end gap-2">+ <ComputerSelector+ computers={computers}+ selectedComputer={selectedComputer}+ onComputerChange={onComputerChange}+ disabled={isComputerLocked}+ vmVersionInfo={vmVersionInfo}+ hasOrg={hasOrg}+ hasWorkspace={hasWorkspace}+ onAddComputer={onAddComputer}+ />++ <ModelSelector+ availableModels={availableModels}+ selectedModel={selectedModel}+ onModelChange={onModelChange}+ disabled={isModelLocked}+ customModelId={customModelId}+ />++ {/* Open VM button */}+ {selectedComputer &&+ isVM(selectedComputer) &&+ ((selectedComputer as VM).vncUrl || customVncUrl) && (+ <Tooltip>+ <TooltipTrigger asChild>+ <button+ type="button"+ onClick={handleOpenVnc}+ className="flex h-8 w-8 items-center justify-center text-neutral-600 transition-colors hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white"+ >+ <Monitor className="h-4 w-4" />+ </button>+ </TooltipTrigger>+ <TooltipContent>+ <p>Open VNC in new tab</p>+ </TooltipContent>+ </Tooltip>)}- </div>++ {/* Send/Stop button */}{isGenerating ? (<buttontype="button"onClick={onStopResponse}- className="flex h-8 w-8 shrink-0 items-center justify-center text-neutral-600 dark:text-neutral-400"+ className="flex h-8 w-8 items-center justify-center text-neutral-600 transition-colors hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white"><StopCircle className="h-4 w-4" /></button>@@ -587,7 +286,14 @@ export function ChatInput({type="button"onClick={onSendMessage}disabled={sendDisabled}- className="flex h-8 w-8 shrink-0 items-center justify-center text-neutral-600 disabled:text-neutral-300 dark:text-neutral-400 dark:disabled:text-neutral-600"+ className="flex h-8 w-8 items-center justify-center text-neutral-600 transition-colors hover:text-neutral-900 disabled:text-neutral-300 dark:text-neutral-400 dark:disabled:text-neutral-600 dark:hover:text-white"+ title={+ selectedComputer &&+ isVM(selectedComputer) &&+ (selectedComputer as VM).status !== 'running'+ ? 'Sandbox is not running'+ : undefined+ }><Send className="h-4 w-4" /></button>diff --git a/libs/typescript/playground/src/components/primitives/ComputerSelector.tsx b/libs/typescript/playground/src/components/primitives/ComputerSelector.tsxnew file mode 100644index 0000000000..e8dd5dbe5d--- /dev/null+++ b/libs/typescript/playground/src/components/primitives/ComputerSelector.tsx@@ -0,0 +1,217 @@+// Computer selector dropdown component+// Extracted from ChatInput.tsx++import { Loader2 } from 'lucide-react';+import { useMemo } from 'react';+import {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectLabel,+ SelectSeparator,+ SelectTrigger,+ SelectValue,+} from '../ui/select';+import type { Computer, VM } from '../../types';+import { isVM, getComputerId, getComputerName, getComputerStatus } from '../../types';++/**+ * Groups computers by workspace name, sorted alphabetically with "Custom" at the end.+ */+export function groupComputersByWorkspace(+ computers: Computer[]+): Array<{ workspaceName: string; computers: Computer[] }> {+ const groups = new Map<string, Computer[]>();++ for (const computer of computers) {+ const wsName = isVM(computer) ? 'Sandboxes' : 'Custom';+ if (!groups.has(wsName)) {+ groups.set(wsName, []);+ }+ groups.get(wsName)!.push(computer);+ }++ // Sort alphabetically, with "Custom" at the end+ return Array.from(groups.entries())+ .sort(([a], [b]) => {+ if (a === 'Custom') return 1;+ if (b === 'Custom') return -1;+ return a.localeCompare(b);+ })+ .map(([workspaceName, computers]) => ({ workspaceName, computers }));+}++export interface ComputerSelectorProps {+ computers: Computer[];+ selectedComputer?: Computer;+ onComputerChange: (computerId: string) => void;+ disabled?: boolean;+ vmVersionInfo?: Map<string, { unreachable?: boolean; isOutdated?: boolean }>;+ hasOrg?: boolean;+ hasWorkspace?: boolean;+ onAddComputer?: () => void;+ /** When true, renders the mobile variant (simpler items, z-index on content) */+ mobile?: boolean;+}++export function ComputerSelector({+ computers,+ selectedComputer,+ onComputerChange,+ disabled = false,+ vmVersionInfo = new Map(),+ hasOrg = true,+ hasWorkspace = true,+ onAddComputer,+ mobile = false,+}: ComputerSelectorProps) {+ const groupedComputers = useMemo(() => groupComputersByWorkspace(computers), [computers]);++ const handleChange = (computerId: string) => {+ if (computerId === '__add_sandbox__') {+ onAddComputer?.();+ return;+ }+ onComputerChange(computerId);+ };++ const value =+ selectedComputer &&+ computers.find((c: Computer) => c.name === selectedComputer.name) !== undefined+ ? getComputerId(selectedComputer)+ : '';++ if (mobile) {+ return (+ <Select value={value} onValueChange={handleChange} disabled={disabled}>+ <SelectTrigger+ minimal+ className="flex-1 border-0 bg-neutral-100 text-neutral-600 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-neutral-800 dark:text-neutral-400"+ >+ <SelectValue placeholder="Sandbox" />+ </SelectTrigger>+ <SelectContent className="z-[100] rounded-lg bg-white dark:bg-card">+ {groupedComputers.map((group) => (+ <SelectGroup key={group.workspaceName}>+ <SelectLabel>{group.workspaceName}</SelectLabel>+ {group.computers.map((c: Computer) => (+ <SelectItem+ key={getComputerId(c)}+ value={getComputerId(c)}+ className="hover:bg-neutral-200 dark:hover:bg-neutral-700"+ >+ {getComputerName(c)}+ </SelectItem>+ ))}+ </SelectGroup>+ ))}+ {onAddComputer && (+ <>+ <SelectSeparator />+ <SelectItem+ value="__add_sandbox__"+ className="text-blue-600 hover:bg-neutral-200 dark:text-blue-400 dark:hover:bg-neutral-700"+ >+ + Add Sandbox...+ </SelectItem>+ </>+ )}+ </SelectContent>+ </Select>+ );+ }++ // Desktop variant with status indicators+ return (+ <Select value={value} onValueChange={handleChange} disabled={disabled}>+ <SelectTrigger+ minimal+ className="border-0 bg-neutral-100 text-neutral-400 hover:bg-white/60 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-neutral-800 dark:text-neutral-400 dark:hover:bg-neutral-700/60 [&>svg]:rotate-180"+ >+ <SelectValue placeholder="Sandbox" />+ </SelectTrigger>+ <SelectContent className="rounded-lg bg-white dark:bg-card">+ {computers.length === 0 ? (+ <div className="p-2 text-center">+ <p className="mb-2 text-muted-foreground text-xs">+ {!hasOrg+ ? 'Set up an organization first'+ : !hasWorkspace+ ? 'Create a workspace first'+ : 'No sandboxes available'}+ </p>+ </div>+ ) : (+ <>+ {groupedComputers.map((group) => (+ <SelectGroup key={group.workspaceName}>+ <SelectLabel>{group.workspaceName}</SelectLabel>+ {group.computers.map((c) => {+ const computerStatus = getComputerStatus(c);+ const isRunning = computerStatus === 'running';+ const versionInfo = isVM(c) ? vmVersionInfo.get((c as VM).vmId) : undefined;+ const isUnreachable = isVM(c) ? versionInfo?.unreachable : false;+ return (+ <SelectItem+ key={getComputerId(c)}+ value={getComputerId(c)}+ className="hover:bg-neutral-200 dark:hover:bg-neutral-700"+ >+ <div className="flex items-center gap-2">+ {computerStatus === 'restarting' || computerStatus === 'starting' ? (+ <Loader2 className="h-3 w-3 animate-spin text-neutral-500 dark:text-neutral-400" />+ ) : (+ <div+ className={`h-2 w-2 rounded-full ${+ isUnreachable+ ? 'bg-orange-500'+ : isRunning+ ? 'bg-green-500'+ : 'bg-red-500'+ }`}+ />+ )}+ <span>{getComputerName(c)}</span>+ {computerStatus === 'starting' ? (+ <span className="text-neutral-500 text-xs dark:text-neutral-400">+ Starting+ </span>+ ) : computerStatus === 'restarting' ? (+ <span className="text-neutral-500 text-xs dark:text-neutral-400">+ Restarting+ </span>+ ) : isUnreachable ? (+ <span className="text-orange-600 text-xs dark:text-orange-400">+ Not responding+ </span>+ ) : (+ versionInfo?.isOutdated && (+ <span className="text-orange-600 text-xs dark:text-orange-400">+ Outdated+ </span>+ )+ )}+ </div>+ </SelectItem>+ );+ })}+ </SelectGroup>+ ))}+ </>+ )}+ {onAddComputer && (+ <>+ <SelectSeparator />+ <SelectItem+ value="__add_sandbox__"+ className="text-blue-600 hover:bg-neutral-200 dark:text-blue-400 dark:hover:bg-neutral-700"+ >+ + Add Sandbox...+ </SelectItem>+ </>+ )}+ </SelectContent>+ </Select>+ );+}diff --git a/libs/typescript/playground/src/components/primitives/MobileInputBar.tsx b/libs/typescript/playground/src/components/primitives/MobileInputBar.tsxnew file mode 100644index 0000000000..96ba9a0974--- /dev/null+++ b/libs/typescript/playground/src/components/primitives/MobileInputBar.tsx@@ -0,0 +1,126 @@+// Mobile-specific chat input layout+// Extracted from ChatInput.tsx++import { Send, StopCircle } from 'lucide-react';+import type { Computer, Model, ModelProvider } from '../../types';+import { ComputerSelector } from './ComputerSelector';+import { ModelSelector } from './ModelSelector';++export interface MobileInputBarProps {+ // Core props+ currentInput: string;+ onInputChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;+ onKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;+ onSendMessage: () => void;+ onStopResponse: () => void;+ isGenerating: boolean;+ sendDisabled: boolean | undefined;++ // Ghost typing+ showGhostTyping: boolean;+ ghostText: string;++ // Computer selection+ computers: Computer[];+ selectedComputer?: Computer;+ onComputerChange: (computerId: string) => void;+ isComputerLocked: boolean;+ onAddComputer?: () => void;++ // Model selection+ availableModels: ModelProvider[];+ selectedModel?: Model;+ onModelChange: (modelId: string) => void;+ isModelLocked: boolean;+ customModelId?: string;+}++export function MobileInputBar({+ currentInput,+ onInputChange,+ onKeyDown,+ onSendMessage,+ onStopResponse,+ isGenerating,+ sendDisabled,+ showGhostTyping,+ ghostText,+ computers,+ selectedComputer,+ onComputerChange,+ isComputerLocked,+ onAddComputer,+ availableModels,+ selectedModel,+ onModelChange,+ isModelLocked,+ customModelId,+}: MobileInputBarProps) {+ return (+ <div className="space-y-2">+ {/* Mobile selectors row */}+ <div className="flex gap-2">+ <ComputerSelector+ computers={computers}+ selectedComputer={selectedComputer}+ onComputerChange={onComputerChange}+ disabled={isComputerLocked}+ onAddComputer={onAddComputer}+ mobile+ />++ <ModelSelector+ availableModels={availableModels}+ selectedModel={selectedModel}+ onModelChange={onModelChange}+ disabled={isModelLocked}+ customModelId={customModelId}+ mobile+ />+ </div>++ {/* Mobile input row */}+ <div className="flex items-end gap-2 rounded-2xl bg-neutral-100 p-2 dark:bg-neutral-800">+ <div className="relative flex-1">+ <textarea+ value={currentInput}+ onChange={onInputChange}+ onKeyDown={onKeyDown}+ placeholder={showGhostTyping ? '' : 'Send a message'}+ disabled={isGenerating}+ rows={1}+ className="w-full resize-none bg-transparent px-2 pt-1 text-neutral-900 placeholder-neutral-400 focus:outline-none disabled:opacity-50 dark:text-white dark:placeholder-neutral-500"+ style={{ minHeight: '36px', maxHeight: '120px' }}+ />+ {showGhostTyping && ghostText && (+ <div+ className="pointer-events-none absolute top-0 left-0 px-2 pt-1 text-neutral-400 dark:text-neutral-500"+ aria-hidden="true"+ >+ {ghostText}+ <span className="animate-pulse">|</span>+ </div>+ )}+ </div>+ {isGenerating ? (+ <button+ type="button"+ onClick={onStopResponse}+ className="flex h-8 w-8 shrink-0 items-center justify-center text-neutral-600 dark:text-neutral-400"+ >+ <StopCircle className="h-4 w-4" />+ </button>+ ) : (+ <button+ type="button"+ onClick={onSendMessage}+ disabled={sendDisabled}+ className="flex h-8 w-8 shrink-0 items-center justify-center text-neutral-600 disabled:text-neutral-300 dark:text-neutral-400 dark:disabled:text-neutral-600"+ >+ <Send className="h-4 w-4" />+ </button>+ )}+ </div>+ </div>+ );+}diff --git a/libs/typescript/playground/src/components/primitives/ModelSelector.tsx b/libs/typescript/playground/src/components/primitives/ModelSelector.tsxnew file mode 100644index 0000000000..605062221c--- /dev/null+++ b/libs/typescript/playground/src/components/primitives/ModelSelector.tsx@@ -0,0 +1,132 @@+// Model selector dropdown component+// Extracted from ChatInput.tsx++import {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectLabel,+ SelectTrigger,+ SelectValue,+} from '../ui/select';+import type { Model, ModelProvider } from '../../types';++export interface ModelSelectorProps {+ availableModels: ModelProvider[];+ selectedModel?: Model;+ onModelChange: (modelId: string) => void;+ disabled?: boolean;+ customModelId?: string;+ /** When true, renders the mobile variant (flex-1, z-index on content) */+ mobile?: boolean;+}++export function ModelSelector({+ availableModels,+ selectedModel,+ onModelChange,+ disabled = false,+ customModelId,+ mobile = false,+}: ModelSelectorProps) {+ if (mobile) {+ return (+ <Select+ value={selectedModel?.id || ''}+ onValueChange={onModelChange}+ disabled={!!customModelId || disabled}+ >+ <SelectTrigger+ minimal+ className="flex-1 border-0 bg-neutral-100 text-neutral-600 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-neutral-800 dark:text-neutral-400"+ >+ <SelectValue placeholder="Model" />+ </SelectTrigger>+ <SelectContent className="z-[100] rounded-lg bg-white dark:bg-card">+ {customModelId && (+ <SelectGroup>+ <SelectLabel>Custom</SelectLabel>+ <SelectItem+ key={customModelId}+ value={customModelId}+ className="hover:bg-neutral-200 dark:hover:bg-neutral-700"+ >+ {customModelId}+ </SelectItem>+ </SelectGroup>+ )}+ {availableModels.map((provider) => (+ <SelectGroup key={provider.name}>+ <SelectLabel>+ {provider.name.charAt(0).toUpperCase() + provider.name.slice(1)}+ </SelectLabel>+ {provider.models.map((m) => (+ <SelectItem+ key={m.id}+ value={m.id}+ className="hover:bg-neutral-200 dark:hover:bg-neutral-700"+ >+ {m.name}+ </SelectItem>+ ))}+ </SelectGroup>+ ))}+ </SelectContent>+ </Select>+ );+ }++ // Desktop variant with preview badges+ return (+ <Select+ value={selectedModel?.id || ''}+ onValueChange={onModelChange}+ disabled={!!customModelId || disabled}+ >+ <SelectTrigger+ minimal+ className="border-0 bg-neutral-100 text-neutral-400 hover:bg-white/60 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-neutral-800 dark:text-neutral-400 dark:hover:bg-neutral-700/60 [&>svg]:rotate-180"+ >+ <SelectValue placeholder="Model" />+ </SelectTrigger>+ <SelectContent className="rounded-lg bg-white dark:bg-card">+ {customModelId && (+ <SelectGroup>+ <SelectLabel>Custom</SelectLabel>+ <SelectItem+ key={customModelId}+ value={customModelId}+ className="hover:bg-neutral-200 dark:hover:bg-neutral-700"+ >+ {customModelId}+ </SelectItem>+ </SelectGroup>+ )}+ {availableModels.map((provider) => (+ <SelectGroup key={provider.name}>+ <SelectLabel>+ {provider.name.charAt(0).toUpperCase() + provider.name.slice(1)}+ </SelectLabel>+ {provider.models.map((m) => (+ <SelectItem+ key={m.id}+ value={m.id}+ className="hover:bg-neutral-200 dark:hover:bg-neutral-700"+ >+ <span className="flex items-center gap-2">+ {m.name}+ {provider.name.toLowerCase() !== 'anthropic' && (+ <span className="rounded bg-amber-100 px-1.5 py-0.5 font-medium text-amber-700 text-xs dark:bg-amber-900/30 dark:text-amber-400">+ Preview+ </span>+ )}+ </span>+ </SelectItem>+ ))}+ </SelectGroup>+ ))}+ </SelectContent>+ </Select>+ );+}diff --git a/libs/typescript/playground/src/hooks/index.ts b/libs/typescript/playground/src/hooks/index.tsindex 6c24db7368..4f85e89287 100644--- a/libs/typescript/playground/src/hooks/index.ts+++ b/libs/typescript/playground/src/hooks/index.ts@@ -11,3 +11,5 @@ export {} from './usePlayground';export { useAgentRequest } from './useAgentRequest';+export { useComputerMapping } from './useComputerMapping';+export { useSelectedComputer } from './useSelectedComputer';diff --git a/libs/typescript/playground/src/hooks/useComputerMapping.ts b/libs/typescript/playground/src/hooks/useComputerMapping.tsnew file mode 100644index 0000000000..ced86d51a5--- /dev/null+++ b/libs/typescript/playground/src/hooks/useComputerMapping.ts@@ -0,0 +1,21 @@+import { useMemo } from 'react';+import type { ComputerInfo } from '../adapters/types';+import type { Computer } from '../types';++/**+ * Maps ComputerInfo[] (adapter shape) to Computer[] (UI shape).+ *+ * The adapter exposes `agentUrl` while the UI `Computer` union expects `url`.+ * This hook performs the conversion and memoises the result so the array+ * reference stays stable across renders when the input hasn't changed.+ */+export function useComputerMapping(computerInfos: ComputerInfo[]): Computer[] {+ return useMemo(+ () =>+ computerInfos.map((c) => {+ const { agentUrl, ...rest } = c;+ return { ...rest, url: agentUrl } as Computer;+ }),+ [computerInfos]+ );+}diff --git a/libs/typescript/playground/src/hooks/useSelectedComputer.ts b/libs/typescript/playground/src/hooks/useSelectedComputer.tsnew file mode 100644index 0000000000..c827dad186--- /dev/null+++ b/libs/typescript/playground/src/hooks/useSelectedComputer.ts@@ -0,0 +1,29 @@+import { useMemo } from 'react';+import type { Computer } from '../types';+import { getComputerId } from '../types';++/**+ * Resolves which computer is currently selected.+ *+ * Priority:+ * 1. The computer whose ID matches `currentComputerId` (playground-level selection).+ * 2. Falls back to `chatComputer` (per-chat selection).+ *+ * This keeps the computer dropdown in sync with the VNC viewer while+ * respecting the per-chat default when no global override exists.+ */+export function useSelectedComputer(+ currentComputerId: string | null,+ computers: Computer[],+ chatComputer: Computer | undefined+): Computer | undefined {+ return useMemo(() => {+ if (currentComputerId) {+ const match = computers.find((c) => getComputerId(c) === currentComputerId);+ if (match) {+ return match;+ }+ }+ return chatComputer;+ }, [currentComputerId, computers, chatComputer]);+}diff --git a/libs/typescript/playground/src/index.ts b/libs/typescript/playground/src/index.tsindex 5c9688936f..eac14f2a12 100644--- a/libs/typescript/playground/src/index.ts+++ b/libs/typescript/playground/src/index.ts@@ -42,6 +42,8 @@ export {useFindDefaultModel,} from './hooks/usePlayground';export { useAgentRequest } from './hooks/useAgentRequest';+export { useComputerMapping } from './hooks/useComputerMapping';+export { useSelectedComputer } from './hooks/useSelectedComputer';export { useDarkMode } from './hooks/useDarkMode';// Primitive Components@@ -83,8 +85,8 @@ export { PlaygroundContent } from './components/composed/PlaygroundContent';// Modalsexport { SettingsModal } from './components/modals/SettingsModal';-export { AddSandboxModal, CustomComputerModal } from './components/modals/CustomComputerModal';-export type { AddSandboxModalProps } from './components/modals/CustomComputerModal';+export { AddSandboxModal, CustomComputerModal } from './components/modals/AddSandboxModal';+export type { AddSandboxModalProps } from './components/modals/AddSandboxModal';export { ExportTrajectoryModal } from './components/modals';export { ReplayTrajectoryModal } from './components/modals';