Repository navigation
feat(remote): remote controls, quick actions and the access dialog in the app - #84
Merged
Merged
Conversation
…ntrols A paired machine can now start, stop and restart a service on a target that allows it (PR 4c-2 of docs/remote-machines.md), through whoever owns the service there. Target: `control` and `control.status` in the remote actor. Checks 1 to 3 (pin and hello, share and control, a fresh lease) run in the actor; the executor in infrastructure/remote/control.rs runs 4 to 9 off it: request entries in services/requests/<peer>/<requestId>.json, published before anything changes and kept 24 h, with request_mismatch for another fingerprint; expiry, ids and profile, one control per service (busy), the state and configRev, then the owner. Who acts follows the contract's table: the app's bridge, a detached `localify dev ... --detach` started from the daemon's own canonical executable with the shell environment, or a refusal. A launch is followed to its record (dispatched, started, settled within 90 s); an unanswered bridge launch waits for its expiry and is reported from the record, never started again elsewhere. Legacy relaunch: the inventory names a proven legacy run of the app or of `dev --detach` with `legacyId`, and a restart with `expect.legacyId` relaunches it through its owner. `localify dev --replace-legacy` refuses under the run lock unless the record still names that legacy run, and the app bridge passes `replacesLegacy` on instead of refusing it. The inventory's controls now follow the switches and the app's presence, so a granted access request shows in the next snapshot. Viewer: `remote_control` streams sent, progress and the result, waits 120 s, and after a lost session reports unknown and asks control.status on a new session, never resending. The desktop DTO and its TypeScript mirror carry the stream; no screen uses it until PR 4d.
… the app
The app now starts, stops and restarts services on another machine, and
answers access requests on this one (PR 4d of docs/remote-machines.md).
Viewer: the remote chip's Start/Stop and the menu's Restart call
`remote_control` with the snapshot's expect values (runId, configRev, and
legacyId for a relaunch). A toast shows the progress ("Starting in the app
on B…"), `unknown` as "Outcome unknown. Checking B…", then the result.
One control per service at a time, and none while the session is down:
the button is disabled with the connection state.
Quick actions: a control that isn't allowed stays clickable and opens a
card. control_disabled and background_disabled offer `Ask B` on protocol
2 (the `remote_access` stream, with Cancel, the outcomes and retryAfter)
and always the command to run there; protocol 1 gets only the command.
A legacy run with a legacyId, its Restart and Output's "Relaunch to
share" go to `Relaunch on B` after the contract's confirmation; with
controls off it asks for access first, then relaunches only if the
snapshot still shows the same legacyId and configRev, and otherwise asks
again. Other codes show their message.
Target: the app subscribes to `remote_events` with `access: true` and
shows the access dialog in the contract's words, one request at a time,
with a system notification while the window isn't focused
(tauri-plugin-notification). Focus lands on the dialog, not a button.
Settings → Remote access: the control and background switches work, and
suppressed machines are listed with `Allow requests again`.
The "comes in a later version" texts and the disabled-only paths are
gone. Pure logic is in lib/util.remote-controls.ts, with node tests.
A control's answer no longer leaves once `share` is off, and status queries read nothing then. A control not dispatched yet is cancelled by an unpairing or a new key, and the pin is checked again right before dispatch. The daemon spawns a detached start's executor itself, so an executor stalled before its admission is killed with its session at expiry and its lock freed. Controls and status queries are admitted within a per-viewer and a global bound before any work, request entries are rate-limited per peer, and stale entries are swept periodically instead of on every publication. A launch's own record now decides readiness over the port, a restart interrupted after its stop reports `failed`, and failure output is cut to fit a session message. On the viewer, a control goes only over an open session and is never queued, and `unknown` is asked again every 2 s for up to 2 minutes instead of ending the stream. The app's "Reload shell environment" now also reloads the daemon's copy, through `remote_reload_shell_environment`. The convergence gate now runs through a real daemon watch against real `localify dev` and `localify stop` processes.
…ground starts - Map the connection-state refusals (`not_connected`, `connecting`, `not_responding`), `busy` and `too_many` to their messages, and `lost` by its code, `not_shared` included. A result never says "Checking B…". - With `control` off, a start while B's app is absent, or a restart of a background run, asks for `backgroundStarts` in one request, and the card's command turns on both switches. - Close a relaunch's access toast when the machine's view goes away.
# Conflicts: # desktop-ui/src/types/localify.ts # docs/remote-machines.md # src/daemon/remote/actor.rs # src/daemon/remote/actor/control.rs # src/daemon/remote/actor/viewer.rs # src/daemon/remote/fake_relay.rs # src/daemon/remote/local.rs # src/daemon/remote/tests/control.rs # src/daemon/remote/tests/convergence.rs # src/daemon/remote/viewing.rs # src/desktop/dto.rs # src/infrastructure/remote/control.rs # src/infrastructure/remote/requests.rs
teo-goulois
marked this pull request as ready for review
November 9, 2026 15:53
…ntil answered - Control streams are kept in a registry and closed when the machine leaves the screen, with their toasts dismissed. Late events, and streams whose opening resolves afterwards, are dropped or closed at once. - The access dialog stays, with its buttons off, until the answer is through or access_closed arrives. A failed answer shows its error in the dialog and lets the request be answered again while it still waits. - A relaunch whose access request ends without access keeps its reason on screen with "Or run this on B:" and the command. The relaunch card shows the command too. - The notification capability grants only is-permission-granted, request-permission and notify.
The daemon can send a control's last event, then keep the stream open while it fetches a fresh snapshot. Settling only forgot the stream, so leaving the machine in that window left its reader running until EOF. Settling now closes the transport too; closing one already ended does nothing.
This was referenced Nov 9, 2026
Merged
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.
PR 4d of
docs/remote-machines.md: the app's buttons for remote controls, the quick actions, and the access dialog.What changed
Controls in the remote chip. Start/Stop and the menu's Restart call
remote_controlwith the snapshot'sexpect(runId and configRev, plus legacyId for a relaunch). While it runs, a toast shows the progress ("Starting in the app on B…", or "…in the background…" when B's app is closed),unknownas "Outcome unknown. Checking B…", then the result. Refusals use the "Errors" wording throughremoteErrorMessage. Each service has one control at a time. Leaving the machine's view closes its control streams and dismisses their toasts; events that arrive later, and streams whose opening resolves after that, are dropped or closed at once. No control is sent while the session is down: the button is disabled and says why ("Connecting to B…", "B: Offline", …).It follows the
remote_controlstream as #83 now has it:resultwith the connection state.not_connected,connectingandnot_respondinghave their own messages ("Not connected to B.", "Still connecting to B. Try again once it is connected.", "B isn't responding right now.");peer_offline,not_pairedandkey_mismatchkeep theirs, andunavailableshows the daemon's message ("The relay dropped a frame; try again in 3 s.").result, so its toast ends with the reason.busysays "Something else is starting or stopping it on B. Try again in a moment." The control result carries noretryAfter, so the wait isn't given.too_manysays "This Mac sent B too many controls lately. Try again later."lostis read by its code:not_sharedsays "B stopped sharing before it said what happened.";not_paired/key_mismatchadd the pairing message; anything else says "B didn't say what happened. The list shows its current state."unknownkeeps the toast on "Outcome unknown. Checking B…" until the result orlost, which the daemon now always sends. Aresultofunknownwould end the toast with the lost text rather than "Checking B…".Quick actions. A control that isn't allowed stays clickable and opens a card under the chip:
control_disabled/background_disabledon protocol 2:Ask Bover theremote_accessstream. Withcontroloff, an action that would run in the background on B asks forbackgroundStarts, which turnscontrolon too, in one request: a start while B's app is absent (machine.app == "absent"), or a restart (or relaunch) of a background run. Asking forcontrolfirst would getbackground_disablednext, and a second request within 10 minutes getstoo_many. The card's command follows the same choice (localify machines settings --control on --background-starts on). The contract's "Quick actions" says so now. It shows "Waiting for an answer on B…" with Cancel, then the outcome, including errors withretryAfter("Try again in 9 min."). The card always shows "Or run this on B:" with the command and a copy button. On protocol 1, only the command shows, under "Update Localify on B to ask from here."legacyIdon protocol 2 (refusedlegacy_run, its Restart, or Output's "Relaunch to share") getsRelaunch on B, after the contract's confirmation. With controls off, the card also shows "Or run this on B:" with the command, and the relaunch asks for access first, in a toast with Cancel. When that request ends without access (nobody,declined, an error), the toast stays, with the reason, "Or run this on B:", the command and Copy, until it is closed. Once access is granted, it relaunches only if the next snapshot still shows the same legacyId and configRev; otherwise it shows the confirmation again.Access dialog on the target. The app subscribes to
remote_eventswithaccess: trueand shows the dialog in the contract's words:Allow/Don't allow, with "Don't ask again from X".It answers with
remote_access_answerand shows one request at a time (others wait in a queue). The dialog stays, with its buttons and checkbox off, until the answer is through oraccess_closedarrives. When the answer can't be sent, the error shows in the dialog and the request can be answered again, as long as it still waits; one closed meanwhile stays gone. Escape and clicks outside don't answer it. Focus lands on the dialog itself, not on a button, so someone typing in a terminal tab can't answer it by pressing Enter. A system notification is sent when the window isn't focused. The app never takes focus.Settings → Remote access. The control and background-start switches now work. Control needs sharing, and background starts need control. Suppressed machines are listed with
Allow requests again(remote_access_suppressed/remote_access_restore).Leaving a machine's view closes a relaunch's "Waiting for an answer on B…" toast. Before, its stream was closed and its events dropped, so nothing closed the toast.
Removed. The "comes in a later version" texts, the disabled-only
ControlButtonandSwitchRowpaths, and the "until PR 4d" notes in the DTOs,dto.rsand the contract.Notification plugin. The notification is the one Rust change:
tauri-plugin-notification~2.3 (crate and JS, pinned so the JS side keeps@tauri-apps/api2.10) and, in the capability, only the three permissions the plugin'swindow.Notificationshim calls:notification:allow-is-permission-granted,notification:allow-request-permissionandnotification:allow-notify. The stream validator also gained thecontrolkind. Without it,tauriClientwould have rejected every control.Pure logic is in
desktop-ui/src/lib/util.remote-controls.ts: which quick action for which code, proto and app presence, buildingexpect, message mapping, the relaunch re-confirm rule, the fingerprint label, and the access dialog's pending, answering and failed states.desktop-ui/src/lib/util.stream-registry.tsholds the control streams that are closed together.How it was tested
pnpm run typecheck,pnpm desktop:test(54 tests: 20 inutil.remote-controls.test.ts, including one that runs a built control through the stream validator, one for thebackgroundStartschoice, one for the refusal andlostmessages, and four for the access dialog's states; 5 inutil.stream-registry.test.ts, for closing on leave, late openings, streams that ended by themselves, and a newer stream of the same service), and oxlint ondesktop-ui/src.cargo clippy --locked --manifest-path src-tauri/Cargo.toml -- -D warningswith a sidecar copied in and removed afterwards. A bogusnotification:permission fails that build, so the three names are checked.cargo fmt --checkfor both crates.cargo clippy --locked -- -D warningsandcargo test --lockedfor the root crate.cargo clippy --locked --manifest-path src-tauri/Cargo.toml -- -D warningsandcargo testthere, with a sidecar copied in and removed afterwards.pnpm desktop:build.pnpm run typecheck,pnpm desktop:testand oxlint were run again. The update changes no Rust, and the merge was clean: on the Rust side, feat(remote): remote controls, quick actions and the access dialog in the app #84 touchesdto.rscomments and the plugin insrc-tauri/src/lib.rs, and 74e7bc1 touchessrc-tauri/src/commands.rs. The cargo checks above were not repeated on the merged tree.Not seen in a running app
None of this was run in the app or on two machines. The contract's gate for 4d (the access dialog end to end, on two machines) is still to do. Not seen: