### Install ydotool and Configure ydotoold Service Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/tools/test-harness/README.md Installs the ydotool package and configures the ydotoold service to make its socket world-writable. This is a one-time setup for Quick Entry tests. ```shell sudo dnf install -y ydotool # or: sudo apt install ydotool sudo mkdir -p /etc/systemd/system/ydotool.service.d sudo tee /etc/systemd/system/ydotool.service.d/override.conf <<'EOF' [Service] ExecStart= ExecStart=/usr/bin/ydotoold --socket-perm=0666 EOF sudo systemctl daemon-reload sudo systemctl enable --now ydotool.service ``` -------------------------------- ### Build Using Local Installer Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/building.md Build the application using a locally downloaded installer executable, useful if the default download URL is outdated. ```bash ./build.sh --exe /path/to/Claude-Setup.exe ``` -------------------------------- ### Installing Build Prerequisites Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/AGENTS.md This bash snippet installs the necessary tools (p7zip-full, wget, nodejs, npm) required for setting up the `build-reference` environment on Debian-based systems. ```bash # Install required tools sudo apt install p7zip-full wget nodejs npm # Install asar and prettier globally (or use npx) npm install -g @electron/asar prettier ``` -------------------------------- ### Install Claude Desktop with Nix Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/README.md Use this command to install the basic version of Claude Desktop using Nix. ```bash nix profile install github:aaddrick/claude-desktop-debian ``` -------------------------------- ### Install .rpm Package Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/building.md Install the generated .rpm package on Fedora/RHEL-based systems using dnf or rpm. ```bash sudo dnf install ./claude-desktop-VERSION-1.ARCH.rpm # Or: sudo rpm -i ./claude-desktop-VERSION-1.ARCH.rpm ``` -------------------------------- ### Install Required Tools for Build Reference Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/CLAUDE.md This bash command installs necessary tools like p7zip-full, wget, nodejs, and npm on Debian-based systems. These are prerequisites for setting up the build reference environment. ```bash # Install required tools sudo apt install p7zip-full wget nodejs npm ``` -------------------------------- ### Install Test Harness Dependencies Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/tools/test-harness/README.md Navigates to the test-harness directory and installs Node.js dependencies using npm. ```shell cd tools/test-harness npm install ``` -------------------------------- ### Build Claude Desktop Installers Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/runbook.md Build the AppImage, deb, and RPM installers from the current branch. Use `--clean no` to avoid cleaning build artifacts between builds. ```bash # Build from the branch under test ./build.sh --build appimage --clean no ./build.sh --build deb --clean no ./build.sh --build rpm --clean no ``` -------------------------------- ### Download Windows Installer for Claude Desktop Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/CLAUDE.md Downloads the Windows installer for Claude Desktop using `wget`. The URL pattern includes placeholders for version and commit hash, which need to be updated accordingly. This step is crucial for obtaining the `app.asar` file. ```bash # Download URL pattern (update version as needed): # x64: https://downloads.claude.ai/releases/win32/x64/VERSION/Claude-COMMIT.exe # arm64: https://downloads.claude.ai/releases/win32/arm64/VERSION/Claude-COMMIT.exe # Example for version 1.1.381: wget -O Claude-Setup-x64.exe "https://downloads.claude.ai/releases/win32/x64/1.1.381/Claude-c2a39e9c82f5a4d51f511f53f532afd276312731.exe" ``` -------------------------------- ### Install Gate Logic for Plugins Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/learnings/plugin-install.md This JavaScript code snippet illustrates the conditional logic for installing plugins, differentiating between local uploads and remote marketplace installs. It checks for specific `pluginSource` values and a remote feature flag (`A0()`) before proceeding with remote API calls, otherwise falling back to CLI installation. ```javascript const a = s?.pluginSource === "local"; // user-uploaded .zip const c = s?.pluginSource === "remote"; // remote marketplace install if (!a && (c || s?.mode === "cowork") && (await A0())) { // remote API: /api/organizations/{orgId}/plugins/... } else { // skip, log reason: "local-sourced" | // "not-cowork-not-remote" | // "sparkplug-disabled" } // always falls through to CLI install on failure ``` -------------------------------- ### Create and Navigate to Build Reference Directory Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/CLAUDE.md Creates a directory named `build-reference` and changes the current directory to it. This is the starting point for downloading and extracting application assets. ```bash # Create working directory mkdir -p build-reference && cd build-reference ``` -------------------------------- ### QEMU System Command for KVM Backend Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/cowork-linux-handover.md This is the full QEMU command used by the KVM backend to start a virtual machine. It includes configurations for memory, CPU, disk, networking, and debugging. ```bash qemu-system-x86_64 \ -enable-kvm \ -m ${memoryGB}G \ -cpu host \ -smp ${cpuCount} \ -nographic \ -kernel ${VM_BASE_DIR}/vmlinuz \ -initrd ${VM_BASE_DIR}/initrd \ -append "root=/dev/vda1 console=ttyS0 quiet" \ -drive file=${sessionDir}/overlay.qcow2,format=qcow2,if=virtio \ -device vhost-vsock-pci,guest-cid=${cid} \ -qmp unix:${sessionDir}/qmp.sock,server,nowait \ -netdev user,id=net0 \ -device virtio-net-pci,netdev=net0 \ -chardev socket,id=virtiofs,path=${sessionDir}/virtiofs.sock \ -device vhost-user-fs-pci,chardev=virtiofs,tag=hostshare ``` -------------------------------- ### Install asar and prettier Globally Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/CLAUDE.md Installs the `@electron/asar` and `prettier` npm packages globally. Alternatively, `npx` can be used to run these tools without global installation. ```bash # Install asar and prettier globally (or use npx) npm install -g @electron/asar prettier ``` -------------------------------- ### Downloading Windows Installer for Reference Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/AGENTS.md This bash snippet downloads the Windows installer for Claude Desktop, which contains the `app.asar` file needed for analyzing and patching the application's source code. Remember to update the `VERSION` and `COMMIT` placeholders with the correct values for the desired release. ```bash # Create working directory mkdir -p build-reference && cd build-reference # Download URL pattern (update version as needed): # x64: https://downloads.claude.ai/releases/win32/x64/VERSION/Claude-COMMIT.exe # arm64: https://downloads.claude.ai/releases/win32/arm64/VERSION/Claude-COMMIT.exe # Example for version 1.1.381: wget -O Claude-Setup-x64.exe "https://downloads.claude.ai/releases/win32/x64/1.1.381/Claude-c2a39e9c82f5a4d51f511f53f532afd276312731.exe" ``` -------------------------------- ### Install .deb Package Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/building.md Install the generated .deb package on Debian-based systems using apt or dpkg. Use apt --fix-broken install to resolve dependency issues. ```bash sudo apt install ./claude-desktop_VERSION_ARCHITECTURE.deb # Or: sudo dpkg -i ./claude-desktop_VERSION_ARCHITECTURE.deb # If you encounter dependency issues: sudo apt --fix-broken install ``` -------------------------------- ### Install Claude Desktop via DNF Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/README.md Installs Claude Desktop using DNF after the repository has been added. Future updates are handled by regular system updates. ```bash sudo dnf install claude-desktop ``` -------------------------------- ### Install Multiple npm Modules Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/styleguides/bash_styleguide.md Installs multiple npm modules efficiently using a single command if the command supports multiple arguments. ```bash modules=(json httpserver jshint) for module in "${modules[@]}"; do npm install -g "$module" done ``` ```bash npm install -g "${modules[@]}" ``` -------------------------------- ### Install Claude Desktop via APT Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/README.md Updates the package list and installs Claude Desktop using APT. This command should be run after adding the GPG key and repository. ```bash sudo apt update sudo apt install claude-desktop ``` -------------------------------- ### Make AppImage Executable and Run Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/building.md Make the generated AppImage executable and run it directly. For system integration, consider using Gear Lever or manually installing the .desktop file. ```bash # Make executable chmod +x ./claude-desktop-*.AppImage # Run directly ./claude-desktop-*.AppImage ``` -------------------------------- ### Extract Installer Contents with 7z Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/CLAUDE.md Extracts the contents of the downloaded Windows installer (`.exe`) using the `7z` command. The installer is treated as a 7-Zip archive. This command extracts files into an `exe-contents` directory. ```bash # Extract the exe (it's a 7z archive) 7z x -y Claude-Setup-x64.exe -o"exe-contents" ``` -------------------------------- ### Download CI Artifacts for Installers Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/runbook.md Download pre-built installers (deb, RPM, AppImage) from GitHub Actions CI artifacts for a specific release run ID. Replace `` with the actual run ID. ```bash # Or pull from CI artifacts for a tagged release gh run download -n claude-desktop-deb-amd64 gh run download -n claude-desktop-rpm-amd64 gh run download -n claude-desktop-appimage-amd64 ``` -------------------------------- ### Starting Integrated Terminal with `node-pty` Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/code-tab-foundations.md Shows the implementation of `startShellPty`, which spawns a new pseudo-terminal using the `node-pty` library. It sets the working directory and terminal type. ```javascript build-reference/app-extracted/.vite/build/index.js:486438 — startShellPty body: spawns node-pty in n.worktreePath ?? n.cwd with TERM=xterm-256color ``` -------------------------------- ### Install Claude Desktop with MCP Server Support (FHS) Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/README.md Install Claude Desktop with support for MCP server in an FHS environment using Nix. ```bash nix profile install github:aaddrick/claude-desktop-debian#claude-desktop-fhs ``` -------------------------------- ### BwrapBackend Command Example Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/cowork-linux-handover.md This command demonstrates the usage of bubblewrap for creating a sandboxed environment for the Claude Code CLI. It sets up necessary mounts and namespaces for isolation. ```bash bwrap --ro-bind / / --dev /dev --proc /proc --tmpfs /tmp --tmpfs /run \ --bind $workDir $workDir --unshare-pid --die-with-parent --new-session ``` -------------------------------- ### Test OS Spoofing with Header Harness Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/learnings/plugin-install.md This example demonstrates how to use the `runTest` function to spoof the OS platform and version headers. It then logs the value of a specific feature flag to check if the server-side gating is dependent on the OS claim. ```javascript (async () => { const r = await runTest('darwin', { set: { 'anthropic-client-os-platform': 'darwin', 'anthropic-client-os-version': '15.0' } }); console.log(r.body.features['2340532315']); })(); ``` -------------------------------- ### Extract nupkg Contents and Copy App Files Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/CLAUDE.md Navigates into the extracted installer contents, finds the `.nupkg` file, extracts its contents, and then copies the `app.asar` and `app.asar.unpacked` files to the current directory. These files contain the application's source code. ```bash # Find and extract the nupkg cd exe-contents NUPKG=$(find . -name "AnthropicClaude-*.nupkg" | head -1) 7z x -y "$NUPKG" -o"nupkg-contents" cd .. # Copy out the important files cp exe-contents/nupkg-contents/lib/net45/resources/app.asar . cp -a exe-contents/nupkg-contents/lib/net45/resources/app.asar.unpacked . ``` -------------------------------- ### Build and Run Nix Package Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/building.md Build the Claude Desktop package using Nix. Includes options for a standard build and an FHS-wrapped variant for specific server support. Can be run without installation. ```bash # Build the package nix build .#claude-desktop # Build the FHS-wrapped variant (for MCP server support) nix build .#claude-desktop-fhs # Run without installing nix run .#claude-desktop ``` -------------------------------- ### Attach Grounding Probe to Running App Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/tools/test-harness/README.md Attaches the grounding probe to an already running Claude Desktop instance via a specified port. Requires manual --inspect setup. ```sh npm run grounding-probe -- --port 9229 --out /tmp/probe.json ``` -------------------------------- ### Get Application and Repository Versions Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/runbook.md Retrieve the version of the Claude Desktop application and the repository version using command-line arguments or GitHub CLI variables. ```bash claude-desktop --version gh variable get CLAUDE_DESKTOP_VERSION gh variable get REPO_VERSION ``` -------------------------------- ### Gate Computer-Use Execution on Linux Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/platform-integration.md This function gates computer-use execution off entirely on Linux. Dispatch-spawned sessions requesting computer use should instead trigger the 'Set up computer use' remote-client setup card. ```javascript TF: function() { // Gates computer-use execution off entirely on Linux // ... } ``` -------------------------------- ### Launcher Script Doctor Checks Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/cowork-linux-handover.md The `launcher-common.sh` script includes `--doctor` checks for Cowork mode dependencies such as KVM accessibility, vsock module, QEMU, and bubblewrap. It also provides distro-specific package installation hints. ```bash --doctor checks for Cowork mode dependencies: KVM accessibility, vsock module, QEMU, qemu-img, socat, virtiofsd, bubblewrap, VM image presence. Includes distro-specific package install hints (Debian/Ubuntu, Fedora, Arch). Shows summary of active backend. ``` -------------------------------- ### Install AppArmor Profile for bwrap Sandbox Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/troubleshooting.md Manually install the AppArmor profile for the bwrap sandbox on systems where automatic installation might fail. This is necessary for AppImage, Nix, rpm, and manual installations of Claude Desktop. ```bash sudo tee /etc/apparmor.d/bwrap <<'EOF' abi , include profile bwrap /usr/bin/bwrap flags=(unconfined) { userns, include if exists } EOF sudo apparmor_parser -r /etc/apparmor.d/bwrap ``` -------------------------------- ### Install Claude Desktop via AUR Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/README.md Installs the claude-desktop-appimage package from the Arch User Repository (AUR) using yay or paru. This installs the AppImage build. ```bash # Using yay yay -S claude-desktop-appimage # Or using paru paru -S claude-desktop-appimage ``` -------------------------------- ### Lazy Initialization of Quick Entry BrowserWindow Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/shortcuts-and-input.md This code demonstrates the lazy construction of the Quick Entry popup's `BrowserWindow`. The `BrowserWindow` instance (`Ko`) is only created when the Quick Entry shortcut is first invoked, ensuring that resources are not consumed until necessary. It also specifies the preload script and HTML file for the quick window. ```javascript if (!Ko || Ko.isDestroyed()) { Ko = new BrowserWindow({ width: 400, height: 600, show: false, webPreferences: { preload: ".vite/build/quickWindow.js" } }); Ko.loadFile(".vite/renderer/quick_window/quick-window.html"); } ``` -------------------------------- ### QEMU Configuration Details Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/cowork-linux-handover.md Details on how the KVM backend configures QEMU, including command-line arguments and key operational aspects. ```APIDOC ## QEMU Configuration The KVM backend dynamically builds QEMU arguments. The actual command is: ```bash qemu-system-x86_64 \ -enable-kvm \ -m ${memoryGB}G \ -cpu host \ -smp ${cpuCount} \ -nographic \ -kernel ${VM_BASE_DIR}/vmlinuz \ -initrd ${VM_BASE_DIR}/initrd \ -append "root=/dev/vda1 console=ttyS0 quiet" \ -drive file=${sessionDir}/overlay.qcow2,format=qcow2,if=virtio \ -device vhost-vsock-pci,guest-cid=${cid} \ -qmp unix:${sessionDir}/qmp.sock,server,nowait \ -netdev user,id=net0 \ -device virtio-net-pci,netdev=net0 \ -chardev socket,id=virtiofs,path=${sessionDir}/virtiofs.sock \ -device vhost-user-fs-pci,chardev=virtiofs,tag=hostshare ``` ### Key Details: - **Overlay disks**: Each session creates a qcow2 overlay backed by `rootfs.qcow2`. Session directory: `~/.local/share/claude-desktop/vm/sessions//`. - **Guest CID**: Allocated incrementally starting at 3, tracked via `~/.local/share/claude-desktop/vm/.next_cid`. - **VHDX conversion**: If `rootfs.vhdx` exists but `rootfs.qcow2` does not, `qemu-img convert` runs automatically on first init. - **virtiofsd**: Started separately, shares user's home directory to guest via `vhost-user-fs-pci` with tag `hostshare`. - **socat bridge**: `socat UNIX-LISTEN:${bridgeSock},fork VSOCK-CONNECT:${cid}:2222` bridges Unix socket to vsock for host->guest communication. - **Graceful shutdown**: ACPI power-down via QMP -> wait 10s -> QMP quit -> wait 3s -> SIGKILL. - **Kernel+initrd**: Optional; if `vmlinuz` exists in `VM_BASE_DIR`, direct kernel boot is used. Otherwise, falls back to full disk boot. ### Remaining rootfs questions: - The actual Anthropic rootfs format (VHDX from Windows downloads) needs testing with the conversion path. - Guest sdk-daemon vsock port and protocol need verification. - virtiofs mount point inside the guest needs confirmation. ``` -------------------------------- ### Track SDK Binary Path Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/cowork-linux-handover.md Ensures that the `installSdk` function correctly resolves and stores the path to the downloaded SDK binary, which is then used by the `spawn` function. ```javascript SDK binary path tracked — `installSdk` resolves and stores the downloaded binary path for use in `spawn` ``` -------------------------------- ### Install AppArmor Profile for Claude Desktop Electron Binary Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/troubleshooting.md Manually install the AppArmor profile for the Claude Desktop Electron binary on Ubuntu 24.04+ when the .deb package's automatic installation fails. This grants necessary user namespace capabilities to the Electron binary. ```bash sudo tee /etc/apparmor.d/claude-desktop <<'EOF' abi , include profile claude-desktop /usr/lib/claude-desktop/node_modules/electron/dist/electron flags=(unconfined) { userns, include if exists } EOF sudo apparmor_parser -r /etc/apparmor.d/claude-desktop ``` -------------------------------- ### Example Diagnostic Output Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/troubleshooting.md This is an example of the output you might see when running the --doctor command, indicating the status of various system checks. ```text Claude Desktop Diagnostics ================================ [PASS] Installed version: 1.1.4498-1.3.15 [PASS] Display server: Wayland (WAYLAND_DISPLAY=wayland-0) [PASS] Electron: found at /usr/lib/claude-desktop/node_modules/electron/dist/electron [PASS] Chrome sandbox: permissions OK [PASS] SingletonLock: no lock file (OK) [PASS] MCP config: valid JSON [PASS] Node.js: v22.14.0 [PASS] Desktop entry: /usr/share/applications/claude-desktop.desktop [PASS] Disk space: 632284MB free [PASS] Log file: 1352KB All checks passed. ``` -------------------------------- ### Install libpam-mount for Auto-mount Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/troubleshooting.md Install the libpam-mount package to enable automatic mounting of encrypted volumes at login. This simplifies the process of unlocking the Claude secure volume. ```bash sudo apt install libpam-mount ``` -------------------------------- ### APT/DNF Request Chain (Direct URL) Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/learnings/apt-worker-architecture.md Illustrates the request flow for new users with sources.list pointing directly to the custom domain. This chain is more direct, with all requests being HTTPS until the final binary download. ```text apt/dnf with sources.list pointing at https://pkg.claude-claude-desktop-debian.dev │ ▼ [Worker route, all HTTPS] ├─ metadata → 200 from raw.githubusercontent.com └─ binaries → 302 → 302 → 200 from release-assets ``` -------------------------------- ### Python Proof-of-Concept for Global Shortcuts Portal Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/learnings/wayland-global-shortcuts-portal.md This Python script demonstrates the correct interaction with the xdg-desktop-portal for registering and binding global shortcuts. It requires a matching systemd scope and a .desktop file for the application ID. It shows the expected output when the portal is functioning correctly. ```python Registry.Register('com.example.GsPortalProof') OK CreateSession OK BindShortcuts OK -> id='open-quick-entry' trigger='Press space' *** ACTIVATED *** (press #1) *** ACTIVATED *** (press #2) ``` -------------------------------- ### Install Gate Logic Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/learnings/plugin-install.md This JavaScript code snippet shows the condition for the install gate in Claude Desktop 1.1.7714. It checks if the mode is 'cowork' and if Tg() is true before allowing remote API access. ```javascript if (!c && (a?.mode) === "cowork" && (await Tg())) { // remote API } // reasons: "local-sourced" | "not-cowork" | "sparkplug-disabled" ``` -------------------------------- ### Build Autostart Content Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/platform-integration.md This JavaScript function is responsible for emitting the content of a spec-compliant `.desktop` entry file for XDG Autostart. It ensures the entry adheres to the `[Desktop Entry]` block format. ```javascript scripts/frame-fix-wrapper.js:429 ``` -------------------------------- ### App Launch Test (T01) Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/launch.md Verifies that the main window opens within approximately 10 seconds after launching the application. Checks for the absence of error toasts or crashes and confirms the expected backend selection in the launcher log. ```shell # Example log line for X11 backend via XWayland # Using X11 backend via XWayland # Example log line for native Wayland backend # Using Wayland backend ``` -------------------------------- ### Extract and Grep Installed App ASAR Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/quick-entry-closeout.md Extracts the installed app.asar and greps the bundled JavaScript for a specific KDE gate string injected by a patch. This is used to verify that the patch ran correctly at build time. ```bash npx asar extract /usr/lib/claude-desktop/app.asar /tmp/inspect-installed && grep -c 'XDG_CURRENT_DESKTOP' /tmp/inspect-installed/.vite/build/index.js ``` -------------------------------- ### Implementing `dialog.showOpenDialog` for Directory Selection Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/code-tab-foundations.md Shows the implementation details of the `browseFolder` function, which calls `dialog.showOpenDialog` with options to select and create directories. This is a core part of the folder selection logic. ```javascript build-reference/app-extracted/.vite/build/index.js:509188 — browseFolder impl calls dialog.showOpenDialog with properties: ["openDirectory", "createDirectory"] ``` -------------------------------- ### JavaScript Power Save Blocker Start Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/routines.md This JavaScript code demonstrates starting a power save blocker in the application, likely mapped to system-level inhibit mechanisms to prevent idle suspension. It's ref-counted by a Set. ```javascript hA.powerSaveBlocker.start("prevent-app-suspension") ``` -------------------------------- ### Host Backend Implementation Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/cowork-linux-handover.md The HostBackend class implements the original Phase 1 logic for direct execution without isolation. It serves as a basic backend for the VM service. ```javascript HostBackend — Original Phase 1 logic moved here verbatim (direct execution, no isolation) ``` -------------------------------- ### Doctor Install Method Check (Debian-based) Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/distribution.md This code block from the doctor script checks for the presence of 'dpkg-query' to determine the installation method. It's specific to Debian-family systems and will skip the install-method check entirely if 'dpkg-query' is not found. ```bash install-method check is gated on command -v dpkg-query; only runs on Debian-family hosts. Falls through to _warn 'claude-desktop not found via dpkg (AppImage?)' only if dpkg-query is present but returns empty. On Fedora/RPM hosts (dpkg-query absent), the entire block is skipped and no install-method line is printed at all — neither the misleading WARN nor a correct rpm -qf PASS. The drift is "no detection" rather than "false-flag as AppImage" on dpkg-less systems. ``` -------------------------------- ### Kvm Backend Implementation Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/cowork-linux-handover.md The KvmBackend class provides full QEMU/KVM virtualization with features like overlay disks, virtiofsd, socat vsock bridge, QMP monitor, and graceful shutdown. ```javascript KvmBackend — Full QEMU/KVM with overlay disks, virtiofsd, socat vsock bridge, QMP monitor, graceful shutdown (ACPI -> QMP quit -> SIGKILL) ``` -------------------------------- ### Extracting Installer Contents Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/AGENTS.md This bash snippet extracts the contents of the downloaded Windows installer (`.exe`) and then further extracts the `app.asar` and `app.asar.unpacked` files from the nested `.nupkg` archive. These extracted files are essential for inspecting and modifying the application's source code. ```bash # Extract the exe (it's a 7z archive) 7z x -y Claude-Setup-x64.exe -o"exe-contents" # Find and extract the nupkg cd exe-contents NUPKG=$(find . -name "AnthropicClaude-*.nupkg" | head -1) 7z x -y "$NUPKG" -o"nupkg-contents" cd .. # Copy out the important files cp exe-contents/nupkg-contents/lib/net45/resources/app.asar . cp -a exe-contents/nupkg-contents/lib/net45/resources/app.asar.unpacked . ``` -------------------------------- ### DEB Package Runtime Dependency Check Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/distribution.md Ensures that installing a DEB package via APT automatically pulls all necessary runtime dependencies. This test verifies that the first launch of the application succeeds without requiring any additional manual package installations. ```shell scripts/packaging/deb.sh:185-197 scripts/packaging/deb.sh:202-230 worker/src/worker.js:22-31 worker/src/worker.js:33-43 ``` -------------------------------- ### Hooking BrowserWindow Prototype Method Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/tools/test-harness/README.md Demonstrates how to reliably hook into Electron's BrowserWindow by wrapping prototype methods, such as loadFile, to capture instance data. ```ts const proto = electron.BrowserWindow.prototype; const orig = proto.loadFile; proto.loadFile = function(filePath, ...rest) { // record `this` + filePath; identify popups by filePath suffix return orig.call(this, filePath, ...rest); }; ``` -------------------------------- ### Build with Nix Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/AGENTS.md Builds the application using Nix. Two variants are available: the default and the FHS (Fully Host-Standard) compliant version. ```bash nix build .#claude-desktop nix build .#claude-desktop-fhs ``` -------------------------------- ### Route Remote Session Start Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/platform-integration.md IPC handler that routes a Dispatch-initiated child session into the local sidebar via dispatchOnRemoteSessionStart. ```javascript onRemoteSessionStart: function(e, t) { // ... dispatchOnRemoteSessionStart(e, t) // ... } ``` -------------------------------- ### Uninstall Claude Desktop (.rpm) Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/troubleshooting.md Remove Claude Desktop installed manually via .rpm packages using dnf or rpm. ```bash # Remove package sudo dnf remove claude-desktop # Or: sudo rpm -e claude-desktop ``` -------------------------------- ### Uninstall Claude Desktop (DNF) Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/troubleshooting.md Remove the Claude Desktop package and its repository configuration when installed via DNF on Fedora/RHEL systems. ```bash # Remove package sudo dnf remove claude-desktop # Remove the repository sudo rm /etc/yum.repos.d/claude-desktop.repo ``` -------------------------------- ### Accessing Electron Windows and WebContents Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/tools/test-harness/README.md Explains how to correctly retrieve window and web content information, noting that BrowserWindow.getAllWindows() may return 0 due to class substitution. Use webContents.getAllWebContents() instead. ```typescript // BrowserWindow.getAllWindows() returns 0 because frame-fix-wrapper // substitutes the BrowserWindow class. Use webContents.getAllWebContents() // instead — works correctly and includes both the shell window and the // embedded claude.ai BrowserView. ``` -------------------------------- ### Generating Sequences with Brace Expansion Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/styleguides/bash_styleguide.md Use bash brace expansion '{start..end}' for generating sequences instead of the 'seq' command. ```bash n=10 # wrong for f in $(seq 1 5); do ... done # wrong for f in $(seq 1 "$n"); do ... done # right for f in {1..5}; do ... done # right for ((i = 0; i < n; i++)); do ... done ``` -------------------------------- ### Quick Entry Callback Logic Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/shortcuts-and-input.md Handles the Quick Entry callback, focusing the main window if it's fullscreen or invoking the Quick Entry popup. ```javascript ut && !ut.isDestroyed() && ut.isFullScreen() ? (ut.focus(), ide()) : Yri() ``` -------------------------------- ### Remove User Configuration Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/troubleshooting.md Delete the user configuration directory for Claude Desktop to reset all user-specific settings and data. This command applies to all installation formats. ```bash rm -rf ~/.config/Claude ``` -------------------------------- ### Clone Repository and Build Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/building.md Clone the source repository and execute the build script. The script auto-detects the distribution format. ```bash git clone https://github.com/aaddrick/claude-desktop-debian.git cd claude-desktop-debian ./build.sh ``` -------------------------------- ### Uninstall Claude Desktop (APT) Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/troubleshooting.md Remove the Claude Desktop package and its associated repository and GPG key when installed via APT on Debian/Ubuntu systems. ```bash # Remove package sudo apt remove claude-desktop # Remove the repository and GPG key sudo rm /etc/apt/sources.list.d/claude-desktop.list sudo rm /usr/share/keyrings/claude-desktop.gpg ``` -------------------------------- ### Add DNF Repository Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/README.md Adds the Claude Desktop DNF repository configuration to your system. This allows DNF to find and install Claude Desktop packages. ```bash sudo curl -fsSL https://pkg.claude-desktop-debian.dev/rpm/claude-desktop.repo -o /etc/yum.repos.d/claude-desktop.repo ``` -------------------------------- ### End-to-End Verification: Runtime State Check Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/learnings/patching-minified-js.md Verify the daemon log for 'lifecycle startup' and 'lifecycle listening', and check that the socket exists and is owned by the correct process. ```bash tail -20 ~/.config/Claude/logs/cowork_vm_daemon.log l s -la "${XDG_RUNTIME_DIR}/cowork-vm-service.sock" ss -lpx | grep cowork-vm-service.sock ``` -------------------------------- ### IPC Channels for Integrated Terminal Source: https://github.com/aaddrick/claude-desktop-debian/blob/main/docs/testing/cases/code-tab-foundations.md Defines the IPC channels used for managing the integrated terminal, including starting, resizing, and writing to the pseudo-terminal (pty). ```javascript build-reference/app-extracted/.vite/build/index.js:69135 — IPC channel claude.web_LocalSessions_startShellPty (also resizeShellPty, writeShellPty at :69184, :69210) ```