Skip to content

fix(send): honor --room flag instead of silent-routing to current scope - #123

Merged
joelteply merged 1 commit into
canaryfrom
fix/send-room-flag-honest
Apr 26, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/send-room-flag-honest

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

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

  • Parse `--room ` at the top of cmd_send before the @-or-not positional check.
  • If `--room` names a subscribed sibling scope (`.airc.` convention), re-exec with `AIRC_HOME` pointed there.
  • If `--room` names an unsubscribed room, die loudly with a list of rooms the tab IS in.
  • Recursion guard via `AIRC_SEND_REROUTED=1` prevents loops on misconfigured siblings.
  • Works for both broadcasts and DMs (`--room general @peer` re-routes correctly).

Also updates README.md's auto-scope section to document the dual-room default and the new `--room` flag with examples.

Test plan

  • `bash test/integration.sh send_room_flag` — 8/8 pass
  • Manual: `airc send --room general "..."` from primary scope appends to `.airc.general/messages.jsonl` (verified)
  • Manual: `airc send --room cambriantech "..."` from a tab not subscribed to that room dies with structured stderr listing `#useideem` and `#general`

🤖 Generated with Claude Code

…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]>
Copilot AI review requested due to automatic review settings April 26, 2026 17:50
@joelteply
joelteply merged commit c08b4bd into canary Apr 26, 2026
@joelteply
joelteply deleted the fix/send-room-flag-honest branch April 26, 2026 17: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 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 --room flag parsing to cmd_send and re-exec into the target sibling scope (with a recursion guard) or error loudly when unsubscribed.
  • Add scenario_send_room_flag integration 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 + #general lobby sidecar and --room send 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.

Comment thread test/integration.sh
Comment on lines +2388 to +2390
echo $$ > "$primary/airc.pid"
echo $$ > "$sidecar/airc.pid"

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines +3613 to +3623
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[@]}"}"

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
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