Repository navigation
fix(send): honor --room flag instead of silent-routing to current scope - #123
Conversation
…h to body Pre-fix: 'airc send --room general "lobby ping"' (or 'airc msg --room') was treated by the argparse as 'first positional = --room', then 'second positional = general', and the message body became literal '--room general lobby ping'. Silent mis-routing to the current scope's room. Caught by vhsm-Claude on 2026-04-26 dogfooding the #122 multi-room sidecar: 'BOTH --room general and --room cambriantech from your tab arrived at my monitor as literal text starting with --room <name> in [#useideem]. the flag is being treated as message body.' This is exactly the evidence-eating shape the project rejects: send returns 0, message LANDED, but in the wrong room. From the receiver's side it looks like a sender mistake; from the sender's side it looks like the substrate works. Neither knows the room got crossed. Fix: - Parse --room <name> at the top of cmd_send (before the @-or-not positional check). If --room names a sibling sidecar scope under the .airc.<name> convention, re-exec ourselves with AIRC_HOME pointing at that scope so the rest of the function runs there. - If --room names a room we're NOT subscribed to, die loudly with a list of rooms we ARE in. Never fall through silently. - Recursion guard via AIRC_SEND_REROUTED=1 prevents loops if a sibling scope is misconfigured (can happen mid-bounce when a sibling's room_name file is empty). - Determine project scope by stripping a trailing .<word> from the current AIRC_WRITE_DIR, so 'airc send --room general' from inside .airc.general/ correctly resolves the project scope as the source of truth for what rooms are subscribed. Test: scenario_send_room_flag — 8 assertions, all green: - --room <current>: no-op route (lands in current scope's log) - --room <sibling>: re-routes to sibling .general scope - No double-write to primary scope on re-route - --room <unsubscribed>: exits non-zero with structured stderr - stderr says 'not subscribed in this scope', lists subscribed rooms - --room <r> @peer DM also re-routes correctly Also updates README.md's auto-scope section to document the dual-room default (auto-scoped project + #general sidecar) introduced in #122, and explains the new send --room flag with examples. Platform: re-exec via 'env' is POSIX-standard. No platform-specific change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR fixes cross-room sending semantics by teaching airc send/msg to parse --room <name> and re-route the send into a subscribed sibling scope (e.g. .airc.general) instead of silently treating --room as message text and broadcasting to the current scope. It also documents the dual-room default behavior and adds an integration scenario covering reroute + error diagnostics.
Changes:
- Add
--roomflag parsing tocmd_sendand re-exec into the target sibling scope (with a recursion guard) or error loudly when unsubscribed. - Add
scenario_send_room_flagintegration test covering in-room no-op, cross-room reroute, unsubscribed error output, and DM reroute. - Update README auto-scope section to document default project room +
#generallobby sidecar and--roomsend examples.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
airc |
Implements send/msg --room <name> reroute via sibling scope re-exec + diagnostics. |
test/integration.sh |
Adds a new integration scenario validating --room behavior for broadcasts, DMs, and unsubscribed rooms. |
README.md |
Updates docs for dual-room default and how to send across subscribed rooms using --room. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| echo $$ > "$primary/airc.pid" | ||
| echo $$ > "$sidecar/airc.pid" | ||
|
|
There was a problem hiding this comment.
The test writes the current test runner PID ($$) into both airc.pid files. cleanup_all calls cleanup_procs, which iterates /tmp/airc-it-*/state/airc.pid and kill -9’s every PID listed; this will kill the integration test process itself when cleanup_all runs at the end of the scenario. Use a dedicated background PID (e.g., a sleep process) for these pidfiles, or avoid calling cleanup_all while these pidfiles exist and instead remove the synthetic dirs/pidfiles directly.
| local positional=() | ||
| while [ $# -gt 0 ]; do | ||
| case "$1" in | ||
| --room|-room) | ||
| target_room="${2:-}" | ||
| [ -z "$target_room" ] && die "Usage: airc send --room <name> <message>" | ||
| shift 2 ;; | ||
| *) positional+=("$1"); shift ;; | ||
| esac | ||
| done | ||
| set -- "${positional[@]+"${positional[@]}"}" |
There was a problem hiding this comment.
cmd_send’s --room parser scans all arguments and will consume --room <name> even if those tokens were intended as part of an unquoted message (e.g., airc send please use --room general will be treated as a reroute, not text). Since send has free-form message arguments, it should either (a) only parse leading options (stop at the first non-flag), and/or (b) support -- as an end-of-options marker so users can force literal --room in the message.
| local positional=() | |
| while [ $# -gt 0 ]; do | |
| case "$1" in | |
| --room|-room) | |
| target_room="${2:-}" | |
| [ -z "$target_room" ] && die "Usage: airc send --room <name> <message>" | |
| shift 2 ;; | |
| *) positional+=("$1"); shift ;; | |
| esac | |
| done | |
| set -- "${positional[@]+"${positional[@]}"}" | |
| while [ $# -gt 0 ]; do | |
| case "$1" in | |
| --room|-room) | |
| target_room="${2:-}" | |
| [ -z "$target_room" ] && die "Usage: airc send --room <name> <message>" | |
| shift 2 ;; | |
| --) | |
| shift | |
| break ;; | |
| -*) | |
| break ;; | |
| *) | |
| break ;; | |
| esac | |
| done |
Summary
Follow-up to #122. Pre-fix: `airc send --room general "lobby ping"` had no `--room` flag in cmd_send's argparse, so the flag became part of the message body and the broadcast silently went to the current scope (project room) instead of `#general`. Receiver sees `[#project] X: --room general lobby ping`. Looks like a sender typo; is actually the substrate violating its own room semantics.
Caught by vhsm-Claude through substrate observation while dogfooding #122 — exactly the AI-to-AI feedback loop Joel was pushing for.
Fix
Also updates README.md's auto-scope section to document the dual-room default and the new `--room` flag with examples.
Test plan
🤖 Generated with Claude Code