Skip to content

fix(init): Pi and OpenCode sessions join Relay on their own after relay init - #2018

Merged
kjgbot merged 4 commits into
mainfrom
fix/init-pi-opencode-auto-join
Oct 30, 2026
Merged

kjgbot merged 4 commits into
mainfrom
fix/init-pi-opencode-auto-join

Conversation

@kjgbot

@kjgbot kjgbot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

An end-to-end test of agent-relay@15.0.0-next.4 showed that after relay init sets up Pi or OpenCode, their sessions never join Relay on their own. Codex and Claude sessions do: with auto_activate on, a Codex session auto-joined as codex-<project>-session and received injected DMs.

Root cause

The fault is in the core's admission check, not in init. relay init already turns on pi_extension / opencode_plugin and auto_activate. But LocalSessions::activation_check (crates/probe/src/relay/local/directory_trait.rs) hard-coded

// Opt-in, like every provider route the plugin opens.
SessionKind::OpenCodeOpen | SessionKind::Pi => false,

As a result, a live Pi or open-OpenCode session was never eligible for automatic activation, whatever the settings were. Init had no setting it could turn on to change that.

Fix

  • Core: two new store settings, pi_auto_activate and opencode_auto_activate. They are off by default, and only the person can turn them on (PERSON_TURNS_ON). They are kept in the store's extras and merged across writers like the other extras.
  • Shared policy (agents/auto_activation.rs): activation_applies now takes ActivationSettings. With auto_activate on, Pi and open OpenCode sessions activate only when their own opt-in is also on. auto_activate off or unset still wins.
  • Activation check: Pi and open OpenCode rows are now structurally eligible. That matches Codex: the row exists only while a live process of this user holds the extension's private registry or serves the plugin socket, and delivery proves that process again on every send. The same policy also gates /setup/status's auto_activates and activation_outstanding.
  • Desktop users keep today's behavior. Turning on auto_activate alone, which the desktop's switch does, still leaves Pi and OpenCode sessions joining only when added. The desktop installs both routes by default, so auto_activate on its own could not be used as the signal.
  • CLI (probe-core.ts): PROBE_DELIVERY.pi is now [pi_extension, pi_auto_activate] and PROBE_DELIVERY.opencode is now [opencode_plugin, opencode_auto_activate]. The existing generic machinery records exactly what init turned on. --uninstall and --delivery mcp turn off exactly that. A refused opt-in rolls the tool back and gives it the MCP fallback, as for any other setting.
  • The Swift contract was regenerated. Docs updated: docs/probe-move.md and crates/probe/docs/relay-core.md. CHANGELOG has an entry under [Unreleased - Major] → Fixed.

The diff only touches the Pi and OpenCode entries in probe-core.ts. init.ts is unchanged.

Tests

  • Unit tests (auto_activation.rs): the policy matrix. auto_activate on alone does not admit Pi or OpenCode. Each opt-in admits only its own kind. Neither opt-in overrides auto_activate off or unset. The settings are read from the store.
  • Core integration tests (local/tests/automatic_admission.rs): a live Pi session, an extension registry held by a fake process, goes through activate_new_sessions against a fake Relaycast.
    • With auto_activate on: no registration.
    • With OpenCode's opt-in on: still none.
    • With pi_auto_activate on: it registers, pinned to the live pi:600:… binding.
    • With auto_activate off or unset: no registration, even with the opt-in on.
  • settings_extras serialization and merge tests cover the new fields, and relay_agents checks the settings.get shape.
  • CLI (init.test.ts, probe-core.test.ts):
    • Pi records and undoes pi_auto_activate.
    • OpenCode records and undoes opencode_auto_activate on --uninstall.
    • An opt-in the person turned on themselves survives --uninstall.
    • A refused opt-in falls back to MCP with nothing left on.

E2E

Run locally against the built core-only probe and CLI, fully isolated: temp HOME, AGENT_RELAY_HOME/INSTALL_DIR, XDG dirs and core socket under /tmp/orlh, project at ~/orl-project.

  1. relay init --tools opencode --yes recorded turnedOn: [opencode_plugin, opencode_auto_activate, auto_activate].
  2. Starting opencode (1.14.22) in the project made it auto-join as opencode-orl-project-new-session (kind opencode-open) without being added.
  3. relay message dm send opencode-orl-project-new-session "E2E-PING-7731…" --as e2e-sender was injected into the running TUI session as an [via Agent Relay — from @e2e-sender …] user message. The model could not answer because OpenCode's free tier was exhausted, so the message showed as QUEUED.
  4. relay init --uninstall turned off exactly opencode_plugin, opencode_auto_activate, auto_activate.

Pi is not installed on the test machine, so Pi is covered by the core integration test above, not a live run.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

kjgbot and others added 2 commits October 29, 2026 10:10
… relay init

The core's activation check hard-coded open Pi and OpenCode sessions as
never eligible, so `auto_activate` (which relay init turns on) put Codex and
Claude sessions on the relay but never Pi or OpenCode ones.

