Spectra-Frontend: The Multiplayer Browser for Humans and AI

How a React application uses VNC streams and Kubernetes namespaces to build a shared, ephemeral workspace for security researchers and autonomous agents.

6 min read • View on GitHub • More from NishithP2004

A vintage steering wheel held by both a human hand and a robot hand, illustrating collaborative control.
Spectra replaces the traditional black-box AI agent with a collaborative, visually observable workspace.
Key Takeaways

The Shared Cursor

Most AI browsing tools operate as headless black boxes. You issue a command, and you wait for a result. Spectra takes a different approach. By embedding a live VNC stream directly into a React application, it creates a multiplayer environment where a human and an AI agent share the same virtual workspace. You can ask the agent to execute a task and watch it happen in real time. If the agent gets stuck, you can intervene using your own mouse and keyboard.

Bridging the RFB Protocol and React

Rendering a remote desktop protocol inside a modern web application presents unique challenges. Spectra relies on react-vnc to handle the raw RFB stream. The BrowserSessionPage synchronizes this visual canvas with a chat interface, treating the remote browser as a first-class application rather than a simple video stream. This requires meticulous JWT lifecycle management to keep long-running websocket connections alive without forcing a page reload.

The session orchestration flow prevents duplicate provisioning during slow Kubernetes cold starts.

Surviving the Kubernetes Cold Start

The brain of the application lives in SessionContext.tsx. When a user requests a session, Kubernetes must spin up a new namespace and container. This cold start is notoriously slow. Spectra uses a global request deduplication pattern to handle this latency. An out-of-cycle activeRequests Map prevents users from mashing the start button and accidentally provisioning duplicate infrastructure.

const activeRequests = new Map<string, boolean>();

const startSession = async (mode: string) => {
  if (activeRequests.has(mode)) return;
  activeRequests.set(mode, true);
  try {
    // Provision Kubernetes namespace and container
  } finally {
    activeRequests.delete(mode);
  }
};

The Disposable Sandbox

Spectra is built with security researchers in mind. The interface includes an explicit hacking mode toggle. This instructs the backend to provision specialized, ephemeral environments designed to safely detonate malicious links or run intensive open-source intelligence tools.

The Visual vs. Headless Paradigm

Headless browsing APIs are faster and cheaper at scale. However, they lack the visual feedback required for complex, unpredictable workflows. Spectra sacrifices the raw speed of a headless API to provide deep observability and the option for immediate human override.

A split scene comparing a robot in an opaque box to a robot in a glass terrarium.
Headless APIs operate in the dark. Spectra puts the agent in a glass box.
FeatureSpectra (Visual)Headless APIsTraditional VNC
Visual FeedbackReal-time VNCScreenshots onlyReal-time VNC
AI IntegrationBuilt-in chatNativeNone
Primary ActorHuman + AIAI onlyHuman only
InfrastructureEphemeral K8sServerlessPersistent or Ephemeral