Skip to content

fix(close): close the session app when close omits the app - #4881

Merged
thymikee merged 1 commit into
mainfrom
fix/close-without-app-stops-session-app
Nov 21, 2026
Merged

thymikee merged 1 commit into
mainfrom
fix/close-without-app-stops-session-app

Conversation

@thymikee

@thymikee thymikee commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

close without an app ended the session but left the app running, although help close says it closes the active session app. The daemon now closes the session's app the way close <app> does, Android close fences included. A session that never opened an app still closes without a platform close. Web sessions are unchanged. The repair close receipt is keyed on the resolved target.

10 files: 1 source file (+12/-4), the rest tests and integration fakes. Fixes #4684.

Impact: a plain close now also stops the app on macOS native app devices, physical Apple devices, cloud providers, at the end of .ad scripts, and in replay test teardown. close --shutdown also closes the app before the device stops, which adds Android close-fence time. None of these were run live.

Before / after

open <app> then close (app omitted), same script and daemon state, base 991325f45c vs head (same code, rebased to 888b4e20d6):

Device Base Head
iPhone 17e sim, Settings exit 0, 1 UIKitApplication entry stays exit 0, 2.5 s, 0 entries
Android API 37 AVD, Settings exit 0, pidof 1153 stays exit 0, 0.9 s, pidof empty

Validation

At 888b4e20d6: the new unit test fails on base and passes on head. The daemon sessions, server and provider-scenario suites pass locally (252 files). CI owns full validation.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.48 MB 6.48 MB +52 B
Package (unpacked) 6.48 MB 6.48 MB +52 B
Package (download) 1.97 MB 1.97 MB -11 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.7 ms 27.6 ms -0.0 ms
CLI --help 54.1 ms 58.9 ms +4.9 ms

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 2 new findings on 3126efe. The verdict and the full list are in the summary comment.

Plain close ended the session but left the app it opened running, although help close says it closes the active session app. The daemon now closes the session's app the way close <app> does. A session that never opened an app still closes without a platform close, and web sessions are unchanged. The repair close receipt is keyed on the resolved target.

Fixes #4684

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee
thymikee force-pushed the fix/close-without-app-stops-session-app branch from 3126efe to 888b4e2 Compare November 21, 2026 09:28
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 888b4e2

Since the review of 3126efe: 0 new · 0 still open · 2 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (c37bb956307c).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 888b4e2, and there are no conflicts. The change selects the session app when close omits the app, and each backend then runs its existing close route. Required evidence is satisfied. The only red run, Body rules 44889718627, was cancelled by the workflow's concurrency rule. The next Body rules run on the same head passed, and the other 21 checks pass.

Not blocking, and you can take or leave these: dispatchTargetedPlatformClose in https://github.com/callstack/agent-device/blob/888b4e2/packages/daemon/src/sessions/session-lifecycle/internal/session-close.ts#L198 now also handles untargeted closes, so dispatchPlatformClose fits better, and some test comments still say "targeted close". Plain close, close --shutdown and replay test teardown can now fail with android-app-close-timeout or android-process-probe-unavailable on an app that refuses to exit. help close documents the fences, but the replay test help does not say that teardown closes the session app. Revyl close refuses a named app that differs from launchedApp.bundleId (https://github.com/callstack/agent-device/blob/888b4e2/packages/provider-revyl/src/interactor.ts#L147). Both ids come from the same open target, so no divergence is reachable today. The body says +12/-4, but the diff is +14/-5.

Of the earlier threads, the one on session retention after a failed fence no longer applies as written (#4881 (comment)). Only claimed sessions are kept. Unclaimed sessions release the lease and retire first, and the fences match close <app> as #4684 requires. The thread on the test-app screen no longer applies because that file left the diff in the rebase (#4881 (comment)). You can resolve both.

Not verified here: the live iOS simulator and Android AVD before/after was taken before the rebase, and the range-diff shows the same logical patch. Not verified here: macOS app devices, physical Apple devices, Limrun and Revyl runs, .ad script end, replay test teardown and close --shutdown. Not verified here: the unit and integration tests were not run locally, so CI covers them.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 21, 2026
@thymikee
thymikee merged commit 0525c45 into main Nov 21, 2026
21 of 22 checks passed
@thymikee
thymikee deleted the fix/close-without-app-stops-session-app branch November 21, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant