Skip to content

Desktop app follow-ups: uninstall, licences, install.sh, setup start - #6

Merged
itrycodinganditsbad merged 17 commits into
mainfrom
desktop-followups
Oct 19, 2026
Merged

itrycodinganditsbad merged 17 commits into
mainfrom
desktop-followups

Conversation

@itrycodinganditsbad

@itrycodinganditsbad itrycodinganditsbad commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Follow-ups from the desktop app PR (#5): its "Left for later" list and the review notes, plus one round of fixes from this PR's review.

What changed

  • Uninstall from "Apps & features": once the setup's process has ended, rmdir /s /q removes the program folder. PowerShell waits for the process; where PowerShell can't run, cmd alone waits using tasklist. rmdir /s removes a junction without following it. The Uninstall key is removed only once one of the two has been started.
  • Licences: LICENSES.txt is generated from cargo tree and cargo metadata for every third-party crate compiled into the shipped programs (normal deps for the target, no proc-macros), sorted by name and version. Each crate gets its licence expression and the licence/notice/copying files it ships. MPL-2.0 crates get a line pointing at their unmodified source on crates.io.
    • A crate with no licence file passes only if it can be taken under plain MIT or Apache-2.0. clipboard-win gets error-code's BSL text. Any other crate fails the package build, by name.
    • The file goes in the tarball (installed next to the programs), the macOS bundle and the setup's payload.
  • install.sh --no-menu: leaves out the app menu entry and removes one an earlier install made.
  • Setup starting the agent: it starts through PowerShell's Start-Process, so it inherits none of the setup's handles, and a setup run from a pipe (WSL) returns. If PowerShell fails, the agent is spawned directly, and the setup says which way it took. System tools are called by full path from %SystemRoot%\System32.
  • Single-instance files: they live in craft-cloud-app/, next to the agent's data folder. The uninstallers remove only the app's own file names (and the old loose ones), then the folder once it is empty, best effort, as the last step.
  • D-Bus tray tests: when they skip, it now shows in the test output; with CRAFT_CLOUD_REQUIRE_BACKENDS set, a skip fails. CI installs dbus and runs them with it set. AGENTS.md says so.
  • install.sh and the running agent: it reads the agent's pid from local-api.json, asks it to quit, then waits for the process to end (kill -0) within CRAFT_CLOUD_INSTALL_WAIT. Only then does it change anything.
    • Starting the agent again: systemctl --user stop then start, or run --log without a unit.
    • On a timeout nothing is changed, and a background step starts the agent again once its process has ended, never from the unpacked package. A failure after the stop starts the agent again from an EXIT trap.
  • Setup, the agent's stop: a tasklist that fails or prints nothing doesn't count as the agent having ended. If it fails after the agent accepted quit, the setup starts the agent again before reporting. An install that fails after the stop does the same.
  • Tray: a failed register is printed.

Testing

  • Linux: cargo xtask ci passes (856 passed, 0 failed, 1 ignored). The install.sh tests cover the upgrade with and without a unit, the timeout with and without one, a failure after the stop, and --no-menu. They run against stand-ins whose agent process is a real sleep named in local-api.json. cargo xtask package builds the tarball, and its LICENSES.txt lists 361 crates.

  • Windows: clippy --all-targets -D warnings and the tests pass for the desktop, setup and xtask crates. Windows-only tests cover:

    • a detached start doesn't hold the caller's pipe;
    • both removers (PowerShell and cmd) wait for the process, then remove a folder with & in its name and a junction inside it, without following the junction.

    cargo xtask package builds the setup with LICENSES.txt in it. The setup and the app weren't run on this machine.

  • On this Windows (German), tasklist's "no tasks" line goes to stdout, so an empty answer really is a failure.

Left

  • Upgrade on Linux: install.sh doesn't stop an old app or tray process. An old tray keeps its old lock, so until the next login there can be two tray icons.
  • The background step that starts the agent again after a timeout dies with the session under logind's KillUserProcesses=yes. It could run under systemd-run --user.
  • Starting the agent through PowerShell fails on a path with [ or ] (wildcards); the direct-spawn fallback then starts it.
  • Uninstall: if the final message stays open for over an hour, the folder stays.
  • PowerShell being blocked by policy hasn't been tried for real. The fallbacks are tested by calling them directly.
  • The real uninstall from "Apps & features" and a setup run from WSL still need a manual check after installing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz

itrycodinganditsbad and others added 17 commits October 19, 2026 08:21
The window and tray locks and ports go into craft-cloud-app, next to the
agent's data folder, instead of loose in the per-user data folder. Both
uninstallers remove that folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
As the Windows setup's --no-start-menu: no entry is written, and one an
earlier install made is removed. An unknown option exits 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
When the wait for a busy agent runs out, the agent has already accepted the
quit and stops after its pass. Starting it at once did nothing (the old one
still ran), and without a systemd unit nothing started it at all. Now a
background step waits until it stops answering and has let go of its data
folder, then starts it again: through systemd when it has a unit, else
`run --log`. The upgrade without a unit waits the same way, so the new copy
doesn't find the folder still taken and exit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
Without dbus-daemon the tray tests returned early and passed, silently.
The skip is now written to stderr past the test capture, and with
CRAFT_CLOUD_REQUIRE_BACKENDS set it is a failure, as for the server's
backends. CI installs dbus on Linux and runs the tray tests again with
the variable set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
A failed RegisterStatusNotifierItem, at start or when the tray restarts,
was dropped without a word. It is now said on stderr, as the app's other
troubles are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
An I/O error once the agent was stopped (a file that can't be written,
the setup's own exe that can't be read) ended the install with the agent
left stopped until the next login. Now it is started again, from the
folder its start at login names, and the error says whether that worked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
An agent counted as gone whenever tasklist couldn't run or failed, so the
setup could carry on while the agent still held its files. Only an answer
counts now: a tasklist that can't run, fails or prints nothing stops the
install or uninstall before anything changes, as an agent that won't stop
does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
The agent was spawned straight from the setup, so it inherited every
inheritable handle, among them the setup's output when that is a pipe.
Run from WSL or a script, the setup then never seemed to end: the pipe
stayed open as long as the agent ran. std can't turn inheritance off on
stable Rust without unsafe, so Windows' shell starts the agent now
(PowerShell's Start-Process), which hands it nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
Uninstalling from "Apps & features" scheduled the folder's removal for
three seconds later, while the setup still showed its last message and so
still held its own exe: rmdir failed and the folder stayed for good. The
removal now waits for the setup's process to end, then deletes the folder,
trying again for a while if a file is still held. The path goes in as an
environment variable, so nothing in it is read as a command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
The app builds in egui's default fonts (Ubuntu Font Licence, OFL-1.1,
MIT), whose licences ask for their text to go with every copy, and no
package carried any licence. cargo xtask package now writes LICENSES.txt:
Craft Cloud's NOTICE, LICENSE-MIT and LICENSE-APACHE, the font licences
from epaint_default_fonts and the Boost licence of clipboard-win,
error-code and xxhash-rust, read from the crates cargo fetched. It goes in
the tarball (install.sh installs it next to the programs), the macOS
bundle's Resources and the Windows setup's payload. NOTICE says what is
bundled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
…g it again

The local API goes away a few seconds before the agent lets go of its data
folder, and an agent started in between exits 0, which nothing restarts.
The script now reads the pid from local-api.json before the quit and waits
for that process to end (kill -0) within the same limit. With the unit,
`systemctl --user stop` then `start` replaces the plain restart. On a
timeout nothing changes, and a background step starts the agent once its
process has ended, from the unit or the installed copy, never the
unpacked package. A failure after the stop (e.g. a failed copy) starts
the agent again from an EXIT trap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
Once the agent has accepted the quit, a tasklist that fails gave "Nothing
was changed" and left the agent stopping, with nothing to start it again.
tasklist is now asked a few more times; if it still can't tell, the stop
is Unknown (not StillRunning) and the install and the uninstall start
the agent again from the folder its Run value names before they report.
A tasklist failure before the quit still refuses the run, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
- tasklist, taskkill, cmd and PowerShell are run from %SystemRoot%\System32:
  a bare name is looked for next to the setup first.
- Starting the agent: when PowerShell fails or exits non-zero, the agent
  is spawned directly (it then shares the setup's handles, but runs); the
  way taken is printed.
- The uninstall's delete: PowerShell waits for the setup's process, then
  cmd's rmdir /s /q removes the folder (Start-Process works in
  constrained language mode; no .NET call). Where PowerShell can't run,
  cmd alone waits with tasklist, then removes it. rmdir /s removes a
  junction without following it. The Uninstall key goes only once one of
  them was started. The remover works in the folder above, not inside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
LICENSES.txt was a hand list of a few texts. It is now generated from
cargo tree (normal dependencies of the packaged programs for this target,
no proc-macros) and cargo metadata: every third-party crate by name and
version, with its licence expression and each licence, notice and
copying file it ships (a text already given is named, not repeated),
and for MPL-2.0 crates where their unmodified source is. A crate with no
such file passes only when it can be taken under plain MIT or Apache-2.0
(clipboard-win gets error-code's BSL-1.0 text); any other fails the
package, by name. Line ends are normalised, so every OS writes the same
text. A test checks that every crate the licence gate excepts that is in
the programs is in the real file. xtask now uses serde_json (in the lock).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
… effort

Both uninstallers removed the derived craft-cloud-app folder recursively,
which would wipe a folder of the same name beside a custom agent folder,
and the setup failed the uninstall when a file there was still held. Now
only the app's own file names go, the folder only once empty, after the
Uninstall key, and a failure there is ignored. The loose files older
versions kept beside the folder go too. uninstall.sh ignores a relative
XDG_DATA_HOME, as the app does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
- The refused-tray test reads what register says, not only that it fails.
- The setup test for "nothing to start" really has nothing to start, and
  checks that this is said.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RC1oqfy9kZznj94RjMojyz
@itrycodinganditsbad

Copy link
Copy Markdown
Owner Author

Tried on the two test machines at 80aab5f:

  • Windows: craft-cloud-setup.exe --no-start-menu --quiet, run from a WSL pipe over a running install, returned in 1.7 s. The agent started again through PowerShell, in sync. LICENSES.txt is in the program folder, with the MPL source lines.
  • Arch/Hyprland: install.sh over the systemd unit took 1.6 s. The unit stopped, then started with the new agent, in sync.

Not tried: uninstalling from Apps & features, and the cmd fallbacks.

@itrycodinganditsbad
itrycodinganditsbad merged commit f810c55 into main Oct 19, 2026
4 checks passed
@itrycodinganditsbad
itrycodinganditsbad deleted the desktop-followups branch October 21, 2026 00:25
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