Skip to content

fix(logs): disclose the physical iOS device app relaunch on logs start - #4695

Merged
thymikee merged 1 commit into
callstack:mainfrom
xiatiandeairen:fix/ios-device-logs-relaunch-disclosure
Nov 19, 2026
Merged

thymikee merged 1 commit into
callstack:mainfrom
xiatiandeairen:fix/ios-device-logs-relaunch-disclosure

Conversation

@xiatiandeairen

@xiatiandeairen xiatiandeairen commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On physical iOS devices, logs start captures console output through devicectl device process launch --console --terminate-existing, which relaunches the session app. logs stop signals devicectl, which forwards the signal to the app and ends it. Neither effect was disclosed.

  • AppLogStartResult gains relaunched?: true. The Apple runtime sets it only for the ios-device backend.
  • logs start reports relaunched: true, and text output prints relaunched=true, following restarted.
  • The logs description (help and MCP), help debugging and the commands docs say that start relaunches the app and stop ends it.

15 files, 8 of them non-test (+20/-4).

Fixes #4688

Validation

Head 06568d1d4 on base aa600e980.

  • check:quick passed. Focused vitest passed. The 5 new tests fail on base and pass on head.
  • check:affected --run --head 06568d1d4 (exactCommit): format, lint, typecheck, layering, fallow, build and vitest-related passed. unit failed only in test/repo-guards/android-sdk-setup-action.test.ts (2 tests). They fail the same way on aa600e980 on this host, where a local Android SDK path leaks into the expected path.
  • iOS 27.2 simulator, base vs head: logs start --json is unchanged and carries no relaunched. stop, appstate and close behave as before.
  • Not verified on a physical iPhone. The relaunch flag and "stop ends the app" rest on unit tests, the devicectl launch arguments, and devicectl device process launch --help ("Catchable signals sent to devicectl are forwarded to the app").

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

@thymikee

Copy link
Copy Markdown
Member

The code at 06568d1 reads correctly to me, but the physical-device path it changes has no live run yet. Nobody has yet shown relaunched: true on a real device, that logs stop ends the app, or that open <app> restores it.

This change is device-facing: it changes what logs start returns on a CoreDevice iPhone, and the help, MCP description and commands.md now tell agents as fact that logs stop ends the app and that they should run open <app> again. The PR validates only on a simulator, which never takes the new branch, and the only physical-device evidence is the issue's 0.21.37 transcript. docs/agents/pull-requests.md asks for live evidence on device-facing changes. Could a maintainer run this head on a physical iPhone in one session: open <app>, appstate (running), logs start --json (expect data.relaunched: true, data.started: true, and app.log starting with Launched application ...), logs stop, appstate (expect notRunning), open <app>, appstate (running again)? Please record device, iOS version, SHA and outputs. Then logs start --json on a simulator should show no relaunched key.

CI has not run on this fork head yet, so a maintainer needs to approve the CI run; nothing is failing. The local failure in the PR body, android-sdk-setup-action.test.ts, does not overlap this diff. There are no conflicts. Before merge, the physical-iPhone run above must be recorded; the notes below can go in the same push.

Not blocking, take or leave: logs clear --restart goes through the same relaunch, but handleLogsClearRestart drops relaunched, so the typed signal exists on only one of the two relaunching routes (carry it through the shared owner, or say in help that this route does not report it); the options bag on createAppLogStartResult serves one caller and converts boolean to true at two layers, so the Apple start could spread relaunched: true on the ios-device branch and drop the bag; the new help tests pin the full sentence in cli-help.test.ts, where a short stable fragment like relaunched: true would do, and the cli-logs test only checks a formatter against a hand-written response that the daemon and Apple tests already cover; and the two relaunched is-undefined lines in live-full-scenarios.ts duplicate the Apple unit test, so keep or drop them.

@thymikee

Copy link
Copy Markdown
Member

On the physical-iPhone run from my last comment: if you have a physical iPhone, please run that sequence at this head and post the output. If you don't, reply here and say so. A maintainer will then run it on their device, so the PR won't wait on hardware you don't have.

@xiatiandeairen

Copy link
Copy Markdown
Contributor Author

I ran the sequence from your comment on a physical iPhone, at this head.

Setup:

  • Device: iPhone 17, iOS 27.2 (24B119), CoreDevice backend.
  • Build: head 06568d1 (CLI 0.21.40-dev), with its own daemon state directory.
  • App: a developer-signed sample todo app (com.todoapp.ios).

On a physical device, appstate does not report whether the app runs. It returns only the session app ("source": "session", no state field). So after each step I also read the process list with xcrun devicectl device info processes.

Step agent-device output Process (devicectl)
open com.todoapp.ios --udid <udid> --session q Opened: com.todoapp.ios, exit 0 running, pid 5127
appstate --session q --json {"appBundleId":"com.todoapp.ios","source":"session","surface":"app",…}, exit 0 —
logs start --session q --json {"success":true,"data":{"path":"…/app.log","started":true,"relaunched":true}}, exit 0 running, pid 5128 (relaunched)
first line of app.log Launched application with com.todoapp.ios bundle identifier. —
logs stop --session q stopped=true …/app.log, exit 0 not running
open com.todoapp.ios --udid <udid> --session q Opened: com.todoapp.ios, exit 0 running, pid 5130
close --session q Closed: q, exit 0 —

A first run of the same sequence without the process reads gave the same logs start output (relaunched: true, the same app.log first line).

Simulator (iOS simulator, same head): logs start --json returned {"path":"…/app.log","started":true} with no relaunched key. logs stop returned stopped=true.

Something I did not investigate. In #4688, appstate on 0.21.37 printed State: notRunning after logs stop. At this head, appstate on the physical device prints no state at all. This may be a separate change in appstate or a regression, not something this PR caused.

Not done yet: the non-blocking notes (carrying relaunched through logs clear --restart, dropping the options bag, and the test trims).

@thymikee

Copy link
Copy Markdown
Member

Thanks, this covers the physical-device run at 06568d1. On the iPhone, logs start --json returns relaunched: true with a new PID. app.log starts with Launched application .... After logs stop the process is gone, and open brings it back. On the simulator there is no relaunched key. The process reads stand in for appstate, which is enough to confirm the documented behavior.

The missing appstate state on a physical device is outside this PR, so we'll look at it separately. The remaining notes are optional. This is ready for a maintainer to merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 19, 2026
@thymikee
thymikee merged commit ea456f7 into callstack:main Nov 19, 2026
13 checks passed
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.

iOS device: logs start relaunches the app and logs stop ends it, without saying so

2 participants