Skip to content

Set up, watch and remove a Linux desktop from the Mac app (851-4497) - #1503

Merged
pondorasti merged 3 commits into
mainfrom
alexandru/851-4497-linux-desktop-step-4-set-up-watch
Nov 27, 2026
Merged

pondorasti merged 3 commits into
mainfrom
alexandru/851-4497-linux-desktop-step-4-set-up-watch

Conversation

@pondorasti

@pondorasti pondorasti commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Fixes 851-4497. Part of 851-4479 (Linux desktops), step 4 of the design ("In the Mac app", "Failure messages").

What changes

Mac app

  • The Desktop card shows for every Linux machine (inspector, Machine tab), in the design's states:

    State Card shows
    No desktop "No desktop on this machine yet." + Set Up a Desktop ("Set Up Again" for a desktop set up for an older Codevisor)
    Setting up One line at a time: "Checking …", "Removing the older desktop…", "Installing Xfce and TigerVNC…", "Starting the desktop…"
    Ready The live picture, as today
    Needs an administrator "Installing packages needs an administrator on ." + Open Terminal
    Failed One sentence + Try Again
    Server too old "Update Codevisor on to set up a desktop."
  • Remove Desktop… in the card's menu, with "Remove the desktop on ? This closes everything open in it." A desktop Codevisor didn't set up only offers Stop Sharing Desktop…, with its own wording (it keeps running). Same rule as the CLI.

  • The Desktop tab offers itself on every Linux machine and shows the same states at pane size until there is a desktop to show.

  • Confirmations follow the CLI: replacing an older root desktop and replacing a desktop config Codevisor didn't write are each asked once before anything happens.

  • Open Terminal opens a terminal tab on that machine and types the server's own setup command, where the person types the sudo password. The app never holds a password and never builds or runs a root command. Where no terminal tab can open (a bot's workspace), the card shows the command to run instead of a button.

How the app drives it (MachineDesktopSetup reducer in CodevisorCoreMac): the same routes as codevisor desktop setup, in the same order: GET /v1/desktop, then after a yes POST /replace-old, POST /packages (polled through busy), POST /start; DELETE /v1/desktop[?unshare=1] for removal. With passwordless sudo the server does the root steps; otherwise the card stops at "needs an administrator". No progress route was needed: the card names its own phase, as step 2 planned.

Server (the CLI uses it too)

  • The status carries setupCommand: the server's own program followed by desktop setup (with CODEVISOR_DATA_DIR when the data folder isn't the account's default), because a terminal the server starts doesn't always have codevisor on its PATH.
  • Adding a machine with a desktop, off by default (decision 1): codevisor machines add <host> --desktop, desktop: true on POST /v1/machines/add, and the agents' machines.add. The remote script sets CODEVISOR_DESKTOP=1, and the installer runs codevisor desktop setup --yes at its end instead of printing the hint. The answer says whether the desktop came up (desktop: "ready" | "not-set-up"), and the command says it plainly. A failed or timed-out desktop setup doesn't fail the add once the machine has joined. There is no add-machine screen in the Mac app to put a checkbox on; that is a separate piece of work.
  • "Server too old" needs no flag: a server from before desktop setup answers 404 on /v1/desktop (a non-Linux server answers 501).

iPhone (decision 5, no setup from the phone): unchanged. A Linux machine without a desktop simply has no "Open Desktop" entry there.

Choices I made

  • No sudo at all looks like "needs an administrator", with Open Terminal: codevisor desktop setup in that terminal prints the commands for an administrator. The app never receives root commands, so it can't show them itself.
  • A desktop that is set up but not running shows as Failed ("The desktop on isn't running."), and Try Again starts it.
  • Try Again repeats what failed: a failed look looks again, a failed removal asks to remove again, a failed setup runs the setup again. It never starts an install nobody asked for.
  • A machine that already shares a working desktop keeps its picture even when its server is older or a status look fails.
  • A started desktop the app doesn't see shared gets ten re-checks over 30 s, then "The desktop on started, but it isn't shared with Codevisor yet." with Try Again, instead of an endless spinner.
  • One shared reducer per machine keeps the card and the tab in step; only the view the person used presents a confirmation.

