Galaxy Shell / docs
Docs / Decisões e planos

Phone app (spec, 2026-11-02)

openspec/changes/phone-app/design.md · Editar no GitHub ↗

Esta página ainda não tem tradução em português. O conteúdo abaixo está em inglês.

Este documento registra decisões, planejamento ou evidências de uma etapa do projeto. Não implica que todos os itens estejam implementados ou validados na versão atual.

Nesta página

Phone app (spec, 2026-11-02)

Doc status: proposal. Spec of 2026-11-02, not approved; no phone output code in web-shell/core or native/smithay. Checked 2026-11-10.

Status

  • Status: proposed on 2026-11-02, revision 3 after docs review rounds 1 and 2 (see Review record). Docs only. No code of this spec exists. The user has not approved the spec yet. Each decision carries a recommended default, a reason and an alternative. The open questions at the end need an answer before the phase that they block, or the defaults apply.
  • Base: origin/main 8cd49d5 for revision 1, rebased onto 8dbb911 for revision 2 (the review round 1 fixes, see Review record). No cited code changed between the two; the line numbers are those of 8cd49d5 and 8dbb911.
  • Owner of the decisions: the user.
  • Depends on: workspaces on several outputs (phase 1 on main, phases 2 to 7 not implemented). Phases 4, 5, 6, 8 and 9 of this spec need its phase 2 (capabilities.outputChats), because the lease is live only from there. The Canvas column of the input table needs its phase 3 (Canvas on an extra output). Multi-output phase 2 needs one change for this spec: the host creates no output chat for an output with headless: true (V4). That change goes into multi-output phase 2 when it is built.
  • Terms: the phone output is the headless Smithay output of this spec. It is not the "two virtual outputs" of the nested QA option of the multi-output spec (its open question 7), which are nested test outputs.
  • Phase 0 approval also approves two boundary changes that AGENTS.md must record when phase 2 and phase 3 land: a second send path outside the protected host on the PC (the phone Conversa screen), and a second reader of notification content (the phone, T5).

The user's words (2026-11-02, Portuguese, quoted)

"teria uma forma de o usuário compartilhar o workspace com um telefone? imagino que tendo o controle do compositor pode ser que seja até melhor que soluções como vnc"

Translation: "is there a way for the user to share the workspace with a phone? I imagine that, with control of the compositor, it can be even better than solutions such as VNC."

"a sugestao de monitor virtual funcionaria como se ele tivesse um workspace próprio para trabalhar?"

Translation: "would the virtual monitor suggestion work as if the phone had its own workspace to work in?" The answer was yes: the phone is a virtual output, and under the per-output workspaces model it shows its own workspace.

"salve um spec disso"

Translation: "save a spec of this."

Then the user widened the scope:

"nao do virtual output, de um app inteiro"

Translation: "not of the virtual output, of a whole app." Asked to clarify, the user chose "App de celular completo" (a complete phone app): one app for the whole system, with the workspace, the chat, the notifications and the controls. The virtual output is one feature of that app.

Then the user asked about the web:

"seria possivel usar uma tecnologia web para poder publicar um workspace online por exemplo? entendo os riscos de segurança, só considerando a possibilidade"

Translation: "would it be possible to use a web technology to publish a workspace online, for example? I understand the security risks, I am only considering the possibility." The user said "sim" (yes) to a section in this spec. See Publishing a workspace online.

Decision summary

  • One phone app, paired with one PC, for the whole system: the chat of each workspace, tool approvals, the read-only review card, notifications, media controls and a part of quick settings, the workspace list, the lock state, and a streamed workspace.
  • The app is a protected-host-level client of the core. It is never generated HTML. It gets a narrow, typed set of routes through a new gateway process, with its own device key and short session tokens.
  • LAN first. Remote access is out of scope for the first phases. Web publishing is a late phase.
  • Platform: a native shell (Android and iOS) around a web UI in React and HeroUI, the same stack as the desktop system UI (P1).
  • The streamed workspace: a phone output of Smithay, rendered at the phone size and scale, encoded on the GPU (H.264 through VA-API, software fallback), sent over WebRTC. Touch is native input. No bar or HUD goes to the phone.
  • Everything ships behind protected settings, off by default. No agent tool, scheduled turn or generated HTML pairs a phone, starts or approves a share, or controls a stream.

Purpose and scope

Purpose

The user works with the system from the phone: talks to the agent of a workspace, answers its approvals, reads notifications, controls media, switches workspaces, and works in a workspace of its own on the phone screen. The compositor owns the scene, so the phone gets a workspace sized for the phone and native touch, which a VNC mirror of the PC screen cannot give.

Main screens

Screen What it shows and does Core source
Pareamento (pairing) Scans the QR code, shows the PC name and the verification code, keeps the connection state. New gateway routes (Pairing)
Conversa (chat) The conversation of one workspace: messages, the composer, stop, the turn state, inline components (isolated), tool approvals. /api/state, /api/send, /api/cancel, /api/approve
Workspaces The list of open workspaces, which output shows each one, select, create. /api/state, /api/select, /api/create
Revisão (review card) The pending source change card and its diff, read-only, with "Aprove no PC". GET /api/proposal, GET /api/proposal/diff
Notificações The history and the popups of the core notification server, dismiss, mark read, do not disturb, actions. /api/notifications* (notification-routes.js:18-42)
Controles Media players (play, pause, next, previous), output volume and mute. /api/quick-settings/media, /api/quick-settings/media-action, /api/quick-settings/volume (quick-settings-routes.js:28-58)
Tela (streamed workspace) The workspace of the phone output, full screen, with touch input and a small protected control strip. New stream path (The streamed workspace)
Estado de bloqueio "Bloqueado no PC" while the session is locked. No unlock. Lock status from the gateway

In scope

  • The app, the pairing, the gateway, the trust model and the routes above.
  • The phone output, the encoder, the WebRTC transport and the input mapping of the streamed workspace.
  • The mirror mode, as a separate option.
  • Publishing a workspace online, as a late phase, view-only first.
  • Push notifications, as an option, with no content in the push message.

Out of scope

  • Remote access to the paired phone outside the LAN in the phases before web publishing. A user VPN that puts the phone on the LAN is not blocked, but the spec does not configure one (open question 3).
  • Audio of the streamed workspace (open question 9).
  • Clipboard sync (open question 10).
  • An unlock of the PC from the phone. The phone never sends the lock password and gets no lock route.
  • Approvals of schedules, themes, source changes, the memory close and recovery from the phone. They stay on the PC (T4).
  • Changes to protected settings from the phone, model selection, account login, profile color, voice and window capture.
  • More than one GPU. The encoder runs on the GPU that renders.
  • Dragging windows between overview cards. Rejected by the owner (AGENTS.md); nothing in this spec adds a drag between cards.

Current state (checked at 8cd49d5)

