Skip to content

fix(computer): a Windows app whose window closes is stopped only once its helper has left too - #594

Merged
earakely-scale merged 1 commit into
mainfrom
edgararakelyan/windows-stop-waits-for-helper
Nov 10, 2026
Merged

earakely-scale merged 1 commit into
mainfrom
edgararakelyan/windows-stop-waits-for-helper

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Part of FD-5437. The branch has no issue id, so merging won't close the issue.

On Windows, stopping an app whose window closes when asked returned as soon as the app's own processes had left its job. It didn't wait for the helper (_job.py) that holds the job, which leaves by itself once the job holds no process but its own. alive(pid) counts every process in the job, the helper included, so it could still read true just after such a stop.

That broke stop's own docstring: a stop waits "until each process it held has exited and it holds none". It also made windows_test.py's notes test fail now and then: its session verifier's obliging stop saw {"shown": true, "waited out": false, "alive": true, "listed": false}. Stops with no window, or with a window that won't close, already ended the whole job and waited for it.

The fix

_session_windows.stop now waits, once the app's processes have closed, up to ENDED_TIMEOUT_S for the helper to leave. If anything is still in the job after that, it ends the job, as the other paths do.

Tests

  • packages/agentenv-protocol/tests/test_computer_session_windows.py:
    • Its FakeWin32 gains leaves, modelling the helper: alone in its job, it leaves after that many looks, or stays for None.
    • The obliging-stop test now asserts alive is false right after stop returns.
    • A new test covers a helper that stays after its app's window closes: it's ended with its job.
  • Run against the old stop, both of those fail. With the fix, all 9 pass.
  • ruff check is clean.

Verified on a VM

EC2 c8i.4xlarge with nested KVM, from this branch at 7a09052. tst/integration/computer/windows_test.py -k notes_app ran three times:

Run Result
1 passed, in 33 min 18 s with a fresh Windows 11 base installed from the ISO
2 passed, in 2 min 30 s
3 passed, in 2 min 31 s

Each run's session verifier checks the obliging stop. Since the race was intermittent, three passes don't prove the fix alone; the unit test that fails on the old stop does.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Windows stop now waits for the helper after the app exits and ends the job if the helper stays.

  • Windows app stops now wait for the job helper to leave.

Reviews (1) · Last reviewed commit: "fix(computer): a Windows app whose windo..." · Reviewed by Greptile

… its helper has left too

stop asked an app's windows to close and returned once its own processes had left the job, while the helper holding
the job, which leaves once the job holds no process but itself, could still be there: alive() counts it, so it read
true just after a stop whose window closed. stop now waits for the helper to leave too, then ends the job should it
not, as its other paths do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale requested a review from a team as a code owner November 10, 2026 08:39
@earakely-scale
earakely-scale merged commit 6eef953 into main Nov 10, 2026
61 of 63 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/windows-stop-waits-for-helper branch November 10, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant