@swmansion/argent 0.33.1-next.17 → 0.33.1-next.18

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/dist/cli-cmds.mjs CHANGED
@@ -36069,7 +36069,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
36069
36069
  var SESSION_ID2 = randomUUID5();
36070
36070
  function readCliVersion() {
36071
36071
  if (true) {
36072
- return "0.33.1-next.17";
36072
+ return "0.33.1-next.18";
36073
36073
  }
36074
36074
  return "0.0.0";
36075
36075
  }
@@ -16986,7 +16986,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16986
16986
  var SESSION_ID = randomUUID4();
16987
16987
  function readCliVersion() {
16988
16988
  if (true) {
16989
- return "0.33.1-next.17";
16989
+ return "0.33.1-next.18";
16990
16990
  }
16991
16991
  return "0.0.0";
16992
16992
  }
@@ -26,6 +26,16 @@ extension ArgentRunnerSession {
26
26
  /// Ceiling on emitted node depth.
27
27
  private static let emittedDepthLimit = 60
28
28
 
29
+ /// View services that present UI over the registered app from their own
30
+ /// process. On iOS 26 the host app's tree no longer bridges into them, so
31
+ /// an ASWebAuthenticationSession or SFSafariViewController sheet is missing
32
+ /// from the app's snapshot even though it covers the screen.
33
+ private static let hostedViewServiceBundleIds = ["com.apple.SafariViewService"]
34
+
35
+ /// Share of the node budget a hosted service may use. A heavy web page
36
+ /// must not crowd out the app's own nodes and the keyboard.
37
+ private static let hostedNodeBudget = 1000
38
+
29
39
  /// Captures the app's accessibility tree and flattens it into a snapshot
30
40
  /// payload. The capture is retried once after a short pause: this is the
31
41
  /// one runner-side retry, kept here because the capture can read its own
@@ -70,7 +80,7 @@ extension ArgentRunnerSession {
70
80
  )
71
81
  }
72
82
 
73
- let nodes = Self.flatten(root)
83
+ let nodes = Self.flatten(root, hosted: hostedServiceRoots(over: root))
74
84
  let capped = nodes.count >= Self.snapshotNodeBudget
75
85
 
76
86
  return .success(
@@ -88,28 +98,122 @@ extension ArgentRunnerSession {
88
98
  )
89
99
  }
90
100
 
101
+ /// Trees of the hosted view services presenting over `root` right now.
102
+ /// The service is read through a proxy and never activated: activating it
103
+ /// would front it as a standalone app and black out the screen.
104
+ ///
105
+ /// Only a foreground service is read. A suspended one, where the service
106
+ /// stays after its sheet closes, blocks `snapshot()` past the command
107
+ /// watchdog and leaves the runner busy. A background one returns stale
108
+ /// pieces of the closed sheet. A tree whose size differs from the app's
109
+ /// belongs to a sheet still animating in or out, and its frames would
110
+ /// mislead taps, so it is dropped too. A failure here never fails the
111
+ /// app's own snapshot.
112
+ private func hostedServiceRoots(over root: XCUIElementSnapshot)
113
+ -> [XCUIElementSnapshot]
114
+ {
115
+ // Before iOS 26 the app's tree already carries the hosted browser.
116
+ if Self.containsHostedBrowser(root) { return [] }
117
+
118
+ var roots: [XCUIElementSnapshot] = []
119
+
120
+ for bundleId in Self.hostedViewServiceBundleIds {
121
+ let service = XCUIApplication(bundleIdentifier: bundleId)
122
+ guard service.state == .runningForeground else { continue }
123
+
124
+ var hosted: XCUIElementSnapshot?
125
+ var failure: String?
126
+ let started = Date()
127
+ let exceptionDescription = ArgentExceptionGuard.runCatching {
128
+ do {
129
+ hosted = try service.snapshot()
130
+ } catch {
131
+ failure = String(describing: error)
132
+ }
133
+ }
134
+ let elapsedMs = Int(Date().timeIntervalSince(started) * 1000)
135
+
136
+ guard let hosted, service.state == .runningForeground,
137
+ Self.sameSize(hosted.frame, root.frame)
138
+ else {
139
+ NSLog(
140
+ "ARGENT_HOSTED_SKIPPED bundle=%@ ms=%d reason=%@",
141
+ bundleId, elapsedMs,
142
+ exceptionDescription ?? failure ?? "not settled on screen"
143
+ )
144
+ continue
145
+ }
146
+
147
+ NSLog("ARGENT_HOSTED bundle=%@ ms=%d", bundleId, elapsedMs)
148
+ roots.append(hosted)
149
+ }
150
+
151
+ return roots
152
+ }
153
+
154
+ /// Whether the tree holds SafariViewService's browser container, whose
155
+ /// identifier starts with "BrowserView". An app's own web view does not
156
+ /// count. Bounded by the raw depth limit.
157
+ private static func containsHostedBrowser(_ root: XCUIElementSnapshot)
158
+ -> Bool
159
+ {
160
+ var stack: [(XCUIElementSnapshot, Int)] = [(root, 0)]
161
+
162
+ while let (snapshot, depth) = stack.popLast() {
163
+ if snapshot.identifier.hasPrefix("BrowserView") { return true }
164
+ if depth >= rawDepthLimit { continue }
165
+ stack.append(contentsOf: snapshot.children.map { ($0, depth + 1) })
166
+ }
167
+
168
+ return false
169
+ }
170
+
171
+ /// Whether two frames have the same size within a point.
172
+ private static func sameSize(_ a: CGRect, _ b: CGRect) -> Bool {
173
+ abs(a.width - b.width) < 1 && abs(a.height - b.height) < 1
174
+ }
175
+
91
176
  /// Flattens the snapshot tree into an ordered node list. Keeps elements an
92
177
  /// agent can name or act on, assigns indices and parent links in emission
93
- /// order, and dedupes mirror elements.
94
- static func flatten(_ root: XCUIElementSnapshot) -> [SnapshotNodePayload] {
178
+ /// order, and dedupes mirror elements. `hosted` trees of view services
179
+ /// presenting over the app are emitted first under the root, within
180
+ /// their own share of the node budget.
181
+ static func flatten(
182
+ _ root: XCUIElementSnapshot,
183
+ hosted: [XCUIElementSnapshot] = []
184
+ ) -> [SnapshotNodePayload] {
95
185
  struct WorkItem {
96
186
  let snapshot: XCUIElementSnapshot
97
187
  let rawDepth: Int
98
188
  let emittedDepth: Int
99
189
  let parentIndex: Int
190
+ var hosted = false
100
191
  }
101
192
 
102
193
  let viewport = root.frame
103
194
  var nodes = [makeNode(root, index: 0, depth: 0, parentIndex: nil)]
104
195
  var seen: Set<String> = [identity(root)]
196
+ var hostedEmitted = 0
105
197
 
106
198
  var stack = root.children.reversed().map {
107
199
  WorkItem(snapshot: $0, rawDepth: 1, emittedDepth: 1, parentIndex: 0)
108
200
  }
109
201
 
202
+ // Pushed last so they are walked first: they cover the screen, and the
203
+ // app's keyboard keys must not use up the budget before them.
204
+ stack.append(
205
+ contentsOf: hosted.reversed().map {
206
+ WorkItem(
207
+ snapshot: $0, rawDepth: 1, emittedDepth: 1, parentIndex: 0,
208
+ hosted: true
209
+ )
210
+ }
211
+ )
212
+
110
213
  while let item = stack.popLast() {
111
214
  if nodes.count >= snapshotNodeBudget { break }
112
215
  if item.rawDepth > rawDepthLimit { continue }
216
+ if item.hosted && hostedEmitted >= hostedNodeBudget { continue }
113
217
 
114
218
  let snapshot = item.snapshot
115
219
  let frame = snapshot.frame
@@ -141,6 +245,7 @@ extension ArgentRunnerSession {
141
245
 
142
246
  childParentIndex = index
143
247
  childEmittedDepth += 1
248
+ if item.hosted { hostedEmitted += 1 }
144
249
  }
145
250
 
146
251
  for child in snapshot.children.reversed() {
@@ -149,7 +254,8 @@ extension ArgentRunnerSession {
149
254
  snapshot: child,
150
255
  rawDepth: item.rawDepth + 1,
151
256
  emittedDepth: childEmittedDepth,
152
- parentIndex: childParentIndex
257
+ parentIndex: childParentIndex,
258
+ hosted: item.hosted
153
259
  )
154
260
  )
155
261
  }
@@ -101278,7 +101278,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
101278
101278
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101279
101279
  function readCliVersion() {
101280
101280
  if (true) {
101281
- return "0.33.1-next.17";
101281
+ return "0.33.1-next.18";
101282
101282
  }
101283
101283
  return "0.0.0";
101284
101284
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.33.1-next.17",
3
+ "version": "0.33.1-next.18",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
6
6
  "license": "Apache-2.0",