Repository navigation
View and control a Linux machine's real screen (851-4496) - #1502
Merged
pondorasti merged 8 commits intoNov 27, 2026
Merged
Conversation
The server's config holds a list of displays. While the screen is set up, the server follows its own account's graphical X11 session: it starts TigerVNC's x0vncserver on a private socket when the session appears and stops it when the session ends. The relay, the display list and `codevisor desktop setup/status/remove` know about the second display. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
- The screen's package step has its own sudo, busy and failure, runs in the background like the desktop's, and names its own command to run again. - A Wayland session is refused before anything is installed. - A helper whose ports can't be checked is stopped, not shared. - Processes left behind by a session that ended don't count as someone logged in: the account must also be among those at the screen. - Sessions that are ending don't count as someone at the screen. - The helper listens on the socket recorded at setup. - Viewers get a message that fits the screen when it goes. Co-Authored-By: Claude Fable 5.2 <[email protected]>
- Each server names its screen socket after its data folder, and only removes a socket it recorded or a helper it started. A helper whose socket has gone is started again. - Who is at the screen comes from logind; who is asked only where loginctl can't be, so a remote X session doesn't count. - A helper that ignores SIGTERM gets SIGKILL and is forgotten only once it has exited. - While sharing, the account must still be at the screen. - One screen install at a time; logind asked once per status; program checks reused for 30 seconds. - Rewriting the config keeps keys it doesn't know. - setup --screen says a screen that isn't shared yet is set up and will be tried again. - The viewing notification fires once the relay reaches the screen. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Found by the code review of the previous commit: - The program list is kept only when nothing is missing, so an install setup --screen ran itself shows at once; sudo is checked only when the screen's setup asks. - logind's session type decides X11 or Wayland. - The screen's zypper install accepts zypper's "installed, but" exit codes, and pacman's messages name the screen's own command. - A screen-sharing.json that isn't a config is left alone. - The helper is found by the socket on its own command line. - A helper that stops right after starting is retried after 30 s. - desktop status doesn't suggest setup --screen on Wayland. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…roblem Third review round on 851-4496: - The session is taken from logind: its display, and the processes of that session only, so a leftover from the last login can't win. Where logind can't be asked, only live displays count, newest first. - Only graphical logind sessions, or a text login running X (startx), count as someone at the screen. - A display that can't be viewed is reported on its own (`unavailable` in the reply); when none can be, the reply fails with the first one's reason, the desktop's when it has one. - computer-use-stream-v1 is listed only for a display other than the real screen. - The desktop routes answer without the screen if looking at it fails. - The screen is called shared only while the account is at it. - README: the socket name in the example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Seen in a VM: a tmux started from the session carries DISPLAY=:0.0 while logind reports :0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Only active logind sessions count as at the screen, so a session switched to the background doesn't, and an account's active session is the one used. - Where logind can't be asked, the display who records picks the processes, with or without XDG_SEAT. - A helper isn't restarted because :0.0 and :0 differ. - remove --screen stops the helper first and fails if it can't. - The retry wait after a failed start doesn't hold back a new login. - When no display can be viewed, the failure names each one's reason. Co-Authored-By: Claude Opus 5.5 <[email protected]>
pondorasti
force-pushed
the
alexandru/851-4496-linux-desktop-step-8-view-and-control-a
branch
from
November 27, 2026 05:09
35c6569 to
90e7d7f
Compare
pondorasti
deleted the
alexandru/851-4496-linux-desktop-step-8-view-and-control-a
branch
November 27, 2026 05:11
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.
Fixes 851-4496
Step 8 of the Linux desktop design (851-4479, section 5, decisions 7 to 9): a Linux machine where the server's account is logged in at the monitor lists two displays, like a Mac with two monitors: Desktop (the virtual one, as before) and Screen (the real one). X11 sessions only in this PR.
What changed
screen-sharing.jsongetsdisplays, a list of{ id, vnc, service }:desktopandscreen. A config in the old form (the desktop'svncandserviceat the top) is read as a one-entry list and is not rewritten until setup next changes something. Viewers seevnc:desktop(first, so it stays the default) andvnc:screen.screen-logind.ts,screen-session.ts). Who is at the screen comes from logind: local, seated, active user sessions that are graphical (x11, wayland, mir) or a text login running X (startx);whoonly whereloginctlcan't be asked. The display and the session type come from the account's own logind session, and only that session's processes (itssession-<Id>.scope) supply the cookie and the bus, so a leftover from the last login can't win.screen-share.ts,screen-helper.ts). No extra service. While the screen is set up the server checks every three seconds: it starts TigerVNC'sx0vncserver(X0tigervncon Debian and Ubuntu) on a private socket with no TCP port when the session appears, and stops it when the session ends or the account is no longer at the screen. Nothing runs at the login screen. The socket is named after the server's data folder, so two servers on one account don't collide. A helper that ignores SIGTERM gets SIGKILL and is forgotten only once it has exited. The same relay and ownership checks as the virtual desktop apply.codevisor desktop setup --screen,statuslists both,remove --screen. Documented inapps/server/README.md.serve-boot.tswas near the 500-line cap, so the Linux desktop start-up wiring moved todesktop/desktop-boot.ts.What the apps need (checked, not changed)
The reply now lists displays that can't be viewed under
unavailable, each with its reason. The apps don't show it yet; they still show the reason when nothing can be viewed. Worth adding with 851-4498.Listing and opening a second VNC display needs nothing. The Mac and iPhone apps take the display list from the server, show a picker when there is more than one, and open the socket by display id.
One gap, filed as 851-4498: picking another display while a VNC connection is live only takes effect at the next connect. The in-session switch exists only for Mac hosts, and the connection restarts for a display change only when it is already reconnecting. I left the Swift change out: it needs a look in the running app, and this Mac's screen is locked.
Not in this PR
Proof
An OrbStack Ubuntu 24.04 machine with a real display manager login: LightDM greeter, password typed at the greeter, Xfce session. There is no GPU, so Xvfb stands in for the X server and plays the monitor. The server runs as
alice, built from this branch. The viewer is a scripted VNC client that connects through the server's WebSocket relay. Run on the final code.The VM has no virtual consoles, so logind first refused LightDM's session ("Seat has no VTs but VT number not 0"). A test-only PAM line in the VM reports VT 0, and the login then becomes a real logind session (
Seat=seat0,Class=user,Type=x11), as on a workstation. Who is at the screen in this run comes from logind, notwho.The real screen, captured inside the VM with
import -window root, after the viewer clicked into alice's terminal and typed a command through the relay. The notification is the one a viewer's arrival shows:The same screen as the viewer received it through the relay (display
vnc:screen):After alice logged out: the login screen, which is not shared.
The session, as run:
Third round, also in the VM: alice logged in, a tmux was started from inside the session (Alt+F2), she logged out (that session stays
closingwith the tmux in its scope) and logged in again. The screen was shared again from the new session (Id=c4,Display=:0) with two older sessions still closing. This run also showed a tmux withDISPLAY=:0.0against logind's:0, which the server now treats as the same display.Also seen in this run: after logout, logind keeps alice's session in
closing(processes outliving the logout), and the server correctly says she isn't at the screen. Step 3b runs a second server on the same account beside the first; the first one's socket survives and its viewer still connects.Package names were checked by installing them in containers, one at a time: Fedora
tigervnc-x11-server+libnotify, Archtigervnc+libnotify, openSUSE Tumbleweed and Leap 15.6xorg-x11-Xvnc+libnotify-toolsall gave bothx0vncserverandnotify-send. On openSUSE,tigervnc-x11vncis only an x11vnc-style wrapper;x0vncserveritself is inxorg-x11-Xvnc.Not proved here: a physical monitor or GPU, several monitors, GDM or SDDM, the
startxpath, a login on Fedora, Arch or openSUSE, and the Mac and iPhone apps.Tests
screen-sharing-config.test.ts: both config forms, adding and removing an entry, what isn't shared.screen-session.test.ts: which processes count as the account's session, and who is at the screen.screen-share.test.ts: set up, wait, follow login and logout, a moved display, refusals, logind's session type, a helper on the network or unchecked, an account that left the screen, a gone socket, a helper that ignores SIGTERM, a helper that dies right after starting, its own socket, another server's socket left alone, an unreadable config, removal.screen-share-notices.test.ts: the notification, the install (one at a time, failures, sudo only when asked, a fresh program list).screen-packages.test.ts: the openSUSE screen install run inshagainst a fake zypper, for its exit codes.vnc-relays.test.ts: the notification fires once the relay reaches the screen's VNC server, not before.vnc-displays.test.ts: two displays listed, relayed each to its own server, no resize of the screen, messages when the screen goes.desktop-screen.test.ts,desktop.test.ts(routes),desktop-manager.test.ts: the command line, the routes, and the desktop keeping the screen's entry.Review
Third review round (the reviewer's seven), all fixed: the session taken from logind; each display's problem reported on its own (
unavailablein the reply, and the old message when nothing can be viewed);computer-use-stream-v1only for a display other than the real screen; text-console logins don't count,startxdoes; a failing screen check leaves the desktop routes working; "shared" only while the account is at the screen; the README's socket example. The code-review run on that found more, also fixed: only active sessions count, thewhofallback matched by display,:0.0equals:0,remove --screenstops the helper first, the retry wait doesn't hold back a new login, and the failure names each display when none can be viewed.Second review round (the reviewer's ten items), all fixed: per-folder socket and only touching what it owns; logind trusted over
who; SIGKILL escalation; presence checked while sharing; package names checked in containers; one install at a time; unknown config keys carried over; a clearer message when the first start fails; the notification on connect; fewer checks per status. The code-review skill on that result found five more and three small ones, also fixed: the program list after the command line's own install, logind's session type, zypper's exit codes for the screen install, a config that doesn't parse left alone, the helper found by its own socket, sudo checked only for the screen flow, a back-off for a helper that dies right after starting, and nosetup --screenhint on Wayland.First round:
Ran the code-review skill on the branch before opening this. Ten findings, all fixed in the third commit: the screen's install has its own sudo and progress and runs in the background; Wayland is refused before installing; a helper whose ports can't be checked is stopped; processes left by an ended session and sessions that are ending no longer count as someone logged in; the helper uses the socket recorded at setup; the messages name the right command and the right display.
🤖 Generated with Claude Code