@deeeed/metamask-harness 0.94.0 → 0.94.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.94.1 - 2026-10-22
6
+
7
+ ### Fixed
8
+
9
+ - Mobile scroll-into-view checks the complete target bounds before treating it as already on screen.
10
+ - iOS simulator launch restarts app processes that have run for six hours or reached 1.5 GiB RSS before opening the dev client, including when the runtime otherwise looks ready.
11
+
5
12
  ## 0.94.0 - 2026-10-22
6
13
 
7
14
  ### Added
@@ -127,6 +127,38 @@ function mobileSourceAwareLifecycleAdapters(lifecycle, readinessProbe = probeMob
127
127
  }
128
128
  }));
129
129
  }
130
+ function staleMobileAppProcessReason(usage) {
131
+ if (usage.elapsedSeconds !== void 0 && usage.elapsedSeconds >= 6 * 60 * 60) {
132
+ return `app process ${String(usage.pid)} has run for ${Math.floor(usage.elapsedSeconds / 60)} minutes`;
133
+ }
134
+ if (usage.residentBytes !== void 0 && usage.residentBytes >= 1.5 * 1024 ** 3) {
135
+ return `app process ${String(usage.pid)} uses ${Math.round(usage.residentBytes / 1024 ** 2)} MiB RSS`;
136
+ }
137
+ return void 0;
138
+ }
139
+ function readIosAppProcessUsage(env = process.env) {
140
+ const device = env.SIM_UDID || env.IOS_SIMULATOR || "booted";
141
+ const pid = readIosAppPid({ simulator: device }, { env });
142
+ if (pid === null) return {};
143
+ try {
144
+ const output = execFileSync("ps", ["-p", String(pid), "-o", "etime=,rss="], {
145
+ encoding: "utf8",
146
+ timeout: 5e3,
147
+ stdio: ["ignore", "pipe", "ignore"]
148
+ });
149
+ const row = output.trim().split("\n").at(-1) ?? "";
150
+ const match = /^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)\s+(\d+)$/u.exec(row.trim());
151
+ if (!match) return { pid };
152
+ const [, days, hours, minutes, seconds, rssKiB] = match;
153
+ return {
154
+ pid,
155
+ elapsedSeconds: Number(days ?? 0) * 86400 + Number(hours ?? 0) * 3600 + Number(minutes) * 60 + Number(seconds),
156
+ residentBytes: Number(rssKiB) * 1024
157
+ };
158
+ } catch {
159
+ return { pid };
160
+ }
161
+ }
130
162
  function readAndroidAppPid(node, context) {
131
163
  const env = context.env ?? {};
132
164
  const device = node.adb_serial ?? node.android_device ?? node.device ?? env.ADB_SERIAL ?? env.ANDROID_SERIAL ?? process.env.ADB_SERIAL ?? process.env.ANDROID_SERIAL;
@@ -296,5 +328,7 @@ function asRecord(value) {
296
328
  }
297
329
  export {
298
330
  mobileSourceAwareLifecycleAdapters,
299
- resolveMobileLifecycleReadinessTimeout
331
+ readIosAppProcessUsage,
332
+ resolveMobileLifecycleReadinessTimeout,
333
+ staleMobileAppProcessReason
300
334
  };
@@ -567,7 +567,16 @@ async function queryMobileViewportTarget(input, testId) {
567
567
  "Mobile ui.scroll scroll_into_view requires the current __AGENTIC__.queryUiTarget bridge."
568
568
  );
569
569
  }
570
- return result;
570
+ const { rect, viewport } = result;
571
+ return {
572
+ ...result,
573
+ visible: result.visible === true && isRecord(rect) && isRecord(viewport) && scrollTargetFillsAxis(rect.x, rect.width, viewport.width) && scrollTargetFillsAxis(rect.y, rect.height, viewport.height)
574
+ };
575
+ }
576
+ function scrollTargetFillsAxis(start, size, viewport) {
577
+ if (typeof start !== "number" || typeof size !== "number" || typeof viewport !== "number" || !Number.isFinite(start) || !Number.isFinite(size) || !Number.isFinite(viewport) || size <= 0 || viewport <= 0) return false;
578
+ const visible = Math.min(start + size, viewport) - Math.max(start, 0);
579
+ return visible >= Math.min(size, viewport);
571
580
  }
572
581
  async function waitForMobileViewportTarget(input, testId, timeoutMs) {
573
582
  const deadline = Date.now() + Math.max(0, Math.min(timeoutMs, 5e3));
@@ -8,6 +8,7 @@ import { ensureHarnessFresh } from "../../adapters/harness-freshness.js";
8
8
  import { pinMobileFeatureFlags } from "../../adapters/mobile/feature-flags.js";
9
9
  import { toRemoteFlagSpec } from "../../feature-flags.js";
10
10
  import { clearMobileReleaseArtifactState } from "../../adapters/mobile/release-artifact-state.js";
11
+ import { readIosAppProcessUsage, staleMobileAppProcessReason } from "../../adapters/mobile/lifecycle.js";
11
12
  async function launchMobile(target, mobileTarget, tier, json, restartApp = false, clearMetro = false, remoteFlags) {
12
13
  clearMobileReleaseArtifactState(target);
13
14
  await ensureHarnessFresh(target, "mobile");
@@ -15,12 +16,15 @@ async function launchMobile(target, mobileTarget, tier, json, restartApp = false
15
16
  const watcherPort = process.env.WATCHER_PORT ? parseInt(process.env.WATCHER_PORT, 10) : void 0;
16
17
  const preflightMode = tier === "build" ? "rebuild-native" : "fast";
17
18
  const source = mobileSourceCheck(target);
19
+ const staleProcess = !restartApp && source.status === "current" && platform === "ios" ? staleMobileAppProcessReason(readIosAppProcessUsage()) : void 0;
20
+ if (staleProcess) process.stderr.write(`Mobile launch: ${staleProcess}; restarting the app process.
21
+ `);
18
22
  const result = await prepareMobile(target, {
19
23
  platform,
20
24
  json,
21
25
  watcherPort,
22
26
  preflightMode,
23
- restartApp: restartApp || source.status !== "current",
27
+ restartApp: restartApp || source.status !== "current" || staleProcess !== void 0,
24
28
  clearMetro
25
29
  });
26
30
  if (result.status !== 0) return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeeed/metamask-harness",
3
- "version": "0.94.0",
3
+ "version": "0.94.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mm-harness": "bin/mm-harness"