Tests

  • MachineDesktopSetupTests (21, TestStore with a fake client and clock): each resting state, the passwordless path line by line, needs-an-administrator for password and no sudo, the failure sentences, Try Again per failure, older root desktop with yes and no, remove and stop sharing, an install someone else started, a removal cancelling a look in flight, the picture kept for a working desktop, a desktop that never appears, one confirmation owner, a question whose view went away, renames, a running unmanaged desktop while asking, a desktop that stops while shown.
  • DesktopRequestTests: each call is one request to the CLI's route; decoding.
  • MachineStatusFeaturesTests: every other Linux machine gets a Desktop card. TerminalControllerTests: a new terminal's first command is typed once after the shell speaks.
  • Server: setupCommand with and without a custom data folder; 501 on a non-Linux server; enrollment with and without a desktop, the outcome read from the installer's output, a join before a desktop timeout counted as added; machines add --desktop and its two answers.
  • Installer: asked for a desktop it runs the setup (starting the server first if needed); a failed setup doesn't fail the install; a release without the command says so; nothing on a Mac.

Proof so far

  • Debian 12 container, real install.sh with this branch's server: CODEVISOR_DESKTOP=1 root install installs and starts the desktop (70 s, exit 0); the setupCommand from the status ran from a terminal with no codevisor on its PATH; without the option, only the hint.
  • The Mac app builds (bun run build:macos); Swift format and lint pass.
  • Code review (medium) on the branch, findings fixed: a working desktop losing its picture, Try Again starting an unrequested install, a stale look overwriting a removal, a dead Open Terminal button in bot workspaces, an endless "Starting…" spinner, the add-machine report claiming a desktop that wasn't set up, a desktop timeout failing an add that had joined, two views presenting one dialog, frozen machine names, the data folder missing from the typed command.

