Skip to content

fix(#388): address Copilot review — Windows/WSL daemon detect + ordering + stale text - #390

Merged
joelteply merged 2 commits into
canaryfrom
fix/388-copilot-concerns
May 1, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fix/388-copilot-concerns

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

Follow-up to #388 (already merged) addressing all 4 Copilot review concerns + a small refactor that makes the underlying drift impossible.

Concerns + fixes

# Copilot concern Fix
1 Prompt copy mentions `--no-daemon-prompt` flag that doesn't exist Removed the flag reference; kept only the working `AIRC_INSTALL_NO_DAEMON=1` env-var hint
2 `_daemon_already_installed()` only checks Darwin/Linux file paths — re-prompts every install on Windows even after `airc daemon install` registered the HKCU Run-key entry Extracted cross-platform detector to `lib/airc_bash/lib_daemon_detect.sh`, sourced by install.sh from `$CLONE_DIR`. Covers darwin / linux / wsl / windows.
3 `AIRC_INSTALL_YES=1` ordering bug: `curl … | AIRC_INSTALL_YES=1 bash` falls into non-TTY tip branch instead of installing Reordered branches so YES check fires BEFORE the `!-t 0` check
4 `cmd_connect.sh:~1707` first-host tip block also Darwin/Linux-only — never fires on Windows Now uses the same `airc_daemon_is_installed` shared helper

The refactor

Pre-fix three places had near-identical detection logic that drifted:

  • `cmd_daemon.sh::_daemon_installed` (covered all platforms correctly)
  • `cmd_connect.sh` first-host tip (Darwin + Linux only — Copilot caught)
  • `install.sh::_daemon_already_installed` (Darwin + Linux only — Copilot caught)

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)

  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 text
  5. interactive `[Y/n]` — default

Test plan

  • `bash -n` clean on all 5 touched files
  • `airc_daemon_is_installed` against real Mac (daemon was installed via `airc daemon install` Apr 24): returns 0 ✓
  • against mocked-windows (`reg query` mocked to succeed): returns 0 ✓
  • `cmd_daemon.sh::_daemon_installed` wrapper still returns same value as direct call (delegation works)
  • install.sh ordering verified by inspection: YES check at line 909 precedes `!-t 0` at line 920+
  • Live-validate on Windows Git Bash on next available Windows peer (BigMama Win-side or Toby's box)

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

…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]>
Copilot AI review requested due to automatic review settings May 1, 2026 21:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_installed as a shared cross-platform detector (darwin/linux/wsl/windows).
  • Update cmd_daemon.sh and cmd_connect.sh to use the shared detector to avoid platform drift.
  • Fix install.sh daemon-prompt ordering so AIRC_INSTALL_YES=1 works in non-TTY curl | bash flows 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.

Comment thread lib/airc_bash/lib_daemon_detect.sh Outdated
# 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.
Comment thread install.sh Outdated
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 thread lib/airc_bash/lib_daemon_detect.sh Outdated
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]>
@joelteply
joelteply merged commit 73ab85e into canary May 1, 2026
6 checks passed
@joelteply
joelteply deleted the fix/388-copilot-concerns branch May 1, 2026 21:46
joelteply added a commit that referenced this pull request May 2, 2026