Skip to content

feat(send): AIRC_SEND_TRIGGERS_POLL=1 fires post-send inbox poll for Codex/non-Monitor runtimes - #557

Closed
joelteply wants to merge 1 commit into
canaryfrom
feat/airc-msg-triggers-poll
Closed

joelteply wants to merge 1 commit into
canaryfrom
feat/airc-msg-triggers-poll

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Codex/non-Monitor runtime ergonomic. With `AIRC_SEND_TRIGGERS_POLL=1`, after a successful `airc msg` the `cmd_inbox` path runs quietly (matching codex-poll defaults: `AIRC_INBOX_QUIET_EMPTY=1 AIRC_INBOX_EXCLUDE_SELF=1`) so the runtime sees inbound peer responses inline instead of waiting for the next user-prompt-submit hook fire.

Why it matters: under Monitor (Claude Code), inbound streams continuously. Under Codex non-Monitor, the user-prompt-submit hook only fires on user input — so after Codex sends and waits for a peer reply, the reply sits unseen until the user types something. Silent latency that makes airc feel broken from inside Codex.

Wiring

  • Opt-in env-gate (`AIRC_SEND_TRIGGERS_POLL=1`), default off — Monitor flows unchanged.
  • `cmd_codex_start` exports the env var so codex-spawned children auto-opt-in (caller-override respected for opt-out via `AIRC_SEND_TRIGGERS_POLL=0`).
  • Post-send poll positioned at success-path tail: only fires on actual delivery success, not on monitor-down failure / queueing / auth failure.
  • `--internal` callers (`cmd_rename`'s propagation, etc.) stay silent — machine-to-machine traffic.

Test plan

New scenario `send_triggers_poll` (5 assertions):

  • `cmd_send.sh` references `AIRC_SEND_TRIGGERS_POLL` (wiring present)
  • gate is on `=1` (opt-in only)
  • `cmd_codex_start` exports the env var (auto-opt-in for codex children)
  • codex-poll surfaces unread peer message (the call cmd_send wires)
  • post-send poll does NOT fire on send-failure path (gate placement)

Existing tests still green:

  • `scenario_inbox` (8/0)
  • `scenario_send_dead_monitor_dies` (14/0)
  • `test_codex_hook.py` (6/6)
  • `test_inbox.py` (3/3)

Live-validated by sibling Codex agent who patched the path locally and sent the validation message through the patched send (their inbox update fired correctly during the dogfood test).

Files

  • `lib/airc_bash/cmd_send.sh` (+13): post-send poll at success-path tail, env-gated
  • `lib/airc_bash/cmd_status.sh` (+5): `cmd_codex_start` exports the env var
  • `test/integration.sh` (+66): `scenario_send_triggers_poll` + dispatch + usage line

🤖 Generated with Claude Code

Codex/non-Monitor runtime ergonomic. With the env var set, after a
successful airc msg the cmd_inbox path runs quietly (matching codex-poll
defaults: AIRC_INBOX_QUIET_EMPTY=1 AIRC_INBOX_EXCLUDE_SELF=1) so the
runtime sees inbound peer responses inline instead of waiting for the
next user-prompt-submit hook fire (which only happens when the user
types a new prompt).

Why this matters: under the Monitor-driven flow (Claude Code), inbound
streams continuously into the agent's context. Under Codex-style
non-Monitor runtimes, the agent can only see new airc traffic when the
user-prompt-submit hook runs, which is gated on user input. After Codex
sends a message via airc msg and waits for a peer reply, the reply sits
unseen until the user types something — silent latency that makes airc
feel broken from inside Codex sessions.

Wiring is opt-in (env-gated, default off) so Monitor flows are unchanged
and the new behavior never accidentally fires for users who don't want
it. cmd_codex_start exports AIRC_SEND_TRIGGERS_POLL=1 by default for
processes it spawns, so any Codex session bootstrapped via codex-start
gets the auto-poll without manual env config. Honors caller override
(AIRC_SEND_TRIGGERS_POLL=0) for opt-out.

The post-send poll is positioned at the success-path tail (after the
user-facing footer, before the closing brace) so it only fires when
delivery actually succeeded — not on monitor-down failure, not on
queueing, not on auth failure. --internal callers (cmd_rename's
propagation, etc.) stay silent since they're machine-to-machine
traffic, not Codex's user-visible send surface.

Regression test (scenario_send_triggers_poll, 5 assertions):
  - cmd_send.sh references AIRC_SEND_TRIGGERS_POLL (wiring present)
  - gate is on '=1' (opt-in only, not 'set to anything')
  - cmd_codex_start exports the env var (auto-opt-in for codex children)
  - codex-poll surfaces unread peer message (the call cmd_send wires)
  - post-send poll does NOT fire on send-failure path (gate placement)

Existing tests still green: scenario_inbox (8/0), send_dead_monitor_dies
(14/0), test_codex_hook.py (6/6), test_inbox.py (3/3).

Live-validated by sibling Codex agent who patched the path locally and
sent this very class of message through the patched send (their inbox
update fired correctly).

Closes the latency gap reported in cmd_send for Codex/non-Monitor
runtime consumers.
Copilot AI review requested due to automatic review settings May 13, 2026 16:24
@joelteply

Copy link
Copy Markdown
Contributor Author

Closing in favor of #556 (sibling Codex shipped same task ~2min earlier with additional fixes I missed: stale-backlog window bound + empty-poll exit status, both caught in live use; plus python tests on inbox.py changes).

Unique value from this PR worth porting to #556: cmd_codex_start exports AIRC_SEND_TRIGGERS_POLL=1 by default for processes it spawns (lib/airc_bash/cmd_status.sh) — this gives codex sessions auto-opt-in to the new behavior without requiring manual env config or per-callsite flag. Caller can override (=0) to opt out. Suggesting as small followup to #556.

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 an opt-in post-send inbox poll intended to improve Codex/non-Monitor ergonomics by surfacing unread peer messages immediately after airc msg.

Changes:

  • Adds AIRC_SEND_TRIGGERS_POLL=1 handling in cmd_send.
  • Exports the env var during Codex detached start.
  • Adds an integration scenario for the new wiring.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/airc_bash/cmd_send.sh Adds env-gated post-send cmd_inbox polling.
lib/airc_bash/cmd_status.sh Attempts to enable the env gate for Codex-started flows.
test/integration.sh Adds and wires a new send_triggers_poll scenario.

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

Comment thread lib/airc_bash/cmd_send.sh
# processes it spawns. --internal callers (rename propagation, etc.)
# stay silent — they're internal traffic, not Codex's user-visible
# send surface.
if [ "$internal" != "1" ] && [ "${AIRC_SEND_TRIGGERS_POLL:-0}" = "1" ]; then
Comment on lines +620 to +624
# Codex/non-Monitor runtime ergonomics: any subsequent `airc msg` from
# this scope auto-fires cmd_inbox post-send so peer responses surface
# inline instead of waiting for separate user traffic. Honors the
# caller's existing setting (allow override to 0 for opt-out).
export AIRC_SEND_TRIGGERS_POLL="${AIRC_SEND_TRIGGERS_POLL:-1}"
Comment thread test/integration.sh
Comment on lines +4078 to +4087
# ── Behavioral: codex-poll itself surfaces the unread peer message.
# cmd_send.sh's post-send wiring invokes the same code path, with the
# same env defaults (AIRC_INBOX_QUIET_EMPTY=1 AIRC_INBOX_EXCLUDE_SELF=1).
# Proving codex-poll surfaces the message proves the call cmd_send
# wires actually does what cmd_send needs.
local out
out=$(AIRC_HOME="$home" "$AIRC" codex-poll 2>&1)
printf '%s' "$out" | grep -q 'unread-before-send' \
&& pass "codex-poll surfaces unread peer message (the call cmd_send wires for codex runtime)" \
|| fail "codex-poll did not surface unread peer message (got: $out)"
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