Skip to content

test(relay): prove the pending-conn capability header reaches acceptControl - #19274

Merged
Jinwoo-H merged 1 commit into
mainfrom
relay/pending-conn-capability-blackbox
Sep 7, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
relay/pending-conn-capability-blackbox

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​73 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​71
Prod 0 0 0 0

ELI5

#19266 taught the relay to send extra detail about a waiting connection, but only to a desktop that asked for it by setting a header. Every piece of that was tested on its own, and nothing tested them joined together. If someone mistyped the header name the relay reads, all the tests still passed and the feature would just quietly stop working. This adds the one test that would catch that.

What Changed

Test-only. One case added to cloud/apps/relay/src/relay.blackbox.test.ts, plus an optional capabilities argument on that file's existing openHostControl helper so a case can set the upgrade header.

The case drives a real control upgrade against a real relay process, creates an invite, connects a phone and never attaches a data socket so the connection stays pending, then rebinds the control twice and asserts the ack:

  • rebound with x-orca-host-capabilities: pending-conn-details — pendingConns is [{connId, connTicket, kind: 'invite', relayDeviceId: 'capability-device'}]
  • rebound without the header — [{connId, connTicket}]

Why

Follow-up to #19266, from a review finding on that PR:

The header → acceptControl wiring here is the one link with no test: parseRelayHostCapabilities is unit-tested, acceptControl/sendHelloAck gating is unit-tested, and the header/constant literals are pinned, but nothing asserts that a real control upgrade carrying x-orca-host-capabilities yields a detailed ack. A typo here (e.g. indexing a differently-spelled header) would pass the whole suite.

That is accurate. The finding arrived after #19266 had already merged, so it lands here instead.

This matters more than a normal coverage gap because the failure mode is silent. A mistyped header name does not error. The relay simply never sees any host as capable, always emits the legacy ack, and the desktop half falls back to its observed conn-open path. Nothing fails, and the fix for the connection-straddling bug is inert.

Linked Issue

N/A. Follow-up to #19266.

Visual Proof

N/A — test-only change.

Testing

Mutation-checked, which is the point of the test. Renaming the header the server reads from RELAY_HOST_CAPABILITIES_HEADER to 'x-orca-host-capability' fails it:

-     "kind": "invite",
-     "relayDeviceId": "capability-device",

 Test Files  1 failed (1)
      Tests  1 failed | 28 passed (29)

Reverted, then re-verified on this branch against current main:

  • npx vitest run src/relay.blackbox.test.ts — 29 passed

  • npx vitest run in apps/relay — 54 files, 535 passed, 95 skipped

  • pnpm typecheck clean

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Internal contributor.

Review

Raised by Pullfrog on #19266. Addressed here rather than rebutted.

Agent skill upstream boundary

  • Not applicable.

Notes

No production code changes, so no security, cross-platform, SSH, mobile, performance, or backwards-compatibility impact. The blackbox suite spawns a real relay process and this case adds roughly one second to it.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

… real upgrade

The unit tests cover parseRelayHostCapabilities, the sendHelloAck gating, and the
header literal separately, but nothing joined them: a typo in the header name
read off the upgrade request passed the entire suite. This drives a real control
upgrade carrying the header, leaves an invite connection pending, and asserts the
rebound control's ack. Renaming the header the server reads fails it.
@coderabbitai

coderabbitai Bot commented Sep 7, 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: Team

Run ID: a9003d1a-a7c5-4480-97dd-da627d51f532

📥 Commits

Reviewing files that changed from the base of the PR and between 9c8f4c3 and 66108e0.

📒 Files selected for processing (1)
  • cloud/apps/relay/src/relay.blackbox.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Relay black-box tests now import host capability constants. The openHostControl helper can send an optional capabilities header during WebSocket setup. A new rebinding test verifies that capable hosts receive detailed pending connection metadata, while legacy hosts receive only connection identifiers and a ticket.

Merge Risk: ⚪ Minimal · up to 66108

This change adds end-to-end coverage that capability-aware relay hosts receive pending-connection details during control rebinding while legacy hosts retain the existing response. No current merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description follows the template and explains the change, motivation, testing, and impact. However, the required Linked Issue section contains “N/A” instead of an issue link. Add the linked issue reference, such as “Fixes #19266” or another valid issue link. If this is only a follow-up and should not close the issue, reference it without using “Fixes”.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. 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 added Relay test and the capability-header behavior it verifies.
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.
  • Fix all pre-merge checks with AI
✨ 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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • openHostControl gains an optional capabilities argument — spreads the RELAY_HOST_CAPABILITIES_HEADER header onto the control upgrade when supplied, so a case can advertise capabilities over the wire.
  • New blackbox case pins the header→acceptControl link — creates an invite, leaves a phone connection pending, then rebinds the control twice (with and without RELAY_HOST_CAPABILITY_PENDING_CONN_DETAILS) and asserts the detailed vs legacy pendingConns ack shape.

I traced the full path the test exercises: relay-server.ts:492 reads the header and passes it to sessions.acceptControl, which stores it per-socket in hostCapabilities (host-session-registry.ts:567), and sendHelloAck (host-session-registry.ts:1197) gates the kind/relayDeviceId fields on it. The test closes the exact gap identified in #19266 — a misspelled header name would otherwise leave the whole suite green — and both assertions (toEqual on the exact object shape) would catch that, as the mutation check in the PR description demonstrates. The no-header rebind assertion additionally proves the capability is per-upgrade rather than sticky across rebinds, which is the correct contract.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 8cd0abf into main Sep 7, 2026
26 checks passed
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.

1 participant