Skip to content

Release a leased mobile device session before stopping the daemon (tester-army/e2e#1900) - #2396

Merged
kblok merged 3 commits into
mainfrom
fix/2319-release-lease-before-stop
Nov 28, 2026
Merged

kblok merged 3 commits into
mainfrom
fix/2319-release-lease-before-stop

Conversation

@kblok

@kblok kblok commented Nov 28, 2026

Copy link
Copy Markdown
Member

Closes #2319

What and why

BrowserStack, TestMu AI and other agent-device lease providers now end the leased device session over RPC (leases.release, attach-only, with a capped budget) before stopping the daemon. A provider that rejects the release (cleanup warnings) now fails the release, and a daemon stop that cannot report (Windows) is accepted once the RPC confirmed the session ended. DeviceReleaseContext.Timeout carries the remaining cleanup budget.

Upstream parity

Ported: e2e-inc/e2e@c801a12 (#1900). Verdict: complete, with justified exceptions (below).

  • releaseLease -> ILeaseHost.ReleaseLeaseAsync; StopDriverOptions; ProviderReleaseWarningError; releaseRpcBudgetMs -> ReleaseRpcBudget; endLeaseDaemon -> EndLeaseDaemonAsync; lifecycle stages; DEFAULT_RELEASE_BUDGET_MS, RELEASE_RPC_TIMEOUT_MS, MIN_RELEASE_RPC_MS, STOP_RESERVE_MS; daemonLifecycle: 'attach' -> DeviceClientConfig.DaemonLifecycle / AgentDeviceDaemon.AttachAsync; timeoutMs -> DeviceReleaseContext.Timeout (TimeSpan).
  • Port-only: TimeProvider parameter of the internal AgentDeviceLeases constructor (stands for vitest fake timers).
  • Docs: BrowserStack page, mobile guide, skill references/mobile.md. The port has no TestMu/Revyl pages.

Upstream tests and local match

  • lease.test.ts: log-throws / interrupt / no-capacity / once-however-often / tries-again (renamed as upstream) / keeps-failing: updated; new ports of un-aborted signal on acquire cleanup, RPC budget cap, slow POSIX stop, fallback on non-warning errors, provider warning rejections (tests/E2E.Mobile.Tests/Lease/AgentDeviceLeasesTests.cs).
  • lease-daemon.test.ts: accepts unconfirmed stop report with sessionEnded; attaches without spawning a daemon; rejects on provider warnings (against a stand-in HTTP daemon) (LeaseDaemon/LeaseDaemonTests.cs).
  • provider.test.ts: release context timeout (Provider/DeviceProviderTests.cs).

Not ported (follow-up #2395)

  • 5 real-daemon tests of lease-daemon.test.ts (could not run npx here).
  • the NaN budget case (no TimeSpan equivalent) of the skip-RPC loop; this test is otherwise complete.
  • TestMu / Revyl docs pages (absent in the port).

Checks

Mobile test project: 690 passed on net10.0 (the two existing real-daemon LeaseDaemonTests need npx and were excluded locally). Not run: real-model tests (no agent change). CSharpier formatted.


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e79eb4e and 85ad9c4.

Files selected for processing: 11

  • docs-site/src/content/docs/get-started/mobile.mdx
  • docs-site/src/content/docs/integrations/browserstack.mdx
  • skills/e2e-dotnet/references/mobile.md
  • src/E2E.Mobile/AgentDeviceDaemon.cs
  • src/E2E.Mobile/DeviceProvider.cs
  • src/E2E.Mobile/Lease/AgentDeviceLeases.cs
  • src/E2E.Mobile/Lease/LeaseDaemon.cs
  • tests/E2E.Mobile.Tests/Lease/AgentDeviceLeasesTests.cs
  • tests/E2E.Mobile.Tests/Lease/FakeLeaseHost.cs
  • tests/E2E.Mobile.Tests/LeaseDaemon/LeaseDaemonTests.cs
  • tests/E2E.Mobile.Tests/Provider/DeviceProviderTests.cs
  • 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

@kblok
kblok merged commit ade853f into main Nov 28, 2026
5 checks passed
@kblok
kblok deleted the fix/2319-release-lease-before-stop branch November 28, 2026 17:25
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.

Upstream: release a leased mobile device session before stopping the daemon (tester-army/e2e#1900)

2 participants