You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 16e0757
Browse filesBrowse the repository at this point in the historyBrowse files
feat(daemon): opt-in inactivity expiry for idle local device claims (#2833) (#2988)
* feat(daemon): opt-in inactivity expiry for idle local device claims
#2833: on a host shared by several agents, a session that never runs `close`
keeps its host-global device claim until the daemon stops, and every other
agent reads DEVICE_IN_USE with no way to tell active from abandoned.
Set AGENT_DEVICE_SESSION_IDLE_TIMEOUT_MS to expire a claim-holding session with
no remote lease and no capture running for it, once it has taken no attached
commands for that long. The daemon that owns the session settles it under that
session's own execution lock pair, releases the claim, and leaves a bounded
marker so the next command answers SESSION_NOT_FOUND with details.reason
SESSION_IDLE_EXPIRED naming the window and the released device. Off by default;
a positive window below one millisecond is the shortest window, not off.
A settle that cannot confirm its claim gone holds the session record back and
retries a window later: this daemon stays alive, so forgetting the record would
strand a claim owned by a process that no longer knows what it holds, which
`device release --stale` cannot reclaim. `clearDeviceClaim` therefore gains
`unattributable` for a record that yields no attributable owner, because that
says nothing about a successor having taken the device.
The lock pair belongs to the release, not to the sweep's wait for it. A teardown
budget bounds only that wait, so one stuck recorder cannot hang a sweep while a
budget releasing the locks would let a retried `close` join a teardown in
progress, or a late release delete a session a retried `open` just created and
mark it expired. A sweep that finds a release in flight defers that address
rather than re-arming at a deadline already past, and a release that lands after
its budget still reports the session it freed.
* chore(gates): declare lastActivityAtMs as a store-owned SessionState field
R7 holds every SessionState field to one declared writer. The #2833 request path
reports activity through `SessionStore.noteSessionActivity` rather than mutating
the record itself, so the store that owns the record is the only writer here and
the field now says so.
Copy file name to clipboardExpand all lines: src/commands/schema/cli-help.ts
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -702,6 +702,7 @@ Runner and daemon lifecycle (applies to simulators too):
702
702
No runner read launches a session app that is not running: snapshot, wait, is, get, a reading find, and an interaction's leading reads (a gesture's viewport read, the capture that resolves a selector click/fill) answer the retriable APP_NOT_RUNNING instead of bare-launching over a launch SpringBoard still holds behind its deep-link confirmation. Only open, activate, and a command that mutates without a leading read bring a stopped app up.
703
703
close keeps a healthy iOS simulator XCTest runner warm by default so the next open on that simulator (same udid in the same simulator set) skips the runner build, unless --shutdown was requested, the session was recording, or the session held a device lease. A retained runner auto-stops after an idle window (default 5 minutes); set AGENT_DEVICE_IOS_RUNNER_IDLE_STOP_MS to override, or 0 to disable idle stop and retain until daemon exit.
704
704
Each AGENT_DEVICE_STATE_DIR runs its own daemon. It self-exits after an idle window (default 5 minutes, matching the runner idle-stop default) once it has no open sessions, no in-flight requests, and no active recording; set AGENT_DEVICE_DAEMON_IDLE_TIMEOUT_MS to override, or 0 to disable idle reap.
705
+
On a machine shared by several agents, set AGENT_DEVICE_SESSION_IDLE_TIMEOUT_MS to also expire an individual session that has taken a host-global device claim and then received no commands for that long; the claim is released and the next command on that session answers SESSION_NOT_FOUND with details.reason SESSION_IDLE_EXPIRED naming the window and the device. Off by default, because on a shared host "idle" and "thinking" are indistinguishable: only set it where an abandoned claim blocking every other agent is the worse failure. Sessions holding a remote lease or any active capture (recording, logs, audio, performance, or trace) are never expired this way.
705
706
A stale iOS runner lease — its owner process dead, or its AGENT_DEVICE_STATE_DIR deleted — is reclaimed automatically instead of failing with "is already owned by another agent-device daemon". A live owner's runner is also reclaimed when the requesting daemon holds the host-global device claim for that device: claims are exclusive, so holding one proves the runner's owner released the device and merely kept the runner warm. The error remains only for owners outside claim arbitration (a pre-claims build, or daemons pointed at different claim stores).
706
707
707
708
For iOS SpringBoard, widget, or other system-UI surfaces, read agent-device help ios-system-ui.`,
0 commit comments