After your review at f83a8eb

  1. machines add --desktop on a machine whose desktop already runs: with CODEVISOR_DESKTOP=1 the installer now always runs codevisor desktop setup --yes, which prints "The desktop is already running" (or restarts a stopped one), so the add reports it as ready. Installer test added.
  2. Open Terminal in the desktop window: that pane isn't in a pane group, so it now shows the command as text, as the card does in a bot workspace. Only a Desktop tab in a workspace with a chat offers the button.
  3. One confirmation per view: each view has its own identity (the pane's id for a tab, its own id for the inspector card), and only the view the person used presents the dialog.
  4. No stuck "Checking…": while a question waits the phase is a new non-busy asking ("Waiting for your answer about the desktop on ."), not a busy one. Cancelling, or the asking view going away, returns the card to its resting state, and a status look that lands meanwhile doesn't overwrite it. Test: ask from one view, drop it, the other view can act and ask again.
  5. No 60 s wait after an early failure: the add only waits for a join when the installer had reached "Setting up a desktop" (matched without the colour codes the installer prints).
  6. Renames: the setup store is kept per machine id and the name is updated in place, so a shown dialog stays; the resting sentence is rebuilt with the new name, and the desktop tab reads the current name rather than the one it was opened with.

The review pass on this round also found and I fixed: the "Setting up a desktop" match failing on the installer's coloured output, the tab pushing a stale name back, and a running desktop Codevisor didn't set up showing as ready behind the "Replace it?" question. Left, with the reason: the tab's Open Terminal decision comes from its pane context, not from the handler's own check for tabless (bot) workspaces, which have no tabs to hold a Desktop tab.

Hand checks in the dev app (light and dark)

  • Dev container, desktop removed: set up from the card and watched it reach ready with the live picture. This closes step 2's Mac-app check. Remove Desktop… asked first, and the server then reported no desktop and its config file was gone.
  • OrbStack VM (Ubuntu 24.04), password sudo: Set Up a Desktop stopped at "Installing packages needs an administrator on Linux VM." Open Terminal opened a terminal tab on the VM that typed the server's setup command, and sudo asked for the password there.
  • Same VM, passwordless sudo: Set Up a Desktop ran the install on the server ("Installing Xfce and TigerVNC…") and reached ready with the live Xfce picture, all from the card.
  • Bug found and fixed: a desktop that stopped while on screen only got the viewer's plain "isn't running / Retry", never Failed with Try Again. The card and the Desktop tab now look again when the picture fails, and the tab reconnects once the desktop is ready again (only a tab whose stream had failed). Checked by hand: Failed with Try Again in card and tab, Try Again restarted the desktop, the tab reconnected. The last guard (reconnect only a failed tab) came from the review pass after that check and is format-checked but not rebuilt.
  • Screenshots of every card state, the Remove confirmation, the empty Desktop tab and the VM runs are in the review inbox entry.
  • Test-setup note: an OrbStack VM can't reach the dev relays, which listen on the Mac's loopback only. I forwarded them into the VM and gave its server the dev CA (CODEVISOR_NET_CA_FILE). That's a dev-environment gap, not something in this PR.

Swift tests run locally

PRs don't run the Swift lane, so I ran the touched targets: CodevisorClientTests, CodevisorCoreTests and CodevisorCoreMacTests in full, and MachineDesktopSetupTests again after the last change (21 pass). The Mac app's only test target, Transcript, isn't touched.

After the look review

  1. Plain failures: every failure on the card and the tab is one plain sentence per attempt, with no paths, socket names or raw server output. The sentences are "The desktop on isn't running.", "Couldn't check the desktop on .", "Couldn't remove the desktop on ." (or "Couldn't stop sharing…"), "The desktop on didn't start.", "Setting up the desktop on didn't work.", "Installing Xfce and TigerVNC on didn't work." and "Xfce and TigerVNC are still missing on after the install." The detail goes to the app log (category MachineDesktop) and stays in codevisor desktop status. "Server too old" and the unknown-system sentence, which names what to install, are unchanged.
  2. Open Terminal's tab is named "Desktop setup". The command typed into it is unchanged.

Tests: MachineDesktopSetupTests asserts each plain sentence (the fake server's detail includes a socket path), the "still missing" case and the terminal's name. TerminalLiveTitleTests checks that a named terminal keeps its name over the shell's title. Ran the whole Swift package locally. The only failure was CloudMachineKeyLookupTests while the machine's load was over 100; it passed when run alone, and this PR doesn't touch it. Rebuilt the Mac app and checked by hand: the container's stopped desktop shows "The desktop on Dev Cloud (kugel) isn't running.", with the socket path in the app log only. On an OrbStack VM with password sudo, Open Terminal opens a tab named "Desktop setup".

Not in this PR

  • An add-machine screen in the Mac app (and so a "with a desktop" checkbox there).
  • Setup from the iPhone (decision 5).

🤖 Generated with Claude Code

@pondorasti
pondorasti marked this pull request as draft November 27, 2026 03:12
@pondorasti
pondorasti force-pushed the alexandru/851-4497-linux-desktop-step-4-set-up-watch branch from f83a8eb to 9e3192a Compare November 27, 2026 03:43
pondorasti and others added 2 commits November 27, 2026 14:46
The Desktop card and the Desktop tab show on every Linux machine and drive
the same server routes as codevisor desktop setup. Root steps run on the
server with passwordless sudo, otherwise in a terminal tab on the machine.
Adding a machine over SSH can ask for a desktop.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The card and the Desktop tab now look again when the live picture fails, so a desktop that stops while on screen gets Try Again instead of the viewer's plain retry, and the tab reconnects once the desktop is ready again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pondorasti
pondorasti force-pushed the alexandru/851-4497-linux-desktop-step-4-set-up-watch branch from 9e3192a to 01ec346 Compare November 27, 2026 22:52
@pondorasti
pondorasti marked this pull request as ready for review November 27, 2026 22:52
…51-4497)

The card and the Desktop tab say what went wrong in one plain sentence per attempt, such as "The desktop on <machine> isn't running.", without paths, socket names or raw server output. The detail goes to the app log under MachineDesktop and stays in codevisor desktop status. Open Terminal opens a tab named "Desktop setup" instead of one titled with the command line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pondorasti
pondorasti merged commit de19d81 into main Nov 27, 2026
@pondorasti
pondorasti deleted the alexandru/851-4497-linux-desktop-step-4-set-up-watch branch November 27, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant