Skip to content

watch: picture-in-picture live view with bundled noVNC and separate take-control #207

Closed

Description

@ElbertePlinio

Why

Users want to glance at what the agent is doing without it interrupting their own work, the way ChatGPT Atlas shows a live agent view you can watch and take over. The lab already runs on an owned Xvfb that never appears on the desktop, so the only way to see it is a viewer window. Today pickforge watch needs an external VNC client, which is often not installed (none on the dev machine), and TigerVNC cannot scale, so a small window would just be a cropped desktop with scrollbars.

Costs the agent nothing: frames never reach the model. Only host CPU while the viewer is open.

Design

One window with two sizes. Small corner thumbnail, scaled, passive, does not automatically take focus. Click expands it to full size. Expansion consumes the click and never grants control; "Take control" is a separate action that goes through the existing takeover lease (packages/desktop-linux/src/takeover.ts), which restarts x11vnc writable. Flipping noVNC's client-side view-only flag is not control.

Viewer: bundled pinned @novnc/novnc assets served by the CLI on loopback, a Node bridge (node:http, node:net, ws) from WebSocket to the session's x11vnc TCP port, opened with chromium --app=URL (or google-chrome) so the window is chromeless with a stable class; Firefox is an ordinary-window fallback. Keep the existing x11vnc. Do not use -enablehttpproxy, it is HTTP CONNECT support, not WebSockets. Node, not Bun: the published CLI targets Node.

Always-on-top comes from the compositor, never the app (no Wayland API; Tauri, GTK and Chrome PiP silently fail). Hyprland is the tested adapter: install a narrowly matched runtime rule (float, pin, no_initial_focus, size, move) before launch, since no_initial_focus is static and evaluated at window open, and remove only that rule afterwards. Precedent: Omarchy's webcam overlay. Everywhere else ship an ordinary resizable window. Auto-open reuses viewer.mode: auto and stays CLI-only; MCP never launches host GUI.

Revised 2026-09-25 after an independent Astra review. A native Rust viewer (winit + softbuffer + x11rb reading the owned Xvfb, or winit + vnc-rs against x11vnc) is feasible and would remove x11vnc and the browser, but npm installs do not ship the Rust binary and Pickforge would own capture, scaling, cursor composition, keyboard mapping and stuck-button cleanup. Decide on it only after measuring v1 CPU. Tauri/WRY for noVNC is out (drags in GTK and WebKitGTK). Xvfb -fbdir is a later optimization, not a capture shortcut.

Decided 2026-10-03 for the takeover increment: "Take control" starts a second, writable x11vnc on a private Unix socket (-unixsock in a 0700 directory, -rfbport 0), reached only by the controlling bridge connection. The read-only server keeps serving every other watcher, so they never inherit writable access and the thumbnail stays live during control. This replaces restarting the shared x11vnc writable. The lease, watchdog and recovery must also own and stop the writable daemon, so it never outlives its lease.

Checklist

Non-goals

  • Native Rust viewer, -fbdir, Android streaming, KDE/GNOME pinning guarantees, XWayland fallback promises. Follow-ups after v1 is measured.
  • Any change to input or capture paths. The real desktop pointer is never touched.

Refs #15 (viewer design), #21 (takeover), #199 (agent cursor overlay).

Activity

  1. added
    enhancement
    on Sep 25, 2026
  2. ElbertePlinio commented on Oct 3, 2026

    @ElbertePlinio
    MemberAuthor

    Kickoff notes before implementation. These findings change parts of the design.

    • Chromium on Wayland ignores --class for --app windows. It derives the app_id from the URL host and path plus the profile name, not the port or fragment. Each launch therefore gets a unique page path, /viewer/<launchId>, and the Hyprland rule matches that identity. X11 still honors --class.
    • A second Chromium launch into a profile that is in use hands off and exits in about 0.1 s. Each launch gets a fresh private profile, so the launched process owns the window.
    • Hyprland 0.56 with a Lua config rejects hyprctl keyword. Runtime rules go through hyprctl eval and hl.window_rule({name=...}). Lua has no delete, so cleanup disables the named rule; it stays registered until a config reload. The adapter applies only when hyprctl -j status reports configProvider: "lua". Hyprlang configs get an ordinary window for now.
    • window.resizeTo changes Chromium's own idea of its size but not the real Hyprland window. Expand and collapse therefore go through a compositor resize from the bridge, with resizeTo as the fallback elsewhere.
    • The token travels in the URL fragment and is required for the WebSocket and the window API. Static assets are allowlisted and need no token, because the fragment is never sent.
    • The bridge reaches VNC only through a check that holds the session VNC lock across record check and connect. It refuses a writable server, so a takeover cannot swap the server between check and connect.
    • Take-control increment: research recommends a second writable x11vnc on a private Unix socket for the controlling connection only, while the read-only server keeps serving other watchers. That differs from "restarts x11vnc writable" in the design above, so it needs a decision before the second PR.

    Plan: PR 1 covers the passive viewer, -nosel, lifecycle, launcher, Hyprland adapter, benchmarks and docs. It refs this issue. The take-control increment stays the second PR.

  3. ElbertePlinio commented on Oct 3, 2026

    @ElbertePlinio
    MemberAuthor

    Cursor visibility in the live view moved here from #200 by maintainer decision. The human overlay is the primary lever.

    Findings from the #200 design brainstorm:

    • A viewer overlay fed by verified pointer events through a local read-only channel can draw the agent pointer outside the captured surface. Hide stale or unverified positions.
    • On bare Xvfb, x11vnc first supplied its own 18x18 arrow. With its XFIXES startup delay disabled, it supplied the real 16x16 root X cursor. So the viewer cursor and the maim capture cursor can differ.
    • A client that advertises cursor shape and position gets both separately. A shape-only client gets no remote position.
    • -nocursorshape embeds the cursor in VNC framebuffer updates, also for clients that advertise shape support. It does not change the X framebuffer, so it is a safe compatibility option. Keep the loopback and read-only flags.

    The root cursor capture policy for model frames is #232.

  4. ElbertePlinio commented on Oct 3, 2026

    @ElbertePlinio
    MemberAuthor

    Status: PR #225 implements the passive viewer, the first part of this issue. CI is green at b0e9661, and PickCheck and a device pass are done. The PR is open, not merged, and waits on two maintainer decisions.

    1. One review finding stays open after three repair rounds. When the browser's pid cannot be written to the launch record right after launch, a browser helper that ignores SIGTERM can outlive cleanup, and teardown later deletes its profile. Details are in the PR body.
    2. The PR adds a token-gated loopback server and changes what pickforge-lab watch opens. That needs a human merge decision.

    The take-control increment (second PR) needs a design decision first. Research recommends a second writable x11vnc on a private Unix socket, used only by the controlling connection, while the read-only server keeps serving other watchers. The design above says to restart x11vnc writable, which would expose writable access to every connected watcher.

    Follow-ups filed from this work: #226, #227, #228, #239.

  5. ElbertePlinio commented on Oct 28, 2026

    @ElbertePlinio
    MemberAuthor

    The take-control increment moves to #341, on a native viewer instead of a second writable x11vnc (owner decision in #338). The noVNC viewer from #225 stays as a watch-only fallback. This issue closes when #341 merges.

  6. ElbertePlinio commented on Oct 28, 2026

    @ElbertePlinio
    MemberAuthor

    The take-control increment shipped in #372. Per the owner decisions in #338, the native viewer from #340 takes control through the existing human lease instead of a second writable x11vnc. noVNC stays as the watch-only fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions