Repository navigation
fix(joiner): preserve cwd/--room channel intent (continuum-b741's WART 1) - #229
Conversation
…ent channel
Closes continuum-b741's WART 1 from Phase 2B.2 e2e (2026-04-28):
joiner's cwd-derived auto-scope or explicit --room intent was being
silently overwritten by the host's advertised channel. Reproduced when
continuum-b741's cwd `cambrian/continuum` should have given them
#cambriantech, but the mesh host (vhsm-d1f4) advertises #useideem, so
they ended up on #useideem with subscribed_channels=['useideem'] only.
## Fix
Joiner branch in cmd_connect.sh: after pair, compare local intent
(`room_name` — set by cwd auto-scope or explicit --room) with the
host's advertised channel (`resolved_room_name`).
- Same: subscribe with --first (becomes default). Same as before.
- Different: subscribe to BOTH:
- intent first → cmd_send default = intent
- host's channel appended → display still picks up its traffic
via the [#channel] envelope-driven prefix
- Legacy room_name file: keep intent when they diverge (cmd_send
third-priority fallback for Phase 1 clients).
Banner reflects the dual subscription:
Joined mesh — host primarily labels #X; subscribed: #Y (default), #X
## What this does NOT do (Phase 2C)
The mesh gist's `channels[]` array is host-controlled — joiners can't
yet push their additional channels into it. So if joiner-A subscribes
to #cambriantech and joiner-B is on the same mesh but only sees the
host's #useideem advertisement, joiner-B doesn't know A is in
#cambriantech. Joiner-driven channels[] update is Phase 2C.
For Phase 2B.2.1 the joiner's LOCAL display routes correctly per
intent, which is the user-visible win.
## Verification
test/integration.sh tabs: 19/0 ✓
test/integration.sh room: 14/0 ✓
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adjusts airc connect join-mode channel subscription so the joiner’s intended channel (from cwd or --room) isn’t overwritten by the host’s advertised channel, while still subscribing to the host channel for display/routing purposes.
Changes:
- When
room_nameintent differs fromresolved_room_name, subscribe to both (intent first, host channel appended). - Write the legacy
room_namefile as the user’s intent in the diverged case (for back-compat/defaulting behavior).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Diverged: user wanted X, host advertises Y. Subscribe to both, | ||
| # X first (default for cmd_send), Y appended (display shows | ||
| # host's channel traffic too). | ||
| echo "$_intent" > "$AIRC_WRITE_DIR/room_name" | ||
| "$AIRC_PYTHON" -m airc_core.config subscribe \ | ||
| --config "$CONFIG" --channel "$_intent" --first 2>/dev/null || true | ||
| "$AIRC_PYTHON" -m airc_core.config subscribe \ | ||
| --config "$CONFIG" --channel "$resolved_room_name" 2>/dev/null || true | ||
| echo " Joined mesh — host primarily labels #${resolved_room_name}; subscribed: #${_intent} (default), #${resolved_room_name}" |
There was a problem hiding this comment.
In the diverged case, this subscribes the joiner to both $_intent and $resolved_room_name but only writes $_intent to $AIRC_WRITE_DIR/room_name. cmd_part (and the Phase 2 unsubscribe logic) uses the room_name file to decide which channel to unsubscribe, so the host-advertised channel will remain in subscribed_channels after /part, which can make the user still see/resume that channel unexpectedly. Consider persisting both channels for this join (or updating the part/unsubscribe path to drop both when this dual-subscription is created).
| local _intent="$room_name" | ||
| if [ -z "$_intent" ] || [ "$_intent" = "$resolved_room_name" ]; then | ||
| echo "$resolved_room_name" > "$AIRC_WRITE_DIR/room_name" | ||
| "$AIRC_PYTHON" -m airc_core.config subscribe \ | ||
| --config "$CONFIG" --channel "$resolved_room_name" --first 2>/dev/null || true | ||
| echo " Joined #${resolved_room_name}" | ||
| else | ||
| # Diverged: user wanted X, host advertises Y. Subscribe to both, | ||
| # X first (default for cmd_send), Y appended (display shows | ||
| # host's channel traffic too). | ||
| echo "$_intent" > "$AIRC_WRITE_DIR/room_name" | ||
| "$AIRC_PYTHON" -m airc_core.config subscribe \ | ||
| --config "$CONFIG" --channel "$_intent" --first 2>/dev/null || true | ||
| "$AIRC_PYTHON" -m airc_core.config subscribe \ | ||
| --config "$CONFIG" --channel "$resolved_room_name" 2>/dev/null || true |
There was a problem hiding this comment.
The intent vs resolved comparison/subscription is done on the raw room_name string. If a user passes --room with a leading # (or other non-normalized form), this will treat it as diverged from a host advertising the normalized name and end up subscribing to two logically-identical channels (e.g., #foo and foo) with potentially confusing display and default-channel behavior. Consider normalizing $_intent (e.g., strip a leading #, enforce the same casing/charset rules as infer_default_room) before comparing/subscribing.
Joiner's cwd-derived intent was overwritten by host's advertised channel. Now subscribes to BOTH when they differ — intent first (default for cmd_send), host's channel appended for display.
Verification: tabs 19/0, room 14/0. Phase 2C will let joiners push their channels into the mesh gist.