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
fix(playground): iframe VM sync, stopped VM validation, and scrolling (#1026)
Sarina Li6eec6301bdf6
diff --git a/libs/python/agent/agent/playground/server.py b/libs/python/agent/agent/playground/server.pyindex 14f844de89..dd9bd28b4f 100644--- a/libs/python/agent/agent/playground/server.py+++ b/libs/python/agent/agent/playground/server.py@@ -133,10 +133,12 @@ class PlaygroundServer:error = Nonewith _EnvOverride(env_overrides):- # Use pre-configured agent if available, otherwise create new one- if self.agent_instance:+ # Use pre-configured agent only if model matches, otherwise create new one+ # This ensures the model picker in the UI is respected+ if self.agent_instance and self.agent_instance.model == model:agent = self.agent_instanceelse:+ # Model changed or no pre-configured agent - create new agent with requested modelagent = ComputerAgent(model=model, **agent_kwargs) # type: ignore[arg-type]total_output: List[Any] = []diff --git a/libs/typescript/playground/src/components/composed/ChatArea.tsx b/libs/typescript/playground/src/components/composed/ChatArea.tsxindex 97a65a89a7..9fe258dbad 100644--- a/libs/typescript/playground/src/components/composed/ChatArea.tsx+++ b/libs/typescript/playground/src/components/composed/ChatArea.tsx@@ -50,7 +50,7 @@ export function ChatArea({ onRetry, onTimeout }: ChatAreaProps) {return (<>{/* Messages area */}- <div className="flex-1 overflow-y-auto p-4 pb-0 md:p-6">+ <div className="flex-1 min-h-0 overflow-y-auto p-4 pb-0 md:p-6"><div className="mx-auto max-w-3xl space-y-6">{processedMessages.length > 0 && (<motion.divdiff --git a/libs/typescript/playground/src/components/composed/ChatContent.tsx b/libs/typescript/playground/src/components/composed/ChatContent.tsxindex f7af760cdd..6a0b27e02a 100644--- a/libs/typescript/playground/src/components/composed/ChatContent.tsx+++ b/libs/typescript/playground/src/components/composed/ChatContent.tsx@@ -259,7 +259,7 @@ export function ChatContent({// Normal layout with messages and input at bottomreturn (- <div className={cn('flex flex-1 flex-col', className)}>+ <><ChatAreaonRetry={handleRetry}onStopResponse={handleStopResponse}@@ -291,6 +291,6 @@ export function ChatContent({/></div></div>- </div>+ </>);}diff --git a/libs/typescript/playground/src/components/composed/ChatSidebar.tsx b/libs/typescript/playground/src/components/composed/ChatSidebar.tsxindex 5d0b23b22c..8906950865 100644--- a/libs/typescript/playground/src/components/composed/ChatSidebar.tsx+++ b/libs/typescript/playground/src/components/composed/ChatSidebar.tsx@@ -26,6 +26,7 @@ import {usePlayground,} from '../../hooks/usePlayground';import type { Chat, Computer } from '../../types';+import { isVM } from '../../types';import { cn } from '../../utils/cn';interface ChatSidebarProps {@@ -49,7 +50,7 @@ export function ChatSidebar({onToast,}: ChatSidebarProps) {const { state, dispatch, adapters } = usePlayground();- const { chats, computers, activeChatId } = state;+ const { chats, computers, activeChatId, currentComputerId } = state;const activeChat = useActiveChat();const defaultModel = useFindDefaultModel();const [isCreating, setIsCreating] = useState(false);@@ -68,8 +69,18 @@ export function ChatSidebar({setIsCreating(true);try {- // Get first computer if available- const computer = computers.length > 0 ? computers[0] : undefined;+ // Priority: use currently selected computer (currentComputerId), then fall back to first available+ const selectedComputer = currentComputerId+ ? computers.find((c) => c.id === currentComputerId)+ : undefined;+ const computer = selectedComputer ?? (computers.length > 0 ? computers[0] : undefined);++ // Check if the computer is stopped+ if (computer && isVM(computer) && computer.status === 'stopped') {+ onToast?.('Cannot create chat: The sandbox is stopped. Please start it first.', 'error');+ return;+ }+let computerAsChat: Computer | undefined;if (computer) {const { agentUrl, ...rest } = computer;@@ -105,7 +116,7 @@ export function ChatSidebar({} finally {setIsCreating(false);}- }, [computers, defaultModel, dispatch, isCreating, adapters.persistence, onToast]);+ }, [computers, currentComputerId, defaultModel, dispatch, isCreating, adapters.persistence, onToast]);const handleDeleteConfirm = async () => {if (!deleteConfirmChat) return;diff --git a/libs/typescript/playground/src/components/composed/PlaygroundContent.tsx b/libs/typescript/playground/src/components/composed/PlaygroundContent.tsxindex 3d1b8f955a..3110f7c0d6 100644--- a/libs/typescript/playground/src/components/composed/PlaygroundContent.tsx+++ b/libs/typescript/playground/src/components/composed/PlaygroundContent.tsx@@ -13,6 +13,7 @@ import {usePlayground,} from '../../hooks/usePlayground';import type { Chat, Computer } from '../../types';+import { isVM } from '../../types';// Re-export for convenienceexport { EmptyStateWithInput } from './EmptyState';@@ -148,15 +149,24 @@ export function PlaygroundContent({// Create a new chat and send the first messageconst handleCreateChatWithMessage = async (message: string) => {- // Find a running computer first, then fall back to first computer+ // Priority: use currently selected computer (currentComputerId), then fall back to first running, then first available+ const selectedComputer = state.currentComputerId+ ? computers.find((c) => c.id === state.currentComputerId)+ : undefined;const runningComputer = computers.find((c) => c.status === 'running');- const computerInfo = runningComputer ?? computers[0];+ const computerInfo = selectedComputer ?? runningComputer ?? computers[0];if (!computerInfo) {onToast?.('Please select a sandbox to interact with.', 'error');return;}+ // Check if the selected computer is stopped+ if (isVM(computerInfo) && computerInfo.status === 'stopped') {+ onToast?.('Cannot start chat: The selected sandbox is stopped. Please start it first.', 'error');+ return;+ }+// Convert ComputerInfo to Computerconst computer: Computer = {id: computerInfo.id,diff --git a/libs/typescript/playground/src/context/PlaygroundProvider.tsx b/libs/typescript/playground/src/context/PlaygroundProvider.tsxindex 7bc0674bc3..ab145eb16e 100644--- a/libs/typescript/playground/src/context/PlaygroundProvider.tsx+++ b/libs/typescript/playground/src/context/PlaygroundProvider.tsx@@ -199,6 +199,22 @@ export function PlaygroundProvider({ adapters, children, initialChats }: Playgroinitialize();}, [adapters, initialChats]);+ // Sync currentComputerId when active chat changes+ // This ensures the VNC iframe shows the correct VM for each chat+ useEffect(() => {+ if (state.activeChatId && state.initialized) {+ const activeChat = state.chats.find((chat) => chat.id === state.activeChatId);++ // If the active chat has an associated computer that differs from the current one, sync it+ if (activeChat?.computer?.id && activeChat.computer.id !== state.currentComputerId) {+ dispatch({+ type: 'SET_CURRENT_COMPUTER',+ payload: activeChat.computer.id,+ });+ }+ }+ }, [state.activeChatId, state.chats, state.currentComputerId, state.initialized]);+// Memoize context value to prevent unnecessary re-rendersconst contextValue = useMemo(() => ({