Skip to content

fix(monitor): refresh channel bearers while running - #453

Merged
joelteply merged 1 commit into
canaryfrom
fix/live-channel-refresh
May 4, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/live-channel-refresh

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

  • detect channel_gists additions/removals inside the live multi-channel watch loop
  • start newly-added channel bearers without waiting for a full monitor restart
  • stop removed channel bearers while keeping other channels and the formatter alive

Why

Live testing #452 exposed another common monitor-heal case: airc join --room X while the monitor is already healthy says the bearer will pick the room up within ~30s, but the monitor only re-read channel_gists at the next outer restart. If no bearer died, the new room never started.

Verification

  • bash -n airc
  • git diff --check
  • ./test/integration.sh inbox

QA ask

With a running monitor, run airc join --room <new-room> and verify a bearer for the new channel appears without bouncing the whole scope.

Copilot AI review requested due to automatic review settings May 4, 2026 16:48
@joelteply
joelteply merged commit c3d2eb7 into canary May 4, 2026
8 checks passed
@joelteply
joelteply deleted the fix/live-channel-refresh branch May 4, 2026 16:50

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 updates the airc bash monitor’s multi-channel mode to refresh channel_gists while the monitor is running, allowing newly added channels to start their bearers immediately and removed channels’ bearers to be stopped without restarting the whole monitor/formatter pipeline.

Changes:

  • Introduces a _start_channel_bearer helper for spawning per-channel bearer_cli recv processes.
  • Adds an in-loop channel_gists refresh to start bearers for newly added channels during steady-state monitoring.
  • Stops bearers for channels removed from channel_gists while keeping other channels running.

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

Comment thread airc
Comment on lines +1393 to +1395
_current_map=$("$AIRC_PYTHON" -m airc_core.config list_channel_gists \
--config "$CONFIG" 2>/dev/null || true)
if [ -n "$_current_map" ]; then
Comment thread airc
_kept+=("$entry")
else
echo "airc: #${ch} removed from channel_gists; stopping its bearer while other channels continue" >&2
kill "$pid" 2>/dev/null || true
Comment thread airc
Comment on lines +1392 to +1419
local _current_map
_current_map=$("$AIRC_PYTHON" -m airc_core.config list_channel_gists \
--config "$CONFIG" 2>/dev/null || true)
if [ -n "$_current_map" ]; then
local _kept=()
for entry in "${_pids[@]}"; do
pid="${entry%%:*}"
ch="${entry#*:}"
if printf '%s\n' "$_current_map" | awk -F '\t' -v c="$ch" '$1 == c {found=1} END {exit found ? 0 : 1}'; then
_kept+=("$entry")
else
echo "airc: #${ch} removed from channel_gists; stopping its bearer while other channels continue" >&2
kill "$pid" 2>/dev/null || true
fi
done
_pids=("${_kept[@]}")

while IFS=$'\t' read -r ch gid; do
[ -z "$ch" ] && continue
local _already=0
for entry in "${_pids[@]}"; do
[ "${entry#*:}" = "$ch" ] && _already=1 && break
done
if [ "$_already" = "0" ]; then
echo "airc: #${ch} added to channel_gists; starting bearer without full monitor restart" >&2
_start_channel_bearer "$ch" "$gid"
fi
done <<< "$_current_map"
Comment thread airc
Comment on lines +1385 to +1391
# Live channel-map refresh. `airc join --room X` can add a
# channel while the monitor is already healthy; pre-fix the
# monitor only re-read channel_gists on the next outer restart,
# so the promised "bearer picks it up within ~30s" was false
# unless something else died. Start newly-added channels and
# stop removed channels in-place while the formatter pipe stays
# alive.
Comment thread airc
@@ -1331,6 +1332,9 @@ _monitor_multi_channel() {
--state-file "$AIRC_WRITE_DIR/bearer_state.${ch}.json" \
2>>"$AIRC_WRITE_DIR/bearer_recv.${ch}.log" &
_pids+=("$!:$ch")
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