Repository navigation
Description
Problem
In a hosted macOS session, agent-device open <macos.host.bundleId> --remote-config <file> can launch a second copy of the app from an earlier app attempt's bundle in the same session. stim stop then reports "macOS app stopped" while that copy keeps running on the host, and stim worktree remove succeeds over it. The orphan also ignored SIGTERM for over 10 seconds.
Expected: per stim guide macos, every process running an app bundle from the workspace's directory is the workspace's owned app, including copies opened through LaunchServices (open, agent-device open), and stop ends all of them. For hosted sessions, either the host stops every process running from the session's apps/* bundles, or earlier attempts' bundles are unregistered or removed when a new attempt is delivered, so LaunchServices cannot resolve the shared <id>.hosted<slot> identifier to a stale copy.
Evidence
Mac mini on macOS 27.0 arm64, Stim 1.23.1 client and worker, agent-device 0.21.29, origin/main d7c2a9f. Steps:
stim macos --remote-build janics-mac-mini --remote janics-mac-minifromapps/desktop(attempt9ecccf52…, pid 60811).- Ran it again after adding a launch argument (attempt
a66039bd…, pid 69522). The first copy stopped as expected. agent-device disconnectandagent-device open dev.stim.desktop.development.hosted1 --platform macos --surface appwith the session's remote config, around 01:04.stim stop, thenstim worktree remove. Both reported success.
The host still had:
70192 ppid 1 started 01:04:19 …/device-host/sessions/b7c507a4-…/apps/9ecccf52-…/App.app/Contents/MacOS/StimDesktop
This is the first attempt's bundle, launched by LaunchServices with no arguments, while the second attempt (pid 69522) was running. SIGTERM did not end it within 10 s, and I removed it with SIGKILL after verifying the path was inside my own session.
Cause
Unconfirmed:
- Both attempts'
App.appbundles share the hosted bundle iddev.stim.desktop.development.hosted1, and the older one stays registered with LaunchServices. agent-device openresolves by bundle id, so it can start the stale copy.- Hosted stop appears to stop only the recorded launch (supervisor child), not every process running from the session's bundles.
Fix idea
On hosted stop and on replacement, find every process whose executable lies under the session's apps/ directory, verifying identity as the local path does, and stop it with the documented SIGTERM, 5 s, SIGKILL sequence. Also remove or unregister superseded attempt bundles once their process exits. This preserves the one-app-per-workspace rule and the bundle-id slot reuse.
Activity
janicduplessis commentedon Oct 23, 2026
More evidence from 2026-10-22/23 on janics-mac-mini, stim-server 1.25.0:
36b8fdfa(workspace.worktrees/4297-desktop) had journal statestopped, but its app process (pid 22793, bundledev.stim.desktop.development.hosted1, started 17:00) was still running hours later.419929eband77c486dfalso left app processes running afterstim stop, and it killed them by hand.agent-device open ... --relaunchagainst it probably ended the leftover process from 36b8fdfa.So a stopped hosted macOS session can leave its app running, and a later session can then share its bundle id with that orphan.
janicduplessis commentedon Oct 26, 2026
Possibly the same root cause, seen 2026-10-25 on janics-mac-mini while visually verifying PR #4381.
stim macos --remote-build janics-mac-mini --remote janics-mac-mini(global stim 1.27.0, mini stim-server 1.26.0): the first launch gave an inspectable window, with 34 AX nodes.stim stop,agent-device closeand a 20 s wait, gave 0 AX nodes and a frozen screenshot of the earlier state.agent-device pressthen failed withUNSUPPORTED_OPERATION: the point is outside the app's on-screen windows.janicduplessis commentedon Oct 26, 2026
Claimed: fix/4127-hosted-macos-stop-apps-dir
janicduplessis commentedon Oct 26, 2026
2026-10-26 on janics-mac-mini (Stim 1.27.0 client):
stim macos --remote-build janics-mac-mini --remote janics-mac-minifromapps/desktop,stim stop, then the same command again. The relaunch gave a drivable window (37 AX nodes,agent-device snapshot -iandscreenshotworking), so the 0 AX nodes / frozen screenshot symptom did not reproduce. Oneagent-device openright after the relaunch returned an error I did not capture; the nextopensucceeded.The orphan described in this issue is real in the code: hosted stop and install scan for running copies only under the workspace
macos/directory, not under the session'sapps/<attempt>bundles. Fix in #4456, unverified on the mini because the worker code reaches it only through a stim-server release.github-actions commentedon Oct 28, 2026
Released: stale claim, 2.2 days old (2026-10-26), with no open pull request for this issue.
Branch fix/4127-hosted-macos-stop-apps-dir is not on origin.
Posted by scripts/stale-claims.mjs. Comment
Claimed: <branch>to take the issue.janicduplessis commentedon Nov 1, 2026
Claimed: codex/4127-verify-hosted-stop. Verifying the already-merged #4456 cleanup on one owned hosted Desktop session on janics-mac-mini, including reopening an earlier owned attempt and stopping it. No shared server update or source change is planned unless current acceptance reveals a real gap.
janicduplessis commentedon Nov 1, 2026
Claim handoff: codex/4127-verify-hosted-stop is now owned by the Desktop runtime agent, continuing the existing verification-only claim. I will first trace current ownership/LaunchServices behavior, then use only an isolated owned Desktop session after the shared mini performance baseline finishes. No foreign apps or shared service changes.
janicduplessis commentedon Nov 1, 2026
Verified the existing fix on janics-mac-mini with Stim/stim-server 1.38.0, host build
6364c6c7fb0859df, and agent-device 0.21.35. No server update or product patch was needed.In one new owned hosted session:
psandlsof; the extra copy had parent PID1.stim stop. Neither process remained, and both attempts' app bundles were removed. No manual signals were sent.This verifies #4456's stop boundary and replacement boundary. The installed build predates #4682, so this does not claim to validate its additional replacement-time pruning.
The older stale accessibility snapshot symptom did not reproduce: fresh named automation sessions matched A's normal window/PID and B's playground window/PID. Temporary arguments were restored, the owned session stopped, and no unrelated app or device was touched. Closing as addressed by the existing fix.