Skip to content

fix(codex): make join the uniform startup path - #524

Merged
joelteply merged 1 commit into
canaryfrom
codex/uniform-join-flow
May 5, 2026
Merged

joelteply merged 1 commit into
canaryfrom
codex/uniform-join-flow

Conversation

@joelteply

@joelteply joelteply commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Make public Codex startup use plain airc join; the CLI detects Codex for join/resume and routes through the detached adapter internally.
  • Guard the detached child with AIRC_CODEX_START_CHILD=1 so airc join cannot recurse through the adapter.
  • Remove the stale ensure_init precondition so Codex can be the first user in a fresh scope.
  • Emit joined / left lifecycle notices through the normal message protocol as from=airc system events instead of local attach-only appends. Join notices are limited to channels with a gist mapping, so legacy --no-room --no-gist smoke starts stay untouched.
  • Update Codex skills/docs away from public airc codex-start.

Verification

  • bash -n airc lib/airc_bash/cmd_connect.sh lib/airc_bash/cmd_send.sh lib/airc_bash/cmd_rooms.sh lib/airc_bash/cmd_status.sh test/integration.sh
  • python3 test/test_codex_start.py
  • python3 test/test_system_event.py
  • python3 test/test_collaboration.py
  • ./test/integration.sh codex_join_detaches_transport
  • Manual temp-scope check: clean-install style airc connect --no-room --no-gist still writes airc.pid promptly.
  • Manual temp-scope check after fix(peers): show recent broadcast peers even when paired records exist #523: stale paired record plus fresh broadcast sender both appear in airc peers.

Notes

PR #523 is already merged to canary as 5991086; this branch is rebased on top of it.

Copilot AI review requested due to automatic review settings May 5, 2026 16:10
Public Codex flow now uses plain airc join. The shell dispatch detects Codex for join/resume and routes through the detached adapter, while the spawned child is guarded from recursive detach. Fresh scopes no longer fail before init.\n\nAlso emit join/part lifecycle notices through the normal message protocol as system events instead of local attach-only appends, and preserve the broadcast-peer listing fix from #523 in this branch.
@joelteply
joelteply force-pushed the codex/uniform-join-flow branch from f716c2c to 88715dd Compare May 5, 2026 16:13
@joelteply
joelteply merged commit 78fe07a into canary May 5, 2026
6 checks passed
@joelteply
joelteply deleted the codex/uniform-join-flow branch May 5, 2026 16:14

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 makes airc join/airc resume the single, uniform startup path across human/Claude/Codex runtimes by moving the Codex “detach from tool process group” behavior behind CLI dispatch, and by emitting join/part lifecycle notices via the normal message protocol.

Changes:

  • Route airc join/resume through the Codex detached-start adapter when a Codex environment is detected, with recursion guards (AIRC_CODEX_START_CHILD).
  • Add a cmd_send --system mode (from=airc) and use it to emit join/part lifecycle notices as signed messages.
  • Update skills/README guidance and add/extend tests to validate Codex join detaching behavior.

Reviewed changes

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

Show a summary per file
File Description
airc Adds Codex-environment detection and routes join/resume through detached start when appropriate.
lib/airc_core/codex_start.py Sets AIRC_CODEX_START_CHILD=1 and updates the detached-start banner to match the new public airc join flow.
lib/airc_bash/cmd_status.sh Removes ensure_init precondition from cmd_codex_start so Codex can start in a fresh scope.
lib/airc_bash/cmd_send.sh Introduces --system flag and stamps system events with from=airc.
lib/airc_bash/cmd_connect.sh Replaces prior join-event emission with message-protocol system events on join.
lib/airc_bash/cmd_rooms.sh Emits system lifecycle notices on /part via the normal send path.
test/test_codex_start.py Extends unit test to assert the recursion-guard env var is set for the detached child.
test/integration.sh Adds integration scenario validating “Codex uses plain airc join without recursive detach.”
README.md Updates Codex documentation to use airc join rather than airc codex-start.
skills/update/SKILL.md Switches Codex update flow to restart via airc join.
skills/resume/SKILL.md Switches Codex resume flow to airc join.
skills/repair/SKILL.md Switches Codex repair flow to airc join "$INVITE".
skills/join/SKILL.md Updates Codex join guidance to use the public airc join command.
skills/canary/SKILL.md Updates canary restart instructions for Codex to use airc join.
Comments suppressed due to low confidence (1)

lib/airc_bash/cmd_status.sh:593

  • cmd_codex_start no longer calls ensure_init (good for fresh scopes), but it still unconditionally calls cmd_status (and then cmd_inbox) after only a fixed 2s sleep. If the detached airc join hasn’t created/repaired config.json yet, cmd_status will die and make airc join in Codex fail even though the transport is starting. Consider making the status/inbox section best-effort (don’t exit on “Not initialized”), or polling briefly for config/health before calling cmd_status.
cmd_codex_start() {
  local _log="$AIRC_WRITE_DIR/codex-airc.log"
  "$AIRC_PYTHON" -m airc_core.codex_start \
    --airc "$0" \
    --home "$AIRC_WRITE_DIR" \
    --log "$_log" \
    -- "$@"

  # Give the detached process a short startup window, then print the same
  # useful local surfaces that `airc join` prints when it returns quickly.
  sleep 2
  echo ""
  echo "Status"
  echo "------"
  cmd_status
  echo ""
  echo "Inbox"
  echo "-----"
  AIRC_INBOX_QUIET_EMPTY=1 AIRC_INBOX_EXCLUDE_SELF=1 cmd_inbox --count 10 || true
}

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

Comment on lines +195 to +205
_join_emit_join_events() {
local _name="$1"
[ -z "$_name" ] && return 0
[ -f "$CONFIG" ] || return 0
local _channels _ch
_channels=$("$AIRC_PYTHON" -m airc_core.config read_channels --config "$CONFIG" 2>/dev/null || true)
[ -z "$_channels" ] && return 0
while IFS= read -r _ch; do
[ -z "$_ch" ] && continue
local _gid
_gid=$("$AIRC_PYTHON" -m airc_core.config get_channel_gist --config "$CONFIG" --channel "$_ch" 2>/dev/null || true)
Comment on lines 244 to 248
if [ -z "$_ch_gist" ]; then
die "Not subscribed to #${arg_room} (no channel_gists mapping). Use 'airc list' to see open rooms; 'airc status' for your subscriptions."
fi
cmd_send --internal --system --channel "$arg_room" "$(get_name) left #${arg_room}" >/dev/null 2>&1 || true
# Delete the gist ONLY if we're hosting it — i.e., it appears
Comment thread airc
Comment on lines +2337 to +2348
_airc_should_use_codex_start() {
[ -n "${AIRC_CODEX_START_CHILD:-}" ] && return 1
[ -n "${AIRC_NO_CODEX_DETACH:-}" ] && return 1
[ -n "${AIRC_NO_ATTACH:-}" ] && return 1

local _arg
for _arg in "$@"; do
[ "$_arg" = "--attach" ] && return 1
done

[ -n "${CODEX_THREAD_ID:-}${CODEX_CI:-}${CODEX_MANAGED_BY_NPM:-}" ]
}
Comment thread airc
Comment on lines +2342 to +2346
local _arg
for _arg in "$@"; do
[ "$_arg" = "--attach" ] && return 1
done

Comment thread lib/airc_bash/cmd_send.sh
Comment on lines 102 to +108
--internal)
internal=1
shift ;;
--system)
system_event=1
internal=1
shift ;;
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