Skip to content

fix(daemon): apply stored runtime hints only to the app they were set for - #5010

Merged
thymikee merged 2 commits into
callstack:mainfrom
imranbarbhuiya:fix/metro-hints-per-app
Nov 23, 2026
Merged

thymikee merged 2 commits into
callstack:mainfrom
imranbarbhuiya:fix/metro-hints-per-app

Conversation

@imranbarbhuiya

@imranbarbhuiya imranbarbhuiya commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stored runtime hints are now bound to the app an open applied them to. A later open without runtime flags re-applies them only to that app. Before, every later open in the session re-applied them to whatever it opened. On Android, opening a non-debuggable app (Photos, Files, the launcher) failed at the run-as write. On an iOS simulator, RCT_jsLocation was written into the other app's defaults, and the first app's launch URL was re-opened. Hints stored before any open bind to the first app; runtime set keeps the binding. close, runtime clear, and expiry clear them from the app they're bound to.

Before / after

Pixel 9 AVD (Android 16), with a debuggable React Native app (<rn-app>):

$ open <rn-app> --relaunch --metro-port 8081      # base and head: Opened
$ open com.google.android.apps.photos
base a4f2dcad0: COMMAND_FAILED: Failed to access Android app sandbox for com.google.android.apps.photos: run-as: package not debuggable
head 91761f668: Opened: com.google.android.apps.photos
$ close      # head: the hints are cleared from <rn-app> (debug_http_host gone), although the session ended on Photos

Validation

  • Head 91761f668, check:affected --run --head, exactCommit: true. Format, lint, typecheck, layering, fallow, build and vitest-related pass. unit fails only on upload-http-deadline and committed-source-tree, which fail the same way on clean main on this macOS host. command-docs, doc-links and doc-prose pass when run directly.
  • The new tests in session-open-runtime.test.ts fail without the fix (apply and clear paths).
  • The iOS defaults write is covered by tests only.

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

View guided diff

… for

An open with --metro-port, --metro-host, --bundle-url or --launch-url stored
the hints for the session without the app they were for. Every later open
without runtime flags re-applied them to whatever app it opened: on Android
the run-as write into a non-debuggable app such as Photos or the launcher
failed the open, and on an iOS simulator it wrote RCT_jsLocation into the
other app's defaults and followed up with the first app's launch URL.

The session store now binds stored hints to the app an open applied them
to. A later open without runtime flags applies them only when it opens that
app; another app opens without them. Hints stored before any open bind to
the first app that applies them, and runtime set keeps the binding.
Opening another app no longer re-applies stored hints, so the session app
moves on while the hints stay bound to the first app. Every clear path
still targeted the session's current app: close, runtime clear, daemon
shutdown and idle expiry, and an open with flags but no Metro address. On
Android the clear then missed the app that held debug_http_host.

Each path now clears the app the stored hints are bound to and falls back
to the session app for unbound hints. The session store returns the hints
with their app, and the lifecycle finalization takes the clear input with
its app id.
@thymikee

Copy link
Copy Markdown
Member

Thanks for the fix. The code at 91761f6 is ready: stored runtime hints now apply only to the app they were bound to. The Smoke Tests failure is most likely unrelated, because it stops in the Linux desktop dependencies step when apt-get update times out, before any agent-device code runs. There are no conflicts. Before merge, re-run the Smoke Tests job and the cancelled Body rules checks. Not verified here: this PR's own Smoke Tests log, a live iOS simulator run, and the new tests against the base commit. Not blocking, and fine to take or leave: the filter at https://github.com/callstack/agent-device/blob/91761f6/packages/daemon/src/sessions/session-lifecycle/internal/session-open-prepare.ts#L225 could drop hints on a re-open if pre-open resolution differs from the open outcome id, so the stored binding and the compared id should come from one resolution; opening app B with new explicit transport hints while hints are bound to app A leaves A's native hints written (https://github.com/callstack/agent-device/blob/91761f6/packages/daemon/src/sessions/session-runtime.ts#L364), which predates this PR and suits a follow-up issue; and SessionStore now has both getRuntimeHints and getStoredRuntimeHints for one map, which could be one accessor.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 23, 2026
@thymikee
thymikee merged commit 45cf4c2 into callstack:main Nov 23, 2026
15 of 18 checks passed
@imranbarbhuiya
imranbarbhuiya deleted the fix/metro-hints-per-app branch November 23, 2026 12:41
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.

2 participants