Own Device Farm launch inputs in SDK plugin - #59
Conversation
Expose getLaunchOptions on the tugboat/launch channel from TugboatPlugin (Android Intent extras, iOS process environment) so host apps need no native code. Add TugboatLaunchOptions, TugboatLaunchParsers (single bool/local-URL policy), resolveTugboatCollectorBaseUrl (release-guarded), and TugboatReplayConfig.withDeviceFarmOverrides for one-call merge.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70e5e9f2ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| factory TugboatLaunchOptions.fromMap(Map<String, Object?> values) { | ||
| final rawBaseUrl = values[keyCollectorBaseUrl] as String?; |
There was a problem hiding this comment.
Handle malformed launch payloads without throwing
When a mismatched native plugin or injected channel returns a non-String collectorBaseUrl, this cast throws a TypeError; a scalar or incorrectly typed map can similarly fail inside invokeMapMethod. Because fromPlatform() catches only MissingPluginException and PlatformException, withDeviceFarmOverrides() then fails during startup instead of returning defaults as its “unexpected payload” contract promises. Decode the payload defensively or also handle payload-shape errors.
Useful? React with 👍 / 👎.
Use a typed launchValue helper (String? ?? NSNull never inferred) and add MethodChannel-mocked fromPlatform tests. Verified on iPhone 17 simulator: SIMCTL_CHILD_TUGBOAT_* env decodes to enabled capabilities; absent env decodes to off.
Summary
Host apps needed hand-written native code to receive Device Farm launch flags (Android Intent extras + iOS process environment) plus Dart-side parsing, URL policy, and endpoint resolution. This moves all of it into the SDK so hosts get it for free:
tugboat/launch#getLaunchOptionsonTugboatPlugin(Android reads Intent extras, iOS readsTUGBOAT_*process environment). Natives pass raw strings through; key contract unchanged (tugboat_emit_scene_inventory,tugboat_accept_action_context,tugboat_collector_base_url/TUGBOAT_*).TugboatLaunchOptions.fromPlatform()(never throws, injectable channel),TugboatLaunchParsers(single1/true/yes+ local-onlyhttppolicy),resolveTugboatCollectorBaseUrl()(runtime > build > fallback; release always prod).TugboatReplayConfig.withDeviceFarmOverrides(): additive merge (ORs capabilities, swaps collector base URL only for validated local URLs in debug) plus oneTUGBOAT_LAUNCHdebug line with no secrets.TugboatCollectorConfig.withBaseUrl()helper + CHANGELOG entry.Validation
bash tool/ci/run-flutter-tests.sh tugboat: 415 passed (10 new intest/launch_options_test.dart)dart analyze sdks/flutter/packages/tugboat: clean (one pre-existing info)git diff --check: clean--ezextras loggedTUGBOAT_LAUNCH {captureRequested:true,...}andTUGBOAT_HEALTH {lifecycle:active, sinks.accepted:34}against the production collector.Compatibility
Additive only. No existing API changed; hosts keep working untouched and can adopt
withDeviceFarmOverrides()(or readTugboatLaunchOptionsdirectly) when ready.