Skip to content

close without an app ends the session but leaves the app running #4684

Closed

Description

@xiatiandeairen

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

  • close without an app closes the session's appBundleId when the session has one. This is what help close says.
  • A session that never opened an app still closes cleanly without a platform close.
  • The Android close fences that help close documents (android-app-close-timeout, android-process-probe-unavailable) apply in the same way as for close <app>.

Completion conditions

  • iOS simulator: after open <app> and then close, launchctl list no longer lists the app.
  • Android emulator: after open <app> and then close, pidof <package> is empty.
  • close on 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

  1. added
    bug
    in-progress
    on Nov 19, 2026
  2. thymikee commented on Nov 21, 2026

    @thymikee
    Member

    An agent is picking this up; the PR will link here.

  3. added a commit that references this issue on Nov 21, 2026
    888b4e2
  4. removed
    in-progress
    on Nov 21, 2026
  5. added a commit that references this issue on Nov 21, 2026
    0525c45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions