Skip to content

[build-tools] Stop agent-device startup when the session is stopped - #4666

Open
gwdp wants to merge 3 commits into
gwdp/supervise-device-session-tunnelsfrom
gwdp/agent-device-startup-stop-20261016
Open

gwdp wants to merge 3 commits into
gwdp/supervise-device-session-tunnelsfrom
gwdp/agent-device-startup-stop-20261016

Conversation

@gwdp

@gwdp gwdp commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Why

A Stop request that arrived while an agent-device session was still starting did not end startup. The worker went on through the build download, Simulator boot, app install and launch, and controller setup, and then reported the session as ready. Hosted Argent QA showed the same gap, so the next PRs in this stack cover Argent, Appium and web preview with the helper that this PR adds.

How

  • New watchDeviceRunSessionStartup in steps/utils/deviceRunSessionStartup.ts. It polls the session status during startup with the existing status poll. On Stop, it aborts the startup tasks with a "stopped during startup" error. A poll failure aborts startup with that error.
  • completeAsync ends the watch when the session reports ready and throws if startup was aborted. finishAsync ends the watch in cleanup without throwing. Only one status poll runs at a time, because the watch ends before the lifetime wait starts.
  • agent-device uses the helper. Work already running finishes, pending startup tasks are cancelled, and teardown errors stay visible.
  • The startup signal goes to the worker API requests (status and ready report), so a pending request ends on Stop.
  • An explicit errored status still fails the session when the duration deadline fires during the status response.
  • Artifact polling is unchanged.

Test Plan

  • New helper tests: Stop aborts startup, completion ends the poll without an abort, a poll failure aborts startup, the first abort reason is kept, and the watch follows the step signal.
  • New agent-device tests for Stop during startup, plus a duration-deadline regression that fails without its fix.
  • Claude Code ran the build-tools typecheck and the src/steps tests on this commit (1943 passed, 8 skipped), and the root build, typecheck, oxlint, oxfmt and Lerna tests on the top of the stack (2511 passed, 8 skipped).
  • CI passes on bf60bca. Codecov reports all changed lines covered.
  • Planned: a hosted check that Stop during the download and during serve-sim startup ends the session without a ready report.

Authorship and LLM use

Gabe directed the approach and excluded artifact-poller changes. Codex wrote the original change and tests. AI review and Devin review found one issue: an errored status was hidden at the duration deadline. That was fixed. Claude Code rebased the PR onto #4526 and adapted the tests to main. On Gabe's request, Claude Code moved the startup watch into a shared helper that the next three PRs reuse. Gabe asked to mark it ready for review. His review of the final diff is pending.

Generated with T3 Code, using Claude Code.

@gwdp

This comment has been minimized.

@gwdp

This comment has been minimized.

@devin-ai-integration

This comment has been minimized.

@gwdp
gwdp added this pull request to stack #4606 October 17, 2026 00:19
devin-ai-integration[bot]

This comment was marked as outdated.

@gwdp

This comment has been minimized.

@devin-ai-integration

This comment has been minimized.

@gwdp
gwdp force-pushed the gwdp/agent-device-startup-stop-20261016 branch from 509e8de to 7a43ac7 Compare October 20, 2026 05:05
@gwdp gwdp changed the title [build-tools] Observe agent-device Stop requests during startup [build-tools] Stop agent-device startup when the session is stopped Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.38%. Comparing base (6fe396e) to head (bf60bca).

Additional details and impacted files
@@                            Coverage Diff                            @@
##           gwdp/supervise-device-session-tunnels    #4666      +/-   ##
=========================================================================
+ Coverage                                  75.36%   75.38%   +0.02%     
=========================================================================
  Files                                       1054     1055       +1     
  Lines                                      52323    52359      +36     
  Branches                                   11427    11390      -37     
=========================================================================
+ Hits                                       39430    39466      +36     
  Misses                                     11904    11904              
  Partials                                     989      989              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Copy link
Copy Markdown

✅ Thank you for adding a changeset!

@gwdp
gwdp marked this pull request as ready for review October 21, 2026 01:20
@gwdp
gwdp requested a review from szdziedzic October 21, 2026 01:20
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