Repository navigation
Description
Purpose
help close says: "Close the named app, or close the active session app when app is omitted." With the app omitted, close ends the session and exits 0, but the app stays in the foreground. An agent that cleans up with close --session <name> leaves the app under test running and gets no signal that it did.
Observed on 0.21.39 (also 0.21.37). iOS 27.2 simulator:
$ agent-device open dev.agentverify.MultiTodo --udid <udid> --session c39
$ agent-device close --session c39
Closed: c39 # exit 0
# 3 s later
$ xcrun simctl spawn <udid> launchctl list | grep MultiTodo
32724 0 UIKitApplication:dev.agentverify.MultiTodo[9985][rb-legacy]
Android emulator:
$ agent-device open dev.agentverify.todo --serial emulator-5600 --session c39a
$ adb -s emulator-5600 shell pidof dev.agentverify.todo
3905
$ agent-device close --session c39a
Closed: c39a # exit 0
# 3 s later
$ adb -s emulator-5600 shell pidof dev.agentverify.todo
3905
$ adb -s emulator-5600 shell dumpsys activity activities | grep -m1 mResumedActivity
mResumedActivity: ActivityRecord{e9e7d3a u0 dev.agentverify.todo/.MainActivity t6}
close dev.agentverify.todo --session c39a stops the app.
The cause is in packages/daemon/src/sessions/session-lifecycle/internal/session-close.ts. For a native session it only dispatches the platform close when a positional app is given, although the session's appBundleId is known:
const shouldDispatchPlatformClose = (req: DaemonRequest, session: SessionState): boolean =>
(req.positionals?.length ?? 0) > 0 || isWebSession(session);Required behavior
closewithout an app closes the session'sappBundleIdwhen the session has one. This is whathelp closesays.- A session that never opened an app still closes cleanly without a platform close.
- The Android close fences that
help closedocuments (android-app-close-timeout,android-process-probe-unavailable) apply in the same way as forclose <app>.
Completion conditions
- iOS simulator: after
open <app>and thenclose,launchctl listno longer lists the app. - Android emulator: after
open <app>and thenclose,pidof <package>is empty. closeon a session with no app ends the session and exits 0.
Environment: macOS 27.2 (26B123), Xcode 27.2 (27B52), Node 26.13.1, iOS 27.2 simulator, Android emulator.
Activity
thymikee commentedon Nov 21, 2026
An agent is picking this up; the PR will link here.
fix(close): close the session app when close omits the app
fix(close): close the session app when close omits the app (callstack…