Skip to content

feat(send): multi-target DM via leading @-tokens or comma-separated peers - #234

Merged
joelteply merged 1 commit into
canaryfrom
feat/multi-target-dm-fanout
Apr 28, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/multi-target-dm-fanout

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Supports IRC-style /msg user1,user2,user3 form AND whitespace form 'airc msg @alice @bob hi'. All collapse to comma-joined CSV in envelope's to field. Mesh substrate has every peer tailing the same log so one envelope reaches all addressees.

Verification: tabs 19/0, queue 7/0; manual envelope inspection.

…eers

Bug observed during the QA-team coordination push: my own attempt to
broadcast to multiple AIs via `airc msg @Anvil @memento @continuum-b741
...` failed with "Usage: airc send @peer <message>" — the parser only
consumed the first @-token and treated subsequent ones as message body.
IRC standard is `/msg user1,user2,user3 message`; the airc fix here
supports both that and the more natural whitespace form.

## Fix

cmd_send.sh: collect ALL leading @-tokens (whitespace-separated) and
expand each into comma-separated sub-targets. All forms collapse to
a comma-joined CSV in the envelope's `to` field.

Accepted forms:
  airc msg @alice                      → to: "alice"
  airc msg @alice,bob                  → to: "alice,bob"
  airc msg @alice @bob                 → to: "alice,bob"
  airc msg @alice,bob @Carol           → to: "alice,bob,carol"

## Wire / display

The mesh substrate (Phase 1) has every peer tailing the SAME host's
messages.jsonl. So one envelope with `to: "alice,bob,carol"` is
visible to all three; receivers can split on comma to detect "is
this addressed to me?". Display:

  airc: [#chan] sender → alice,bob,carol: msg

## Verification

  bash -n: clean
  Manual: `airc msg @x @y @z hi` → envelope `to: "x,y,z"`
  test/integration.sh tabs:  19/0 ✓
  test/integration.sh queue: 7/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:15
@joelteply
joelteply merged commit 75e2d17 into canary Apr 28, 2026
@joelteply
joelteply deleted the feat/multi-target-dm-fanout branch April 28, 2026 19:15

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

Adds multi-target direct-messaging support to cmd_send by allowing multiple recipients to be specified via leading @ tokens and/or comma-separated recipient lists, collapsing them into a CSV stored in the envelope’s to field.

Changes:

  • Parse multiple leading @peer tokens and combine them into a comma-separated recipient list.
  • Support comma-separated peers inside a single @... token (e.g., @alice,bob).
  • Update usage handling for the multi-target DM case (when recipients are detected).

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

Comment thread lib/airc_bash/cmd_send.sh
Comment on lines +100 to +110
# Multi-target DM: collect leading @-tokens (whitespace-separated)
# and/or comma-separated peers within a single @-token. All forms
# collapse to a comma-joined CSV in peer_name. The mesh substrate
# has every peer tailing the same host's messages.jsonl, so one
# envelope with `to: "alice,bob,carol"` is visible to all three;
# display shows the CSV recipient list. Receivers can split on
# comma to detect "is this addressed to me?".
#
# IRC norm: /msg user1,user2 message
# Also supported: airc msg @user1 @user2 message (whitespace)
# Mixed: airc msg @user1,user2 @user3 message

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.

The implementation only treats leading tokens that start with '@' as recipients. That means the PR-described “/msg user1,user2 …” (no leading '@') is not actually supported: airc msg alice,bob hi will be treated as a broadcast with message alice,bob hi. Either implement the comma-separated non-@ form (possibly behind a distinct subcommand like privmsg) or update the in-code comment/CLI docs to reflect that an '@' prefix is still required for multi-target DMs.

Copilot uses AI. Check for mistakes.
Comment thread lib/airc_bash/cmd_send.sh
Comment on lines +113 to +125
while [ $# -gt 0 ]; do
case "$1" in
@*)
local _p="${1#@}"
if [ -z "$_peer_csv" ]; then
_peer_csv="$_p"
else
_peer_csv="${_peer_csv},${_p}"
fi
shift
;;
*) break ;;
esac

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 parsing consumes all leading @... tokens as recipients. That introduces a regression vs the previous behavior: you can no longer DM a single peer a message whose first word starts with @ (e.g., airc send @alice @bob hi used to DM alice with message @bob hi, but now it becomes a multi-target DM). Consider adding a conventional delimiter (e.g., stop recipient parsing at --) or an explicit --to/--dm flag so messages can still start with @ without being interpreted as additional recipients.

