Skip to content

fix(update): loud stale-running-monitor warning on airc canary / update - #235

Merged
joelteply merged 1 commit into
canaryfrom
fix/canary-update-warns-stale-running-monitor
Apr 28, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/canary-update-warns-stale-running-monitor

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

vhsm-d1f4 ran 'airc canary' for #232, saw the dim 'Running monitor still uses old code' hint, missed it in install.sh's output, and ran on stale in-memory bash for a while. Phase 2C didn't surface until teardown+reconnect.

Fix: cmd_update probes $AIRC_WRITE_DIR/airc.pid; if alive, prints a multi-line action-shaped warning with the restart command on its own line. Silent when nothing's running.

… monitor is alive

vhsm-d1f4's gotcha 2026-04-28: ran 'airc canary' to pick up #232,
saw 'Updated X -> Y' confirmation, but their RUNNING monitor was
still executing the pre-#232 in-memory bash. Phase 2C heartbeat
scan never fired until they explicitly tore down + reconnected.

The existing dim hint at the end of cmd_update was easy to miss
amid install.sh's output. This makes the warning conditional + loud
when it actually matters (running monitor present).

## Fix

cmd_update detects `.airc/airc.pid` in the current scope and probes
the PID. If alive, prints a multi-line action-shaped block with
the rebar command on its own line:

  ⚠  A running airc monitor (PID NNNN) is still on the OLD code.
     Restart to pick up <new-sha>:

       airc teardown && airc connect

Silent when nothing is running. The single-line hint that fired
ALWAYS-on-update is dropped — the conditional version is more useful
when it matters and quieter when it doesn't.

## What this does NOT do

Auto-restart. That would interrupt active SSH sessions (DM in flight,
file transfer, takeover dance). User decides when to bounce.

## Verification

  bash -n: clean
  test/integration.sh tabs: 19/0 ✓

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings April 28, 2026 19:22
@joelteply
joelteply merged commit 63d14fc into canary Apr 28, 2026
@joelteply
joelteply deleted the fix/canary-update-warns-stale-running-monitor branch April 28, 2026 19:23

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

Improves airc update UX by surfacing a clearer, action-oriented warning when an airc connect monitor is still running after an update, since long-running bash processes keep old function definitions in memory.

Changes:

  • Replaces the previous dim, unconditional stale-monitor hint with a conditional warning based on $AIRC_WRITE_DIR/airc.pid.
  • Prints a multi-line “restart” instruction only when a live PID is detected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +103 to +106
if [ -n "$_pid" ] && kill -0 "$_pid" 2>/dev/null; then
echo ""
echo " ⚠ A running airc monitor (PID ${_pid}) is still on the OLD code."
echo " Restart to pick up ${after}:"

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

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

This warning will also print when no code update occurred (when before == after). In that case the running monitor is not on “OLD code”, so the message is misleading. Gate the stale-monitor warning on an actual revision change (e.g., only run this block when before != after), or adjust the wording to avoid claiming the monitor is old when nothing changed.

Copilot uses AI. Check for mistakes.
# warning ONLY when a monitor is actually running in the current
# scope. Silent when nothing is running.
if [ -f "$AIRC_WRITE_DIR/airc.pid" ]; then
local _pid; _pid=$(awk '{print $1; exit}' "$AIRC_WRITE_DIR/airc.pid" 2>/dev/null)

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

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

_pid=$(awk ...) runs in a command substitution under set -euo pipefail (inherited from airc). If the pidfile exists but can’t be read (permissions, transient IO), awk exits non-zero and will abort airc update unexpectedly. Use the established pattern used elsewhere (e.g., ... || true inside the substitution) so a read failure just results in “no warning”.

Suggested change
local _pid; _pid=$(awk '{print $1; exit}' "$AIRC_WRITE_DIR/airc.pid" 2>/dev/null)
local _pid; _pid=$(awk '{print $1; exit}' "$AIRC_WRITE_DIR/airc.pid" 2>/dev/null || true)

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Apr 28, 2026
…low-up) (#238)

Self-caught 2026-04-28: ran 'airc update' when already at HEAD; the
warning still fired ("A running airc monitor is still on the OLD code")
even though no code changed. False positive that nags users to bounce
for nothing.

## Fix

Gate the warning on `before != after` AND the running-monitor probe.
When the SHA didn't advance, the running monitor IS up-to-date — no
warning needed.

## Verification

  bash -n: clean
  Manual: `airc update` when already at HEAD → silent on warning.
          `airc update` when SHA advances → warning still fires.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.

2 participants