Skip to content

fix(mobile): detect new-tab agents on runtime execution owner - #13977

Closed
OrcaWin wants to merge 2 commits into
mainfrom
OrcaWin/gh-13752
Closed

OrcaWin wants to merge 2 commits into
mainfrom
OrcaWin/gh-13752

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Mobile new-tab agent menu previously resolved detection from repo.connectionId only, so runtime-hosted repos (connectionId: null) probed the paired host instead of the runtime execution owner.
  • Adds host-side preflight.detectRuntimeAgents that proxies preflight.detectAgents to a registered paired runtime environment (authorization: environment must exist in the host store; loop prevention: remote hop never re-delegates).
  • Mobile loader prefers executionHostId (runtime → SSH → local/connectionId) and falls back to paired-host detection when the host predates the new RPC.

Fixes #13752

Wire compatibility

  • New RPC method only; no protocol version bump required for optional new methods.
  • Old mobile / new host: unused method; behavior unchanged.
  • New mobile / old host: method_not_found falls back to preflight.detectAgents (previous behavior, not a hard failure).
  • Remote hop always calls plain preflight.detectAgents so a runtime host cannot re-proxy.

Testing

  • pnpm exec vitest run — preflight-runtime-agent-detection.test.ts, preflight.test.ts (RPC), mobile-rpc-allowlist.test.ts
  • cd mobile && pnpm exec vitest run src/session/mobile-new-tab-agent-loader.test.ts (6 tests)
  • pnpm run typecheck:node
  • mobile tsc --noEmit
  • oxlint on changed files
  • Live paired-runtime + mobile emulator QA (not available in this environment; Electron binary install failed)

Remaining gaps

  • NewWorktreeModal and tasks workspace-create agent detection still use connectionId-only resolution (same class of bug, out of new-tab menu scope).
  • No live multi-host pairing verification in this run.

Runtime-hosted repos have connectionId null, so the mobile new-tab agent
menu fell through to preflight.detectAgents on the paired host. Prefer
executionHostId and proxy via host-side preflight.detectRuntimeAgents so
the menu lists agents installed on the runtime that owns the workspace.

Fixes #13752
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 61d5dd26-49da-4952-8ee0-389faf994311

📥 Commits

Reviewing files that changed from the base of the PR and between 095161c and 81899cd.

📒 Files selected for processing (1)
  • mobile/src/source-control/mobile-create-pr-action.test.ts

📝 Walkthrough

Walkthrough

Adds runtime agent detection for repositories owned by runtime execution hosts. The flow validates and resolves the environment, invokes paired preflight.detectAgents, removes invalid or duplicate agent IDs, and returns an empty list on failure. IPC and RPC handlers expose the method, and the mobile RPC allowlist permits it. Mobile routing now prioritizes execution hosts, supports SSH targets, and falls back to paired-host detection when runtime detection is unavailable. Tests cover backend handling, RPC dispatch, routing precedence, fallback behavior, and local repositories.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The Bitbucket pull-request action test changes are unrelated to issue #13752 and the runtime agent-detection objectives. Remove the unrelated Bitbucket test changes, or provide a linked requirement that explains why they belong in this pull request.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the mobile new-tab agent detection fix for runtime execution owners.
Description check ✅ Passed The description explains the change, rationale, linked issue, compatibility, testing, and known gaps, but omits several required template sections.
Linked Issues check ✅ Passed The changes satisfy issue #13752 by using executionHostId, adding secure runtime delegation, preserving fallback compatibility, and adding regression tests.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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

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

…pport

Bitbucket is a HostedReviewCreationProvider after #5832, so the
provider-unavailable case must use the unsupported sentinel. Keeps the
structural gate coverage and adds a positive bitbucket create assertion.

Unblocks Mobile Checks verify on #13977.
@OrcaWin

OrcaWin commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by the current workspace-scoped detection and direct-pair policy on main (a93e31a93395953b795e9f5098a6b93c8ee331af).

The original bug was presenting the paired host's agents for a workspace owned by another runtime. Main now advertises an explicit other-runtime refusal capability. preflight.detectAgents resolves the workspace on the owning host, including SSH/WSL, and refuses a foreign runtime rather than probing the paired host. Mobile detects runtime-owned repos and refuses the wrong-host inventory, with the explicit remediation: pair that server directly to see its agents. Folder workspaces use the same ownership/refusal policy.

This replaces the proposed cross-runtime proxy/fallback design and removes the incorrect-owner detection behavior that motivated the PR. Reviewed the complete functional diff and current client/server routing; no tests or emulator run were performed for this audit.

@OrcaWin OrcaWin closed this Oct 26, 2026
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.

[Bug][Mobile]: New-tab agent menu resolves detection from repo.connectionId only, so runtime-hosted workspaces list the paired host's agents

1 participant