Workspace

Displays & Screens

Share Android, local desktop, or cloud Sandbox virtual displays in a Cohub Space to view live over WebRTC, inspect elements, run UI actions, handle human handover, and record sessions.

This page explains how to share an Android phone screen, a local computer desktop, or a cloud Sandbox virtual display inside a Cohub Space so teammates and agents can watch live over WebRTC, read the accessibility tree, drive apps via the CLI, hand off sensitive steps to a person, and record or replay runs.

Display sources

A Space can receive live displays from three runtime environments. Media streams use WebRTC with DTLS-SRTP end-to-end encryption (direct via STUN by default, or through a TURN relay when configured).

Source How to enable Live viewing & input Background / virtual screen
Android phone (with phone control) Space Runtime menu → Set up phone control (one-time setup on Android 14+) Shares the phone screen with no per-session recording prompt; injects touch, key, and accessibility actions Yes — cohub spaces displays start creates an isolated agent screen while you keep using your phone
Android phone (without phone control) Space Runtime menu → Share screen Prompts for full-screen recording consent each session; input runs through Android Accessibility No — only the phone's own screen; no app launching or clipboard paste
Local desktop cohub runtime up --display (default auto when a screen is available) or --display xvfb:1920x1080; or toggle from the desktop app Streams the main display (macOS), primary monitor (Windows), or $DISPLAY (Linux) Yes, on Linux/headless hosts via xvfb[:WIDTHxHEIGHT] (default 1280x800)
Cloud Sandbox Space header screen button → Start virtual screen, or cohub spaces displays start Streams an on-demand Xvfb virtual screen (default 1280x800) with an AT-SPI accessibility bus Yes — nothing runs until started; processes launched afterward inherit DISPLAY

Android phone

  • Phone control (Android 14+): Open the Space's Runtime menu and choose Set up phone control. Setup requires notifications (and local network access on Android 17) plus a Wi-Fi connection so Cohub can discover Wireless debugging's Pair device with pairing code dialog over mDNS. Once paired, the helper process grants WRITE_SECURE_SETTINGS, enables Cohub's accessibility service, and exempts it from battery restrictions. Afterward, Cohub starts the helper automatically whenever the phone serves a Space on Wi-Fi.
  • Agent screen: Calling cohub spaces displays start (or launch) creates a dedicated virtual display (agent screen) with its own focus and keyboard so agents work in the background without interrupting your phone use. Apps running on the agent screen stay muted until moved to the phone's screen. The agent screen stops when cohub spaces displays stop runs or after 10 minutes with no agent, viewer, or person active. launch refuses an app you currently have open on the phone.
  • Without phone control: If Wi-Fi is unavailable or phone control is not set up, you can still choose Share screen and enable the accessibility service. Each share asks for whole-screen recording consent, and only the phone's own screen is available (no agent screen, no launch, and no clipboard paste).

Local desktop

Start a Local Runtime with display sharing enabled:

# Auto-detect the local screen (main display on macOS, primary monitor on Windows, $DISPLAY on Linux)
cohub runtime up --display

# Start a headless virtual display at a specific resolution (Linux with Xvfb)
cohub runtime up --display xvfb:1920x1080

# Explicitly disable screen sharing when starting the Runtime
cohub runtime up --no-display
  • macOS permissions: Live viewing and screenshots require System Settings → Privacy & Security → Screen Recording for the terminal or app running the Runtime. Interactive input and reading the front window's element tree also require Accessibility. After granting permissions, restart the Runtime.
  • Linux accessibility: Element trees read over AT-SPI (AT_SPI_BUS_ADDRESS or the desktop session's org.a11y.Bus). Start Chrome with --force-renderer-accessibility if agents need to read its UI tree (for web pages inside a Sandbox browser, agent-browser over CDP is more precise).
  • Video encoders: Live streaming uses native ScreenCaptureKit + VideoToolbox on macOS 12.3+, Media Foundation on Windows (Windows N editions fall back to ffmpeg), and ffmpeg (libx264 / h264_videotoolbox) elsewhere. If no encoder is installed on a desktop, agents can still capture screenshots, read element trees, and send input; only live video viewing needs an encoder.
  • Desktop app toggle: Desktop apps can toggle screen sharing for one Space at a time without restarting the Runtime, prompting for consent each time.

Cloud Sandbox virtual display

Cloud Sandboxes with Xvfb do not start a virtual screen until someone requests one. Start or stop it from the Space header screen button (Start virtual screen / Stop virtual screen) or through the CLI:

cohub spaces displays start --size 1280x800
cohub spaces displays stop

Programs started in the Sandbox after the virtual display starts inherit DISPLAY. When dbus-daemon and at-spi2-core are installed (included in the standard Sandbox image), the virtual display also starts an accessibility bus and exports AT_SPI_BUS_ADDRESS, ACCESSIBILITY_ENABLED=1, and QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1 so GUI apps expose readable elements.

Permissions, takeover, and handover

Space permissions

Action Required permission Who has it
Watch live stream, list displays, capture screenshots, read element trees, list windows/apps sandbox.view Anyone who can view the Space's Runtime
Send pointer/keyboard input, run action plans, start/stop virtual display, record, interrupt, handover command.execute Builder access or above (and agents running in the Space)

If your role only allows viewing, or if the host OS has not granted control permission (such as macOS Accessibility), the viewer opens in view-only mode and displays a banner explaining what is missing.

Live activity and human takeover

  • Shared cursors and agent pointer: Live viewers see who else is watching or controlling the screen, along with smoothed cursor pointers. While an agent runs a plan (and for 30 seconds afterward), the viewer displays the agent's current step label and highlights where each click, type, or scroll lands.
  • Stop agent: Click Stop agent in the viewer (or Stop in the Android floating indicator) to cancel the running plan and its Turn immediately. Any subsequent plans from that same Turn are also refused; a new Turn can act again.
  • Take over: On Android, opening the floating indicator and tapping Take over moves the agent screen's app to the phone screen and blocks agent plans with preempted until you choose Hand back (or Done, hand back in the web viewer, or stop sharing). Interacting directly on the device similarly preempts agents without resuming the interrupted plan when handed back.

Agent handover for sensitive steps

When an agent reaches a step it must not perform—such as signing in, entering a one-time verification code, or approving a payment—it requests human help:

cohub spaces displays handover --reason "Sign in to your account and complete 2FA"
  • While a handover is active, agent plans on that display are refused (preempted) and screen recording automatically pauses.
  • On Android, the floating indicator turns amber and opens, accompanied by a notification offering Take over.
  • In the web viewer click Done, hand back (or tap Hand back in the Android indicator) once you finish the step.
  • The command exits with returned when handed back, stopped if sharing stops, gone if the display disconnects, or expired after --timeout-ms (default 10 minutes / 600000 ms, max 12 hours / 43200000 ms) or 15 seconds after a polling caller disconnects. Pass --no-wait to raise the handover prompt and return immediately.

Viewer controls and recordings

Open a shared display in the Space web app to watch and interact:

  • Navigation & input: Click, drag, scroll, and type directly on the screen (desktop displays forward hover, right-click, and keyboard shortcuts; Paste always types from the viewer's own clipboard). Use Keyboard / Show keyboard on touch devices, Trackpad mode for pointer precision, Fit to screen to reset zoom, and the device's advertised system buttons (Back, Home, Recent apps on Android).
  • Connection status: Click the live status pill (Connection details) to inspect Path (Direct or Relay), Ping, Video resolution and frame rate, Bitrate, Jitter buffer, Decode, Packets lost, and Freezes, or use Reconnect to re-establish WebRTC.
  • Manual and automatic recording:
    • Click Record screen (Alt+Shift+R, or ⌥⇧R on macOS) to record the live stream as fragmented MP4 without starting a second encoder; click Stop recording to finish.
    • Toggle Record agents' steps to start recording automatically whenever an agent runs a plan, ending 15 seconds after the last plan finishes so consecutive plans stay in one clip.
    • Privacy pauses: Recording automatically pauses while a password field has focus, during a handover, or while a person holds the display.
    • Managing recordings: Open Recordings in the viewer to play saved clips, Save to files (copies the recording into recordings/ in the Space), or Delete recording.
  • Replay from Chats: Shell tool calls in Chat that acted on a display show a Replay button, stepping through the matching recording with chapter markers and the agent's pointer overlay (or stepping through the saved per-plan screenshots if no recording exists).

CLI workflow (cohub spaces displays)

Every interactive subcommand executes through the on-device plan runner (act), returns each step's effect (none, changed, or navigated) plus the post-action screen state, and saves a screenshot automatically when the accessibility tree is sparse or --screenshot is passed.

Discover displays, windows, and apps

# List shared displays, capabilities, and active viewers
cohub spaces displays ls

# Start or stop a virtual / agent screen
cohub spaces displays start --size 1280x800
cohub spaces displays stop

# List desktop windows (front first) or launchable apps
cohub spaces displays windows
cohub spaces displays apps

Read the screen without acting

# Read the screen state as act reports it (optional --until-* wait and --screenshot)
cohub spaces displays look --screenshot

# Save a screenshot (defaults to .cache/cohub/displays/, latest 20 kept)
cohub spaces displays capture --max-size 1280

# Read the accessibility tree (compact by default; add --full for the nested tree)
cohub spaces displays tree --max 300
cohub spaces displays tree --full

Pass -w <window-id> (from windows) on look, capture, tree, or any action command to restrict screenshots, element trees, and coordinates to one desktop window.

Drive UI elements and multi-step plans

Prefer targeting elements by --name and --role (or element refs like e3.12 from tree) over raw coordinates. Element refs are bound to their snapshot and refused if the control moved or changed. When using pixel coordinates, coordinates match the latest captured image (or --size WxH).

# Launch an app by ID or open a URL / settings page
cohub spaces displays launch com.android.settings
cohub spaces displays open "https://example.com"

# Tap by name (scrolls a list until visible when --scroll is set), double-tap coordinates, or long-press
cohub spaces displays tap --name "Wi-Fi" --label "Opening Wi-Fi"
cohub spaces displays tap --name "Ada" --scroll
cohub spaces displays tap 300 200 --count 2
cohub spaces displays long-press --name "Draft" --duration 800

# Type into a named field, send keys/shortcuts, scroll, swipe, press system buttons, or wait
cohub spaces displays type "hello" --name "Message" --role textField
cohub spaces displays key Control+a
cohub spaces displays key Enter
cohub spaces displays scroll down
cohub spaces displays swipe 500 1400 500 400
cohub spaces displays press back
cohub spaces displays wait --until-gone "Loading" --timeout-ms 8000

Supported system buttons for press: back, home, recents, notifications, quickSettings, lock (only buttons supported by the target display succeed).

To run up to 32 steps on the device in one round-trip—stopping at the first unexpected screen—use act:

echo '[{"type":"tap","name":"Search"},{"type":"type","text":"Ada"},{"type":"key","key":"Enter","until":{"gone":"Loading"}}]' \
  | cohub spaces displays act --label "Searching contacts"

Record from the CLI

Recordings are stored in the Space working directory under .cache/cohub/displays/recordings/<id>/ (meta.json and 000.mp4, rolling to a new file if resolution changes):

# Start or stop manual recording
cohub spaces displays record start
cohub spaces displays record stop

# Auto-record every agent plan (stops 15 s after the last plan)
cohub spaces displays record start --auto
cohub spaces displays record stop --auto

# List recordings in the Space folder (newest first)
cohub spaces displays record ls

Subcommand reference

Subcommand Purpose Key flags
ls List active displays, capabilities, and viewers --json
start / stop Start or stop a phone agent screen or Sandbox virtual screen --size <WxH>, --json
capture Save a screenshot (default .cache/cohub/displays/) -d, -w, -o, --max-size, --json
tree Read accessibility elements (e<snap>.<idx> refs, roles, bounds) -d, -w, --max, --full, --json
windows List desktop windows front to back -d, --json
apps List apps the display can launch -d, --json
look Observe screen state without acting -d, -w, --screenshot, --tree, --until-*
launch / open Launch an app by ID or open a URL/settings page -d, --until-*, --label, --screenshot
tap / long-press Tap or hold an element (--name, ref) or x y point --name, --role, --nth, --scroll, --count, --button, --duration
swipe / scroll Drag between two points or scroll up/down/left/right -d, -w, --size, --until-*, --label
type / key / press Enter text, send key/shortcut, or press a system button --name, --role, --nth, --scroll, --until-*
wait Wait for --ms or --until-text/--until-gone/--until-app/--until-stable --ms, --timeout-ms, --until-*
handover Pause automation and ask a person to complete a sensitive step --reason, --timeout-ms, --no-wait, --json
act Execute a JSON array of up to 32 steps on-device --actions, stdin, -d, -w, --label, --screenshot
record start / stop / ls Manage manual or --auto agent recordings -d, --auto, --json

Boundaries & common errors

  • sandbox_offline (503): The device or cloud Sandbox serving the Space is offline. Reconnect your Local Runtime, wake the cloud Sandbox with a Chat turn, or recover it in Space settings.
  • display_not_found (404) / display_unavailable (409): No screen is currently shared. Run cohub runtime up --display on a desktop, choose Share screen on Android, or run cohub spaces displays start for a virtual/agent screen.
  • display_preempted (409): A person took over the screen, clicked Stop agent, or a handover is still active. Wait until the person clicks Done, hand back (or start a new Turn after an interrupt).
  • display_busy (429): Either the viewer limit is full or another plan held the display past the 5-second queue wait. Only one plan runs on a display at a time (bounded at 90 seconds per plan).
  • display_unsupported (501): An older sandboxd does not support displays or virtual screens. Restart or recover the cloud Sandbox from Space settings, or update Cohub on the local device.
  • macOS Screen Recording or Accessibility missing: Without Screen Recording, the viewer shows Screen Recording is not allowed; without Accessibility, the display opens in view-only mode. Grant the permission to Cohub or the terminal running the Runtime under System Settings → Privacy & Security, then restart the Runtime.
  • Android Wi-Fi and open-app limits: Starting phone control requires Wi-Fi (wifi_off otherwise) because Android Wireless debugging only runs over Wi-Fi. On the agent screen, launch refuses apps currently open on the phone's main screen.
  • Linux AT-SPI unavailable: Without a reachable AT-SPI bus, element trees are unavailable and recording cannot automatically detect focused password fields to pause.
  • Occluded desktop windows: Passing --window <id> can capture and read a window behind another, but pointer and keyboard input always lands on the visible screen surface.
  • Storage retention and checkpoints: Screenshots in .cache/cohub/displays/ (latest 20 kept) and recordings in .cache/cohub/displays/recordings/ (max 2 hours per clip, 2 GB total per Space, stopping when free disk drops below 1 GB) live outside git and Saves. Copy any clip you want to keep into Space files via Save to files.

Next steps

  • Local Runtime — Connect a computer or Android device and manage cohub runtime up
  • Files & Sandbox — Understand /workspace persistence and cloud Sandbox lifecycle
  • Spaces — Manage Space roles, permissions, and collaborators
  • CLI — Full cohub command reference and authentication setup