Add per-provider opt-ins `pi_auto_activate` and `opencode_auto_activate`
(store settings, off by default, person-only to turn on). With
`auto_activate` on, a live Pi or open OpenCode session now joins by itself
only when its own opt-in is on; `auto_activate` alone (the desktop's
switch) keeps today's join-only-when-added behavior. relay init turns on
the opt-in for each chosen tool next to `pi_extension` / `opencode_plugin`,
records it, and `--uninstall` / `--delivery mcp` turn off exactly that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-ins

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c5f38438-5b38-4f47-9e74-7ffc77534fd0
Commits

Reviewing files that changed from the base of the PR and between 7c66962 and a80c1a7.

Files selected for processing: 2
  • crates/probe/tests/relay_agents.rs
  • docs/probe-move.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

This change adds default-off Pi and OpenCode auto-activation settings. The settings flow through core contracts and storage, control provider-specific session eligibility, and are enabled for selected tools by relay init.

Changes: Pi and OpenCode automatic activation

Layer / File(s) Summary
Add and persist provider settings
crates/probe/contract/CoreContract.swift, crates/probe/src/relay/contract/agents/settings.rs, crates/probe/src/relay/store/settings_extras.rs, crates/probe/src/relay/store_settings.rs, crates/probe/src/relay/spawn/settings.rs, crates/probe/src/relay/settings_registry.rs, crates/probe/tests/relay_agents.rs, crates/probe/docs/relay-core.md
Settings contracts and store extras add optional Pi and OpenCode activation values. Store settings expose both values, and save and restore paths handle them.
Apply provider opt-ins to session eligibility
crates/probe/src/relay/agents.rs, crates/probe/src/relay/agents/auto_activation.rs, crates/probe/src/relay/local/directory_trait.rs, crates/probe/src/relay/setup.rs, crates/probe/src/relay/local/tests/automatic_admission.rs
Pi and open OpenCode sessions require global auto_activate and their respective opt-in. Session admission and setup checks evaluate the combined settings. Tests cover the opt-in requirements.
Enable settings through relay init
packages/cli/src/cli/lib/probe-core.ts, packages/cli/src/cli/lib/probe-core.test.ts, packages/cli/src/cli/commands/init.test.ts, docs/probe-move.md, CHANGELOG.md
Tool delivery enables the corresponding provider setting. Tests cover setting ownership, uninstall behavior, and rejected settings. Documentation and the changelog describe the settings and init behavior.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant relay_init
  participant Core
  participant Store
  participant activate_new_sessions
  participant activation_applies
  participant AgentRelay
  relay_init->>Core: enable selected provider setting
  Core->>Store: persist settings extras
  activate_new_sessions->>Store: read ActivationSettings
  Store-->>activate_new_sessions: global and provider settings
  activate_new_sessions->>activation_applies: evaluate session kind and settings
  activation_applies-->>activate_new_sessions: eligibility result
  activate_new_sessions->>AgentRelay: register eligible session
Loading

Possibly related PRs

  • AgentWorkforce/relay#2016: Adds the core-backed relay init delivery flow and per-tool delivery settings extended by this change.
Merge Risk: Minimal · up to a80c1

No actionable merge-blocking risk remains from the reviewed change.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description gives detailed problem, root-cause, fix, and test information, but it does not follow the required template. It omits the required Summary, Test Plan, and RelayFlow Proof sections, inc… Add the required template sections. Include a Summary, a Test Plan with the tests-added/updated and manual-testing items, and a RelayFlow Proof with Change type set to bugfix and exactly one RelayFlow case under tests/relayflows/cases/<case…
Docstring Coverage Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: enabling Pi and OpenCode sessions to join Relay automatically after init.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description gives detailed problem, root-cause, fix, and test information, but it does not follow the required template. It omits the required Summary, Test Plan, and RelayFlow Proof sections, including the change type and case identifier.

Resolution

Add the required template sections. Include a Summary, a Test Plan with the tests-added/updated and manual-testing items, and a RelayFlow Proof with Change type set to bugfix and exactly one RelayFlow case under tests/relayflows/cases/<case-id>/. Add a Screenshots section if applicable.

Full details: Docstring Coverage

Explanation

Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 15 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the settings store,
Pi and OpenCode join the floor.
With global and local switches bright,
New sessions hop into Relay’s light.
relay init sets each chosen key,
Then sends the messages happily.

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Pi and OpenCode sessions can now join Relay automatically after relay init.

  • Live Pi and OpenCode sessions join Relay with their own opt-ins.
  • relay init enables automatic joining for the Pi or OpenCode tool you choose.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Live Pi or OpenCode session] --> B{auto_activate is on?}
  B -->|No| E[Do not join automatically]
  B -->|Yes| C{Tool's own opt-in is on?}
  C -->|No| E
  C -->|Yes| D[Try automatic registration]
Loading

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

…ed as unused

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
khaliqgant
khaliqgant previously approved these changes Oct 29, 2026
…auto-join

# Conflicts:
#	docs/probe-move.md
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