Copilot uses AI. Check for mistakes.
Comment thread lib/airc_bash/cmd_send.sh
Comment on lines +116 to +121
local _p="${1#@}"
if [ -z "$_peer_csv" ]; then
_peer_csv="$_p"
else
_peer_csv="${_peer_csv},${_p}"
fi

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.

_p="${1#@}" is accepted as-is and appended into the CSV, so inputs like @ (empty), @alice, (empty segment), or @alice,@bob (second recipient retains a leading '@') will produce a malformed to field (empty recipients / unexpected '@' characters). Since peer_name is embedded into JSON without escaping, it’s also important to restrict it to the allowed nick charset. Suggest splitting _p on commas, stripping any leading '@' from each segment, rejecting empty segments, and validating each recipient with the existing _validate_peer_name helper before constructing peer_name.

Suggested change
local _p="${1#@}"
if [ -z "$_peer_csv" ]; then
_peer_csv="$_p"
else
_peer_csv="${_peer_csv},${_p}"
fi
local _p_raw="${1#@}"
local _peer_parts=()
local _peer_part=""
IFS=, read -r -a _peer_parts <<< "$_p_raw"
for _peer_part in "${_peer_parts[@]}"; do
_peer_part="${_peer_part#@}"
[ -z "$_peer_part" ] && die "Usage: airc send @peer [@peer2 ...] <message>"
_validate_peer_name "$_peer_part" || die "Invalid peer name: $_peer_part"
if [ -z "$_peer_csv" ]; then
_peer_csv="$_peer_part"
else
_peer_csv="${_peer_csv},${_peer_part}"
fi
done

Copilot uses AI. Check for mistakes.
Comment thread lib/airc_bash/cmd_send.sh
Comment on lines +127 to +134
if [ -n "$_peer_csv" ]; then
peer_name="$_peer_csv"
msg="$*"
[ -z "$msg" ] && die "Usage: airc send @peer [@peer2 ...] <message>"
else
peer_name="all"
msg="$*"
fi

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 change introduces new recipient-parsing behavior (multi-target via whitespace and commas) but there are no corresponding integration tests. Since test/integration.sh already exercises airc send @peer ..., please add coverage for: (1) airc send @a,b @c msg producing to:"a,b,c", (2) airc send @a @b msg, and (3) the chosen escape hatch for messages that start with @ (e.g., -- delimiter) to prevent regressions.

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Apr 28, 2026
…#253)

continuum-b741's QA finding 2026-04-27: `airc msg "@bob looks good"`
parsed @bob as DM target and rejected the multi-word remainder (or in
post-#234 sent rest as DM). Users want IRC-style in-channel @-mentions
for emphasis without forcing them to add filler text before the @name.

## Fix

After collecting leading @-tokens into _peer_csv, check for internal
whitespace. Peer names are [a-z0-9-] — whitespace inside the parsed
target means it's not a peer name. Treat as broadcast intent: put the
@-prefix back in the message body, set peer_name=all.

  airc msg "@bob looks good"  →  broadcast: '@bob looks good'
  airc msg @bob "looks good"  →  DM to bob: 'looks good'  (unchanged)
  airc msg @bob               →  empty-body error w/ recovery hint  (#147)

Verification: tabs 19/0; manual exercise of all 3 cases.
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