Repository navigation
feat(takeover): take control in the native viewer, and let agents ask for help - #372
Merged
Merged
Conversation
Port the keymap parsers, level lookup and spare keycode planner from desktop-linux to Rust, with the legacy keysym table. The injector sends pointer, scroll, named keys, chords and composed text only while a control grant is valid, reconciles modifiers per character, and releases every held key and button on revoke, expiry and drop. Refs #341
Add the #341 stdio control messages: attention, clearAttention and control commands, and takeRequested, returnRequested and controlAck events. A control state machine owns the XTEST injector. It releases every held key and button before it reports a revoke or a return, and on expiry, focus loss, close, session end, shutdown and stdin end of file. The watch bar offers Take control. While controlling, the bar shows Return control and Fullscreen, every key goes to the session, and pointer input maps through the scale and letterbox. The attention banner wraps the host's message inside the window and highlights Take control. Tests cover protocol parsing, the state machine, banner layout, and on Xvfb the absence of input and held keys after each end reason.
…rt a crash as viewer_closed
…d refuse format characters in help messages
A second control start stopped the live host and took its lease over. The launcher now checks the lease under the session lock before it stops the open host, and fails with HumanLeaseHeldError.
…ing each sample A 3 s sample cap timed out slow but healthy captures, and a capture that ignored SIGTERM still held its permit past the lease drain timeout. Each wait capture now keeps the full wait budget, watches for a published lease, and cancels its commands with a short kill grace. The digest runs outside the permit because it reads a file, not the screen.
3 tasks done
This was referenced Oct 28, 2026
Member
Author
|
Live check after merge, on main at 4c6e18e, on the owner's Hyprland desktop with fcitx5 set as the input method. The PiP opened pinned in the corner without focus. |
3 tasks done
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.
Taking control of a lab session needs
pickforge-lab watch --controland an external VNC client. An agent cannot ask for help in a way the user notices, and it learns about a takeover only from busy errors.The native viewer from #340 now has Take control and Return control. Its host holds the existing human lease and grants input to the viewer only while the lease is live, and the viewer sends pointer, scroll and keyboard input to the session's Xvfb with XTEST. A new MCP tool,
request_takeover, grows the viewer, shows the agent's message with a highlighted Take control button, and sends a desktop notification without taking focus. A second tool,takeover_wait, waits for the human to return control. No writable network server is started; the x11vnc path stays as the fallback forwatch --controlwithout a native viewer.Closes #341
watch --controlwatch --controlstartup; a secondwatch --controlduring live controlnative-viewer-host.test.ts,native-viewer.test.ts,control_xvfb.rs,wait.test.ts, QA item 1, F2 and F3olá ção ÁÉ ñ ß €, chords, named keys, held modifiers, lock keys dropped; buttons 1 to 9; scroll capped at 32 steps per axis with the grant checked before each step; grant expiry mid-burst; revoke; stdin end of file; ABNT2 dead keys on a br/abnt2 host typing into a US sessionáãêàüç,ÁÕandÇarrive with no stray dead keyinject_xvfb.rs,control_xvfb.rs, QA J1, item 1, F4returned; no held input after any end; the watchdog recovers in about 5 sstuck-input.test.tsdesktop_screenshotanddesktop_waitfail closed with busy during controltakeover.test.ts,security-takeover-observations.test.ts, QA item 1request_takeovergrows the viewer, shows the message and notifies without focus, and returns on return, timeout or cancel with a fresh screenshotrequest-takeover.test.ts, QA items 1, 2 and 5, J3 to J5viewer.mode: "auto", MCP opens a missing viewer; otherwise it returns the CLI commandpickforge-lab watch --session <id>and launches nothingrequest-takeover.test.ts, QA J2takeover_waitwaits until no human lease is activetakeover-wait.test.tsrequest_user_inputpoints torequest_takeoverfor secretsuser.test.tscrates/for listeners; the x11vnc argv recorder never sees a writable start on the viewer path; no socket op grants control or injects inputsecurity-native-control.test.ts,security-viewer-takeover.test.ts,native-viewer.test.tsQA pass: I drove the built CLI, the MCP server and the release viewer on nested Xvfb displays, with a fake
notify-sendthat records its arguments. The first pass found four defects, all fixed here: closing the window while controlling reportedviewer_closed, a cut emoji in the notification, bidirectional characters in the message, and a held time counted from the request instead of from Take control. The rerun found that a secondwatch --controltook over a live control, and that a refusedwatch --controlgave a vague error and closed the open viewer. One check fixes both, with tests that fail without it. The final pass confirmed both fixes, close while controlling, and Brazilian ABNT2 dead keys on the viewer's display. A last pass on 26599e4 started control three ways while a long wait ran. The wait failed with busy within 0.21 s of the lease, and control was granted within 0.8 s. Waits after return reportedchangedandstablewith samples counted. Not covered: take control on a Wayland desktop with an input method such as fcitx5. Every QA run used the viewer's X11 backend on Xvfb, without an input method.Declined:
viewer.mode: "auto"from a project config can let MCP open the viewer. That is the documented behavior from before this change, and no input is granted until the human presses Take control. Filed as viewer: a repository config can turn on automatic viewer launch #370 for an owner decision.Follow-ups: #369 (
watch --controlwithout a VNC client suggests a tunnel to a read-only server), #370 (viewer.modetrust), #371 (a version-mismatchedwatchstops a host that holds live control), and #317, which already covers the.takeover-identityand.input-closedfiles that destroyed sessions leave.Rollback: revert this PR. The native viewer goes back to watch only,
watch --controluses the external VNC client again, and the two MCP tools disappear. No stored data changes; a lease file left by a running host is recovered as stale by the existing watchdog.Council review, 3 rounds:
Astra's round 3 asked for changes. It showed that the 3 s cap on each wait sample timed out slow but healthy captures, and that a capture ignoring SIGTERM still held its permit past the lease drain. Fable raised the same timeout. A wait capture now stops when a takeover starts, and keeps the whole wait budget otherwise. After round 3, a fresh Fable review rechecked these fixes and the D6 fix from QA, and approved at 9/10. Its two nits: the wait cleanup docs, now fixed, and #371.