Repository navigation
feat(watch): passive picture-in-picture viewer with bundled noVNC - #225
Merged
Merged
Conversation
Shared routes, asset resolution and typed stubs for the bridge, the viewer state and the Hyprland adapter. Adds ws and pinned noVNC. Refs #207
Detect a Hyprland instance with a Lua config, install a named runtime rule that floats, pins and places the thumbnail without initial focus, and disable it by name afterwards. applyHyprlandWindowMode finds the launch's floating window by class pattern and pid and resizes and moves it by client address, from the work area of its monitor. Refs #207
Detect Chromium, Chrome or Firefox, give each launch a fresh profile, record the launch before spawning and the browser identity right after, and keep the Hyprland rule active only until the window maps, the browser exits or the bounded wait ends. Refs #207
A view-only noVNC page that fits the CSP: the token moves from the fragment to sessionStorage, a shield catches every pointer event above the canvas, a click expands the window through the window API, and status text covers each bridge close code. Refs #207
Plain watch, session create --viewer and viewer.mode auto now start the viewer bridge and open the browser window. Without a GUI or a browser they print the viewer URL and an SSH tunnel command. watch --control keeps its external VNC client. Refs #207
Copy the page and the pinned noVNC core, vendor files and license texts into dist/viewer after each build, where resolveViewerAssets finds them. Refs #207
test/security forbids execFile; runCommand keeps the argv array, the timeout and the output bound. Refs #207
The bridge serves the bundled viewer page and pinned noVNC, and relays a token-gated WebSocket to the session's read-only x11vnc. It checks Host, Origin and the capability token, sends a restrictive CSP and no-store, and bounds buffers with backpressure. It reaches VNC only through a check that holds the session VNC lock and refuses a writable server. The detached bridge survives the CLI, records its identity in the session, exits when idle or when the session ends, and stops on teardown together with owned viewer browsers. x11vnc now runs with -nosel. Refs #207
After an abnormal WebSocket close the page asks GET /api/status with its token. 401 or 403 ends with Link expired, two failed probes in a row end with Viewer stopped, and any other answer keeps the backoff retry. Refs #207
Without a graphical session, watch prints only the SSH tunnel and URL guidance. Without a browser, it adds the install hint. Refs #207
Keep validSize within the PickCheck boolean operator limit. Refs #207
Add the authenticated viewer status endpoint and test its request boundary. Expand bridge and viewer state code for readability, group imports, and simplify validation and daemon startup without changing their checks. Refs #207
Refs #207 # Conflicts: # docs/releases/UNRELEASED.md
This was referenced Oct 3, 2026
The viewer bridge security tests send the published sample nonce as Sec-WebSocket-Key. Allowlist that exact value, as the policy in .gitleaks.toml describes. Refs #207
Take the session VNC lock around a fresh running check, the profile, the launch records and the spawn, so a teardown either runs first or finds the recorded browser. Release it before the placement wait. When the browser identity cannot be recorded, stop its group by verified identity with escalation, and keep the launch for teardown unless the group is confirmed gone. Handle interrupts from before the spawn through placement and the exit wait. The first sends SIGTERM to the browser group, the next SIGKILL. Once the browser is gone, disable the rule, remove the launch and end with the same signal. Report a browser exit seen during the placement wait of an automatic launch. Place the mapped window once on its own monitor, because the rule used the focused monitor's reserved area. Refs #207
Fail an automatic launch whose browser exited with an error during placement, so watch and session create --viewer report it. When the browser stops because the session ended, say so instead of claiming that the session still runs. Refs #207
Verify bridge reuse through the authenticated status endpoint. Keep viewer profiles until their browser process groups are empty. Skip unsafe launch entries during pruning and name teardown failures. Report ended sessions with the correct WebSocket close code. Support linked registry roots and paint read-only cursor pixels. Complete protocol and signal assertions and control the idle test clock. Refs #207
This was referenced Oct 3, 2026
Member
Author
|
From #234: The random display from Cleanup stops Xvfb with SIGKILL, which leaves a stale #234 adds a |
…acement When the pid-bearing launch record cannot be written, stop the browser through the process group this process spawned it to lead, with stopOwnedDaemonGroup. This also works when the leader already exited and left members behind. The launch is removed only once the group is empty. Otherwise the error names the browser pid and says to close it by hand. Pin the Hyprland launch rule to the focused monitor whose reserved space it uses, and drop the post-map thumbnail placement. That placement could land after an early expansion and shrink an expanded window. Refs #207
Treat reused live leaders as proof that the recorded group is gone. Stop orphaned browser members only when their arguments name the exact profile. Retain state for unverified members and report their pids and launch id. Apply the same identity rules to launch removal and bridge cleanup. Cover reused leaders, orphaned members, mixed groups, and natural exits. Refs #207
Wait for accepted requests and upstream connects after closing the bridge servers. Keep VNC lock sentinel cleanup inside the shutdown boundary. Use the display allocator and managed Xvfb startup in the cursor test. Stop Xvfb with SIGTERM first and verify its socket and lock are gone. Cover delayed connects and queued locks, and stress all four viewer test files. Refs #207
This was referenced Oct 3, 2026
When the pid-bearing launch record write failed and the browser group could not be confirmed gone, the launch kept a record without a pid, so teardown deleted the profile while the browser still ran. Retry the record with the pid and start ticks so teardown can find the group. Keep the manual-close error when the retry also fails. Refs #207
Escalate group cleanup when the leader closes after SIGTERM but members remain. Document why surviving members keep the original process group id reserved. Cover a detached leader that exits normally and a member that ignores SIGTERM. Confirm that the member identity and the whole group are gone before success. Refs #207
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pickforge-lab watchnow opens a small live view in a browser instead of an external VNC client. A loopback bridge serves a bundled, pinned noVNC 1.7.0 page and relays a token-gated WebSocket to the session's read-only x11vnc. The window opens as a 384 px thumbnail. A click expands it and never grants control. On Hyprland with a Lua config, it floats pinned in the corner without taking focus. Frames never reach the agent.This is the first PR for #207. It covers the passive viewer. The take-control increment stays the second PR, so this PR refs the issue instead of closing it.
Status at 0db3456
stopOwnedDaemonGroupnow sends SIGKILL to group members that survive their leader. When a stop is still not confirmed, the launcher rewrites the launch record with the browser pid, so teardown keeps ownership evidence. Astra's recheck at 788dd5e found it resolved, with no new defects. The maintainer approved this final round and the merge.rerun/torerun4/beside the report.-nocursorshape, so the agent's pointer shows in the view. Launch is serialized with teardown. Ctrl+C cleans up at any point. Bridge reuse is verified with an authenticated status probe. Teardown never signals a process without identity evidence. The Hyprland rule pins the window to one monitor.Minor observations from Fable with no failure shown: a record without start ticks plus later pid reuse keeps a launch unremovable; a zombie leader no longer authorizes a group signal; the SIGTERM grace before SIGKILL is 1 s.
Follow-ups: #226 (small bridge entry point), #227 (pause the stream while hidden), #228 (hyprlang adapter), #239 (agents test timeout under load). The take-control increment for #207 uses a second writable x11vnc on a private Unix socket, as recorded in the issue.
Changes from the issue design
--classand derives the app id from the URL host and path. Each launch therefore gets a unique path,/viewer/<launchId>, and the Hyprland rule matches it. X11 still uses--class.hyprctl keyword, so the adapter useshyprctl eval. Lua has no rule delete, so cleanup disables the named rule; it stays registered until a config reload. Hyprlang configs get an ordinary window.window.resizeTodoes not resize a Hyprland window, so expand and collapse go through the bridge's window API and a compositor resize. Elsewhere the page falls back toresizeTo.Traceability
Evidence lives outside the repo, in
~/Artifacts/pickforge/2026-10-03/device-pass/. The QA report ismanifest.htmlin that folder.ssshows only 127.0.0.1test/security/security-viewer-bridge.test.ts;manifest.htmllifecyclelocalhost, rebinding Host; foreign, duplicate,nullOrigin; Origin required for POST and upgradererun/rerun.logJ13/api/status204/401/405packages/cli/test/viewer-bridge.test.ts, security test;rerun/rerun.logpackages/desktop-linux/test/viewer-state.test.ts; takeover scenariono-store,nosniff,no-referreron every response; zero CSP violations in Chromiummanifest.htmllifecycletoken=anywhere under the QA homeviewer-bridge.test.ts;manifest.htmllifecycleperMessageDeflate: falseviewer-bridge.test.ts-noselon x11vncpackages/desktop-linux/test/builders.test.ts; process args in the QA runmanifest.htmlexpand scenario02-expanded-desktop.png,rerun/r02-expanded.png05-human-control-thumbnail.png,rerun/r15-bridge-killed.png,07-no-token-page.pngsession create --viewer;session destroywith the window open stops browser and bridge and removes the viewer dir; idle and session-ended exit in testsviewer-bridge.test.ts,viewer-state.test.ts;16-after-teardown.pngpackages/cli/test/viewer-launch.test.ts11-firefox-fallback.png,10-no-gui-url-in-separate-browser.png,12-x11-expanded.pngpackages/cli/test/viewer-hyprland.test.ts;07-no-token-page.pngactivewindowempty after launch and after auto-open01-thumbnail-desktop.png-nocursorshape; RFB frames change at the pointer; pointer at 1100,650 shows in the expanded viewpackages/desktop-linux/test/viewer-cursor.test.ts;rerun3/r17-cursor-expanded.pngviewer-launch.test.ts,viewer-state.test.ts;rerun3/rerun3.logbenchmark-summary.md,benchmark-results.jsonlUNRELEASED.md, tests, typecheck, test, coveragebun run typecheck,bun run lint,bun run test:coverage(2,615 passed, 6 skipped at 0db3456), PickCheck 0 violationsBenchmarks
Nested Hyprland 0.56.2, 1280x800 session, Chromium 152. Percent of one CPU core, mean of three 20 s samples at 6afd5ad. "Animation" is unthrottled glxgears, a worst case. "Hidden" moves the window to a special workspace, since Hyprland has no minimize. Browser memory sums its process tree and counts shared pages more than once.
QA limits
The pass ran in a nested Hyprland inside a headless Sway, never on a live desktop. Page clicks and keys went through CDP input events, because that compositor has no pointer device. Hyprlang configs, KDE and GNOME were not tested.
Refs #207