Repository navigation
Show apps opened by agents and terminals in the Linux desktop (851-4494) - #1498
Merged
pondorasti merged 4 commits intoNov 27, 2026
Merged
Conversation
Agent harnesses, terminals, exec commands and stdio MCP servers that the server starts while a Codevisor-managed desktop is set up get its DISPLAY and XAUTHORITY. One helper reads screen-sharing.json at each launch, so a desktop that appears, moves or goes is followed. An environment that already has a display is left alone. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…sor's Review findings on 851-4494: - A desktop that is set up but not running no longer gives its display, so an app that can run headless doesn't fail on a display that isn't there. - The injected pair is marked with CODEVISOR_DESKTOP_DISPLAY, so a server started from a Codevisor terminal still follows the config instead of treating the inherited display as chosen on purpose. - DISPLAY and XAUTHORITY are only ever set together. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…splay it is Second review round on 851-4494: - Restored terminals start their shells once the desktop has been resumed and is up (at most 15 seconds), and every terminal's launch environment is now resolved when its process is spawned. - One shared check for "the desktop is up", used by status and by the launch environment: the socket is there and private, and the session mark names a live desktop runner, so a stale mark with a reused process id no longer counts. - The marked pair records which server's config it came from. A server manages only its own pair; another server's is left as it is unless this server has a desktop of its own up. - An environment stripped of Codevisor's pair is what is returned when a Wayland display is there too. Co-Authored-By: Claude Fable 5.2 <[email protected]>
- Agent turns the server continues at start wait for the desktop like restored terminals do. - A restored terminal keeps its saved program in snapshots until its process has started, and its resume file is only written then. - The up-check wants the runner of this server's data folder, so another server's desktop on the same account doesn't count. - The start-up wait is skipped for a desktop nothing will start, and ends 15 seconds after the server started at the latest. - The launch environment no longer needs the account's passwd entry. Co-Authored-By: Claude Fable 5.2 <[email protected]>
pondorasti
force-pushed
the
alexandru/851-4494-linux-desktop-step-7-apps-opened-by
branch
from
November 27, 2026 01:10
0e777e8 to
d917884
Compare
pondorasti
deleted the
alexandru/851-4494-linux-desktop-step-7-apps-opened-by
branch
November 27, 2026 01:12
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-4494
Step 7 of the Linux desktop design (851-4479, decision 6): what the server starts on a machine with a running Codevisor-managed desktop gets that desktop's
DISPLAYandXAUTHORITY, so a window it opens shows in the desktop you are watching.What changed
desktopEnvironment(apps/server/src/desktop/desktop-environment.ts). It readsscreen-sharing.jsoneach time a process is started, so a desktop that is set up, moves to another display number or is removed while the server runs is followed by the next launch.launchEnvironment), wired once inserve.ts:envFor, which now applies it;execcommands run on the machine for an agent (the environment is now read per command instead of once at server start);apps/server/README.md:DISPLAYorWAYLAND_DISPLAY(even empty) is left exactly as it is, cookie included.DISPLAYandXAUTHORITYare set together, never one without the other.CODEVISOR_DESKTOP_DISPLAY) and the config it came from (CODEVISOR_DESKTOP_CONFIG). A server manages only its own pair: replaced when the desktop moved, taken away when it is down or removed. Another server's pair (a dev server with its own data folder, started in a Codevisor terminal) is left exactly as it is unless this server has a desktop of its own up.servicekey (someone else's desktop, including the dev container's own script), with an older port-based config, or on macOS.desktop-liveness.ts), shared bycodevisor desktop statusand the helper: the socket is there and private, and the session mark names a live process that is this server's desktop runner. A stale mark whose process id was reused doesn't count.serve.tswas at the 500-line cap, so a small helper moved toserve-boot.tsand its two imports from that file were merged.The server has no user setup scripts today (worktree setup only creates the worktree), so there was no such path to cover.
Not changed, on purpose
Proof
Dev container (
node:22-bookworm, the dev container's entry script, started without its own desktop so the server's environment has noDISPLAY), one container at a time, removed afterwards. The desktop was set up withcodevisor desktop setup --yes(config has"service": "process", display:1).Captured inside the container with
import -window root(ImageMagick), on the second commit; the launch paths it shows are unchanged since:POST /v1/terminalsPOST /v1/agents, running the command with its shell tool (the agent replied "done")POST /v1/execRun again on the final commit (
echo "DISPLAY=[$DISPLAY] XAUTHORITY=[$XAUTHORITY]"):DISPLAY=[] XAUTHORITY=[]codevisor desktop setupdesktop status: running. New terminal and exec:DISPLAY=[:1] XAUTHORITY=[/root/.codevisor/run/codevisor-desktop.xauth], with both marks. The mark's process isnode …/cli.js desktop run --data-dir /codevisor-data/datadocker restart: every process dies, the socket and mark files stay)DISPLAY=:1kill -9, mark left pointing at another live processdesktop status: isn't running. exec:DISPLAY=[] XAUTHORITY=[]Seen on the second commit and not run again: after
codevisor desktop remove, and with a hand-made config without aservicekey, a new terminal and exec got nothing; the first agent's harness process kept:1after the removal, as documented.Not shown live, unit tests only: the "already has a
DISPLAY" rule, the rules for a marked pair (this server's and another server's), agent turns waiting at server start, and macOS. The Mac app was not driven (this Mac's screen is locked).Tests
desktop-liveness.test.ts: the shared up-check (socket problem, no mark, dead runner, reused process id, another server's runner).desktop-environment.test.ts: the helper (running managed desktop, launch-time read, existing display kept, a pair from this server followed or taken away, a pair from another server left alone, Wayland beside Codevisor's pair, stopped desktop, someone else's config, old port config, no cookie, unreadable config, macOS).desktop-manager-robust.test.ts: the start-up wait (until up, gives up after 15 s, no wait with no desktop, someone else's, another server's unit, or a systemd it can't reach).launch-environment.test.ts(agent runtime, including a hook that has to wait),terminal-manager-shell.test.ts(including restored terminals waiting, one closed while waiting, and the saved program kept in snapshots meanwhile),exec-tasks.test.ts,mcp-stdio-environment.test.ts(a real stdio server reporting what it was started with).Review
🤖 Generated with Claude Code