Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(ios): keep call participant touch targets stable (#7856)
Peter Chinman8dc23835b8ac
diff --git a/apps/web/tauri/callkit_plugin/ios/Sources/CallVideoOverlayController.swift b/apps/web/tauri/callkit_plugin/ios/Sources/CallVideoOverlayController.swiftindex e59fd8e7a5..556400c8fd 100644--- a/apps/web/tauri/callkit_plugin/ios/Sources/CallVideoOverlayController.swift+++ b/apps/web/tauri/callkit_plugin/ios/Sources/CallVideoOverlayController.swift@@ -66,10 +66,10 @@ struct CallVideoOverlayTheme: Equatable {/// overlay, structural work (hierarchy changes, visibility flips on/// hit-testable views, frame/scroll geometry) is deferred and only safe/// restyles run; the pending state flushes when the interaction settles.-/// Mutating the hierarchy mid-touch corrupts UIKit's delayed-touch gesture-/// machinery (-[UIGestureRecognizer _delayTouchesForEvent:] throws-/// NSInvalidArgumentException and the app dies), and structural/geometry-/// updates applied non-atomically leave the participant strip unscrollable.+/// Participant tiles are visual-only: the persistent strip scroll view owns+/// their touches, so replacing a participant never detaches UIKit's touch+/// target. Deferral keeps the primary and row stable during interaction; it+/// isn't the safety boundary for the lifetime of a participant's touch target.final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, UIScrollViewDelegate, @unchecked Sendable {private let rootView = PassthroughOverlayView()private let modalOverlayView = UIView()@@ -82,8 +82,8 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, Uprivate let primaryInitialsLabel = UILabel()private let primaryEmptyStateLabel = UILabel()private let primaryParticipantLabel = UILabel()- private let stripScrollView = TileStripScrollView()- private let stripStackView = UIStackView()+ private let stripScrollView = ParticipantStripScrollView(frame: .zero)+ private let stripContentView = UIView()private let localTileView = RemoteVideoTileView(isMirrored: true)private let controlsView = UIStackView()private let microphoneButton = UIButton(type: .system)@@ -172,7 +172,6 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, Uprivate var audioRoute: CallAudioRouteSnapshot { desired.audioRoute }private var isLocalVideoEnabled: Bool { desired.isLocalVideoEnabled }private var localVideoTrack: VideoTrack? { desired.localVideoTrack }- private var primaryRemoteParticipantId: String? { desired.primaryRemoteParticipantId }private var pinnedRemoteParticipantId: String? { desired.participants.first(where: { $0.isPinned })?.id }private var primaryRemoteParticipant: NativeVideoParticipant? {@@ -187,7 +186,7 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, Uprivate var primaryRemoteVideoTrack: VideoTrack? { primaryRemoteParticipant?.track }private var stripParticipants: [NativeVideoParticipant] {- desired.participants.filter { $0.id != desired.primaryRemoteParticipantId }+ desired.participants.filter { $0.id != primaryRemoteParticipant?.id }}override init() {@@ -330,6 +329,7 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, Uvar next = OverlayViewState()next.theme = self.desired.themeself.desired = next+ self.stripScrollView.invalidateSelection()self.didAutoPresent = falseself.scheduleApply()print("[CallKit] Native video overlay reset")@@ -417,12 +417,19 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, U/// flips on hit-testable views, no video track swaps.private func applyRestyleOnly() {applyTextContent()- for participant in stripParticipants {- guard let tile = stripTileViews[participant.id] else { continue }- tile.restyle(participant: participant, isPrimary: participant.id == primaryRemoteParticipantId)+ // Restyle the identities actually on screen. `desired` may already+ // name a different primary or omit a participant who just left.+ for item in stripScrollView.displayedItems {+ guard let participant = desired.participants.first(where: { $0.id == item.id }),+ let tile = stripTileViews[item.id] else { continue }+ tile.restyle(participant: participant, isPrimary: false)}- primaryParticipantLabel.text = primaryRemoteParticipantTitle- primaryInitialsLabel.text = primaryRemoteParticipantTitle.map(initials)+ let displayedPrimary = applied.participants.first { $0.id == applied.primaryRemoteParticipantId }+ ?? applied.participants.first+ let primary = desired.participants.first { $0.id == displayedPrimary?.id } ?? displayedPrimary+ let title = primary.map { $0.isScreenShare ? "Screen" : $0.title }+ primaryParticipantLabel.text = title+ primaryInitialsLabel.text = title.map(initials)configureControlState()}@@ -447,7 +454,9 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, UrootView.blocksBackgroundTouches = desired.mode == .expandedlocalTileView.isHidden = !shouldShowDrawer- stripScrollView.isHidden = !shouldShowDrawer || stripParticipants.isEmpty+ // Keep the gesture surface attached and visible even when the row+ // becomes empty. Only the drawer's presentation controls its lifetime.+ stripScrollView.isHidden = !shouldShowDrawerunpinButton.isHidden = pinnedRemoteParticipantId == nilswitchCameraButton.isHidden = !desired.isLocalVideoEnabled || localTileView.isHidden}@@ -500,8 +509,6 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, U|| stripScrollView.isDragging|| stripScrollView.isDecelerating|| stripScrollView.panGestureRecognizer.state != .possible- || stripTileViews.values.contains(where: \.isTracking)- || localTileView.isTracking|| drawerPanIsActive}@@ -516,8 +523,6 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, U+ " scrollDragging=\(stripScrollView.isDragging)"+ " scrollDecelerating=\(stripScrollView.isDecelerating)"+ " scrollPanState=\(stripScrollView.panGestureRecognizer.state.rawValue)"- + " tileTracking=\(stripTileViews.values.contains(where: \.isTracking))"- + " localTileTracking=\(localTileView.isTracking)"+ " drawerPanState=\(drawerPanRecognizer.map { String($0.state.rawValue) } ?? "nil")"}@@ -602,6 +607,7 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, UprimaryEmptyStateLabel.numberOfLines = 0primaryPlaceholderView.addSubview(primaryEmptyStateLabel)+ primaryParticipantLabel.accessibilityIdentifier = "call.primary-participant"primaryParticipantLabel.textColor = theme.textColorprimaryParticipantLabel.font = .systemFont(ofSize: 14, weight: .semibold)primaryParticipantLabel.lineBreakMode = .byTruncatingTail@@ -614,15 +620,15 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, UstripScrollView.showsHorizontalScrollIndicator = falsestripScrollView.alwaysBounceHorizontal = truestripScrollView.backgroundColor = .clear- stripScrollView.delaysContentTouches = falsestripScrollView.delegate = self+ stripScrollView.accessibilityIdentifier = "call.participant-row"+ stripScrollView.onSelectParticipant = { [weak self] id in+ self?.selectDisplayedParticipant(id)+ }drawerView.addSubview(stripScrollView)- stripStackView.axis = .horizontal- stripStackView.alignment = .fill- stripStackView.distribution = .fill- stripStackView.spacing = 10- stripScrollView.addSubview(stripStackView)+ stripContentView.isUserInteractionEnabled = false+ stripScrollView.addSubview(stripContentView)localTileView.applyTheme(theme)localTileView.configure(@@ -637,7 +643,6 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, U),isPrimary: false)- localTileView.onTrackingEnded = { [weak self] in self?.scheduleApply() }drawerView.addSubview(localTileView)controlsView.axis = .horizontal@@ -815,10 +820,8 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, U// MARK: - Participant strip- /// Structural sync of strip tiles to `desired`. Runs only inside the gated- /// full apply, never while a touch is active — inserting, removing, or- /// reordering tiles while UIKit is delivering a touch through the strip- /// corrupts the delayed-touch gesture machinery.+ /// Structural sync of visual-only tiles. Runs with geometry and primary+ /// updates in the same gated pass so the row doesn't move under a finger.private func syncParticipantStrip() {let participants = stripParticipants@@ -827,32 +830,27 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, Ufor id in staleIds {guard let tile = stripTileViews.removeValue(forKey: id) else { continue }tile.prepareForRemoval()- stripStackView.removeArrangedSubview(tile)tile.removeFromSuperview()}- for (index, participant) in participants.enumerated() {+ for participant in participants {let tile = stripTileViews[participant.id] ?? RemoteVideoTileView()stripTileViews[participant.id] = tile- configureStripTile(tile, participant: participant)- tile.ensureFixedSize()- let arrangedTiles = stripStackView.arrangedSubviews- if index >= arrangedTiles.count || arrangedTiles[index] !== tile {- stripStackView.insertArrangedSubview(tile, at: min(index, arrangedTiles.count))+ tile.applyTheme(theme)+ tile.configure(participant: participant, isPrimary: false)+ tile.accessibilityIdentifier = "call.participant.\(participant.id)"+ tile.onAccessibilityActivate = { [weak self] in+ self?.selectDisplayedParticipant(participant.id)}+ if tile.superview !== stripContentView { stripContentView.addSubview(tile) }}}- private func configureStripTile(_ tile: RemoteVideoTileView, participant: NativeVideoParticipant) {- tile.applyTheme(theme)- tile.configure(participant: participant, isPrimary: participant.id == primaryRemoteParticipantId)- tile.onTap = { [weak self] id in- print("[CallKit] Native video overlay remote tile tapped id=\(id)")- self?.onSelectRemoteParticipant?(id)- }- tile.onTrackingEnded = { [weak self] in- self?.scheduleApply()- }+ private func selectDisplayedParticipant(_ id: String) {+ // A departure may have arrived while the displayed row was frozen.+ guard desired.participants.contains(where: { $0.id == id }) else { return }+ print("[CallKit] Native video overlay remote tile selected id=\(id)")+ onSelectRemoteParticipant?(id)}// MARK: - Theme@@ -1073,17 +1071,20 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, Uwidth: max(0, drawerView.bounds.width - scrollX - rowHorizontalInset),height: stripHeight)- stripStackView.frame = CGRect(+ stripContentView.frame = CGRect(x: 0,y: 0,width: CGFloat(stripParticipantCount) * tileWidth + CGFloat(max(stripParticipantCount - 1, 0)) * tileSpacing,height: stripHeight)- let stripContentSize = CGSize(width: stripStackView.frame.width, height: stripHeight)- if stripScrollView.contentSize != stripContentSize {- stripScrollView.contentSize = stripContentSize+ let items = stripParticipants.enumerated().map { index, participant in+ ParticipantStripScrollView.Item(+ id: participant.id,+ frame: CGRect(x: CGFloat(index) * (tileWidth + tileSpacing), y: 0, width: tileWidth, height: stripHeight)+ )}- stripStackView.arrangedSubviews.forEach { $0.frame.size = CGSize(width: tileWidth, height: stripHeight) }+ for item in items { stripTileViews[item.id]?.frame = item.frame }+ stripScrollView.updateItems(items, contentSize: stripContentView.bounds.size)switchCameraButton.frame = CGRect(x: localTileView.frame.maxX - 44,@@ -1329,6 +1330,9 @@ final class CallVideoOverlayController: NSObject, UIGestureRecognizerDelegate, Ufunc gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {guard gestureRecognizer.view === drawerView else { return true }+ // The strip owns both horizontal scrolling and participant selection;+ // the drawer pan must not compete with a touch that starts in the row.+ if let view = touch.view, view.isDescendant(of: stripScrollView) { return false }return !(touch.view is UIControl)}@@ -1347,7 +1351,7 @@ private enum ThumbnailCorner {case bottomRight}-private final class RemoteVideoTileView: UIControl {+private final class RemoteVideoTileView: UIView {private let videoView = VideoView()private let placeholderView = UIView()private let initialsLabel = UILabel()@@ -1355,11 +1359,10 @@ private final class RemoteVideoTileView: UIControl {private let speakingIndicator = UIView()private let isMirrored: Boolprivate var theme = CallVideoOverlayTheme.fallback- private var participantId: String?private var hasVideoTrack = false- private var didInstallFixedSizeConstraints = false- var onTap: ((String) -> Void)?- var onTrackingEnded: (() -> Void)?+ var onAccessibilityActivate: (() -> Void)? {+ didSet { accessibilityTraits = onAccessibilityActivate == nil ? .staticText : .button }+ }init(frame: CGRect = .zero, isMirrored: Bool = false) {self.isMirrored = isMirrored@@ -1373,11 +1376,8 @@ private final class RemoteVideoTileView: UIControl {configureViews()}- /// Full sync, including the video track swap. VideoView replaces internal- /// renderer subviews when its track changes, so this must only run from the- /// gated apply pass, never while this control is tracking a touch.+ /// Full sync, including the video track swap, for this visual-only tile.func configure(participant: NativeVideoParticipant, isPrimary: Bool) {- participantId = participant.idhasVideoTrack = participant.track != nilif videoView.track !== participant.track {videoView.track = participant.track@@ -1391,6 +1391,7 @@ private final class RemoteVideoTileView: UIControl {func restyle(participant: NativeVideoParticipant, isPrimary: Bool) {initialsLabel.text = initials(from: participant.avatarTitle ?? participant.title)label.text = participant.isScreenShare ? "Screen" : participant.title+ accessibilityLabel = label.textapplyLabelBackground()speakingIndicator.isHidden = !participant.isSpeakinglayer.borderColor = (isPrimary ? theme.edgeColor : theme.edgeMutedColor).cgColor@@ -1399,24 +1400,17 @@ private final class RemoteVideoTileView: UIControl {}func prepareForRemoval() {- onTrackingEnded = nil- cancelTracking(with: nil)videoView.track = nilplaceholderView.isHidden = false- onTap = nil- participantId = nil+ onAccessibilityActivate = nilhasVideoTrack = falseapplyLabelBackground()}- override func endTracking(_ touch: UITouch?, with event: UIEvent?) {- super.endTracking(touch, with: event)- onTrackingEnded?()- }-- override func cancelTracking(with event: UIEvent?) {- super.cancelTracking(with: event)- onTrackingEnded?()+ override func accessibilityActivate() -> Bool {+ guard let onAccessibilityActivate else { return false }+ onAccessibilityActivate()+ return true}func applyTheme(_ theme: CallVideoOverlayTheme) {@@ -1431,13 +1425,6 @@ private final class RemoteVideoTileView: UIControl {speakingIndicator.backgroundColor = theme.successColor}- func ensureFixedSize() {- guard !didInstallFixedSizeConstraints else { return }- didInstallFixedSizeConstraints = true- widthAnchor.constraint(equalToConstant: 128).isActive = true- heightAnchor.constraint(equalToConstant: 92).isActive = true- }-private func configureViews() {backgroundColor = theme.messageBackgroundColorlayer.cornerRadius = 6@@ -1446,9 +1433,7 @@ private final class RemoteVideoTileView: UIControl {videoView.layoutMode = .fillvideoView.mirrorMode = isMirrored ? .auto : .offvideoView.backgroundColor = theme.messageBackgroundColor- // Keep hit-testing on the control itself: VideoView swaps its internal- // renderer subviews when tracks change, and detaching the view UIKit- // associated with an in-flight touch corrupts touch delivery.+ // Rendering never participates in hit-testing; the row owns touches.videoView.isUserInteractionEnabled = falseaddSubview(videoView)@@ -1476,7 +1461,9 @@ private final class RemoteVideoTileView: UIControl {speakingIndicator.isUserInteractionEnabled = falseaddSubview(speakingIndicator)- addTarget(self, action: #selector(tapped), for: .touchUpInside)+ isUserInteractionEnabled = false+ isAccessibilityElement = true+ accessibilityTraits = .staticText}private func applyLabelBackground() {@@ -1519,20 +1506,6 @@ private final class RemoteVideoTileView: UIControl {return "?"}- @objc private func tapped() {- guard let participantId else { return }- onTap?(participantId)- }-}--/// The participant strip is wall-to-wall UIControl tiles, and-/// `UIScrollView.touchesShouldCancel(in:)` returns false for UIControls by-/// default — so with `delaysContentTouches = false` a drag that starts on a-/// tile is owned by the tile's tracking forever and the strip cannot scroll.-/// Let the pan steal the touch: the tile gets `cancelTracking` (no-/// touch-up-inside, so no accidental pin) and the scroll proceeds.-private final class TileStripScrollView: UIScrollView {- override func touchesShouldCancel(in view: UIView) -> Bool { true }}/// Non-recognizing gesture recognizer attached to the overlay root purely todiff --git a/apps/web/tauri/callkit_plugin/ios/Sources/ParticipantStripScrollView.swift b/apps/web/tauri/callkit_plugin/ios/Sources/ParticipantStripScrollView.swiftnew file mode 100644index 0000000000..dce2294bfb--- /dev/null+++ b/apps/web/tauri/callkit_plugin/ios/Sources/ParticipantStripScrollView.swift@@ -0,0 +1,85 @@+import UIKit++/// The row itself owns every touch. Participant views are disposable render+/// targets, never the views UIKit associates with a delayed touch event.+final class ParticipantStripScrollView: UIScrollView, UIGestureRecognizerDelegate {+ struct Item: Equatable {+ let id: String+ let frame: CGRect+ }++ private(set) var displayedItems: [Item] = []+ var onSelectParticipant: ((String) -> Void)?+ private var touchedParticipantId: String?+ private var selectionGeneration = 0++ override init(frame: CGRect) {+ super.init(frame: frame)+ let tap = UITapGestureRecognizer(target: self, action: #selector(selectParticipant(_:)))+ tap.delegate = self+ tap.cancelsTouchesInView = false+ tap.delaysTouchesBegan = false+ tap.delaysTouchesEnded = false+ tap.require(toFail: panGestureRecognizer)+ addGestureRecognizer(tap)+ }++ required init?(coder: NSCoder) {+ fatalError("init(coder:) has not been implemented")+ }++ override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {+ // In particular, don't return the content container, tiles, or a+ // LiveKit renderer: any of those may be removed on the next update.+ super.hitTest(point, with: event) == nil ? nil : self+ }++ func participant(at point: CGPoint) -> String? {+ displayedItems.first { $0.frame.contains(point) }?.id+ }++ /// Preserve a surviving visible participant's position when membership+ /// changes. Frame coordinates and contentOffset share the content space.+ func updateItems(_ items: [Item], contentSize newSize: CGSize) {+ let surviving = displayedItems.filter { old in items.contains { $0.id == old.id } }+ let anchor = surviving.first { $0.frame.intersects(bounds) }+ ?? surviving.min { abs($0.frame.minX - bounds.minX) < abs($1.frame.minX - bounds.minX) }+ let oldOffset = contentOffset.x+ displayedItems = items+ contentSize = newSize+ let proposedOffset: CGFloat+ if let anchor, let replacement = items.first(where: { $0.id == anchor.id }) {+ proposedOffset = oldOffset + replacement.frame.minX - anchor.frame.minX+ } else {+ proposedOffset = oldOffset+ }+ let maxOffset = max(0, newSize.width - bounds.width)+ let offset = CGPoint(x: min(max(0, proposedOffset), maxOffset), y: 0)+ if contentOffset != offset { setContentOffset(offset, animated: false) }+ }++ func invalidateSelection() {+ selectionGeneration += 1+ touchedParticipantId = nil+ }++ func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {+ guard gestureRecognizer is UITapGestureRecognizer,+ gestureRecognizer.numberOfTouches == 0 else { return true }+ // A touch that stops momentum must not also pin a participant. Capture+ // identity at touch-down, rather than looking up a potentially new row+ // at touch-up.+ touchedParticipantId = isDecelerating ? nil : participant(at: touch.location(in: self))+ return true+ }++ @objc private func selectParticipant(_ recognizer: UITapGestureRecognizer) {+ guard recognizer.state == .ended, let id = touchedParticipantId else { return }+ touchedParticipantId = nil+ let generation = selectionGeneration+ DispatchQueue.main.async { [weak self] in+ guard let self, self.selectionGeneration == generation else { return }+ self.onSelectParticipant?(id)+ }+ }+}diff --git a/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/HarnessApp.swift b/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/HarnessApp.swiftnew file mode 100644index 0000000000..701ab332ac--- /dev/null+++ b/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/HarnessApp.swift@@ -0,0 +1,112 @@+import UIKit+import WebKit++/// Runs the production overlay without authentication, a backend, or a call.+/// A physical device can use this same screen to stress the gesture lifecycle.+@main+final class HarnessApp: UIResponder, UIApplicationDelegate {+ var window: UIWindow?+ private let overlay = CallVideoOverlayController()+ private var timer: Timer?+ private var ids = ["Alice", "Bob", "Carol", "Dave", "Eve", "Frank"]+ private var primary = "Alice"+ private var tick = 0+ private let status = UILabel()+ private var heldPrimary: String?+ private var heldRow: [String]?+ private var violations = 0++ func application(_ application: UIApplication, didFinishLaunchingWithOptions options: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {+ let window = UIWindow(frame: UIScreen.main.bounds)+ let controller = UIViewController()+ let webview = WKWebView(frame: window.bounds)+ controller.view = webview+ window.rootViewController = controller+ self.window = window+ window.makeKeyAndVisible()+ overlay.attach(to: webview)+ overlay.setMode(.expanded)+ overlay.onSelectRemoteParticipant = { [weak self] id in+ guard let self else { return }+ self.primary = id+ self.publish()+ }+ publish()+ // Above the drawer, so stress controls remain available.+ let controls = UIStackView(frame: CGRect(x: 12, y: window.safeAreaInsets.top + 4, width: window.bounds.width - 24, height: 36))+ controls.distribution = .fillEqually+ for (title, action) in [("Speakers", #selector(startSpeakers)), ("Departures", #selector(startDepartures)), ("Stop", #selector(stop))] {+ let button = UIButton(type: .system)+ button.setTitle(title, for: .normal)+ button.addTarget(self, action: action, for: .touchUpInside)+ controls.addArrangedSubview(button)+ }+ status.frame = CGRect(x: 12, y: controls.frame.maxY, width: window.bounds.width - 24, height: 30)+ status.accessibilityIdentifier = "harness.status"+ status.text = "Ready"+ // Overlay is installed asynchronously. Add controls afterwards.+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {+ let row = window.descendants.first { $0.accessibilityIdentifier == "call.participant-row" }+ let overlayRoot = row?.superview?.superview ?? window+ overlayRoot.addSubview(controls)+ overlayRoot.addSubview(self.status)+ }+ return true+ }++ private func publish() {+ overlay.setRemoteVideoParticipants(ids.map {+ NativeVideoParticipant(id: $0, title: $0, track: nil, isSpeaking: $0 == primary, isPinned: false, isScreenShare: false)+ }, primaryId: primary)+ }++ @objc private func startSpeakers() { start(departures: false) }+ @objc private func startDepartures() { start(departures: true) }+ @objc private func stop() {+ timer?.invalidate()+ timer = nil+ status.text = "Stopped; violations=\(violations)"+ }++ private func start(departures: Bool) {+ timer?.invalidate()+ tick = 0+ violations = 0+ heldPrimary = nil+ heldRow = nil+ timer = Timer(timeInterval: 0.08, repeats: true) { [weak self] _ in+ guard let self else { return }+ self.auditPresentation()+ self.tick += 1+ self.ids = ["Alice", "Bob", "Carol", "Dave", "Eve", "Frank"]+ if departures, self.tick % 2 == 0 { self.ids.remove(at: (self.tick / 2) % self.ids.count) }+ self.primary = self.ids[self.tick % self.ids.count]+ self.publish()+ self.status.text = "Updates=\(self.tick); violations=\(self.violations)"+ }+ RunLoop.main.add(timer!, forMode: .common)+ }++ private func auditPresentation() {+ guard let window,+ let row = window.descendants.first(where: { $0.accessibilityIdentifier == "call.participant-row" }) as? UIScrollView,+ let label = window.descendants.first(where: { $0.accessibilityIdentifier == "call.primary-participant" }) as? UILabel else { return }+ let tiles = row.descendants.filter { $0.accessibilityIdentifier?.hasPrefix("call.participant.") == true }+ .sorted { $0.convert($0.bounds, to: row).minX < $1.convert($1.bounds, to: row).minX }+ let items = tiles.compactMap { $0.accessibilityIdentifier?.replacingOccurrences(of: "call.participant.", with: "") }+ if items.contains(label.text ?? "") { violations += 1 }+ if row.isTracking || row.isDragging || row.isDecelerating {+ if let heldPrimary, heldPrimary != label.text { violations += 1 }+ if let heldRow, heldRow != items { violations += 1 }+ heldPrimary = label.text+ heldRow = items+ } else {+ heldPrimary = nil+ heldRow = nil+ }+ }+}++extension UIView {+ var descendants: [UIView] { subviews.flatMap { [$0] + $0.descendants } }+}diff --git a/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/OverlayGestureTests.swift b/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/OverlayGestureTests.swiftnew file mode 100644index 0000000000..224c93e80a--- /dev/null+++ b/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/OverlayGestureTests.swift@@ -0,0 +1,50 @@+import XCTest++final class OverlayGestureTests: XCTestCase {+ @MainActor+ func testParticipantTapAndScrollDoNotCompete() {+ let app = XCUIApplication()+ app.launch()+ let row = app.scrollViews["call.participant-row"]+ XCTAssertTrue(row.waitForExistence(timeout: 10))+ row.coordinate(withNormalizedOffset: CGVector(dx: 0.2, dy: 0.5)).tap()+ let primary = app.staticTexts["call.primary-participant"]+ XCTAssertTrue(primary.waitForExistence(timeout: 5))+ XCTAssertEqual(primary.label, "Bob")+ row.swipeLeft()+ XCTAssertEqual(primary.label, "Bob", "Scrolling must not select a participant")+ }++ @MainActor+ func testTapAfterScrollingSelectsTheVisibleParticipant() {+ let app = XCUIApplication()+ app.launch()+ let row = app.scrollViews["call.participant-row"]+ XCTAssertTrue(row.waitForExistence(timeout: 10))+ row.swipeLeft()+ let frank = app.buttons["call.participant.Frank"]+ XCTAssertTrue(frank.waitForExistence(timeout: 5))+ frank.tap()+ XCTAssertEqual(app.staticTexts["call.primary-participant"].label, "Frank")+ XCTAssertFalse(app.buttons["call.participant.Frank"].exists, "The primary is excluded from the row")+ }++ @MainActor+ func testSpeakerAndMembershipChurnDuringGestures() {+ let app = XCUIApplication()+ app.launch()+ let row = app.scrollViews["call.participant-row"]+ XCTAssertTrue(row.waitForExistence(timeout: 10))+ for mode in ["Speakers", "Departures"] {+ app.buttons[mode].tap()+ for _ in 0..<8 {+ let start = row.coordinate(withNormalizedOffset: CGVector(dx: 0.8, dy: 0.5))+ let end = row.coordinate(withNormalizedOffset: CGVector(dx: 0.2, dy: 0.5))+ start.press(forDuration: 0.3, thenDragTo: end, withVelocity: .slow, thenHoldForDuration: 0.3)+ row.swipeRight()+ }+ app.buttons["Stop"].tap()+ XCTAssertEqual(app.staticTexts["harness.status"].label, "Stopped; violations=0")+ }+ }+}diff --git a/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/ParticipantStripTests.swift b/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/ParticipantStripTests.swiftnew file mode 100644index 0000000000..14babd79f6--- /dev/null+++ b/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/ParticipantStripTests.swift@@ -0,0 +1,82 @@+import XCTest+@testable import CallOverlayHarness++@MainActor+final class ParticipantStripTests: XCTestCase {+ private func items(_ ids: [String]) -> [ParticipantStripScrollView.Item] {+ ids.enumerated().map { index, id in+ .init(id: id, frame: CGRect(x: index * 138, y: 0, width: 128, height: 92))+ }+ }++ func testHitTargetSurvivesParticipantRemovalAndReplacement() {+ let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 400, height: 200))+ let row = ParticipantStripScrollView(frame: CGRect(x: 0, y: 0, width: 200, height: 92))+ window.addSubview(row)+ let tile = UIView(frame: row.bounds)+ row.addSubview(tile)+ XCTAssertTrue(row.hitTest(CGPoint(x: 20, y: 20), with: nil) === row)+ tile.removeFromSuperview()+ row.addSubview(UIView(frame: row.bounds))+ XCTAssertTrue(row.hitTest(CGPoint(x: 20, y: 20), with: nil) === row)+ XCTAssertNil(row.hitTest(CGPoint(x: -1, y: 20), with: nil))+ }++ func testSpeakerSwapPreservesSurvivingVisibleParticipantPosition() {+ let row = ParticipantStripScrollView(frame: CGRect(x: 0, y: 0, width: 200, height: 92))+ row.updateItems(items(["Bob", "Carol", "Dave", "Eve"]), contentSize: CGSize(width: 542, height: 92))+ row.contentOffset.x = 150+ // Alice was primary. Now Bob is primary and Alice enters before Carol.+ row.updateItems(items(["Alice", "Carol", "Dave", "Eve"]), contentSize: CGSize(width: 542, height: 92))+ XCTAssertEqual(row.contentOffset.x, 150)+ // Alice leaves: Carol keeps the same on-screen position.+ row.updateItems(items(["Carol", "Dave", "Eve"]), contentSize: CGSize(width: 404, height: 92))+ XCTAssertEqual(row.contentOffset.x, 12)+ }++ func testEmptyRowAndContentShrinkClampOffset() {+ let row = ParticipantStripScrollView(frame: CGRect(x: 0, y: 0, width: 200, height: 92))+ row.updateItems(items(["Bob", "Carol", "Dave"]), contentSize: CGSize(width: 404, height: 92))+ row.contentOffset.x = 204+ row.updateItems(items(["Bob"]), contentSize: CGSize(width: 128, height: 92))+ XCTAssertEqual(row.contentOffset.x, 0)+ row.updateItems([], contentSize: CGSize(width: 0, height: 92))+ XCTAssertEqual(row.contentOffset.x, 0)+ XCTAssertFalse(row.isHidden)+ }++ func testSelectionUsesDisplayedFramesAndIgnoresGaps() {+ let row = ParticipantStripScrollView(frame: CGRect(x: 0, y: 0, width: 200, height: 92))+ row.updateItems(items(["Bob", "Carol"]), contentSize: CGSize(width: 266, height: 92))+ XCTAssertEqual(row.participant(at: CGPoint(x: 150, y: 20)), "Carol")+ XCTAssertNil(row.participant(at: CGPoint(x: 133, y: 20)))+ }++ func testOnlyFirstTapTouchIsUsedForParticipantCapture() {+ let row = ParticipantStripScrollView(frame: CGRect(x: 0, y: 0, width: 200, height: 92))+ row.updateItems(items(["Bob", "Carol"]), contentSize: CGSize(width: 266, height: 92))+ let touch = LocationCountingTouch()+ let tap = PendingTouchTapRecognizer()++ XCTAssertTrue(row.gestureRecognizer(tap, shouldReceive: touch))+ XCTAssertEqual(touch.locationReads, 1)+ tap.pendingTouchCount = 1+ XCTAssertTrue(row.gestureRecognizer(tap, shouldReceive: touch))+ XCTAssertTrue(row.gestureRecognizer(UIPanGestureRecognizer(), shouldReceive: touch))+ XCTAssertEqual(touch.locationReads, 1)+ }+}++private final class PendingTouchTapRecognizer: UITapGestureRecognizer {+ var pendingTouchCount = 0+ override var numberOfTouches: Int { pendingTouchCount }+}++private final class LocationCountingTouch: UITouch {+ private(set) var locationReads = 0++ override func location(in view: UIView?) -> CGPoint {+ locationReads += 1+ return CGPoint(x: 20, y: 20)+ }+}diff --git a/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/project.yml b/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/project.ymlnew file mode 100644index 0000000000..77aa09dd74--- /dev/null+++ b/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/project.yml@@ -0,0 +1,51 @@+name: CallOverlayHarness+options:+ deploymentTarget:+ iOS: '16.0'+settings:+ base:+ SWIFT_VERSION: '5.0'+ CODE_SIGNING_ALLOWED: NO+ GENERATE_INFOPLIST_FILE: YES+packages:+ LiveKit:+ url: https://github.com/livekit/client-sdk-swift.git+ exactVersion: 2.13.0+targets:+ CallOverlayHarness:+ type: application+ platform: iOS+ sources:+ - HarnessApp.swift+ - ../../Sources/CallVideoOverlayController.swift+ - ../../Sources/ParticipantStripScrollView.swift+ - ../../Sources/CallAudioRouteController.swift+ dependencies:+ - package: LiveKit+ settings:+ base:+ PRODUCT_BUNDLE_IDENTIFIER: com.macro.tests.call-overlay+ INFOPLIST_KEY_UILaunchScreen_Generation: YES+ CallOverlayTests:+ type: bundle.unit-test+ platform: iOS+ sources:+ - ParticipantStripTests.swift+ dependencies:+ - target: CallOverlayHarness+ CallOverlayUITests:+ type: bundle.ui-testing+ platform: iOS+ sources:+ - OverlayGestureTests.swift+ dependencies:+ - target: CallOverlayHarness+schemes:+ CallOverlayHarness:+ build:+ targets:+ CallOverlayHarness: all+ test:+ targets:+ - CallOverlayTests+ - CallOverlayUITestsdiff --git a/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/run-tests.sh b/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/run-tests.shnew file mode 100755index 0000000000..043e6699ad--- /dev/null+++ b/apps/web/tauri/callkit_plugin/ios/Tests/OverlayHarness/run-tests.sh@@ -0,0 +1,28 @@+#!/usr/bin/env bash+set -euo pipefail++harness_dir="$(\cd "$(dirname "$0")" && pwd)"+test_dir="$(mktemp -d "${TMPDIR:-/tmp}/macro-call-overlay.XXXXXX")"+destination="${1:-platform=iOS Simulator,name=iPhone Air}"++# Resolve sources before generating outside the checkout. No generated Xcode+# project, downloaded SDK, or test result belongs in the production source tree.+python3 - "$harness_dir" "$test_dir" <<'PY'+from pathlib import Path+import re+import sys+source, output = map(Path, sys.argv[1:])+spec = (source / 'project.yml').read_text()+spec = re.sub(r'^(\s+- )(.*\.swift)$', lambda m: m[1] + str((source / m[2]).resolve()), spec, flags=re.M)+(output / 'project.yml').write_text(spec)+PY++echo "Native overlay test artifacts: $test_dir"+xcodegen generate --spec "$test_dir/project.yml" --project "$test_dir"+xcodebuild test \+ -project "$test_dir/CallOverlayHarness.xcodeproj" \+ -scheme CallOverlayHarness \+ -destination "$destination" \+ -derivedDataPath "$test_dir/DerivedData" \+ -resultBundlePath "$test_dir/results.xcresult" \+ -parallel-testing-enabled NOdiff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.mdindex 1be2f0c263..d9c38069c6 100644--- a/docs/AGENT_GUIDE/surfaces.md+++ b/docs/AGENT_GUIDE/surfaces.md@@ -1792,6 +1792,15 @@ A channel's `Calls` tab lists that channel's recordings with the same rows, filtby the channel id. Its search field matches call names and transcripts in thatchannel.+In the native iOS call drawer, the horizontal participant row excludes the person+shown in the large video. While holding or scrolling the row (including momentum),+the displayed primary and row membership stay fixed; speaking indicators still+update. The latest primary and membership update together after scrolling settles,+preserving a surviving participant's position where possible. Verify that dragging+does not pin someone, tapping pins the displayed person, and a participant who+leaves during a held touch cannot be selected. Exercise speaker changes and+departures during row gestures on a physical iPhone as well as the simulator.+If a recording fails to play, reload the page to obtain a fresh recording link,or use **Open or download recording**. The playback warning does not assumethat the failure is caused by an unsupported media format.