Repository navigation
fix(#388): address Copilot review — Windows/WSL daemon detect + ordering + stale text - #390
Merged
Merged
Conversation
…ing + stale text PR #388 landed with 4 Copilot review concerns. This PR addresses all 4 + extracts the cross-platform "is the daemon installed?" detect into a shared helper so install.sh + cmd_connect.sh + cmd_daemon.sh all use ONE implementation. Per Joel "if you code modularly like we require": three near-identical case statements collapse to one detector. NEW: lib/airc_bash/lib_daemon_detect.sh airc_daemon_is_installed() — covers darwin (LaunchAgents plist), linux+wsl (systemd user unit), windows (HKCU\...\Run\airc-monitor). Sourced from top-level airc + install.sh. CHANGED: - install.sh: drops local _daemon_already_installed (Darwin/Linux only), sources lib_daemon_detect.sh from $CLONE_DIR, calls the shared helper. Fixes Copilot concern #2 (Windows/WSL gap). - install.sh: AIRC_INSTALL_YES=1 check now runs BEFORE the !-t 0 non-TTY check, so `curl … | AIRC_INSTALL_YES=1 bash` actually installs the daemon instead of falling into the non-TTY tip branch. Fixes Copilot concern #3 (ordering bug). - install.sh: prompt text drops the bogus `--no-daemon-prompt` flag reference (the flag was never implemented anywhere); keeps only the AIRC_INSTALL_NO_DAEMON=1 env-var hint that DOES work. Fixes Copilot concern #1 (lying-to-user copy). - install.sh: launchd/systemd → "launchd / systemd / HKCU-Run" in the prompt body so Windows users see their platform mentioned. - cmd_connect.sh: first-host daemon-tip block (line ~1707) replaces its Darwin-only/Linux-only case statement with a single call to airc_daemon_is_installed. Fires correctly on Windows now where the previous code never fired (HKCU Run-key wasn't checked). Fixes Copilot concern #4. - cmd_daemon.sh::_daemon_installed becomes a thin wrapper around the shared detector. Preserves the local-private-helper API used by callers in this file; cross-platform logic now lives in one place. Detection guaranteed consistent across all sites. Branch ordering rationale (install.sh, top→bottom): 1. AIRC_INSTALL_NO_DAEMON=1 — explicit opt-out trumps everything 2. AIRC_INSTALL_YES=1 — explicit auto-install (now BEFORE non-TTY) 3. airc_daemon_is_installed — idempotent re-run no-op 4. !-t 0 || !-t 1 — non-TTY tip 5. interactive [Y/n] — default TEST: - bash -n on all 5 touched files: clean - airc_daemon_is_installed against real Mac (daemon installed): returns 0 ✓ - against mocked-windows (reg query mocked to succeed): returns 0 ✓ - cmd_daemon.sh::_daemon_installed wrapper: still returns same value as direct airc_daemon_is_installed call (delegation works) - install.sh ordering: verified YES check (line 909) precedes !-t 0 check (line 920+) by inspection Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR follows up on #388 by centralizing “is the daemon installed?” detection into a single cross-platform helper and fixing install-time prompt behavior on Windows/WSL and in non-TTY installs.
Changes:
- Add
airc_daemon_is_installedas a shared cross-platform detector (darwin/linux/wsl/windows). - Update
cmd_daemon.shandcmd_connect.shto use the shared detector to avoid platform drift. - Fix
install.shdaemon-prompt ordering soAIRC_INSTALL_YES=1works in non-TTYcurl | bashflows and remove stale flag text.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/airc_bash/lib_daemon_detect.sh | Introduces centralized daemon-installed detection across platforms. |
| lib/airc_bash/cmd_daemon.sh | Replaces duplicated detection with a wrapper calling the shared helper. |
| lib/airc_bash/cmd_connect.sh | Uses the shared detector so the first-host daemon tip works on Windows/WSL too. |
| install.sh | Sources shared detector, fixes YES/non-TTY ordering, and updates prompt copy. |
| airc | Sources the shared detector via the existing lib-dir resolver so command surfaces can use it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # the installer ever changes the path / unit name / entry name, this | ||
| # detector is what tells the install-time + first-host UX whether the | ||
| # offer/tip should fire. Misalignment = re-prompt loop or never-prompt | ||
| # silent miss; both are users-experience bugs Copilot flagged. |
| if _daemon_already_installed; then | ||
| info "airc daemon already installed (skipping prompt)" | ||
| elif [ "${AIRC_INSTALL_NO_DAEMON:-0}" = "1" ]; then | ||
| # Order matters here. Three NON-prompt branches first, ordered so the |
Comment on lines
+32
to
+33
| # windows — HKCU\Software\Microsoft\Windows\CurrentVersion\Run\airc-monitor | ||
| # (matches the entry name cmd_daemon.sh's installer creates) |
Three pure comment fixes from Copilot review: 1. lib_daemon_detect.sh: 'users-experience bugs' → 'user experience bugs' (grammar) 2. install.sh: 'Three NON-prompt branches' → 'Four NON-prompt branches' (the list below the comment has 4 branches: NO_DAEMON, YES, already-installed, non-TTY) 3. lib_daemon_detect.sh: HKCU\...\Run\airc-monitor reads as a subkey path; airc-monitor is actually the VALUE NAME under the Run key. Reworded to clarify. No code changes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
What
Follow-up to #388 (already merged) addressing all 4 Copilot review concerns + a small refactor that makes the underlying drift impossible.
Concerns + fixes
The refactor
Pre-fix three places had near-identical detection logic that drifted:
Post-fix: ONE detector in `lib_daemon_detect.sh`, used by all three. `cmd_daemon.sh::_daemon_installed` becomes a thin wrapper to preserve the file-private-helper shape its callers use.
Per Joel: "if you code modularly like we require" — three case statements collapse to one detector.
install.sh branch ordering (top → bottom)
Test plan
Out of scope
This PR doesn't change the underlying daemon-install flow itself — only the detect / prompt logic around it. The `cmd_daemon_install` Windows path that creates the HKCU Run-key entry is unchanged.
🤖 Generated with Claude Code