What exists:

  • Output model. Slot is Primary or Extra(id) (native/smithay/src/outputs.rs:23). add_extra_output maps an output and runs a layout pass (outputs.rs:482-487); remove_extra_output returns its windows (outputs.rs:492). layout places every output on one row, left to right (outputs.rs:85), and clamp_pointer lets the pointer cross each shared edge (outputs.rs:107). layout_bounds maps absolute pointer devices onto all outputs (outputs.rs:146-150).
  • Per-output workspaces phase 1, behind the workspaceOutputs lease (native/smithay/src/desktop/workspace_outputs.rs): shown_on (:22), output_workspace (:35), shown_slot (:45), focus_slot (:75), focused_workspace (:85), workspace_output_command (:340) and workspace_geometry (:522). A workspace already draws in the local coordinates of the output that shows it (scene::workspace_elements, scene.rs:1392-1401). The core sends no lease in a real session until phase 2, because it asks for capabilities.outputChats too (multi-output workspaces, The lease).
  • Rendering of an extra output. The DRM backend creates each head with a GBM allocator for render and scanout (create_head, drm.rs:113-135). render_extra renders scene::secondary_elements (scene.rs:529) into the next GBM buffer with a damage tracker, flips only a damaged frame (secondary_needs_flip, drm.rs:282) and sends frame callbacks to the windows of that output (drm.rs:252-300). While locked, the scene of an extra output is its lock content or black (drm.rs:262-264).
  • Offscreen render. render_offscreen renders elements into a GlesRenderbuffer with its own OutputDamageTracker and reads it back (capture.rs:256-279). The original-resolution screenshot uses it (screenshots). This is the CPU readback path, not a zero-copy path.
  • Smithay is pinned at =0.7.0. Since step 10 of the GLES removal plan (2026-11-11) Smithay has no backend_winit: every build asks for backend_egl and backend_gbm directly, and DRM and libinput come with the session feature (native/smithay/Cargo.toml). The nested and headless backends open a GBM device on the render node only for the dma-buf self-test of the renderer (open_gpu, native/smithay/src/wgpu_output.rs); their frames go into wgpu textures, so they still have no GBM allocator for render or scanout.
  • Input. The compositor handles swipe and pinch gestures (input.rs:678-689, input.rs:973). It has no touch input and no touch, text-input, input-method, relative-pointer or pointer-constraints protocol (canvas windows, phase 4). The nested test input test_input feeds typed events through the real input path, only in the nested backend (synthetic_input.rs:1-8, MAX_TEXT 256 at :22).
  • Core network surface. The core listens on 127.0.0.1 only (web-shell/core/server.js:2359) and refuses any Host other than 127.0.0.1:<port> (server.js:788-789). Every /api/ route needs the one shell token in x-shell-token and, when present, the loopback origin (server.js:1062-1069). That token is all or nothing: it opens every route of the protected host. The launch cookie gates the pages (server.js:313-319). The lock page has its own token (server.js:297-305, lock-routes.js:62).
  • Approvals. /api/approve answers a tool permission of the live turn (server.js:1798). /api/schedule-approval (server.js:1783), /api/theme/approve and /api/proposal/approve (server.js:1380) answer the other kinds. The agent prompt says that each execute_command, open_application, open_path and memory_add_note call waits for the user's approval (web-shell/core/runtime.js:75). So a tool approval can allow a command with the privileges of the user.
  • Notifications. The core is the notification server. No model tool reads notification content, and the routes need the host token (notifications).
  • Lock. Only the lock page unlocks, after PAM (lock screen). The lock covers every output the compositor drives.
  • System UI stack. The host UI is React 19.3.1 with shadcn/ui on Base UI (shadcn/ui migration).
  • Nested QA. scripts/nested-qa.py runs one nested output with synthetic input and capture (nested QA).

What does not exist: a LAN listener, a scoped token, a device registry, a phone output, an encoder, a WebRTC stack, touch input, a text-input protocol, and a sharing indicator.

Platform

Decision P1: a native shell around a web UI (recommended). The app is a small native shell for Android and iOS that hosts a web UI in React and HeroUI, the same stack and components as the desktop system UI. Native plugins do only what a web page cannot do safely: the QR scan, the device key in the Android Keystore or the iOS Secure Enclave, the pinned TLS connection, the biometric check, the push token, and a separate WebView with no bridge for generated HTML.

Decision P3: the native plugin owns the pinned TLS (finding of review round 1). A WebView cannot pin a self-signed certificate for its own fetch or WebSocket on both platforms (the iOS WebView gives no trust callback for a WebSocket). So the WebView never opens a network connection to the PC. A native plugin opens the one TLS connection with the pin and acts as a request and WebSocket proxy; the web UI talks to it over the bridge with typed messages. The WebRTC media is not affected: DTLS-SRTP checks the fingerprint that comes over the pinned channel (The transport). The proxy reaches only the one pinned host and port of the paired PC; any other destination is refused in the plugin. The bridge exists only in the main app WebView, never in the generated-HTML WebView. Phase 1 starts with a spike on both platforms that proves the pinned proxy and the bridgeless WebView for generated HTML, with a test where generated HTML tries to call the bridge (and any plugin entry point) and fails. Fallback, if the spike fails on a platform: React Native with HeroUI Native for that platform, with the same plugin model. A Capacitor-style shell is the default (the library and version are chosen in phase 1).

Native shell + web UI (P1) React Native (HeroUI Native) Fully native (Kotlin and Swift) PWA
Fits "every visual part stays web-based" Yes. The screens are web, the same React and HeroUI code. Partly. React, but native views, not web. No. Two more native UIs. Yes.
Reuse of web-shell/ui-src components High (the same DOM components). Low (other primitives; HeroUI Native is a separate library). None. High.
Pinned TLS to a self-signed PC certificate Yes, in a native plugin that proxies every request (P3). Yes. Yes. No. The browser needs a trusted certificate or a click-through warning.
Device key in hardware Yes. Yes. Yes. No (WebCrypto keys in browser storage).
Push in the background Yes (FCM, APNs, UnifiedPush). Yes. Yes. Android yes; iOS only for a web app on the home screen.
WebRTC video Yes (WebView WebRTC). Yes (a native module). Yes. Yes.
Work to build Medium. Medium to high. High (two codebases). Low.

Reason: the rule in architecture decisions (Web visual components) is about the shell: Smithay draws no native UI, and every visual part of the system is web. The phone app is a separate device, so the rule does not bind it directly. P1 still keeps it: the phone screens are web, built from the same React and HeroUI sources, and the native code draws no UI except the platform camera view of the QR scan and the system biometric prompt. A PWA fails on the pinned certificate and the hardware key, which the trust model needs. Alternative: React Native with HeroUI Native, the fallback of the P3 spike.

Decision P2: the app UI source. The phone screens live in a new directory beside the desktop UI sources and import shared components from them. The exact path follows the HeroUI migration layout when phase 1 starts. The app bundle is built at release time and shipped inside the app; the app never loads UI code from the PC. Reason: a PC that serves the phone UI code could change it after a compromise; a bundled UI changes only with an app update. Alternative: the gateway serves the UI; rejected for that reason.

Architecture

phone app ── TLS (pinned) ──> anos-phone gateway ── private socket ──> core (loopback)
    │                              │
    └── WebRTC (DTLS-SRTP) ───> anos-stream ── private socket (dmabuf fds) ──> Smithay

Decision A1: a separate gateway process (recommended). A new process, anos-phone, listens on the LAN with TLS. The core starts and supervises it only while the protected setting phoneAccess is on. The gateway authenticates the phone, keeps the device registry, and forwards an allowlist of typed requests to the core over a private Unix socket with a new phone authority (T3). Reason: the core keeps its loopback-only listener and its one Host check (server.js:788-789, 2359). A parser bug on the LAN side runs in a process that holds no shell token and no OpenCode credential. Alternative: the core listens on the LAN itself; rejected, because one bug would reach every route of the shell token.

Decision A2: a separate stream process (recommended). A new process, anos-stream, takes frames of the phone output from Smithay, encodes them and runs WebRTC. The core starts it per approved stream session and stops it at the end. The core holds the approval, so the core creates the output (V5) and hands anos-stream only the session handle. Reason: an encoder or a WebRTC bug cannot take down the compositor, and the compositor stays free of a media stack. Alternative: encode inside Smithay; rejected for that reason.

The streamed workspace

