Status: implemented (phases 0–4 of the Linux design). This page is the plan the design started from; where the code ended up differently, As built says so. Items still marked (to verify) were not confirmed on real machines. Install and use: README; other distributions: building on Linux. The Windows plan is separate: Windows.
Decided by the owner: desktops sleep (freeze) when idle and are closed only when the user archives or deletes the conversation or closes its desktop; low memory is reported to the user (warning below 15% available), never solved by closing desktops; low disk is reported the same way.
mobd stopasks before closing desktops (default no); uninstalling closes them; data is always kept. Desktops use the machine's locale. Ubuntu and Debian are supported; other distributions get build and configuration instructions.
On macOS mobd drives the one real desktop of the logged-in user, shared by every task and
serialized by the FIFO desktop queue (maxRunning, default 1, internal/api/server.go
scheduleLocked). On Linux mobd instead gives each conversation its own virtual X display.
Desktops do not compete, so conversations run side by side, mobd needs no graphical login, no
permission prompts, and the same setup works on a desktop PC, a headless server or a VM.
There is no Wayland and no xdg-desktop-portal in this plan. The physical screen of the Linux machine is not watched or controlled (see Not supported in v1).
| Linux | |
|---|---|
| Desktop model | one virtual X display per conversation (session), created on demand, frozen when idle, closed only when the user deletes the conversation or closes the desktop |
| Display server | Xvfb, one per desktop, plus openbox and a private D-Bus session bus |
| Capture | XShm + XDamage on that display (pure Go, jezek/xgb) |
| Encode | GStreamer: VA-API, then NVENC, then OpenH264 (not bundled); never x264 |
| Input | XTest on our own display: no permission prompt |
| Permissions | none |
| Process model | systemd --user unit with linger (default) or a system unit with a dedicated user |
| Concurrency | one running turn per conversation, maxRunning turns overall; memory is reported, never reclaimed by closing desktops |
| Distributions | Ubuntu 22.04/24.04 and Debian 12/13 supported (.deb, tarball); others build and configure it themselves from a guide |
| Tests | real end-to-end desktop and stream tests on hosted Ubuntu CI runners |
-
One desktop per conversation. A desktop is created when a turn of that session is dispatched (see Concurrency) and kept across turns, so the agent's browser, windows and half-finished forms are still there on the next turn.
-
A desktop is never closed behind the user's back. It is the conversation's working state (open windows, tabs, half-filled forms, unsaved text), so mobd only freezes it:
State When Resume Running a turn is active, someone watches it, or it is still busy (see When a desktop sleeps) — Asleep idle by every signal for desktopSleepAfter(proposed default 10 min)instant, everything as it was Closed only when the user archives the conversation ( PATCH /sessions/{id}witharchived: true), deletes it (DELETE /sessions/{id}) or closes its desktop (DELETE /desktops/{sessionId}, a "Close desktop" action in the apps)the next turn starts a new one: files and browser profile kept, windows gone Archiving closes the desktop to free its memory; the apps confirm first ("Open windows on this conversation's desktop will be closed. Files and browser logins are kept."). An unarchived conversation gets a new desktop with its next turn. A turn,
POST /stream, orPOST /desktops/…wakes an asleep desktop; a snapshot does not. -
Sleeping = cgroup freezer. Every desktop lives in its own cgroup (a systemd transient scope, see Process model): Xvfb, openbox, dbus, the apps, and the runners of its turns. Writing
cgroup.freeze = 1stops every process in it, including apps the agent started from its shell withsetsid, which a process-groupSIGSTOPwould miss. An asleep desktop uses no CPU; its memory stays allocated (and can be swapped out, see Memory). After waking, web pages may have dropped their network connections while frozen, so some reconnect or need a reload; the windows themselves are intact. -
What sleeps with the desktop: everything in its cgroup: the apps, and any command or server the agent left running in the background (
setsid npm run dev &, a long download). Turns never sleep: a desktop with an active turn, including one waiting for a question or approval, stays awake, and a desktop that is still doing work is not put to sleep (next section). If a frozen background job matters, waking the desktop resumes it where it stopped; network connections it held may have timed out. -
Restarts: desktops survive a mobd restart or upgrade (they are not mobd's children; mobd re-attaches at start, see Process model). A machine reboot cannot keep them: windows are lost, files and browser profiles are kept, and browsers restore their tabs. The apps say "the desktop was restarted after the office machine rebooted". Checkpointing a running X server and browser to disk (CRIU) is not practical.
-
When a desktop sleeps: mobd checks every desktop once a minute. It goes to sleep only after all of these have held for
desktopSleepAfter:- No active turn for the session: none running, queued, or waiting for an answer (task store).
- Nobody watching: no live-view session (stream manager); snapshots do not count (below).
- No CPU work: the desktop's cgroup used less than
desktopSleepCPU(proposed 2% of one core) on average (cpu.statusage_usec). A build, test run, server handling requests or page still loading keeps it awake. - No screen changes: no XDamage events on the display (mobd keeps a damage subscription on every desktop; it costs nothing while the screen is still). A playing video, a progress bar or a terminal printing output keeps it awake.
Any signal resets the timer. Signals 3 and 4 catch background work the agent left behind, so "idle" means really idle, not just "no turn". A job that waits silently for minutes (a long
sleep, a slow network transfer with no output) can still be frozen; the agent's MCP instructions tell it to finish or report background work before ending a turn. The apps show the state (running/asleep) per conversation. -
Viewers do not keep a desktop awake forever. An open but unattended live view or a polling snapshot would otherwise block sleep indefinitely (signal 2):
- Snapshots never wake or hold a desktop. Before freezing, mobd keeps the desktop's last
frame;
GET /screenon an asleep desktop returns it withX-Mob-Desktop-State: asleepand does not count as watching. Only a live view (POST /stream), a turn orPOST /desktops/{sessionId}wakes it. - Clients pause an unattended live view (client work, all platforms including macOS):
after
liveIdlePause(proposed 10 min) with no input from the user and no new frame, the app ends the stream and shows "Live view paused · click to resume". - Clients stop when nobody can see the view: a hidden or minimised window, or a phone app in the background, ends the live view and stops snapshot polling (the desktop app already stops snapshots when its window is hidden).
Once the stream ends, the normal timer applies and the desktop sleeps after
desktopSleepAfter; resuming the view wakes it instantly. - Snapshots never wake or hold a desktop. Before freezing, mobd keeps the desktop's last
frame;
-
Why per conversation, not per task: a conversation is the unit the user continues ("now submit the form"), and its turns already run one at a time (a session with an active turn rejects a new one with
ErrSessionBusy,internal/task/store.go). A per-task desktop would close the browser at the end of every turn, and the follow-up turn would start from an empty screen and a logged-out browser. A per-conversation desktop gives exactly one actor per display, so no locking is needed inside a desktop. -
Why start at dispatch, not at the first desktop tool call: runners get
DISPLAYwhen they start, and agents often launch apps from their shell (google-chrome &) before any MCP call. Starting Xvfb + openbox + dbus costs well under a second and some 30–50 MB, so mobd starts the desktop with the turn. A per-turn "no desktop" option (taskOptions) can come later.
| Option | For | Against |
|---|---|---|
| Xvfb (chosen) | in every distro, no GPU, driver or config file, small; has MIT-SHM, DAMAGE, XTEST, XFIXES, RANDR; starts in ~100 ms | size fixed at start; software GL only (Mesa llvmpipe) |
| Xorg + dummy driver | real Xorg, xrandr modes | needs a generated xorg.conf per display, heavier, no real GPU benefit with the dummy driver |
headless Wayland (sway/weston --headless) |
modern stack | capture and input need compositor-specific protocols (wlr-screencopy, virtual-pointer), no portable window list; out of scope by decision |
Each desktop runs
Xvfb :N -screen 0 <W>x<H>x24 -dpi <96·scale> -nolisten tcp -auth <xauth> -s 0 +extension RANDR
(-s 0 disables the screen saver, so a desktop is never "asleep" or "locked").
Size is desktopSize (default 1920x1080) and desktopScale (default 1; 2 sets the DPI,
Xft.dpi and GDK_SCALE, and Display.Scale = 2, so agent coordinates stay in points like on
macOS). Changing the size means a new desktop; Xvfb cannot resize a running display.
The live view's resize keeps working: it scales the encoded picture, not the display.
Without a window manager, X windows have no focus handling, no EWMH client list and no
maximize/activate, so list_windows and "click to focus" break. openbox: small (~10 MB),
fully EWMH compliant (_NET_CLIENT_LIST, _NET_ACTIVE_WINDOW, _NET_WM_STATE), stacking
(overlapping windows like macOS/Windows, which agents expect), configured by one XML file.
mobd writes its own rc.xml per desktop: no root menu, no desktops/pager, smart placement,
title bars kept (agents use them to read window titles). Tiling WMs (i3) rearrange windows
unexpectedly; xfwm4/metacity pull in more of a desktop environment. No panel or desktop shell.
- Locale and time zone: each desktop uses the machine's settings:
LANG/LC_*from/etc/default/locale(orlocalectl), the time zone from/etc/localtime, and the matching XKB layout as the default fordesktopKeyboardLayout. A system unit gets them the same way, since systemd does not pass the login locale. Fonts for the locale (e.g.fonts-noto-cjkfor zh/ja/ko) become a dependency of the.deb, not a recommendation. Typing still goes through mobd (keysym remapping); no input method (ibus/fcitx) runs inside a desktop in v1. - D-Bus: one
dbus-daemon --session --nofork --address=unix:path=<rundir>/busper desktop. Browsers, GTK and Electron apps expect a session bus; sharing one across desktops would mix single-instance apps between displays. - Notifications (optional): mobd can own
org.freedesktop.Notificationson each bus (godbus) so apps do not block on a missing daemon, and log them as activity. Without it, most apps just skip notifications. - Clipboard: X selections are per display, so each desktop has its own clipboard.
PasteownsCLIPBOARDon that display through xgb (answeringSelectionRequest), then presses Ctrl+V. Terminals need Ctrl+Shift+V, an accepted limitation; agents can fall back tokey. No clipboard sync with clients (as on macOS).
- Pure Go through xgb:
XShmGetImageof the root window into a shared segment, with XDamage telling which regions changed. An unchanged screen produces no frames, which keeps the stream contract (internal/desktop/backend.goStreamOptions). Snapshots (/screen, agent screenshots) use the same path and the existingdesktop.Encode; no GStreamer involved. - GStreamer
ximagesrc display-name=:N use-damage=trueis a quick prototype path but emits frames at the configured rate even when nothing changes (to verify), so it is not the target. - Xvfb's
-shmem/-fbdirframebuffer export could avoid even theXShmGetImagecopy; a later optimisation (to verify).
- GStreamer in a thin C shim (
stream_linux.c):appsrcfed with damaged frames, thenvapostproc ! vah264enc(VA-API, Intel/AMD),nvh264enc(NVIDIA), oropenh264enc, thenh264parse config-interval=-1 ! appsink(Annex B, SPS/PPS on every IDR). Settings: constrained baseline (the stream service signalsprofile-level-id=42e01f,internal/stream/stream.go), no B-frames, CBR/low latency, keyframes on request only, livebitrate,GstForceKeyUnitforKeyframe(), avideoscalecapsfilter change forSetSize,videorateforSetFrameRate. Probe at start which encoder actually encodes a frame and report it in/health. - VA-API and NVENC encode through the render node (
/dev/dri/renderD*) or the NVIDIA driver, not the display, so they work with Xvfb and on headless machines. The mobd user needs therendergroup for VA-API. - x264 is never used (GPL); the pipeline excludes
x264enc. FFmpeg libs are avoided for the same reason (distro builds are often--enable-gpl). - OpenH264: Cisco covers the H.264 patent royalties only for its own binary downloaded from
Cisco, so we do not bundle
libopenh264. Rely on the distro package or download Cisco's binary at install time like Firefox and Fedora do (legal check needed). Servers and VMs usually have no GPU, so here software encoding is the common case, not a rare fallback. Encoding runs only while someone watches; an unwatched desktop costs no encoder time. - Ubuntu 22.04 ships GStreamer 1.20 and may need
vaapih264enc(gstreamer1.0-vaapi) instead ofvah264enc(to verify); 24.04 ships 1.24.
- XTest (
FakeMotion,FakeButton,FakeKey) through xgb. No prompt: mobd owns the display. - Keyboard layout: mobd sets a fixed XKB layout on each desktop (
desktopKeyboardLayout, default the machine's layout, elseus). Live-viewkeymessages mapKeyboardEvent.codeto evdev codes (X keycode = evdev + 8) and stay physical, which is whatcodemeans. Agentkey("a")resolves the keysym through the known keymap, so letters are right whatever the layout. - Unicode text (live-view
text, agent typing): for keysyms missing from the keymap, map a spare keycode withXChangeKeyboardMapping, press, restore (as xdotool does). CJK and emoji work this way because the keymap is ours. - Cursor: position from
QueryPointerfor thecursormessage. XFixesGetCursorImagealso gives the cursor shape, which macOS cannot; sending it to clients is a later option. - Click(count): presses within the double-click time, as on macOS.
- ListWindows: EWMH
_NET_CLIENT_LIST_STACKING,_NET_WM_NAME,_NET_WM_PID,WM_CLASSasApp, frame geometry,_NET_WM_STATE_HIDDENfor on-screen. Works fully on X11, unlike Wayland. - OpenApp: match the target against desktop entries (
XDG_DATA_DIRS,~/.local/share/applications; desktop ID orName=, case-insensitive), else an executable onPATH. mobd serve launches it itself with the desktop's environment, in the desktop's cgroup (apps/in its scope) and its own session, not the turn's process group: the runner's group is killed when a turn is cancelled (internal/runner/cli/cli.go), and apps opened throughopen_appshould survive it. Apps the agent starts from its shell must detach (setsid, output redirected) to outlive a cancelled turn; the MCP instructions say so. The MCP argumentname_or_bundle_idkeeps its name; its description says "desktop file ID" on Linux.
A virtual desktop never sleeps or locks: State() is always awake and unlocked, KeepAwake is a
no-op, and the macOS lock-screen rules do not apply.
mobd no longer needs a graphical login session. It runs as a systemd unit; today
internal/service/service.go fails unless GOOS == darwin, so a systemd Manager is new work
(phase 0).
- Default:
systemd --userunit with linger.mobd startwrites~/.config/systemd/user/mobd.service(ExecStart=<exe> serve --config ~/.mobd/service.json,Restart=on-failure, capturedPATH) and enables linger (loginctl enable-linger), so mobd starts at boot without anyone logging in. Agents run as the user, with theircodex/claudelogins, git and SSH keys.--login=systemctl --user enable;stop= stop + disable;logsfollows~/.mobd/mobd.log(the unit appends to it, as on macOS).restartand upgrades leave desktops running; mobd re-attaches to them. Keep capturingPATHand absolutecodex/claudepaths atstart, asservice.godoes (nvm and~/.npm-global/binare missing from systemd). - Option: dedicated user for servers: a
mobdsystem user (home/var/lib/mobd) with linger runs the same user unit in its own user manager (mobd setup-system-user, shipped by the.deb). A system unit insystem.sliceis not used: it could not move runners into desktop scopes under a user manager, and its own cgroup would take the desktops down with it (design). The runners must be logged in as that user. mobd stopand desktops: desktops are not mobd's children, so stopping mobd does not end them by itself. With desktops open,mobd stopasksClose 3 desktops (2 asleep)? Open windows will be lost; files and browser profiles are kept. [y/N]. No (the default) stops mobd and leaves the desktops as they are; the nextmobd startre-attaches. Yes closes them first.--close-desktops/--keep-desktopsanswer without a prompt (scripts, no terminal: keep). Session data is never deleted.- Uninstall:
apt remove mobd(the.debprerm) and the tarball's uninstall step stop mobd and close every desktop;~/.mobdand<dataDir>/desktops(profiles, downloads) are kept.apt purgekeeps user data too; the docs say which directories to delete by hand. - Desktop supervision: each desktop runs in its own systemd transient scope
(
mobd-desktop-<session>.scope, created over D-Bus withStartTransientUnitunder the user manager,Delegate=yes): Xvfb, then dbus-daemon, then openbox (each waits for the previous one: Xvfb readiness via-displayfdor by connecting). The scope gives the freezer, per-desktop memory accounting (memory.current) and lets the desktop outlive mobd. Runners of that session's turns start in a child cgroup of the same scope, so the turn-cancel kill (process group,internal/runner/cli/cli.go) still works and the runner's shell-started apps sleep with the desktop. Requires cgroup v2 (default on every supported release).- Xvfb or dbus-daemon exits: the desktop is dead. The running turn's desktop calls fail with
a clear error, live-view sessions get
endedwith the reason, an SSEdesktopevent saysclosed(reasoncrashed), and the next turn creates a new one. Three crashes within a few minutes mark the session's desktop failed until the next turn (threshold to tune). - openbox exits: restarted in place; X clients survive a WM restart.
- The kernel OOM killer may kill an app inside a desktop (usually a browser tab or the
browser); the desktop continues and the apps show it. Apps and runners get a raised
oom_score_adj(an unprivileged user manager can raise scores but not lower them (to verify)), so mobd and Xvfb are the last to go.
- Xvfb or dbus-daemon exits: the desktop is dead. The running turn's desktop calls fail with
a clear error, live-view sessions get
- Display numbers: allocated from
desktopDisplayBase(default 100) upward, skipping numbers with a live/tmp/.X<N>-lock, so mobd displays are easy to recognize and never collide with a real:0. Each desktop gets a random MIT-MAGIC-COOKIE in its own Xauthority file: Xvfb also listens on the abstract socket@/tmp/.X11-unix/X<N>, so without a cookie any local user could connect. - Re-attach at start: mobd records each desktop (
display, scope, pids, Xauthority, bus, state) in<dataDir>/desktops/<sessionId>/desktop.json. At startup it re-attaches to every recorded desktop whose scope is alive and whose Xvfb answers with the recorded cookie, keeping its state (an asleep desktop stays asleep). Records whose processes are gone (after a reboot) are marked closed and their lock, socket and runtime files removed; their sessions start a new desktop on the next turn. Desktops of sessions that no longer exist are closed. mobd touches nothing it did not record. - Runtime directory:
$XDG_RUNTIME_DIR/mobd/d<N>(0700; bus socket, Xauthority), or<dataDir>/run/d<N>whenXDG_RUNTIME_DIRis unset. Paths stay short for the 108-bytesun_path.
Desktops no longer compete, so the global "one desktop, FIFO" rule becomes:
- One running turn per conversation: already enforced (
ErrSessionBusy). maxRunningkeeps its name and meaning, "turns running at once across all sessions", but now limits CPU, memory and API use, not desktop access. Its default stays 1 on macOS and becomes 4 on Linux when session desktops are on (to tune);mobd initmust then stop writing"maxRunning": 1into new configs (internal/config/config.goInit)./healthkeeps reporting it.maxDesktops(new,MOBD_MAX_DESKTOPS, default0= no cap): an optional hard cap for admins who want one. At the cap a turn that needs a new desktop waits; mobd never closes another desktop to make room.desktopSleepAfter(new, default10m),desktopSize,desktopScale,desktopKeyboardLayout,desktopDisplayBase: as above.
When a turn is dispatched (scheduleLocked): an asleep desktop of its session is woken; a session
without a desktop gets a new one unless the memory guard or maxDesktops says no, in
which case the turn stays queued with the reason ("waiting: the office machine is low on memory").
Turns whose session already has a desktop may pass it, so one waiting turn does not block the
queue.
Desktops are only closed by the user, so memory is managed by telling the user, not by closing desktops:
- Usage per desktop comes from its cgroup (
memory.current), the machine's from/proc/meminfo(MemAvailable) and pressure from PSI (/proc/pressure/memory). - Low (warning):
MemAvailablebelowmemoryWarnPercent(proposed 15%) or sustained memory pressure./healthgets amemorycheck with the detail,GET /eventssends amemoryevent, and the apps show a banner: "The office machine is low on memory. Close the desktops or delete the conversations you no longer need." with the desktops listed largest first, each with Close desktop and Delete conversation. - Critical: below
memoryFloorPercent(proposed 5%) mobd starts no new desktops; turns that need one wait (above). Running and asleep desktops are untouched. - systemd-oomd (active by default on Ubuntu desktop installs) may kill a whole desktop's scope
under memory pressure, which loses its windows. mobd does not change it (that needs root);
mobd desktops doctorwarns when it is active, and users who want to exclude mobd can add a drop-in foruser@.servicewithManagedOOMMemoryPressure=auto(to verify the exact setting) or raiseManagedOOMMemoryPressureLimit. - Swap or zram lets the kernel move asleep desktops out of RAM, so many more conversations can stay open; the docs recommend it (Ubuntu desktop installs have a swap file; servers often do not). Waking a swapped-out desktop takes a moment longer.
- Disk, reported the same way: mobd measures each desktop's directory (profiles, cache,
downloads; a walk every few minutes, cached) and the free space of the data dir's filesystem.
Below
diskWarnPercent(proposed 10%) ordiskWarnBytes(5 GB), whichever is lower: adiskcheck in/health, adiskSSE event and the same banner, listing conversations by disk use. BelowdiskFloorBytes(proposed 1 GB) mobd starts no new desktops. Browser wrappers cap the cache (--disk-cache-size, Firefoxbrowser.cache.disk.capacity) so caches do not dominate. - Apps learn it from mobd only: the levels and per-desktop numbers come from
/health,GET /desktopsand SSE; the apps compute nothing themselves. - Sizing: Xvfb at 1080p is ~10–20 MB plus the framebuffer (8 MB), openbox and dbus a few MB each. The browser dominates: 0.5–1.5 GB per desktop with a few tabs. Without swap, about 8–10 open conversations with a browser fit a 16 GB machine.
Each viewer is one encode; asleep desktops are never encoded. NVIDIA consumer GPUs limit concurrent NVENC sessions (a driver limit of a few sessions (to verify the current number)); VA-API has no hard limit but finite throughput; OpenH264 costs roughly one CPU core per 1080p30 stream (to measure). When a hardware encoder refuses a new session, mobd falls back to the next encoder for that stream. Sharing one encode among viewers of the same desktop and size is a later optimisation.
- Runner env: today codex and claude get
os.Environ()(internal/runner/codex/runner.go,internal/runner/claude/runner.go) andmobd mcpgetsMOB_API,MOB_TASK_ID,MOB_TASK_TOKENthroughMCPEnv(internal/api/media.gorunOptions). Runners launched for a session additionally getDISPLAY,XAUTHORITYandDBUS_SESSION_BUS_ADDRESSof that session's desktop (XDG_RUNTIME_DIRstays the user's, sosystemctl --userand agents keep working), and a per-sessionbindirectory first onPATH(browser wrappers, below). This needs arunner.Options.Envfield. - Desktop calls are forwarded.
mobd mcpis its own process and callsinternal/desktopdirectly (hostDesktop,internal/mcpserver/server.go). On Linux it uses aproxyBackendthat sendsScreenshot/Click/Key/TypeText/ListWindows/OpenApptoPOST /internal/tasks/{id}/desktop/{op}on mobd serve, authenticated with the task token likeaskdoes (internal/mcpserver/ask.go, route next to/internal/tasks/{id}/askininternal/api/server.go). mobd serve maps the task to its session and routes the call to that session's desktop. Tokens exist only while a turn is dispatched (runTaskdeletes them), so a finished turn cannot drive a desktop. - Browser profiles: apps start with no logged-in state, and Chrome and Firefox lock a profile
to one running instance. Worse, launching Chrome with a profile already open on another display
opens the window in the existing process, on the other desktop. So every session gets its
own profiles under
<dataDir>/desktops/<sessionId>/profiles/:- per-session wrappers for
google-chrome,chromiumandfirefoxonPATHadd--user-data-dir=…/--profile … --no-remote;OpenAppuses the same wrappers. Tools that manage their own browser (Playwright, Chrome DevTools MCP) are unaffected. - seed profile (optional):
desktopBrowserSeedpoints at a prepared profile that is copied (without lock and cache files) when a session's profile is created, so sites the user logged into once are logged in for every new conversation. There is no keyring on a virtual desktop, so the wrappers pass--password-store=basic; a seed must be created the same way or Chrome cannot decrypt its cookies. The seed is made from a conversation: log in to the sites in any conversation's desktop, close its browser, then "Use this browser profile as the seed" in the apps (ormobd desktops seed <session>). Profiles are copied, never shared: two running browsers cannot use one profile. - profiles survive sleep, closing the desktop and reboots, and are removed with the session.
- per-session wrappers for
- HOME and XDG dirs: shared by default. A per-session
HOMEorXDG_CONFIG_HOMEwould isolate apps but would also hide the runners' and tools' logins (ghkeeps its token in~/.config/gh).desktopIsolateConfig: truecan later give each session its ownXDG_CONFIG_HOME/XDG_CACHE_HOME/XDG_STATE_HOMEseeded with chosen shared entries. - Downloads: the wrappers point browser downloads at
<sessionDir>/Downloads(mechanism to verify per browser), so files stay with the conversation. - Isolation: all desktops run as the same Unix user. Each desktop has its own X cookie, bus and clipboard, so they do not interfere by accident, but an agent can read another session's profile or Xauthority file. This is not a security boundary (on macOS all tasks share one desktop today). Later option: a pool of per-session Unix users, which needs root to start runners.
- Cleanup: deleting a session removes
<dataDir>/desktops/<sessionId>(profiles, downloads, state) after closing its desktop; archiving closes the desktop and keeps the files and profiles./tmpstays shared.
Gated by a new /health feature sessionDesktops; without it (macOS, Windows) clients behave
as today.
POST /streambody gains"sessionId". WithsessionDesktopsit is required: 404 for an unknown session, 409 "the conversation has no desktop yet" when none exists. It wakes an asleep desktop, and a viewer keeps it awake. When the desktop stops, the session getsendedwith the reason. The stream manager today takes one globalStart/Display/NewInput(internal/api/server.goNew); these become per-desktop.GET /screen?sessionId=…: same rule, except that an asleep desktop is not woken: mobd returns its last frame withX-Mob-Desktop-State: asleep.GET /desktops:{desktops: [{sessionId, title, display, width, height, scale, state, memoryBytes, diskBytes, startedAt, lastUsedAt, activeTaskId, viewers}], memory, disk}.DELETE /desktops/{sessionId}closes one (besides archiving or deleting the conversation).POST /desktops/{sessionId}starts or wakes one without a turn, so a user can log in somewhere before the agent runs.- SSE:
GET /eventsgainsdesktopevents{sessionId, state: starting|running|asleep|waking|closing|closed|failed, reason}(a crash isclosedwith reasoncrashed) andmemoryevents{level: ok|low|critical, availableBytes, totalBytes}anddiskevents{level, freeBytes, totalBytes}. /health: addsdesktops: {count, asleep, memoryBytes, diskBytes},maxDesktops, andmemoryanddiskchecks. The macOS permission checks are generalized to backend checks: on Linuxxvfb,windowManager,dbus,encoder(detail e.g. "vah264enc (VA-API)" or "openh264enc (software)"), andfonts(a warning; see Packaging).accessibilityandscreenRecording(internal/api/health.gopermissionChecks) are reportedokwith detail "not needed on Linux" so API v3 clients show no false warning;displayreports the desktop cap instead of sleep/lock.mobd desktopsCLI (over the control socket, likemobd clients):mobd desktops list: session, title, display, state, memory, disk, uptime, last used;mobd desktops close <session>(asks;--yes),mobd desktops wake <session>;mobd desktops logs <session>: Xvfb, openbox and dbus output, kept per desktop in<dataDir>/desktops/<sessionId>/logs/(rotated, 1 MB each) along with crash reasons;mobd desktops doctor: checks Xvfb, openbox, dbus, cgroup v2 and the freezer, encoders, fonts and locale, and prints what to install or fix.
- Clients: with
sessionDesktops, the live view follows the open conversation: opening another conversation re-POSTs/stream(one session per client already replaces the old one). Before the first turn it shows "no desktop yet; it starts with the first turn". A conversation's menu gets Close desktop (confirming that open windows will be lost and a running turn stopped); the chat list marks conversations with a running or asleep desktop; the low-memory banner lists desktops by memory. Archiving and deleting a conversation warn that its desktop closes too. - macOS unchanged: one desktop,
sessionIdaccepted and ignored, nosessionDesktopsfeature, FIFO desktop queue withmaxRunning1. - MCP text: instructions and tool descriptions stop saying "office Mac", "Quartz",
"pasteboard + Cmd+V" and "bundle id" off macOS (
internal/mcpserver/server.go); on Linux they tell agents to usectrl+c/ctrl+vand that the desktop is theirs for the conversation.
- The physical screen of the Linux machine is neither watched nor controlled. On Wayland this is impossible without a portal dialog or private compositor APIs, which is why this plan avoids it entirely.
- Later, opt-in: attach to an existing X11 display (
desktopMode: "attach", withDISPLAYandXAUTHORITYof a logged-in X11 session). One shared desktop, the macOS FIFO queue andmaxRunning1 come back. Same capture/input code. - GPU inside Xvfb: none. GL is Mesa llvmpipe; browsers fall back to software compositing and SwiftShader WebGL. Pages work but use more CPU; WebGL-heavy sites and video are slow; WebGPU is off. Later options: Xorg with a real GPU driver headless, or VirtualGL.
- Desktop size per conversation: fixed
desktopSizefor everyone in v1, also when watched from a portrait phone. A per-conversation size (a new desktop) can come later. - Audio: each desktop runs its own PulseAudio server with one virtual output, named in the
agent's environment; the live view plays it over WebRTC. Optional: without
pulseaudiodesktops are silent. See desktop audio.
-
Networking: TCP listen port and UDP
streamPort9527 as on macOS. The.debdoes not touch the firewall; docs giveufw allow 9527/udpandfirewall-cmd --add-port=9527/udp --permanent. Tailscale works the same (tailscale serve/ Funnel for the WebSocket path, UDP over the tailnet). On a server without a desktop, host-only ICE candidates still cover LAN and tailnet addresses. -
Supported distributions: Ubuntu 22.04 and 24.04, Debian 12 and 13, amd64 and arm64. These get the
.deb, CI tests and support. The glibc floor is 2.35 (Ubuntu 22.04); Debian 12 has 2.36. -
Other distributions (Fedora, RHEL/Rocky/Alma, Arch, openSUSE, …): not packaged or tested. A guide,
docs/linux-build.md(written in phase 4), tells users how to do it themselves:- build: Go, a C compiler,
pkg-configand the GStreamer development headers, thenmake build(cgo links the system GStreamer, so the binary matches their glibc); - runtime packages by name per family (e.g.
xorg-x11-server-Xvfb,openboxfrom EPEL on RHEL,gstreamer1-plugins-bad-free,openh264from Cisco's repository on Fedora/RHEL); - the systemd user unit and linger, cgroup v2 check, firewall (
firewall-cmd), SELinux notes; mobd statusand/healthchecks to confirm the setup. The tarball (built on Ubuntu 22.04) also runs where glibc ≥ 2.35 and the libraries are present.
- build: Go, a C compiler,
-
Packages: keep the R2 layout and add
linux-x86_64/linux-aarch64keys torelease.json.mobd_<v>_linux_amd64.tar.gz/_arm64:mobd, LICENSE, README, unit templates; SHA256SUMS.mobd_<v>_amd64.deb/_arm64.deb:/usr/bin/mobd, the disabled system unit. Depends:xvfb,openbox,dbus-x11(ordbus-daemon),xkb-data,x11-xkb-utils(setxkbmap),gstreamer1.0-plugins-base,gstreamer1.0-plugins-bad(va, nvcodec, openh264 elements). Recommends:fonts-dejavu,fonts-noto-cjk(a bare Xvfb machine has almost no fonts, so pages render boxes),xdg-utils,gstreamer1.0-vaapion 22.04. Suggests: a browser.- Built with cgo (GStreamer shim) on
ubuntu-22.04for the glibc floor (2.35) andubuntu-24.04-arm. GStreamer is linked dynamically, never bundled. AppImage is not planned.
-
Install:
install.shgains a Linux branch (today it exits on anything but Darwin arm64): detectuname -s/-m, download the tarball, check SHA256 fromrelease.json, install into~/.local/bin, print theapt installline for the dependencies, and offermobd start. -
CI can run real end-to-end desktop tests. Xvfb needs no GPU, no display and no login, so a hosted
ubuntu-24.04runner gets exactly the environment production uses. This is a big change from macOS, where desktop tests need a logged-in Mac with TCC grants (internal/stream/desktop_darwin_test.gocannot run on hosted runners). A CI job installsxvfb openboxand an OpenH264 build (CI does not ship it, so the licensing question does not arise there), startsmobd servewith a fake runner and checks, on every pull request:- a turn creates a desktop,
xtermopens throughopen_app, and click, key, Unicode text, paste andlist_windowsthrough the MCP proxy change what a snapshot shows; cmd/stream-probereceives and decodes a stream for the session, over WebRTC and with-ws, with-pli,-clickand-type;- two sessions run at once on separate displays; sleep after a short
desktopSleepAfterand wake with windows intact (a counter in anxtermdoes not advance while asleep); a busy background process or a changing screen keeps it awake; archive, close and delete end the desktop; the memory guard with a low fake threshold; killing Xvfb mid-turn; restarting andkill -9of mobd re-attach to running and asleep desktops.
The mob clients can also be tested end to end against a Linux mobd in CI. Hardware encoders (VA-API, NVENC) still need manual or self-hosted runs.
- a turn creates a desktop,
-
Manual matrix (extend
docs/office-smoke-checklist.md): Ubuntu 24.04 and 22.04, Debian 12, desktop PC with Intel VA-API, NVIDIA NVENC, a GPU-less VM; several sessions watched at once; Chrome and Firefox with a seed profile; HiDPI scale 2;stream-probefirst-picture time, bitrate and fps against the macOS baseline.
Phase 0 changes code that all three platforms run, not only the new ones:
| Phase 0 item | macOS | Linux | Windows |
|---|---|---|---|
| Desktop provider between the API and the desktop | one shared desktop, behaves as today | one desktop per conversation | one shared desktop |
| Service manager interface | launchd (today's code moves behind it) | systemd user unit | per-user logon task |
| File locking, runner process kill | Unix version (today's code) | Unix version | new: LockFileEx, Job Objects |
| Control socket | Unix version | Unix version | new: AF_UNIX file with an ACL |
Config and data folders per OS (config.Dir()) |
~/.mobd, data in ~/Library/Application Support/mob (unchanged) |
~/.mobd, data in ~/.local/share/mob |
%LOCALAPPDATA%\\mobd (Windows) |
| Health checks per platform | Accessibility, Screen Recording (as today) | Xvfb, openbox, dbus, encoder, fonts | Windows checks |
| Shared H.264 cleanup and frame delivery | moves out of stream_darwin.go, used by macOS too |
used | used |
| Key tables per OS | macOS table (today's keys.go) |
Linux table | Windows table |
Agent desktop calls through mobd serve (MCP proxy) |
optional (MOB_DESKTOP_PROXY=1, off by default) |
always | always |
Phase 0 is mostly a restructuring of today's macOS code: new interfaces with the current behaviour
behind them, then the Linux and Windows implementations. It can break macOS, so every phase 0 step
must pass the macOS tests, and before merging it is checked on a real office Mac (live view, agent
clicks and typing, pairing, mobd start/stop).
These macOS-only assumptions block both Linux and Windows; each is cited so the work list is concrete.
- Build:
GOOS=linux CGO_ENABLED=0 go build ./...succeeds today.GOOS=windowsfails ininternal/pairing/store.go(syscall.Flock) andinternal/runner/cli/cli.go(Setpgid,syscall.Kill);internal/control/control.go(Flock,Stat_townership check) andinternal/servicefollow. Work: aninternal/filelockpackage (flock /LockFileEx),control_unix.go/control_windows.go,proc_unix.go/proc_windows.go(Job Objects). - Service: one
Managerinterface with launchd (today), systemd (this plan) and Scheduled Task (Windows) implementations, sharing the preflight checks andservice.json. - Paths: one
config.Dir()per OS (~/.mobdon macOS and Linux). - Desktop per session:
desktop.Current()is one process-wide backend today (internal/api/server.goNew). Adesktop.Providerreturns the backend for a session: macOS and Windows return the single one, Linux the session's desktop. - Desktop proxy:
proxyBackendformobd mcpand the/internal/tasks/{id}/desktop/{op}routes (above). Required on Linux, used on Windows too so both behave the same; macOS keeps direct calls whenMOB_APIis unset (to decide). - Shared stream code in
internal/desktop: an Annex B normalizer (AUD first, SPS/PPS before IDR,Keyset) and the delivery and drop logic now instream_darwin.go(16-unit buffer, drop deltas until the next keyframe), pure Go, tested with theh264_test.gohelpers. - Keys: per-OS tables keyed by
KeyboardEvent.code(internal/desktop/keys.goholds macOS key codes today);commandmeans Super on Linux and Win on Windows,optionmeans Alt; addsuper/winaliases. - Errors and health:
ErrUnsupportedsays "only supported on macOS" andunavailable()mentions the "office Mac" (internal/desktop/desktop.go,screen.go);/healthhard-codes macOS TCC checks. Both become per-backend.
Rough effort assumes one engineer familiar with the codebase.
| Phase | Scope | Effort |
|---|---|---|
| 0. Portable core | the list above. Result: mobd runs runners on Linux and Windows (no desktop), GOOS=windows builds, and macOS behaves as before. |
1.5–2 weeks |
| 1. Desktop manager | systemd scopes, Xvfb/openbox/dbus supervision, mobd stop/uninstall handling, mobd desktops, per-desktop logs, locale, disk guard, display numbers, Xauthority, re-attach after restart, sleep and wake (cgroup freezer), close and delete, runners in the desktop's cgroup, memory guard, /desktops, SSE events, health checks, systemd unit. |
2.5–3 weeks |
| 2. X11 backend | xgb capture and snapshots, XTest input, key tables, Unicode, clipboard, EWMH windows, OpenApp, MCP text, CI desktop tests. |
1.5 weeks |
| 3. Streaming | GStreamer shim, encoder probe and fallback, per-session POST /stream and /screen, stream-probe in CI. |
1.5–2 weeks |
| 4. Agent environment and release | browser wrappers, per-session profiles, seed profile, downloads, .deb and tarball, install.sh, CI release matrix, linux-build.md for other distributions, docs. |
1–1.5 weeks |
| 4b. Clients | mob, mob-ios, mob-android: live view per conversation, running/asleep state, Close desktop, archive/delete warnings, memory and disk banners, pausing an unattended view, stopping when hidden or in the background. Each app's docs are updated when this ships. | 1.5–2 weeks |
| 5. Later | cursor shape, shared encodes, attach mode, per-session users, GPU. | as needed |
Linux first remains the recommendation: phase 0 is mostly Unix code that already works, there are no permission prompts or code-signing costs, and every desktop path is testable in CI.
- Memory: desktops are never closed automatically, so open conversations accumulate. Asleep desktops cost no CPU but keep their RAM. Mitigated by swap, the low-memory banner and the critical floor that stops new desktops; it depends on users acting on the reminder. CPU: browsers on software rendering and software encoding on GPU-less machines; encoding runs only while watched.
- Encoder variability: VA-API driver differences (Intel iHD vs i965, Mesa AMD), NVENC session limits. Probe at start, fall back per stream.
- OpenH264 licensing: cannot be bundled; on GPU-less servers it is the only encoder.
- Apps that assume a full desktop session: no keyring, no portal, no notification daemon, no GPU. Some apps may warn or misbehave (to collect while testing).
- Lost windows on reboot: a machine reboot (or an Xvfb crash) loses open windows and unsaved state; only profiles and files survive. Pages may need a reload after waking from sleep.
- Same-user isolation: sessions can read each other's files and profiles.
Browser profilesdecided: one per conversation, copied from a seed made from a conversation; never shared.desktopSleepAfter10 min anddesktopSleepCPU2% of a core (proposed)? Stop new desktops at 5% available memory (proposed; the 15% warning is decided)?- Should every turn get a desktop, or should clients be able to mark a turn "no desktop"?
- Should mobd ever support the physical desktop (attach to an X11 display; Wayland is out)?
- Service default:
systemd --userwith linger (proposed) or a system unit with a dedicated user? - OpenH264: download Cisco's binary at install, rely on the distro package, or refuse to stream without a hardware encoder?
- Desktop keyboard layout: fixed
us, configurable, or follow the client? - Should the live view map a Mac client's Cmd to Ctrl when the desktop is Linux?
- Should
mobd mcpuse the desktop proxy on macOS too (one code path)?