peachsim 0.1.627 → 0.1.628

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.
Files changed (92) hide show
  1. package/LICENSE +1 -1
  2. package/cli/bin.ts +6 -2
  3. package/cli/bridge-flow-runner.ts +79 -72
  4. package/cli/commands/cleanup.ts +6 -6
  5. package/cli/commands/control.ts +4 -5
  6. package/cli/commands/detox.ts +25 -11
  7. package/cli/commands/flow.ts +3 -2
  8. package/cli/commands/inspect.ts +22 -37
  9. package/cli/commands/mode.ts +11 -7
  10. package/cli/commands/report-issue.ts +1 -1
  11. package/cli/commands/setup.ts +16 -11
  12. package/cli/commands/show-touches-mode.ts +33 -0
  13. package/cli/commands/skills.ts +16 -0
  14. package/cli/commands/test.ts +8 -1
  15. package/cli/commands/welcome.ts +3 -3
  16. package/cli/drivers/playwright-sim-host.ts +6 -5
  17. package/cli/help-core.ts +9 -4
  18. package/cli/internal-child.ts +14 -2
  19. package/cli/levenshtein.ts +27 -0
  20. package/cli/main.ts +28 -18
  21. package/cli/ws-bridge.ts +3 -2
  22. package/detox/index.ts +234 -7
  23. package/dist-lib/agent-daemon-client.cjs +1 -1
  24. package/dist-lib/agent-events.cjs +1 -1
  25. package/dist-lib/agent-identity.cjs +1 -1
  26. package/dist-lib/agent-sessions.cjs +1 -1
  27. package/dist-lib/attached-projects.cjs +1 -1
  28. package/dist-lib/auth/shared-session.cjs +1 -1
  29. package/dist-lib/backend-origin.cjs +1 -1
  30. package/dist-lib/beta.cjs +1 -1
  31. package/dist-lib/beta.mjs +1 -1
  32. package/dist-lib/bridge-constants.cjs +1 -1
  33. package/dist-lib/bridge-contract-input.cjs +1 -1
  34. package/dist-lib/bridge-contract-input.mjs +1 -1
  35. package/dist-lib/bridge-contract.cjs +1 -1
  36. package/dist-lib/bridge-contract.mjs +1 -1
  37. package/dist-lib/capture-contract.cjs +1 -1
  38. package/dist-lib/capture-contract.mjs +1 -1
  39. package/dist-lib/cli-constants.cjs +1 -1
  40. package/dist-lib/cloud-contract.cjs +1 -1
  41. package/dist-lib/cloud-contract.mjs +1 -1
  42. package/dist-lib/cloud-test-args.cjs +1 -1
  43. package/dist-lib/cloud-test-args.mjs +1 -1
  44. package/dist-lib/cloud.cjs +1 -1
  45. package/dist-lib/cloud.mjs +1 -1
  46. package/dist-lib/config.cjs +1 -1
  47. package/dist-lib/detox/index.cjs +170 -13
  48. package/dist-lib/dev-bundle-resolution.cjs +2 -2
  49. package/dist-lib/home-paths.cjs +1 -1
  50. package/dist-lib/host/bridge-host.cjs +42 -37
  51. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  52. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  53. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  54. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  55. package/dist-lib/host/websocket-proxy.cjs +1 -1
  56. package/dist-lib/index.cjs +44 -5
  57. package/dist-lib/jump-to-source-babel.cjs +1 -1
  58. package/dist-lib/jump-to-source-native.cjs +1 -1
  59. package/dist-lib/menu.cjs +7 -1
  60. package/dist-lib/menu.mjs +7 -1
  61. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  62. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  63. package/dist-lib/metro-production-bundle.cjs +1 -1
  64. package/dist-lib/metro-production-bundle.mjs +1 -1
  65. package/dist-lib/metro.cjs +43 -4
  66. package/dist-lib/profiles.cjs +1 -1
  67. package/dist-lib/public-brand.cjs +1 -1
  68. package/dist-lib/react-native-host-modules.cjs +1 -1
  69. package/dist-lib/react-native-host-modules.mjs +1 -1
  70. package/dist-lib/render-mode.cjs +1 -1
  71. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  72. package/dist-lib/sdk.cjs +1 -1
  73. package/dist-lib/sdk.mjs +1 -1
  74. package/dist-lib/skills.cjs +140 -149
  75. package/dist-lib/swift-compile.cjs +1 -1
  76. package/dist-lib/swift-compile.mjs +1 -1
  77. package/dist-lib/swift-package.cjs +1 -1
  78. package/dist-lib/swift-package.mjs +1 -1
  79. package/dist-lib/swift-submit.cjs +1 -1
  80. package/dist-lib/swift-submit.mjs +1 -1
  81. package/dist-lib/swift.cjs +7234 -7069
  82. package/dist-lib/vite-kotlin.cjs +1 -1
  83. package/dist-lib/vite-swift.cjs +1 -1
  84. package/dist-lib/vite.cjs +43 -4
  85. package/package.json +1 -1
  86. package/skills/contrast/SKILL.md +1 -1
  87. package/src/dev-bundle-resolution.ts +1 -1
  88. package/src/host/bridge-host.ts +2 -34
  89. package/src/menu.ts +7 -0
  90. package/src/native-seam-manifest.ts +4 -16
  91. package/src/runtime-assets.ts +59 -2
  92. package/src/vite-plugin.ts +723 -25
package/LICENSE CHANGED
@@ -3,7 +3,7 @@ Proprietary Software License
3
3
  Copyright (c) Tamagui LLC. All rights reserved.
4
4
 
5
5
  This package (peachsim) is proprietary software of Tamagui LLC, licensed under
6
- the rnx Software License Agreement: https://peachsim.com/legal/license
6
+ the Peach Software License Agreement: https://peachsim.com/legal/license
7
7
 
8
8
  In summary (the agreement governs): personal, non-commercial use is free;
9
9
  commercial use requires an active Pro subscription after a single 30-day
package/cli/bin.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  // whole process, so the CLI itself lives in `./main` and is imported only once
11
11
  // none of them has claimed the run.
12
12
 
13
- import { RNX_INTERNAL_COMMAND } from './internal-child'
13
+ import { RNX_FORKED_SCRIPT_ENV, RNX_INTERNAL_COMMAND } from './internal-child'
14
14
 
15
15
  if (process.argv[2] === '__shell-init') {
16
16
  const { renderRnxShellInit } = await import('./shell-init')
@@ -51,7 +51,11 @@ if (process.argv[2] === '__cloud-confirm') {
51
51
  // are still working when their handler returns, and the process ends when that
52
52
  // work does. so this is the branch that must skip the CLI rather than the CLI
53
53
  // that must skip it.
54
- if (process.argv[2] === RNX_INTERNAL_COMMAND) {
54
+ const forkedScript = process.argv[2]
55
+ if (process.env[RNX_FORKED_SCRIPT_ENV] === '1' && forkedScript?.endsWith('.js')) {
56
+ const { runScript } = await import('./internal-child')
57
+ runScript(forkedScript, process.argv.slice(3))
58
+ } else if (process.argv[2] === RNX_INTERNAL_COMMAND) {
55
59
  const { runInternalChild } = await import('./internal-child')
56
60
  await runInternalChild(process.argv.slice(3))
57
61
  } else {
@@ -30,8 +30,6 @@ const DEFAULT_TIMEOUT = 10000
30
30
  const ASSERTION_LOOKUP_MS = 17_000
31
31
  const FLOW_TIMEOUT_SCALE = flowTimeoutScale()
32
32
  const scaledTimeout = (ms: number) => Math.round(ms * FLOW_TIMEOUT_SCALE)
33
- const SCREEN_W = 393
34
- const SCREEN_H = 852
35
33
  type FlowScreenshotPathMode = 'dir' | 'flow'
36
34
  type ReplayTapTarget = SootSimReplayTarget
37
35
 
@@ -472,18 +470,16 @@ export function normalizeFlowScreenshotSpec(
472
470
 
473
471
  function parsePoint(
474
472
  value: string,
475
- bounds?: { x: number; y: number; width: number; height: number },
473
+ bounds: { x: number; y: number; width: number; height: number },
476
474
  ) {
477
475
  const [rawX, rawY] = value.split(',').map((part) => part.trim())
478
476
  const parseCoord = (coord: string, max: number) =>
479
477
  coord.endsWith('%')
480
478
  ? (Number.parseFloat(coord) / 100) * max
481
479
  : Number.parseFloat(coord)
482
- const originX = bounds?.x ?? 0
483
- const originY = bounds?.y ?? 0
484
480
  return {
485
- x: originX + parseCoord(rawX, bounds?.width ?? SCREEN_W),
486
- y: originY + parseCoord(rawY, bounds?.height ?? SCREEN_H),
481
+ x: bounds.x + parseCoord(rawX, bounds.width),
482
+ y: bounds.y + parseCoord(rawY, bounds.height),
487
483
  }
488
484
  }
489
485
 
@@ -624,6 +620,28 @@ export class SootSimBridgeFlowRunner {
624
620
  }) as Promise<T>
625
621
  }
626
622
 
623
+ private async screenBounds() {
624
+ const snapshot = await this.callTest<Record<string, unknown> | null>(
625
+ 'getSurfaceMetricsSnapshot',
626
+ )
627
+ const window = snapshot?.window
628
+ if (
629
+ !window ||
630
+ typeof window !== 'object' ||
631
+ !('width' in window) ||
632
+ !('height' in window) ||
633
+ typeof window.width !== 'number' ||
634
+ typeof window.height !== 'number' ||
635
+ !Number.isFinite(window.width) ||
636
+ !Number.isFinite(window.height) ||
637
+ window.width <= 0 ||
638
+ window.height <= 0
639
+ ) {
640
+ throw new Error('live screen dimensions are unavailable')
641
+ }
642
+ return { x: 0, y: 0, width: window.width, height: window.height }
643
+ }
644
+
627
645
  // ordered input batch executed inside the page in one round-trip; the
628
646
  // engine emits agent-cursor actions for every step natively.
629
647
  private async perform(steps: PerformStep[]): Promise<PerformResult> {
@@ -939,6 +957,7 @@ export class SootSimBridgeFlowRunner {
939
957
  // (match scoped to a container). a nested selector resolves the same way,
940
958
  // and a relative filter holds when ANY match of its anchor satisfies it.
941
959
  private async findElementScoped(opts: FlowTargetSelector) {
960
+ const screen = await this.screenBounds()
942
961
  const needsEveryNode =
943
962
  !opts.id ||
944
963
  opts.childOf != null ||
@@ -1045,7 +1064,7 @@ export class SootSimBridgeFlowRunner {
1045
1064
  // paints nothing, and maestro's hierarchy never holds it.
1046
1065
  const onScreen = candidates.filter((n) => {
1047
1066
  const cy = n.absolutePosition.y + n.layout.height / 2
1048
- return cy > 0 && cy < ${SCREEN_H}
1067
+ return cy > 0 && cy < ${screen.height}
1049
1068
  })
1050
1069
  if (candidates.some(painted)) candidates = candidates.filter(painted)
1051
1070
  else if (onScreen.length > 0) candidates = onScreen
@@ -1263,7 +1282,7 @@ export class SootSimBridgeFlowRunner {
1263
1282
  !opts.childOf
1264
1283
  ) {
1265
1284
  return {
1266
- ...parsePoint(opts.point),
1285
+ ...parsePoint(opts.point, await this.screenBounds()),
1267
1286
  element: null,
1268
1287
  target: undefined,
1269
1288
  }
@@ -1903,34 +1922,21 @@ export class SootSimBridgeFlowRunner {
1903
1922
  return outputDir
1904
1923
  }
1905
1924
 
1906
- async swipe(direction: string = 'UP', duration: number = 300) {
1907
- const centerX = SCREEN_W / 2
1908
- const centerY = SCREEN_H / 2
1909
- const distance = 200
1910
- let fromX = centerX
1911
- let fromY = centerY
1912
- let toX = centerX
1913
- let toY = centerY
1914
-
1915
- switch (direction.toUpperCase()) {
1916
- case 'UP':
1917
- fromY += distance
1918
- toY -= distance
1919
- break
1920
- case 'DOWN':
1921
- fromY -= distance
1922
- toY += distance
1923
- break
1924
- case 'LEFT':
1925
- fromX += distance
1926
- toX -= distance
1927
- break
1928
- case 'RIGHT':
1929
- fromX -= distance
1930
- toX += distance
1931
- break
1932
- }
1933
-
1925
+ // maestro's ios driver: a directional swipe spans the screen, from 90% to
1926
+ // 10% for UP, 20% to 90% for DOWN, and 10% to 90% across for LEFT/RIGHT,
1927
+ // over the command's 400ms default.
1928
+ async swipe(direction: string = 'UP', duration: number = 400) {
1929
+ const screen = await this.screenBounds()
1930
+ const midX = screen.width / 2
1931
+ const midY = screen.height / 2
1932
+ const [fromX, fromY, toX, toY] =
1933
+ direction.toUpperCase() === 'DOWN'
1934
+ ? [midX, screen.height * 0.2, midX, screen.height * 0.9]
1935
+ : direction.toUpperCase() === 'LEFT'
1936
+ ? [screen.width * 0.9, midY, screen.width * 0.1, midY]
1937
+ : direction.toUpperCase() === 'RIGHT'
1938
+ ? [screen.width * 0.1, midY, screen.width * 0.9, midY]
1939
+ : [midX, screen.height * 0.9, midX, screen.height * 0.1]
1934
1940
  const steps = Math.max(10, Math.round(duration / 16))
1935
1941
  await this.drag(fromX, fromY, toX, toY, steps, 16)
1936
1942
  }
@@ -1960,39 +1966,34 @@ export class SootSimBridgeFlowRunner {
1960
1966
  await this.settleAfterInput()
1961
1967
  }
1962
1968
 
1963
- async swipeCoords(start: string, end: string, duration = 300) {
1964
- const from = parsePoint(start)
1965
- const to = parsePoint(end)
1969
+ async swipeCoords(start: string, end: string, duration = 400) {
1970
+ const screen = await this.screenBounds()
1971
+ const from = parsePoint(start, screen)
1972
+ const to = parsePoint(end, screen)
1966
1973
  const steps = Math.max(10, Math.round(duration / 16))
1967
1974
  await this.drag(from.x, from.y, to.x, to.y, steps, 16)
1968
1975
  }
1969
1976
 
1977
+ // maestro's ios driver swipes from the element's center to the 10% or 90%
1978
+ // edge in the swipe's direction.
1970
1979
  async swipeFrom(
1971
1980
  from: { id?: string; text?: string },
1972
1981
  direction: string = 'UP',
1973
- duration = 300,
1982
+ duration = 400,
1974
1983
  ) {
1975
1984
  const element = await this.findElement(from)
1976
1985
  if (!element) throw new Error(`swipeFrom: element not found: ${JSON.stringify(from)}`)
1977
1986
  const startX = element.absolutePosition.x + element.layout.width / 2
1978
1987
  const startY = element.absolutePosition.y + element.layout.height / 2
1979
- const distance = 180
1980
- let endX = startX
1981
- let endY = startY
1982
- switch (direction.toUpperCase()) {
1983
- case 'UP':
1984
- endY -= distance
1985
- break
1986
- case 'DOWN':
1987
- endY += distance
1988
- break
1989
- case 'LEFT':
1990
- endX -= distance
1991
- break
1992
- case 'RIGHT':
1993
- endX += distance
1994
- break
1995
- }
1988
+ const screen = await this.screenBounds()
1989
+ const [endX, endY] =
1990
+ direction.toUpperCase() === 'DOWN'
1991
+ ? [startX, screen.height * 0.9]
1992
+ : direction.toUpperCase() === 'LEFT'
1993
+ ? [screen.width * 0.1, startY]
1994
+ : direction.toUpperCase() === 'RIGHT'
1995
+ ? [screen.width * 0.9, startY]
1996
+ : [startX, screen.height * 0.1]
1996
1997
  const steps = Math.max(10, Math.round(duration / 16))
1997
1998
  await this.drag(startX, startY, endX, endY, steps, 16)
1998
1999
  }
@@ -2103,24 +2104,24 @@ export class SootSimBridgeFlowRunner {
2103
2104
  )
2104
2105
  const deadline = Date.now() + (opts.timeout || 20000)
2105
2106
  const direction = opts.direction?.toUpperCase() || 'DOWN'
2106
- const centerX = SCREEN_W / 2
2107
- const centerY = SCREEN_H / 2
2108
- const swipeEnd =
2109
- direction === 'UP'
2110
- ? { x: centerX, y: SCREEN_H * 0.9 }
2111
- : direction === 'LEFT'
2112
- ? { x: SCREEN_W * 0.9, y: centerY }
2113
- : direction === 'RIGHT'
2114
- ? { x: SCREEN_W * 0.1, y: centerY }
2115
- : { x: centerX, y: SCREEN_H * 0.1 }
2116
-
2117
2107
  while (Date.now() < deadline) {
2108
+ const screen = await this.screenBounds()
2109
+ const centerX = screen.width / 2
2110
+ const centerY = screen.height / 2
2111
+ const swipeEnd =
2112
+ direction === 'UP'
2113
+ ? { x: centerX, y: screen.height * 0.9 }
2114
+ : direction === 'LEFT'
2115
+ ? { x: screen.width * 0.9, y: centerY }
2116
+ : direction === 'RIGHT'
2117
+ ? { x: screen.width * 0.1, y: centerY }
2118
+ : { x: centerX, y: screen.height * 0.1 }
2118
2119
  const element = await this.findElement(target)
2119
2120
  if (element) {
2120
2121
  const { x, y } = element.absolutePosition
2121
2122
  const { width, height } = element.layout
2122
- const shownX = Math.max(0, Math.min(x + width, SCREEN_W) - Math.max(x, 0))
2123
- const shownY = Math.max(0, Math.min(y + height, SCREEN_H) - Math.max(y, 0))
2123
+ const shownX = Math.max(0, Math.min(x + width, screen.width) - Math.max(x, 0))
2124
+ const shownY = Math.max(0, Math.min(y + height, screen.height) - Math.max(y, 0))
2124
2125
  const share = width * height > 0 ? (shownX * shownY) / (width * height) : 0
2125
2126
  if (share >= required) {
2126
2127
  if (opts.centerElement) {
@@ -2839,7 +2840,13 @@ export class SootSimBridgeFlowRunner {
2839
2840
  await this.swipe(step.swipe.direction, step.swipe.duration)
2840
2841
  }
2841
2842
  } else if (step.scroll) {
2842
- await this.swipe(step.scroll.direction === 'DOWN' ? 'UP' : 'DOWN')
2843
+ // maestro's scrollVertical drags 50% to 10% of the screen over 333ms;
2844
+ // scrollUp mirrors it
2845
+ const screen = await this.screenBounds()
2846
+ const midX = screen.width / 2
2847
+ const toY =
2848
+ step.scroll.direction === 'UP' ? screen.height * 0.9 : screen.height * 0.1
2849
+ await this.drag(midX, screen.height / 2, midX, toY, Math.round(333 / 16), 16)
2843
2850
  } else if (step.scrollTo) {
2844
2851
  const target =
2845
2852
  typeof step.scrollTo.nodeId === 'number'
@@ -58,13 +58,13 @@ export async function runCleanup(args: string[]): Promise<number> {
58
58
  if (args.length === 1 && args[0] === '--automatic-worker') {
59
59
  try {
60
60
  const result = applyAutomaticSootsimCleanup()
61
- if (result.status === 'complete') {
61
+ // a run that found nothing stays silent: this worker writes to the
62
+ // user's terminal after the command that spawned it has returned.
63
+ if (result.status === 'complete' && result.reclaimedBytes > 0) {
62
64
  process.stderr.write(
63
- result.reclaimedBytes > 0
64
- ? ` peach automatic cleanup reclaimed ${formatSootsimBytes(
65
- result.reclaimedBytes,
66
- )}; active runtimes and app data were kept.\n`
67
- : ' peach automatic cleanup found no obsolete local data.\n',
65
+ ` peach automatic cleanup reclaimed ${formatSootsimBytes(
66
+ result.reclaimedBytes,
67
+ )}; active runtimes and app data were kept.\n`,
68
68
  )
69
69
  } else if (result.status === 'deferred') {
70
70
  process.stderr.write(
@@ -835,7 +835,8 @@ export interface BuildShellUrlOptions {
835
835
  // host page URL at boot (syncProofModeFromInitUrl) and pin everything that
836
836
  // would otherwise differ frame to frame: the TextInput caret stops blinking
837
837
  // and stays visible, and notifications stop auto-dismissing. capture-frame
838
- // also reads the raw param and stops clipping the device corners, so a
838
+ // also reads the raw param and stops clipping the device corners, and the
839
+ // shell leaves out the Dynamic Island, which is hardware, so a
839
840
  // capture matches simctl's rectangular framebuffer. without it a
840
841
  // screen holding a focused text field never reaches three identical idle
841
842
  // frames, so the screenshot guard burns all 12 attempts and then fails.
@@ -1611,16 +1612,14 @@ export async function runOpenCommand(
1611
1612
  rnxExit(1)
1612
1613
  }
1613
1614
  // the window fits the box the browser stage fits the device into, which for
1614
- // a foldable spans every posture and orientation, so the device draws at its
1615
- // natural size in the pose it opens in instead of shrinking into a window
1616
- // sized for one pose.
1615
+ // a foldable spans both postures, so the device draws at its natural size in
1616
+ // the posture it opens in instead of shrinking into a window sized for one.
1617
1617
  const deviceFitBox = deviceArg
1618
1618
  ? resolveDeviceFitBox(
1619
1619
  deviceArg as DeviceModel,
1620
1620
  false,
1621
1621
  undefined,
1622
1622
  postureArg === 'open' ? 'open' : 'closed',
1623
- true,
1624
1623
  )
1625
1624
  : undefined
1626
1625
 
@@ -13,7 +13,6 @@ import {
13
13
  unlinkSync,
14
14
  } from 'fs'
15
15
  import { createRequire } from 'module'
16
- import { fileURLToPath } from 'node:url'
17
16
  import { tmpdir } from 'os'
18
17
  import { dirname, resolve, join, relative } from 'path'
19
18
  import { rnxPublicBrand } from '../../src/public-brand'
@@ -34,15 +33,17 @@ peach detox — run detox-style tests against a peach shell
34
33
 
35
34
  usage:
36
35
  peach detox [testFiles...] run all tests under e2e/, test/e2e/, or detox/
36
+ peach detox --app <port|url> the app each device.launchApp() opens
37
37
  peach detox --config <path> use a specific jest config
38
38
  peach detox init scaffold rnx-detox.config.cjs + sample test
39
39
  peach detox --watch jest watch mode
40
40
  peach detox --headed keep the peach shell window visible
41
41
  peach detox -t <pattern> pass a jest --testNamePattern
42
- peach detox --no-launch skip auto-launching a peach shell
42
+ peach detox --no-launch skip the running-shell check
43
43
 
44
- peach detox auto-launches a peach shell if none is running on the
45
- expected port. disable with --no-launch if you're managing the shell yourself.
44
+ peach detox needs a running peach shell: start your app and run
45
+ \`peach open <app-port>\` first (the background service keeps one ready).
46
+ it warns when none is reachable; --no-launch skips that check.
46
47
  `
47
48
 
48
49
  export async function runDetox(args: string[], opts: RunDetoxOpts = {}): Promise<void> {
@@ -140,9 +141,25 @@ export async function runDetox(args: string[], opts: RunDetoxOpts = {}): Promise
140
141
  }
141
142
  testDir ??= process.cwd()
142
143
 
143
- // auto-launch: make sure a peach shell is reachable before running jest.
144
- // Reuse the Maestro discovery path: scan local dev servers.
145
- // and `peach open` the first match.
144
+ // jest runs from the project, so the preset must resolve from it too; the
145
+ // standalone binary has no package directory of its own to point at.
146
+ let presetPath = ''
147
+ if (!localConfig) {
148
+ try {
149
+ presetPath = createRequire(join(process.cwd(), 'package.json')).resolve(
150
+ `${rnxPublicBrand.packageName}/detox/jest-preset`,
151
+ )
152
+ } catch {
153
+ console.error(
154
+ ` error: ${rnxPublicBrand.commandName} detox runs Jest from this project, which needs its dev dependencies:\n` +
155
+ ` npm i -D ${rnxPublicBrand.packageName} jest`,
156
+ )
157
+ rnxExit(1)
158
+ }
159
+ }
160
+
161
+ // the driver navigates to a running peach shell; warn before jest starts
162
+ // when none is reachable.
146
163
  if (!noLaunch) {
147
164
  await ensureShellRunning(port)
148
165
  }
@@ -162,9 +179,6 @@ export async function runDetox(args: string[], opts: RunDetoxOpts = {}): Promise
162
179
  // subpath exports, so we generate a real config file instead.
163
180
  // scope roots + testMatch to the discovered test dir so jest doesn't
164
181
  // scan the entire repo (which causes haste collisions in monorepos).
165
- const presetPath = fileURLToPath(
166
- import.meta.resolve(`${rnxPublicBrand.packageName}/detox/jest-preset`),
167
- )
168
182
  // an external suite may optionally declare its own ignore patterns via e2e/jest-ignore.cjs
169
183
  const suiteIgnoreFile = testDir ? join(testDir, 'e2e', 'jest-ignore.cjs') : null
170
184
  let suiteIgnorePatterns: string[] = []
@@ -483,7 +497,7 @@ describe('example', () => {
483
497
  }
484
498
 
485
499
  console.log(`\n next:`)
486
- console.log(` peach detox # run the sample`)
500
+ console.log(` peach detox --app <dev-server-port> # run the sample`)
487
501
  console.log(` peach detox --watch`)
488
502
  rnxExit(0)
489
503
  }
@@ -268,8 +268,9 @@ options:
268
268
  headless or stale
269
269
  --proof deterministic-capture mode: pin the TextInput caret
270
270
  visible instead of blinking, stop notifications
271
- auto-dismissing, and leave the device corners unclipped
272
- to match a native simctl framebuffer. a screen holding a
271
+ auto-dismissing, leave the device corners unclipped and
272
+ leave out the Dynamic Island, to match a
273
+ native simctl framebuffer. a screen holding a
273
274
  focused text field cannot reach three identical idle
274
275
  frames without this, so its screenshot fails after 12
275
276
  tries. use it for any run whose screenshots get
@@ -17,6 +17,7 @@ import { getCliIdentityKey } from '../current-sim'
17
17
  import { rememberFlowCandidate } from '../flow-session'
18
18
  import { maybeHint } from '../hints'
19
19
  import { shouldPrintInspectNotice } from '../inspect-notice-state'
20
+ import { levenshtein } from '../levenshtein'
20
21
  import { TOP_LEVEL_RUNTIME_COMMANDS } from '../parse-args'
21
22
  import { rethrowIfExit, rnxExit } from '../run-rnx'
22
23
  import {
@@ -243,34 +244,6 @@ function scoreIdSimilarity(needle: string, candidate: string): number {
243
244
  return levenshtein(needle, candidate) - prefix
244
245
  }
245
246
 
246
- function levenshtein(a: string, b: string): number {
247
- if (a === b) return 0
248
- if (!a.length) return b.length
249
- if (!b.length) return a.length
250
- // standard two-row dp: prev[] is the previous row, cur[] is the row being
251
- // computed; swap pointers per outer iteration. the earlier in-place rolling
252
- // version overwrote prev[j-1] twice per cell and never set prev[0]=i, so
253
- // distance(`kitten`,`sitting`) returned 8 instead of 3 and the fuzzy-suggest
254
- // ranking was effectively random.
255
- let prev = new Array<number>(b.length + 1)
256
- let cur = new Array<number>(b.length + 1)
257
- for (let j = 0; j <= b.length; j++) prev[j] = j
258
- for (let i = 1; i <= a.length; i++) {
259
- cur[0] = i
260
- for (let j = 1; j <= b.length; j++) {
261
- cur[j] = Math.min(
262
- prev[j] + 1,
263
- cur[j - 1] + 1,
264
- prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1),
265
- )
266
- }
267
- const tmp = prev
268
- prev = cur
269
- cur = tmp
270
- }
271
- return prev[b.length]
272
- }
273
-
274
247
  function formatNetworkStatus(e: NetworkEntryPayload): string {
275
248
  if (e.error) return 'err'
276
249
  if (e.status == null) return ' … '
@@ -3539,7 +3512,16 @@ export async function runInspect(args: string[], opts: InspectOptions) {
3539
3512
  if (reloadResult && reloadResult.engineStale) {
3540
3513
  console.log(' engine build changed since page load — full page reload')
3541
3514
  }
3542
- } catch {
3515
+ } catch (error) {
3516
+ // no sim at all is not a reload in flight: report it rather than
3517
+ // waiting out the reconnect budget.
3518
+ const message = error instanceof Error ? error.message : String(error)
3519
+ if (
3520
+ message === 'no sim connected' ||
3521
+ message.startsWith('could not connect to ws://')
3522
+ ) {
3523
+ throw error
3524
+ }
3543
3525
  // the sim may already be in the middle of reloading; fall through to reconnect wait
3544
3526
  }
3545
3527
  console.log(' reloading...')
@@ -3623,7 +3605,7 @@ export async function runInspect(args: string[], opts: InspectOptions) {
3623
3605
  // ignore errors checking for errors
3624
3606
  }
3625
3607
  }
3626
- if (readyResult && !readyResult.ready) {
3608
+ if (!readyResult?.ready) {
3627
3609
  rnxExit(1)
3628
3610
  }
3629
3611
  break
@@ -4655,15 +4637,18 @@ export async function runInspect(args: string[], opts: InspectOptions) {
4655
4637
  // single 15s timeout into ~60s of apparent hang (QA F19-1). there is
4656
4638
  // nothing useful to fetch from a sim that just timed out, so skip them.
4657
4639
  const timedOut = /^command timed out after (\d+)s$/.exec(message)
4658
- // a disconnected / never-connected bridge is genuinely gone; recover is
4659
- // right and probing it would just re-incur a full timeout.
4640
+ // a disconnected bridge is genuinely gone; recover is right and probing
4641
+ // it would just re-incur a full timeout. no bridge at all means there is
4642
+ // no sim to recover, only one to open.
4660
4643
  const disconnected =
4661
4644
  message.startsWith('sim disconnected:') ||
4662
- message.startsWith('bridge never reconnected') ||
4663
- message.startsWith('could not connect to ws://')
4645
+ message.startsWith('bridge never reconnected')
4664
4646
  if (unknownSim) {
4665
4647
  await printUnknownSimHint(bridge, wsPort, unknownSim[1])
4666
- } else if (/^no sim connected$/.test(message)) {
4648
+ } else if (
4649
+ /^no sim connected$/.test(message) ||
4650
+ message.startsWith('could not connect to ws://')
4651
+ ) {
4667
4652
  printMissingSimHint(wsPort)
4668
4653
  } else if (timedOut) {
4669
4654
  // a command timeout alone does not mean a wedged sim — a large screen
@@ -4677,9 +4662,9 @@ export async function runInspect(args: string[], opts: InspectOptions) {
4677
4662
  process.stderr.write(
4678
4663
  ` the sim is still responsive — '${cmd}' just exceeded the ${timedOut[1]}s command budget.\n` +
4679
4664
  ` the screen's node tree is large; narrow the query or raise the budget:\n` +
4680
- ` peach --testid <id> # scope to one subtree\n` +
4665
+ ` peach ${cmd} --subtree <id> # scope to one subtree\n` +
4681
4666
  ` peach find --testid <id> # targeted single-node lookup\n` +
4682
- ` peach --timeout 60000 # raise per-command budget (ms)\n`,
4667
+ ` peach ${cmd} --timeout 60000 # raise per-command budget (ms)\n`,
4683
4668
  )
4684
4669
  } else {
4685
4670
  printRecoverHint()
@@ -1,5 +1,6 @@
1
1
  import { rnxExit } from '../run-rnx'
2
2
  import { runScreenshotMode } from './screenshot-mode'
3
+ import { runShowTouchesMode } from './show-touches-mode'
3
4
  import { runThreeMode } from './three-mode'
4
5
 
5
6
  interface ModeOptions {
@@ -8,7 +9,7 @@ interface ModeOptions {
8
9
  }
9
10
 
10
11
  const VALUE_FLAGS = new Set(['--sim', '--port', '-p'])
11
- const SUBCOMMANDS = new Set(['screenshot', 'three'])
12
+ const SUBCOMMANDS = new Set(['screenshot', 'three', 'show-touches', 'touches'])
12
13
 
13
14
  function findSubcommand(args: string[]): { name: string; index: number } | null {
14
15
  for (let i = 0; i < args.length; i++) {
@@ -32,21 +33,20 @@ peach mode — toggle live display modes
32
33
 
33
34
  usage:
34
35
  peach mode screenshot [on|off|toggle]
36
+ peach mode show-touches [on|off|toggle]
35
37
  peach mode three [on|off|toggle]
36
38
  peach mode three configure [options]
37
39
  `)
38
40
  }
39
41
 
40
42
  export async function runMode(args: string[], opts: ModeOptions): Promise<void> {
41
- if (args.includes('--help') || args.includes('-h')) {
42
- printHelp()
43
- return
44
- }
45
-
46
43
  const sub = findSubcommand(args)
47
44
  if (!sub) {
48
45
  printHelp()
49
- rnxExit(1)
46
+ if (!args.includes('--help') && !args.includes('-h')) {
47
+ rnxExit(1)
48
+ }
49
+ return
50
50
  }
51
51
 
52
52
  const rest = withoutSubcommand(args, sub.index)
@@ -54,5 +54,9 @@ export async function runMode(args: string[], opts: ModeOptions): Promise<void>
54
54
  await runScreenshotMode(rest, opts)
55
55
  return
56
56
  }
57
+ if (sub.name === 'show-touches' || sub.name === 'touches') {
58
+ await runShowTouchesMode(rest, opts)
59
+ return
60
+ }
57
61
  await runThreeMode(rest, opts)
58
62
  }
@@ -260,7 +260,7 @@ export async function runReportIssue(
260
260
  return 2
261
261
  }
262
262
  const approved = await dependencies.confirmSubmission(
263
- 'send this compatibility report to the peach team??',
263
+ 'send this compatibility report to the peach team?',
264
264
  false,
265
265
  )
266
266
  if (!approved) {
@@ -54,6 +54,7 @@ interface SetupOptions {
54
54
 
55
55
  interface SetupRunOptions {
56
56
  launchConnectRN?: boolean
57
+ port?: number
57
58
  }
58
59
 
59
60
  export interface SetupResult {
@@ -120,6 +121,7 @@ export async function runSetup(
120
121
  channel: 'stable',
121
122
  setActive: true,
122
123
  protectVersions: activeRuntime ? [activeRuntime] : [],
124
+ quiet: !options.json,
123
125
  })
124
126
  const result = options.json
125
127
  ? await install()
@@ -130,10 +132,16 @@ export async function runSetup(
130
132
  let serviceInstalled = serviceStatus.installed
131
133
  if (service && !serviceStatus.installed && !options.dryRun) {
132
134
  if (options.json) {
133
- await daemonInstall({ port: DEFAULT_SOOTSIM_BRIDGE_PORT, force: false })
135
+ await daemonInstall({
136
+ port: runOptions.port ?? DEFAULT_SOOTSIM_BRIDGE_PORT,
137
+ force: false,
138
+ })
134
139
  } else {
135
140
  console.log(`\n ${accent('◆')} ${bold('Enabling the background service')}`)
136
- await daemonInstall({ port: DEFAULT_SOOTSIM_BRIDGE_PORT, force: false })
141
+ await daemonInstall({
142
+ port: runOptions.port ?? DEFAULT_SOOTSIM_BRIDGE_PORT,
143
+ force: false,
144
+ })
137
145
  }
138
146
  serviceInstalled = true
139
147
  }
@@ -144,13 +152,10 @@ export async function runSetup(
144
152
 
145
153
  if (launchConnectRN) {
146
154
  console.log(`\n ${accent('◆')} Opening ConnectRN`)
147
- await runOpenCommand([
148
- 'ConnectRN',
149
- '--driver',
150
- simulatorDriver,
151
- '--no-describe',
152
- '--quiet',
153
- ])
155
+ await runOpenCommand(
156
+ ['ConnectRN', '--driver', simulatorDriver, '--no-describe', '--quiet'],
157
+ { port: runOptions.port },
158
+ )
154
159
  }
155
160
 
156
161
  const productAnalytics = await decidePrivacy(options, privacy)
@@ -324,7 +329,7 @@ async function decideSimulatorDriver(
324
329
  desktopDescription,
325
330
  'The Desktop app opens in a dedicated native window.',
326
331
  ])
327
- const choice = await select('Where should peach open??', [
332
+ const choice = await select('Where should peach open?', [
328
333
  'Browser (recommended) No additional download',
329
334
  desktopChoice,
330
335
  ])
@@ -343,7 +348,7 @@ async function decidePrivacy(
343
348
  'Reports can contain package compatibility or an error class.',
344
349
  'They never contain your code or app data.',
345
350
  ])
346
- return confirm('Share bounded diagnostics to improve peach??', false)
351
+ return confirm('Share bounded diagnostics to improve peach?', false)
347
352
  }
348
353
 
349
354
  async function decideRepository(