The phone output in Smithay

  • Decision V1: a headless extra output. The compositor creates a smithay::output::Output with a wl_output global and no DRM head, on a typed control command headless_output_create {name, width, height, scale, transform, refresh} (V5). It joins the extras as Slot::Extra(id) with a new flag headless, so the per-output workspace rules apply unchanged: it shows its own workspace, windows follow their workspace (W5 of the multi-output spec), and Super+Left/Right, the wheel and the swipe step the workspace of the focus output. The snapshot reports outputs[].headless: true and capabilities.headlessOutput. The name is PHONE-1. headless_output_destroy {name} removes it with the rules of remove_extra_output.
  • Decision V2: outside the pointer row. The phone output does not join the row of outputs::layout (outputs.rs:85), clamp_pointer or layout_bounds. It gets a global position far below the row (for example y = 1,000,000), so the desktop pointer and absolute devices of the PC never reach it, and only phone input reaches it. Reason: a desktop mouse that walks onto an invisible phone screen loses the pointer. Super+Shift+Left/Right and a title bar drag do not reach it either; a window goes there only with its workspace.
  • Decision V2b: a separate seat for the phone (findings of review rounds 1 and 2). Smithay has one seat today, and a phone tap through it would make the phone output the focus output (press_focus_output, workspace_outputs.rs:99-115) and give the PC keyboard to a window that the PC user cannot see. So the phone gets its own Smithay seat, phone, created with the phone output and removed with it. It has its own pointer, its own keyboard focus, its own grabs and its own selection (clipboard and primary selection). phone_input drives only that seat; the PC seat keeps its pointer, keyboard focus, grabs, modifiers and selection. The phone seat never changes focus_output. Because the two seats do not share state, no time gate between PC and phone input is needed. Rejected alternative (revision 2): borrow the PC seat for each phone event batch and give the focus back, with a 500 ms gate after PC input. Reason: the PC seat would still see focus changes, grabs and modifier state from the phone during a batch, the PC user could not type while the phone works, and a crash in a batch could leave the PC focus on a hidden window. Rust tests: a phone drag while the PC types keeps both streams apart (each window gets only the events of its seat); a phone wl_keyboard.enter carries no PC keys or modifiers; the PC selection is never offered to a window that only the phone seat focuses, and the phone selection never reaches the PC seat; a phone tap leaves focus_output and the PC keyboard focus as they were; the phone seat goes away with the output. Open item (open question 21): how a second seat interacts with focus-follows rules and with xdg_activation (which seat an activation token belongs to), and how clients that use only the first wl_seat behave.
  • Decision V3: a workspace at creation. The phone output always shows a workspace. At creation the phone names one: a free workspace (shown on no output), or a new empty one. A workspace shown on another output moves to the phone by the W3 move rule of the multi-output spec; this is the accepted rule "a workspace shows on one output at a time". The PC sees the old output show its next workspace (or its shared grid) at once, and the indicator says "Workspace no telefone".
  • Decision V4: no HUD and no chat window on the phone output. No bar, quick settings, notification popup, tray menu, web panel or overview goes to the phone (the "exceto HUD" rule of monitor 2). The output chat of the phone workspace is not a host window on the phone output: the Conversa screen of the app is that chat. The compositor reserves no chat cells there. A Canvas workspace on the phone has no floating chat window either. Multi-output phase 2 must skip outputs with headless: true when it creates output chats.
  • Decision V5: the core creates the output, bound to one stream session (finding of review round 1). After the PC approval (S1), the core sends headless_output_create on its own control connection with a new session key (256 bits). The compositor binds the output to that key. The core starts anos-stream and gives it the key through an inherited fd. anos-stream opens a second control connection and sends stream_attach {key}; the compositor accepts one attach per key and then sends frames and takes phone_input only on that connection. When that connection closes, or the core sends headless_output_destroy, the compositor destroys the output. A key is single use and dies with the output. Without stream_attach within 10 s of the create, the compositor destroys the output and the core ends the session.
  • Size and scale. The phone sends its viewport in physical pixels and its device pixel ratio. The output mode is that size, capped to 1920 pixels on the long side by default (open question 6), and the output scale is the ratio rounded to an integer (2 or 3). Fractional scale follows the canvasSharpZoom rule of today, because the compositor offers fractional scale only with that setting.
  • Rotation. An orientation change of the phone sends a new mode with width and height swapped, after a 300 ms debounce. The compositor changes the output mode as for a mode change of a real head, and clients get a configure. The phone shows the last frame scaled until the first frame of the new mode comes.
  • Render path (DRM backend). The phone output renders scene::secondary_elements with its own damage tracker into a small pool (3 buffers) of GBM buffers from the same GBM device, with a modifier that the encoder can import (LINEAR as the fallback). Only a damaged frame goes out, at most at the phone refresh. Each sent frame carries its buffer index, its dmabuf fd (sent once per buffer), its damage rectangles, a timestamp and a sync file fd of the render fence over the private stream socket. anos-stream waits on the fence before it reads, and sends release {index} when the encoder no longer reads the buffer (after the encoder import, or after the CPU upload). The compositor renders only into a released buffer; with no released buffer it skips the frame and keeps the damage for the next one. Release watchdog: when no buffer comes back for 2 s, the compositor ends the stream session as a lost connection. Phase 5 tests: no render into an unreleased buffer, a skipped frame keeps its damage, a lost connection releases every buffer, and a read waits on the fence. Frame callbacks go to the windows of the phone output after each render, as render_extra does (drm.rs:288-295).
  • Render path (nested backend). The nested build has no GBM (Cargo.toml features). The phone output renders with render_offscreen (capture.rs:256) and sends the pixels through shared memory (a memfd per buffer, with the same release rule). This path is slow; it exists for nested QA only. anos-stream takes both frame kinds: dmabuf on DRM and shared memory in nested.
  • Lock. While locked the phone output renders black, as every extra output does (drm.rs:262), and the stream stops at once (S5).

The encoder pipeline

  • Decision E1: GStreamer in anos-stream (recommended). The stream process imports each dmabuf into a GStreamer pipeline: VA-API color conversion to NV12 on the GPU, then the VA-API H.264 encoder (vapostproc and vah264enc of the va plugin), then webrtcbin. Low-latency settings: no B-frames, constrained baseline or main profile, CBR or VBR with a cap, a keyframe on a picture loss indication, and a frame only on damage. Intra refresh is not assumed: phase 5 checks whether vah264enc exposes it on the test GPU. Reason: GStreamer has the VA-API encoder, dmabuf import and WebRTC in one maintained stack. Alternative: a Rust WebRTC stack (str0m or webrtc-rs) with libva bindings; more custom code.
  • Fallbacks, in order:
    1. VA-API with dmabuf import (zero copy).
    2. VA-API with a CPU upload (when the modifier import fails).
    3. Software H.264 (x264enc, tune=zerolatency, speed-preset=ultrafast) at 720p and 30 frames per second at most. On NVIDIA (no VA-API encoder on the proprietary driver) the path is software H.264. An NVENC path (nvh264enc) is not in this spec and is not tested.
    4. No stream: the app shows "Sem codificador de vídeo" and the reason. The stream process reports the path that runs, and the PC indicator shows it.
  • Decision E2: a private fd-passing socket, not PipeWire (recommended). Smithay sends the frames to anos-stream over a Unix socket in the private runtime directory, with SCM_RIGHTS. Reason: fewer moving parts, no session PipeWire policy, and only the process that the core started gets the frames. Alternative: Smithay publishes a PipeWire video node; it would also serve the portal alternative later (The PipeWire portal alternative), but it adds a dependency and a node that any PipeWire client of the user can find.

The transport

  • Signaling. In the gateway, over the authenticated TLS WebSocket of the app. The gateway forwards the offer, the answer and the ICE candidates between the app and anos-stream. No separate signaling server.
  • ICE. Host candidates on the LAN only. No STUN or TURN server in the LAN phases: both ends are on one network, so host candidates are enough, and no packet leaves the LAN. anos-stream gathers candidates only on the interface of the gateway listener. The app sends its host candidates over the pinned channel. Whether webrtcbin resolves the mDNS candidates of the phone WebView is not assumed; phase 5 tests it, and the app falls back to plain host candidates.
  • QA exemption. For nested QA and the desktop-browser test, the gateway and anos-stream also accept loopback, behind a test flag that testEnvironment sets and the release build refuses.
  • Encryption. WebRTC encrypts media and data with DTLS-SRTP. The gateway puts the DTLS fingerprint of anos-stream in the signed answer, and the app checks it, so a LAN attacker who can answer ICE cannot take the stream.
  • TLS for the gateway. At the first phoneAccess start the gateway makes a self-signed certificate (ECDSA P-256, 2 years) and keeps its key in the profile (0600). The QR code carries the SHA-256 fingerprint, and the app pins it. No public CA is involved. Rotation: 30 days before expiry the PC settings and the app warn. The gateway makes the next certificate and announces its fingerprint, signed with the old key, over the old pinned channel; the app pins both until the switch. A reset ("Remover todos") makes a new certificate with no announcement, so every app needs a new pairing.

Input mapping

The input goes over a WebRTC data channel (ordered, reliable) to anos-stream, which sends typed events to Smithay on the stream connection with a new command phone_input {events}. Smithay accepts it only for the phone output and only from the connection that created it, and feeds the events through the real input path, as test_input does (synthetic_input.rs:1-8). It is never accepted while locked.

Phone gesture Grid or Focus workspace Canvas workspace
Tap Left click at the point Left click at the point
One-finger drag Pointer drag with the left button (move, select, scroll bars) Pan the camera when it starts on empty canvas; else pointer drag
Long press (500 ms) Right click Right click
Two-finger drag Scroll (axis events, finger source) Scroll over a window; pan on empty canvas
Pinch Nothing Zoom about the midpoint (the compositor pinch path, input.rs:973)
Three-finger horizontal swipe Step the workspace of the phone output Same
  • Decision I1: pointer emulation first (recommended). The compositor has no touch protocol today, so the phone drives the pointer path. A real wl_touch seat capability is a later phase (open question 8). Reason: every client takes pointer input today; touch support differs per toolkit.
  • Keyboard. The app shows a keyboard button. The phone soft keyboard types into a hidden field. The app sends committed text and special keys (Enter, Backspace, Tab, Escape, the arrows, Ctrl and Alt combinations from a small key row). Smithay types text through the active xkb keymap, as test_input does. A character that the keymap cannot type is dropped, and the app says "Caractere não suportado pelo layout do PC".
  • IME. The phone composes (accents, predictions, other scripts) and sends only committed text. The compositor has no text-input-v3 or input method protocol, so no preedit reaches the client. A text-input protocol is out of scope (open question 8).
  • Rate limit. At most 500 events per second and 256 characters per text event (the MAX_TEXT of synthetic input). Extra events are dropped, and the data channel gets a warning.

The phone page and its controls

  • The Tela screen is part of the app bundle (P2), so it is protected code, not generated HTML.
  • A small protected control strip at an edge: previous and next workspace of the phone output, open the Conversa screen of that workspace, keyboard, end the stream. It hides after 3 s and returns with a tap on its handle.
  • The WebView of the app has a strict Content Security Policy: default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' blob: data:; media-src 'self' blob:; connect-src 'none'; frame-src 'none' for the app frame. It opens no network connection; every request goes through the native TLS proxy (P3). WebRTC peer connections are not governed by connect-src; the app creates them only with the offer from the pinned channel. Inline components of the chat render only in the second WebView with no bridge (T6).

The chat on the phone

  • The Conversa screen shows the conversation of one workspace: by default the workspace of the phone output while a stream runs, else the focused workspace of the PC. The user can open any workspace from the Workspaces screen.
  • The core runs one turn at a time (turn, server.js:328). A send from the phone while a turn runs gets the same refusal as on the PC.
  • /api/send sends to store.state.active today, and a voice send must name that conversation or it is refused (server.js:1682-1685). A phone send names its conversation, and the core sends to that conversation. It never follows the active workspace of the PC, so a selection on the PC cannot redirect a phone message. Multi-output phase 2 adds the same routing for the output chats (/api/state?output and the send routing). That phase lands first, and the phone send uses its code path with a named conversation. The phone send takes text only; attachment is refused in phases 2 to 7.

The mirror mode (separate option)

  • The mirror mode streams the primary output of the PC as it is: bars, chat and every window, at the PC resolution, scaled on the phone. It creates no phone output. Smithay sends the frames of the primary output to anos-stream after each render, with the same socket and encoder.
  • Default: view-only. Input in the mirror mode is a separate choice in the PC approval dialog of that session, off by default. The phone cannot turn it on; only the PC dialog sets it.
  • Mirror input reaches application windows only (findings of review rounds 1 and 2). With input on, the mirror mode creates a phone seat (V2b) with a pointer and no keyboard by default: phone text and keys are refused in the mirror mode. Phone coordinates map to the primary output, and the compositor delivers a phone pointer event only to a window that is not a protected host window: no chat, bar, panel, approval dialog, recovery page, review card, lock content, overview or other window with a host role (window-layers.md). An event over such a window is dropped. Mirror keyboard input is open question 22. Phase 6 test: a phone tap on an approval dialog, on the composer, on a bar and on the recovery page does nothing, and a tap on an application window works.
  • The mirror mode is a separate approval on the PC ("Espelhar a tela no telefone"), with its own indicator text. It shows the HUD, notifications and the chat, so it shows more than the phone workspace does.
  • Reason: the user may want to watch the whole PC from the phone. It is a separate option because it breaks the "exceto HUD" boundary on purpose.

Connection

Pairing

  1. On the PC, the user opens Configurações, Telefone, and presses "Parear telefone". This works only in the protected host, unlocked.
  2. The gateway makes a pairing secret (128 random bits, single use, valid 120 s). The host shows a QR code with the gateway URL (https://<LAN address>:<port>), the certificate fingerprint, the secret and the PC name. The QR window is a host window with a new role, private, that phase 1 adds to window layers. Only the core declares it, from its own template; no agent tool, generated HTML or trusted page can. The compositor leaves every private window out of mirror, publish, capture and screenshot renders (it draws as a blank there). Phase 1 test: a frame diff of a mirror render and a capture with and without the QR window shows only a blank rectangle. The secret in the QR code gives a viewer who sees it only a denial of service: a pairing still needs the code typed on the PC and the PC approval, and a wrong code ends that pairing.
  3. The app scans it, connects with the pin, and sends the secret, a device name and the public key of a new device key in hardware (ECDSA P-256).
  4. Only after that connection does the PC open the pairing dialog. The app shows a 6-digit code, derived from the secret and the device key; the user types it into the PC dialog. A wrong code ends the pairing. The PC dialog uses the approval dialog rules of the host (modal, focus on "Recusar", 1.5 s arming), and "Permitir" is armed only after a correct code.
  5. The gateway stores the device record in <profile>/phone-devices.json (0600, atomic write): id, name, public key, created, last seen, scopes. No session token is stored.

At most 5 paired devices. At most 5 pairing tries per minute; 10 failed tries close the pairing until the user starts it again.

LAN first

The gateway listens only on the addresses of the interfaces that the user picks (default: the interface of the default route). It accepts source addresses in the private ranges (RFC 1918, IPv6 ULA and link-local) by default. Any other interface or range (for example tailscale0 and the CGNAT range 100.64.0.0/10 of Tailscale) is an explicit user setting. This source filter is defense in depth; the pinned TLS and the device key are the access control. The app finds the PC by the address in the QR code, and by an mDNS name as the fallback when the address changes (open question 4).

Remote access

Out of scope before web publishing. A user VPN (WireGuard, Tailscale) works only after the user adds its interface and its range in the setting of LAN first; Tailscale uses 100.64.0.0/10, which is not a private range. The spec adds no relay, no port forwarding and no public listener for the app. Web publishing (below) is the only public path, and it is a separate feature with its own modes.

Push notifications

  • Default: off. With push off, the app gets notifications only while it is open (foreground event stream).
  • With push on, the PC sends a push message with no content: only a wake signal and a counter. The app wakes, connects over the LAN and reads the notifications. Off the LAN, the app shows "Nova atividade no PC" and nothing else.
  • What leaves the machine: the push token of the phone, a wake signal, and the time of the push, to the push vendor (Firebase Cloud Messaging for Android, Apple Push Notification service for iOS). No notification text, no app name, no conversation content.
  • Android can use UnifiedPush with a self-hosted server (for example ntfy) instead of FCM. iOS has no alternative to APNs, and iOS needs a visible notification for each push, so the wake signal shows "Nova atividade no PC" there. iOS also asks for the Local Network permission at the first connection to the PC.
  • Phase 3 ships push off, with UnifiedPush as the only option. FCM and APNs wait for an answer to open question 5.
  • Sending to FCM or APNs needs a vendor credential on the PC (a service account or an APNs key). That credential is a project secret of whoever ships the app, not of the user. Open question 5.

Background behavior

  • In the foreground the app holds one TLS WebSocket for state and events.
  • In the background the app closes the WebSocket after 30 s and the stream at once. It keeps no background poll. Push (when on) is the only wake.
  • The stream never runs in the background, so no frame is sent to a phone that does not show it.

Trust model and security

What the phone is

Decision T1: a protected-host-level client. The app is protected code (bundled, P2). It acts for the user, as the protected host does. It is not generated HTML and never runs generated code with a bridge. Its authority is narrower than the host's: it gets only the routes of T3.

Tokens

  • Device key. Made in hardware at pairing, never leaves the phone. The app unlocks it with the phone biometric or device credential, at app open and after 5 minutes in the background.
  • Session. The gateway sends a challenge; the app signs it with the device key over the pinned TLS connection; the gateway checks the signature against the device record and gives a session token (256 bits, valid 15 minutes, renewed while the connection lives, bound to that TLS connection). The token never leaves the gateway and the app memory.
  • Expiry. A device record that is not used for 30 days expires (open question 2). The certificate expires after 2 years; a renewal needs a new pairing.
  • Revocation. Configurações, Telefone lists each device with its last use, and "Remover" deletes the record, ends its connections and its stream at once. "Remover todos" resets the certificate too, so every app needs a new pairing. A profile reset removes the file.

Routes and scopes (T3)

The gateway reaches the core over a private socket with a new phone authority, never with the shell token. The core accepts only these requests from it, each with exact keys:

Scope Requests Notes
chat Read the state of one named conversation; send to a named conversation; cancel the turn of that conversation; read the inline components as documents A phone view of /api/state with no settings, no profile, no paths.
approve Answer a tool permission of the live turn (/api/approve) T4.
workspaces List; select; create; put a workspace on the phone output No archive or unarchive in the first phases.
review Read the review card and its diff No approve, no discard.
notifications Read; dismiss; remove; mark read; do not disturb; run a notification action The phone reads notification content (T5).
media List players; media actions; output volume and mute No device choice, no per-application mixer in the first phases.
stream Ask for a stream session; end it Every start needs the PC approval (S1).
lock Read the lock state No unlock.

Every other route stays out, for example: schedule, theme and source change approvals, /api/changes/recover, /api/restore, /api/model, /api/account/*, /api/profile-color, every protected setting route, /api/window-capture, /api/screenshot, /api/manual-control, /api/memory/close, /api/surface-pin, /api/voice/*, network, VPN, Bluetooth and power actions, and /api/applications/open (open question 7).

Approvals from the phone (T4)

  • Default: tool permissions only, each with a fresh biometric check. A phone tap on "Permitir" counts as a user approval of a tool permission of the live turn, after the phone biometric prompt for that one approval. The PC chat shows "Permitido pelo telefone <name>" on the answer.
  • Schedules, themes, source changes, the memory close and recovery stay on the PC. Reason: they persist (a standing schedule, code at the next login, a theme), so their approval needs the PC host. A tool permission ends with its turn.
  • The risk is real: a tool approval can allow execute_command, which runs with the privileges of the user (runtime.js:75). So a phone approval is as strong as a PC approval for that call. Open question 1.

Notification content (T5)

The phone reads the content of notifications. This is a new reader beside the protected host. The model tools still read no notification content. The scope notifications is a separate switch per device, on by default at pairing, and the user can turn it off.

Generated HTML on the phone (T6)

Inline components render in a second WebView that has no native bridge, no network (connect-src 'none') and the CSP of the desktop surfaces (host/surface.js:16). They get the document from the gateway as data. They can draft a continuation (window.surface.action), which the app puts in the composer for the user to send, as on the PC. They never get a token, a route or the bridge.

The trust model on the LAN

  • Every LAN host is untrusted. The gateway takes only pinned TLS from a device with a valid key, after a PC-approved pairing.
  • An attacker on the LAN without a device key gets: the open port, the TLS handshake (the certificate tells nothing private), and the pairing endpoint while a pairing runs (a 120 s window, single-use secret, the 6-digit check and the PC approval).
  • WebRTC media and data are encrypted end to end between anos-stream and the app, and the DTLS fingerprint comes over the pinned channel.

Rate limits

  • Pairing: 5 tries per minute, close after 10 failures.
  • Session: 10 challenge failures per hour per device, then the device needs the PC to re-enable it.
  • Chat: the core rules of today (one turn at a time); at most 10 sends per minute from the phone.
  • Approvals: one answer per request (the core already removes the request first, server.js:1808-1811).
  • Input: 500 events per second.
  • Stream: one stream session at a time for all devices.

What a stolen pairing allows

A thief who has the phone, can unlock it and passes the app biometric gate (or who copies a device key out of a rooted phone) can, on the LAN, until the user revokes the device:

  • read and send in every conversation, so start agent turns as the user;
  • answer tool permissions, which can allow execute_command with the privileges of the user (T4), also while the PC is locked (open question 12);
  • read notifications and control media;
  • ask for a stream, which still needs the PC approval (S1), unless open question 11 turns that off.

Limits: no unlock of the PC, no approval of schedules, themes or source changes, no settings, and nothing off the LAN. The PC shows each connected device (S4), so the user can see and remove it.

The lock

  • The phone does not unlock the PC (default and only option). The app shows "Bloqueado no PC".
  • While locked: the stream and its input stop at once (S5). Chat, tool approvals and notifications keep working by default, because the lock defends the screen of the PC, not the agent, and scheduled turns already run while locked (open question 12). So a phone approval works while the PC is locked. While locked, the app asks for the phone biometric again before each send and each approval, also within the 5-minute window.

The agent and generated HTML

  • No agent tool, scheduled turn or generated HTML pairs a phone, removes a device, starts, approves, ends or controls a stream, publishes a workspace, or changes phoneAccess.
  • system_context reports only the status: phoneAccess on or off, the number of paired devices, and whether a stream runs. No device names, addresses or keys.
  • The agent send_to_output to the phone output is refused with phone_output, so the agent cannot put a window on the phone screen. Agent window actions on windows of the phone workspace follow the rules of the turn workspace, as for any extra output.
  • Advisory limit, as in self-maintenance (What a job can still reach): an agent steered into execute_command runs as the user and can read phone-devices.json, the certificate key, and connect to the control socket. These rules bind the agent tools and generated HTML, not a prompt-injected shell command.
  • S1: approval per session. Each stream start shows a PC dialog: "Compartilhar o workspace <name> com <device>?" (or the mirror text). The user answers on the PC. Without an answer in 60 s the request ends.
  • S2: end. The phone, the PC indicator ("Parar"), a revocation, a lock, the app in the background, phoneAccess off, or a core or compositor restart ends the session. The phone output goes away, and its workspace shows on no output; it does not return to the PC by itself.
  • S3: one session at a time.
  • S4: the indicator. While a phone is connected, the top bar shows a phone icon. While a stream runs, the icon turns to the sharing state, with the device name, the mode (Workspace or Espelho), the encoder path and "Parar". The indicator is protected host UI on the primary output.
  • S5: the lock. The lock request stops the stream before the lock frame: Smithay stops sending frames of the phone output at the lock request, and anos-stream sends one black frame and closes the media track. After the unlock the stream does not resume; the phone asks again and the PC approves again.

Performance targets

Measure Target How to measure
Glass-to-glass latency, 5 GHz Wi-Fi 80 ms median, 120 ms p95 A test client on the phone output flips a frame counter on a key event from the phone; a 240 fps camera films both the phone and a PC timestamp. Needs the user and a real phone.
Render to encoded frame 8 ms median on VA-API Timestamps in anos-stream from the frame socket to the encoder output.
Frame rate 60 fps on change, 30 fps minimum; 0 fps while nothing changes WebRTC getStats (framesDecoded, framesDropped) on the phone; frame counts in anos-stream.
Bitrate 2 to 12 Mbit/s adaptive by congestion control, 6 Mbit/s typical at 1080p getStats (bytesReceived), the encoder log.
PC CPU, VA-API path under 5% of one core for anos-stream plus the extra compositor work pidstat on the compositor and anos-stream, with and without a stream.
PC CPU, software path under one core at 720p 30 fps Same.
PC GPU under 10% render and encode busy intel_gpu_top or radeontop, by GPU.
Phone battery under 15% per hour of streaming Android battery stats, iOS Instruments energy log. Needs the user.
Idle app cost no traffic in the background with push off The router or ss on the PC.

The phase 5 gate runs the PC-side measures in nested QA (software path) and on the DRM backend with the user (VA-API path).

Offline, failure, battery and data

  • PC out of reach. The app shows "PC fora de alcance" and the time of the last contact. It does not show cached conversation content: by default the app stores no conversation, notification or frame on the phone (open question 13). A send while offline is refused, not queued, so no late turn starts by surprise.
  • Core down. The gateway reports "Núcleo indisponível". The app does not claim that the conversation is available (AGENTS.md, current operating philosophy).
  • Compositor down. Chat and notifications keep working if the core lives; the Tela screen shows "Compositor indisponível" and ends the stream.
  • Gateway down. The app retries with backoff (1 s, 2 s, 5 s, then 30 s).
  • Data. A stream at 6 Mbit/s uses about 2.7 GB per hour, on the LAN only. Chat and notifications use a few kB per minute while the app is open.
  • Battery. No background connection, no background poll; push wakes only with a counter.

The PipeWire portal alternative

The alternative is: Smithay implements a screen capture protocol, a portal backend gives ScreenCast through PipeWire, and an existing remote desktop server and phone client do the rest.

Correction to the first proposal: gnome-remote-desktop needs the private ScreenCast and RemoteDesktop D-Bus interfaces of Mutter, so it does not run on Smithay. The realistic stack is:

  • Smithay implements ext-image-copy-capture-v1 (or wlr-screencopy-unstable-v1), and for input wlr-virtual-pointer-unstable-v1 and virtual-keyboard-unstable-v1. Whether Smithay 0.7.0 has handlers for these protocols needs a check in the crate; if not, the compositor implements them.
  • xdg-desktop-portal-wlr gives ScreenCast through PipeWire (it has no RemoteDesktop portal), or wayvnc uses the protocols directly.
  • The phone uses a VNC client app.
This spec (phone output + WebRTC) Portal and wayvnc
Phone-sized workspace of its own Yes No (a mirror of a PC output, or a headless output that the server cannot size from the phone)
Native touch: pan, pinch on the canvas Yes (mapped by the compositor) No (the VNC client emulates a mouse)
Latency and bandwidth H.264 on the GPU, damage-aware VNC encodings; wayvnc can use H.264 on some GPUs, many clients cannot
No app to install for the stream The phone app is installed anyway A third-party VNC app
Security Typed commands on the stream connection, approval per session, the phone output only The capture and virtual input protocols open the screen and the input to any Wayland client unless the compositor gates them; VNC auth is weak, so it needs a tunnel
Work to build High Medium
Also helps other tools (OBS, browser screen share) No Yes (ScreenCast)

Recommendation: build this spec for the phone. Do not use the portal path for the phone app. ScreenCast through PipeWire is still useful for browser screen share and OBS; it is a separate feature, with its own gate on which clients may capture, and it is not part of this spec (open question 14).

Publishing a workspace online

The user accepts the risks and wants them listed. This section reuses the base of the streamed workspace: an offscreen render of one workspace, the GPU encoder, and a browser client. It is a late phase (phase 8 and later), view-only first.

What is published

  • Decision PW1: one workspace, offscreen. A published workspace renders on a headless output with no input from the PC desktop, as the phone output does (V1, V2), at a size that the user picks (default 1920 x 1080). Only the windows of that workspace go out. No bar, HUD, chat window, notification popup, lock content, overview or pointer of the PC goes out. Reason: the per-workspace boundary is the main defense; the whole primary output (the mirror mode) is never published.
  • Decision PW2: new windows stay covered. A window that opens on a published workspace, or joins it, renders as a blank rectangle with "Janela nova oculta" in the published frames until the user presses "Mostrar" in the PC indicator. Reason: a password dialog, a file chooser or a browser tab with private data must not go out by surprise. Open question 16.
  • Decision PW3: the PC side (finding of review round 1). A workspace shows on one output at a time (W1 of the multi-output spec), and the published output is an output. So the publish dialog names the workspace and says "Este workspace sai da tela do PC enquanto estiver publicado". On "Publicar", the workspace moves to the published output by the W3 move rule, and the PC output shows its next workspace. The windows already on the workspace go out at once, and the dialog lists their titles before the user confirms; new windows follow PW2. The dialog also says that covered windows are blank in the PC preview too, and that the PC cannot type into the published workspace while it is published (it shows on no PC output). The PC watches the published frames through a protected preview in the indicator panel (the encoded frames, decoded by the host), not by showing the workspace twice. "Parar" returns nothing by itself: the workspace shows on no output, and the user selects it again. The indicator shows "Publicado: <n> espectadores".

Reach options

Option How Pros Cons
Tunnel (Cloudflare Tunnel, Tailscale Funnel) A tunnel client on the PC dials out and publishes an HTTPS name. Simplest. No port forwarding, no server to run. TCP only, so no WebRTC UDP media; the media must go over WebSocket or TURN over TCP. Cloudflare terminates TLS at its edge, so it sees the stream; its terms for video need a check. Tailscale Funnel ends TLS on the PC, but limits ports and bandwidth.
Self-hosted relay A small cloud server runs WebRTC signaling and TURN (coturn). The PC dials out to it. Viewers connect peer to peer where they can, else through TURN. WebRTC latency. The relay sees only encrypted media (DTLS-SRTP is end to end, TURN relays ciphertext). A server to run and pay for. One encode per viewer peer connection, unless the PC sends one stream per viewer (upload cost grows with viewers).
SFU (LiveKit, mediasoup) The PC sends one encode (with simulcast layers) to an SFU; the SFU forwards it to every viewer. Many viewers from one encode and one upload. Late joiners and network adaption are handled. The SFU decrypts media unless end-to-end encryption (insertable streams) is on; more infrastructure; a heavier client.
H.264 over WebSocket or WebTransport, WebCodecs decode The PC sends the encoded H.264 access units over a WebSocket (or WebTransport); the browser decodes them with VideoDecoder and draws to a canvas. Works through any HTTPS tunnel. Small server (static page plus one socket). One encode, the same bytes to every viewer. TCP head-of-line blocking adds latency on a lossy link (WebTransport over HTTP/3 avoids it, but not through every tunnel). No built-in congestion control: the PC must drop frames per viewer. WebCodecs support needs a check per browser at the phase start.

Recommendation (default): H.264 over a WebSocket with WebCodecs decode, through Tailscale Funnel, for view-only. One encode goes out to every viewer as the same bytes, the server is a small process, and TLS ends on the PC. Cloudflare Tunnel is the alternative when the user has a domain there, with the note that Cloudflare sees the content. Invited control adds input over the same authenticated WebSocket. An SFU is the path only if the user needs more viewers than the PC upload allows (open question 17). Reason: the fewest new parts, and a tunnel that the user can turn off in one step.

Decision PW4: a separate publish server (finding of review round 1). A new process, anos-publish, serves the viewer page and the viewer WebSocket. It is not anos-phone: it holds no phone authority and has no pairing, device or phone route; a request for one gets 404. Its core allowlist is only: read the publication state, report viewer events for the audit log, ask for a viewer approval, and pass the input of an approved controller to the stream. The page sends Referrer-Policy: no-referrer and a strict CSP. The link id is in the URL fragment, never in the path or the query, so it does not reach the tunnel logs; the page sends it as the first WebSocket message after load.

Modes

  • View-only (public link). A link with a random 256-bit id. Anyone with the link watches. No input, no chat, no audio. Default expiry: 2 hours, and at most 20 viewers.
  • Invited control. A link that needs a login of the viewer (an invite code per viewer, single use, plus a viewer name), and a PC approval of each viewer session, with the same dialog rules as the phone stream (S1). One controlling viewer at a time. Input maps as in the phone table, from mouse and keyboard of the browser, under the same rules: the published output has no protected host window, the compositor drops any event for a host role, and viewer input never changes the PC focus output or keyboard focus (V2b). The indicator shows "Controle remoto: <viewer>" and "Parar".
  • The lock cuts everything. A lock ends every published session, view-only and control, at once (S5 rules), and the links stop working until the user publishes again.

Security of publishing

What an attacker gets from a leaked link:

Mode What a leaked link gives What it does not give
View-only Live video of the published workspace until the link expires or the user stops it: every window of that workspace that the user shows, and what it displays (documents, a terminal, a web page). Input, the chat, notifications, other workspaces, the clipboard, audio, files.
Invited control Nothing without an invite code and the PC approval of the session. With a stolen invite code and an approval that the user gives by mistake: mouse and keyboard on the windows of that workspace, so anything those applications can do as the user (a terminal in that workspace runs commands). Other workspaces, the chat, the agent, approvals, settings, the lock, the clipboard.

Content in the shared workspace:

  • Notifications. Never published: they are HUD on the primary output.
  • The chat. Never published: the published output has no chat window (V4). The agent can still put windows on that workspace through its normal tools if it works in that conversation; such windows stay covered (PW2) until the user shows them.
  • Secrets on screen. Whatever a published window shows goes out. PW2 covers new windows; it does not cover a password that an already shown window displays. The docs and the publish dialog say so.
  • Clipboard. Never published, also in invited control (no clipboard channel).
  • The pointer and the keys of the PC. The PC pointer is not drawn. Keys typed on the PC into a published window go out only as what the window shows.

Other rules:

  • Expiry and revocation. Every link has an expiry (default 2 hours, at most 24 hours). "Parar" and "Revogar link" end it at once and drop every viewer. A core restart ends every publication; nothing republishes at login.
  • The viewer address (findings of review rounds 1 and 2). Behind a tunnel every connection comes from the tunnel. anos-publish starts the tunnel client itself, and the tunnel client reaches anos-publish only through a private Unix socket or an inherited fd. anos-publish honors the viewer address header (CF-Connecting-IP for Cloudflare, the Funnel request metadata for Tailscale) only on that socket or fd; every other listener drops the header. The Tailscale Funnel header may not carry the viewer IP address; phase 8 checks it before it starts, and without it the audit has no address. An address from a header is the tunnel's claim; the global and per-code limits are the real defense.
  • Rate limits. Global: at most 20 viewers, at most 10 new viewer connections per minute, at most 30 failed invite codes per hour (then invites stop until the user starts them again). Per invite code: 5 failed tries close that code. Per source address (when the tunnel header gives one): 5 failed codes per minute, then 10 minutes of refusal. Input of a controlling viewer at most 500 events per second.
  • Audit log. <profile>/publish-audit.log (0600, append only): the time, the event (publish, join, leave, approve, refuse, input start and end, stop, revoke), the mode, the workspace id, the viewer name of invited control, and the viewer address from the tunnel header, truncated to /24 (IPv4) or /48 (IPv6), marked as the tunnel's claim. No frame, no typed text. Kept 30 days. The PC settings show it (open question 18).
  • The agent boundary. No agent tool, scheduled turn or generated HTML publishes a workspace, makes or sends a link, approves a viewer, gives control, or stops a publication. system_context reports only whether a publication runs and the number of viewers. The same advisory limit applies to execute_command.

Cost and bandwidth

  • Per viewer at 1080p, 30 fps, text and windows: about 2 to 4 Mbit/s typical, 6 Mbit/s with motion. At 720p: about 1.5 to 3 Mbit/s.
  • With the WebSocket fan-out, the PC upload is the viewer count times the bitrate. A home upload of 20 Mbit/s carries about 5 viewers at 1080p. The default cap of 20 viewers needs about 60 Mbit/s or a lower size; the PC lowers the bitrate to fit the measured upload and refuses new viewers beyond it.
  • Encode cost is one encode for all viewers, the same as one phone stream.
  • Each viewer has a send queue of at most 1 s of video. When a viewer falls behind that, anos-publish drops its queued frames up to the next IDR frame, and the encoder makes an IDR at most every 2 s for that purpose and on a new viewer. The other viewers are not affected.
  • Tailscale Funnel and Cloudflare Tunnel have no direct fee for this use at the time of writing, but both have limits and terms; a self-hosted relay or SFU costs a server plus egress per viewer.

Phases

Each phase has its own commit, its own gates and its own docs update. The web shell gates are the AGENTS.md list (prepare-project.py --dependencies-only, npm run format:check, npm run check, npm test, the Python suite without AGENT_NATIVE_*, DISPLAY and WAYLAND_DISPLAY). A compositor phase adds cargo fmt --check, the cargo tests with --features session and Clippy with -D warnings. App phases add the app build and its unit tests on both platforms.

Phase Content Gates and tests QA
0 This spec. format:check, check. None.
1 App shell and pairing. The P3 spike first. The private role. phoneAccess setting (off). The anos-phone gateway: TLS, certificate, pairing, device registry, session tokens, revocation, rate limits, the private socket with the phone authority, the lock state. The app: pairing, connection state, the lock screen state. The PC: Configurações, Telefone, the pairing dialog, the connected indicator. Node tests of the gateway with a synthetic core from testEnvironment: the pairing (secret expiry, single use, the code check, the PC approval), the challenge, token expiry, revocation that ends connections, each rate limit, a refused public address, a refused route outside the scopes. App unit tests. Browser: the app web UI against a synthetic gateway and core. Nested QA for the PC dialogs (scripts/nested-qa.py). A real phone pairing needs the user.
2 Chat, approvals and workspaces. The scopes chat, approve, workspaces, review; the phone view of the state; the send to a named conversation; inline components in the bridgeless WebView; the biometric check per approval; "Permitido pelo telefone". Node tests per route and per refusal; a test that a phone send never follows the active workspace; a test that schedule, theme and source change approvals are refused; the bridgeless WebView CSP test. Browser against a synthetic core. Real phone with the user, with the free provider only when needed.
3 Notifications and controls. The scopes notifications and media; the foreground event stream; push as an option (off), with the wake-only message. Node tests per route; a test that the push message has no content. Browser; real phone with the user for push.
4 The phone output, no stream. headless_output_create, headless_output_destroy, phone_input, capabilities.headlessOutput, the output outside the pointer row, the nested render path, the lock rules, the agent phone_output refusal, the V2b phone seat, the V5 session key. Needs per-output workspaces phase 2 (and phase 3 for the Canvas column). Rust in-process tests: creation and removal, the workspace move rule, no pointer path into the output, each gesture of the input table, the lock refusal of phone_input, the V5 key binding (one attach, destroy on close), the V2b seat tests, the attach timeout, no output chat for a headless output. Node tests of the core side. Nested QA: create the output, put a workspace on it, read it with state, render it through the nested path to a capture, send gestures. Nested proof only (one real output, no GPU encoder).
5 The stream. anos-stream with GStreamer, VA-API and the software fallback, the frame socket, WebRTC with host candidates, the DTLS fingerprint check, the per-session approval, the indicator, the lock cut, the Tela screen and its control strip. Tests of the frame socket, the release, watchdog and fence rules and the fallbacks (a pipeline with no VA-API must pick the software path); the mDNS candidate test; the lock cut test; the PC-side measures of Performance on the software path. Nested QA with a desktop browser as the phone on loopback. The DRM backend, VA-API, a real phone and the latency measure need the user under coordination.lock.
6 The mirror mode, view-only, then input set only in the PC dialog. Tests of the separate approval, the indicator text, the view-only refusal of input, and that a phone event on an approval dialog, the composer, a bar or the recovery page does nothing. Same split as phase 5.
7 Rotation, the keyboard row, mDNS fallback, the battery measure. Tests of the mode change. Real phone with the user.
8 Web publishing, view-only: anos-publish, the headless output of one workspace, the publish dialog with the move off the PC (PW3), covered new windows, the WebSocket fan-out, WebCodecs viewer page, the tunnel setup, expiry, revocation, rate limits, the audit log. Tests of the boundary (no HUD, no chat, covered new windows, the QR window blank), expiry, revocation, the global and per-code rate limits, the tunnel header trusted only from the tunnel process, the link id never in a path, the audit log fields. Nested QA with a local browser viewer; a real tunnel needs the user.
9 Web publishing, invited control: invite codes, the approval per viewer session, input. Tests of single-use codes, the approval, one controller at a time, no event to a host window, no PC focus change, the lock cut. Same as phase 8.

Every phase reports the browser proof, the nested proof, the Electron host proof and the real system proof separately, as AGENTS.md asks. A phase that needs the live session waits for the user and coordination.lock.

Review record

  • Review round 1 of ee98e62 (docs review): 4 HIGH, 7 MEDIUM and 5 LOW. Each finding was checked against the spec and the code; none was declined. Fixed in revision 2:
    1. HIGH: mirror input could press protected host windows. Input is set only in the PC dialog, and the compositor drops phone events for host roles; the same rule for invited control; a phase 6 test.
    2. HIGH: one seat, so a phone tap moved the PC focus (press_focus_output, workspace_outputs.rs:99-115). V2b keeps a separate phone focus, refuses phone input within 500 ms of PC input, and lists Rust tests.
    3. HIGH: a WebView cannot pin a self-signed certificate for its own requests. P3 moves the pinned TLS into a native proxy, the CSP has connect-src 'none', and phase 1 starts with a spike and a stated fallback.
    4. HIGH: behind a tunnel the source address is the tunnel. The viewer address comes from the tunnel header, trusted only from the tunnel process, with global and per-code limits.
    5. MEDIUM: the dependencies on multi-output phases 2 and 3, the skip of output chats for headless outputs, and the rename to "phone output" and headless.
    6. MEDIUM: the core creates the output and binds it to a single-use session key (V5).
    7. MEDIUM: the buffer release message and the fence rule, with phase 5 tests.
    8. MEDIUM: the PC dialog opens after the app connects, the user types the app code on the PC, and the QR window stays out of mirror, publish and screenshot frames.
    9. MEDIUM: the Tailscale range is not private; extra interfaces and ranges are a user setting, and the source filter is defense in depth.
    10. MEDIUM: PW3 moves the published workspace off the PC output with a dialog, and the PC watches a protected preview.
    11. MEDIUM: anos-publish (PW4), with no phone authority, no-referrer, and the link id in the fragment.
    12. LOW: the phone send uses the routing of multi-output phase 2, which lands first; no attachment.
    13. LOW: phone approvals work while locked, with a biometric check before each one.
    14. LOW: certificate rotation over the old pin, and a 30-day warning.
    15. LOW: no intra-refresh claim, the NVIDIA software path, the mDNS candidate test, iOS visible push and Local Network permission, both frame kinds in anos-stream, and the loopback QA exemption. The per-viewer queue is in Cost and bandwidth.
    16. LOW: the push default, questions 19 and 20, and the AGENTS.md boundary edits under phase 0 approval.
  • Review round 2 of 6192b1c (docs review, the last round for this spec): 1 HIGH, 7 MEDIUM and 4 LOW. Each finding was checked; none was declined. Fixed in revision 3:
    • H1, M1, M2 and L4: the borrowed-seat batches and the 500 ms gate are replaced by a separate Smithay seat for the phone (V2b), with Rust tests for a phone drag while the PC types, no PC keys or modifiers in a phone enter, and no PC selection to phone windows. The rejected alternative stays in V2b. Open: focus-follows, xdg_activation and first-seat clients (open question 21).
    • M3: the mirror mode refuses phone text and keys by default and uses a pointer-only phone seat; taps reach only non-host windows (open question 22).
    • M4: anos-publish starts the tunnel client and honors the viewer header only on its private socket or fd. Open: whether the Funnel header carries the viewer IP (checked before phase 8).
    • M5: the proxy reaches only the pinned host and port; the bridge is never in the generated-HTML WebView; a phase 1 spike test.
    • M6: the private host role for the QR window, declared only by the core, left out of mirror, publish and capture renders, with a frame-diff test; window-layers.md gets the role in phase 1.
    • M7: the publish dialog says covered windows are blank in the PC preview and the PC cannot type into the published workspace.
    • L1 to L3: the 10 s attach timeout, the 2 s release watchdog, and the QR secret allows only a denial of service.
  • No further review round follows. The open items are open questions 21 and 22, and the Funnel header check.

Open questions

Each question has a default that applies if the user does not answer.

  1. Is a phone tap a valid user approval? Default: yes for tool permissions of the live turn, each with a fresh biometric check; no for schedules, themes, source changes, the memory close and recovery. Alternative: no approvals from the phone at all.
  2. Device expiry. Default: 30 days without use. Alternative: no expiry, revocation only.
  3. Remote access for the app outside the LAN. Default: out of scope; a user VPN works with no change. Alternative: a relay of the project.
  4. Address changes on the LAN. Default: the QR address first, then mDNS. Alternative: QR only, a new pairing after a change.
  5. Push. Default: phase 3 ships push off, with UnifiedPush as the only option (wake-only messages). FCM and APNs need an answer on who holds their credentials.
  6. Stream size cap. Default: 1920 pixels on the long side. Alternative: the full phone resolution.
  7. Open applications from the phone (/api/applications/open). Default: no in the first phases. Alternative: yes, with the same refusals as the PC route.
  8. Real touch and text input protocols (wl_touch, text-input-v3). Default: pointer emulation and committed text only. Alternative: a later phase.
  9. Audio of the streamed workspace. Default: out of scope. Alternative: a later phase through PipeWire capture of the applications of that workspace.
  10. Clipboard. Default: out of scope. Alternative: text only, on an explicit button, never automatic.
  11. Approval of each stream session on the PC. Default: yes, every time (the accepted basis). Alternative: a per-device "permitir sem aprovação" switch, so the user can stream when away from the PC.
  12. Chat and approvals while the PC is locked. Default: allowed; the stream is cut. Alternative: the phone app is read-only while locked.
  13. Cache on the phone. Default: none. Alternative: the last 50 messages of each conversation, encrypted with the device key.
  14. A ScreenCast portal for browsers and OBS. Default: not in this spec. Alternative: its own spec.
  15. Platform. Default: a native shell around the React and HeroUI web UI (P1). Alternative: React Native with HeroUI Native.
  16. New windows on a published workspace. Default: covered until the user shows them. Alternative: shown at once.
  17. Web publishing reach. Default: WebSocket and WebCodecs through Tailscale Funnel, view-only first. Alternative: Cloudflare Tunnel, a self-hosted relay, or an SFU for more viewers.
  18. Audit log retention and address storage. Default: 30 days, addresses truncated. Alternative: no addresses.
  19. A phone stream and a publication at the same time. Default: refused; one headless session of either kind at a time. Alternative: both, at twice the encode cost.
  20. The phone output name. Default: PHONE-1, fixed, because S3 allows one session. Alternative: a name per device.
  21. The second seat (V2b): how it interacts with focus-follows rules and xdg_activation, and with clients that use only the first wl_seat. Default: the phone seat gives activation only to its own focus, and phase 4 tests the toolkits of the nested QA list. Open item after the last review round.
  22. Keyboard input in the mirror mode. Default: refused. Alternative: a keyboard on the mirror seat, set in the PC dialog.