noracu 0.3.0 → 0.3.2

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.
@@ -46,7 +46,7 @@ def app_switcher() -> None:
46
46
  x0, y0 = b.denormalize(0.5, 0.90)
47
47
  x1, y1 = b.denormalize(0.5, 0.45)
48
48
  src = inp._source()
49
- inp._require_focus() # F26 / R13 §3: before mouse-down
49
+ inp._require_focus() # before mouse-down
50
50
  cx, cy = x0, y0
51
51
  inp._mouse_event(inp.kCGEventLeftMouseDown, cx, cy, src)
52
52
  try:
@@ -60,7 +60,7 @@ def app_switcher() -> None:
60
60
  inp._mouse_event(inp.kCGEventLeftMouseDragged, nx, ny, src)
61
61
  cx, cy = nx, ny
62
62
  time.sleep(0.016)
63
- inp._require_focus() # R18: before the hold, the mirror must still be in front
63
+ inp._require_focus() # before the hold, the mirror must still be in front
64
64
  time.sleep(0.55) # hold to trigger the switcher
65
65
  finally:
66
66
  inp._mouse_event(inp.kCGEventLeftMouseUp, cx, cy, src)
@@ -75,7 +75,7 @@ def scroll_down(distance: float = 0.5) -> None:
75
75
  """Reveal content further down a list by about `distance` window heights.
76
76
 
77
77
  Uses trackpad-style scroll events; a vertical mouse drag does not scroll
78
- lists in iPhone Mirroring (F16). Swipes stay for gestures such as paging.
78
+ lists in iPhone Mirroring. Swipes stay for gestures such as paging.
79
79
  """
80
80
  b = get_bounds()
81
81
  inp.scroll_trackpad(-distance * b.height * _SCROLL_PX_PER_PT, bounds=b)
@@ -93,7 +93,7 @@ SCROLL_MIN_DIFF = 2.0
93
93
 
94
94
  def scroll_checked(direction, distance=0.5, *, luma=None, scroller=None,
95
95
  sleep=time.sleep, settle_s=0.6) -> bool:
96
- """Scroll by `distance` window heights and confirm the screen moved (F20).
96
+ """Scroll by `distance` window heights and confirm the screen moved.
97
97
 
98
98
  `direction` is "up" or "down"; `distance` is in window heights and
99
99
  must satisfy 0 < distance <= 3. Both are validated before anything
@@ -113,7 +113,7 @@ def scroll_checked(direction, distance=0.5, *, luma=None, scroller=None,
113
113
 
114
114
  Returns True when the screen changed by at least SCROLL_MIN_DIFF.
115
115
 
116
- Capture failures are never swallowed (F25): a WindowError or
116
+ Capture failures are never swallowed: a WindowError or
117
117
  CaptureError from the luma captures propagates to the caller (the
118
118
  CLI reports capture_failed) — an unreadable screen is not evidence
119
119
  that the scroll had no effect.
@@ -137,7 +137,7 @@ def scroll_checked(direction, distance=0.5, *, luma=None, scroller=None,
137
137
  return verify.mean_abs_diff(before, after) >= SCROLL_MIN_DIFF
138
138
 
139
139
 
140
- # F45 (device run 2026-11-07): iPhone Mirroring turns a mouse drag into pointer input, and a
140
+ # Device run 2026-11-07: iPhone Mirroring turns a mouse drag into pointer input, and a
141
141
  # pointer drag that starts on an app icon picks the icon up at once. A page swipe at mid-height
142
142
  # starts on an icon row: twice it carried an icon onto another one and made a folder (and left the
143
143
  # Home Screen in edit mode, where every icon shows a "−" delete badge). Page swipes start in the
@@ -149,19 +149,19 @@ PAGE_SWIPE_TO_NX = 0.1
149
149
 
150
150
 
151
151
  def page_left() -> None:
152
- """Swipe right-to-left: go to the next home-screen page (from the strip above the Dock, F45)."""
152
+ """Swipe right-to-left: go to the next home-screen page (from the strip above the Dock)."""
153
153
  inp.swipe(PAGE_SWIPE_FROM_NX, PAGE_SWIPE_NY, PAGE_SWIPE_TO_NX, PAGE_SWIPE_NY, duration_ms=280)
154
154
 
155
155
 
156
156
  def page_right() -> None:
157
- """Swipe left-to-right: go to the previous home-screen page (from the strip above the Dock, F45)."""
157
+ """Swipe left-to-right: go to the previous home-screen page (from the strip above the Dock)."""
158
158
  inp.swipe(PAGE_SWIPE_TO_NX, PAGE_SWIPE_NY, PAGE_SWIPE_FROM_NX, PAGE_SWIPE_NY, duration_ms=280)
159
159
 
160
160
 
161
161
  def pull_down_search() -> None:
162
162
  """Swipe down from mid-screen (DEPRECATED — never use for Spotlight).
163
163
 
164
- F13: iOS sometimes reads this swipe as an icon long-press-drag, which
164
+ iOS sometimes reads this swipe as an icon long-press-drag, which
165
165
  drops the home screen into edit (jiggle) mode — a stray tap on a "−"
166
166
  badge there offers to DELETE apps. open_spotlight() replaces it.
167
167
  Kept only as a raw gesture primitive; nothing in imctl calls it.
@@ -273,7 +273,7 @@ def open_spotlight() -> bool:
273
273
  """Open the phone's Spotlight search (View ▸ Spotlight).
274
274
 
275
275
  Never a swipe: the old pull-down could be misread by iOS as a
276
- long-press-drag that triggers home-screen edit mode (F13).
276
+ long-press-drag that triggers home-screen edit mode.
277
277
  """
278
278
  return _run_view_menu_command("Spotlight")
279
279
 
@@ -288,7 +288,7 @@ SPOTLIGHT_MIN_DIFF = 6.0
288
288
 
289
289
  def open_spotlight_checked(settle_s=1.0, *, luma=None, sleep=time.sleep, opener=None, home=None,
290
290
  home_settle_s=0.8, read_screen=None) -> bool:
291
- """Go to the Home Screen, open Spotlight, and confirm it (F17 guard).
291
+ """Go to the Home Screen, open Spotlight, and confirm it.
292
292
 
293
293
  Two layers of protection, in order:
294
294
 
@@ -308,7 +308,7 @@ def open_spotlight_checked(settle_s=1.0, *, luma=None, sleep=time.sleep, opener=
308
308
  SPOTLIGHT_MIN_DIFF (calibrated for the single home-screen →
309
309
  Spotlight transition).
310
310
 
311
- ③ F43 (2026-11-05 real-device, iOS 27): going Home from an app that
311
+ ③ 2026-11-05 real-device, iOS 27: going Home from an app that
312
312
  was opened from Spotlight lands back IN Spotlight, with the previous
313
313
  query and its Top Hit card. The Spotlight command then closed it, and
314
314
  that big change fooled layer ② into "opened" while the paste went to
@@ -351,7 +351,7 @@ def open_spotlight_checked(settle_s=1.0, *, luma=None, sleep=time.sleep, opener=
351
351
  if not home():
352
352
  return False
353
353
  sleep(home_settle_s)
354
- # F43: Home itself brought up a Top Hit card — Spotlight with the previous query: do not
354
+ # Home itself brought up a Top Hit card — Spotlight with the previous query: do not
355
355
  # toggle it shut. A card that was already there before Home may be another app's own
356
356
  # (Safari shows one too) with Home ignored; then, and when unsure, the gate below decides.
357
357
  if before_home == "none" and card() == "card":
@@ -381,7 +381,7 @@ SPOTLIGHT_HEADER_MAX_NY = 0.3
381
381
 
382
382
  # Spotlight's search field is in the bottom part of the window (ny >= SEARCH_FIELD_NY) and echoes
383
383
  # the typed query. choose_app_hit never takes a label there; open_app reads that echo as the proof
384
- # that a late paste has reached the phone (F42). 2026-11-06 device run (macOS 27.2 / iOS 27): the
384
+ # that a late paste has reached the phone. 2026-11-06 device run (macOS 27.2 / iOS 27): the
385
385
  # field is not always at the very bottom — it sat at ny ≈ 0.93 on one screen and floated at
386
386
  # ny ≈ 0.82 on others ("Q Search" read at 0.821 before typing, the query at 0.821–0.823 after),
387
387
  # where the old 0.88 bound never saw it: every unmatched name waited out the late-paste reads and
@@ -434,7 +434,7 @@ def _norm_label(s: str) -> str:
434
434
  return "".join(_LABEL_LOOKALIKES.get(ch, ch) for ch in s)
435
435
 
436
436
 
437
- # Two matching labels closer than this in both axes are one label read twice (choose_app_hit, Y6).
437
+ # Two matching labels closer than this in both axes are one label read twice (choose_app_hit).
438
438
  SAME_SPOT_EPS = 0.03
439
439
 
440
440
 
@@ -453,14 +453,14 @@ def choose_app_hit(hits: list, name: str, ambiguous: list | None = None) -> visi
453
453
  forbidden: "X" must never hit "Xcode" or "X Corp". Returns None
454
454
  when nothing qualifies.
455
455
 
456
- Y6 (review R37, 2026-11-07): when labels that match sit at two or
456
+ When labels that match sit at two or
457
457
  more different spots inside the card (more than SAME_SPOT_EPS apart
458
458
  in either axis), nothing says which one is the app, so none is
459
459
  chosen: the result is None and, when the caller passes a list as
460
460
  ``ambiguous``, True is appended to it. Matches at one spot (the same
461
461
  label read twice) are one label; the topmost of them is returned.
462
462
 
463
- F35 (2026-11-05 real-device): an exact label is not an app. The
463
+ 2026-11-05 real-device: an exact label is not an app. The
464
464
  query "Pinduoduo" matched a Chrome *suggestion* row of that name
465
465
  (the app's own Top Hit label reads 拼多多), the tap opened a web
466
466
  search, and the open was reported as confirmed. Only a row INSIDE
@@ -499,7 +499,7 @@ def choose_app_hit(hits: list, name: str, ambiguous: list | None = None) -> visi
499
499
  if hit.ny >= SEARCH_FIELD_NY:
500
500
  continue # the search field echoing the query
501
501
  if not lo < hit.ny <= hi:
502
- continue # outside the Top Hit card (F35) / the block under the top field
502
+ continue # outside the Top Hit card / the block under the top field
503
503
  found.append(hit)
504
504
  if not found:
505
505
  return None
@@ -507,7 +507,7 @@ def choose_app_hit(hits: list, name: str, ambiguous: list | None = None) -> visi
507
507
  if any(abs(h.nx - best.nx) > SAME_SPOT_EPS or abs(h.ny - best.ny) > SAME_SPOT_EPS for h in found):
508
508
  if ambiguous is not None:
509
509
  ambiguous.append(True)
510
- return None # Y6: several labels of the same name are never tapped
510
+ return None # several labels of the same name are never tapped
511
511
  return best
512
512
 
513
513
 
@@ -518,7 +518,7 @@ def find_app_hit(read_screen, name, attempts=2, delay_s=1.0, sleep=time.sleep,
518
518
  Each pass calls ``read_screen()`` for OCR hits and hands them to
519
519
  choose_app_hit(); a match returns immediately. Between passes we
520
520
  wait ``delay_s`` — Spotlight results can lag the keystrokes, so a
521
- single read races them (F17). No sleep after the last pass. Returns
521
+ single read races them. No sleep after the last pass. Returns
522
522
  None when no pass matches. ``read_screen`` and ``sleep`` are
523
523
  injectable so tests can drive this without a phone.
524
524
 
@@ -526,16 +526,16 @@ def find_app_hit(read_screen, name, attempts=2, delay_s=1.0, sleep=time.sleep,
526
526
  extra read per pass, with ``read_screen(language_correction=False)``:
527
527
  Vision's language correction tends to drop or rewrite
528
528
  single-character labels, and they are recognized more reliably
529
- without it. F27: Vision's full-frame pass can also skip such a label
529
+ without it. Vision's full-frame pass can also skip such a label
530
530
  entirely (the app "X" on 2026-11-04), so a short name that both
531
531
  reads miss gets a third read that adds the minimumTextHeight sweep
532
532
  to the default pass on the same frame —
533
- ``read_screen(language_correction=False, also_sweep=True)`` (F35:
533
+ ``read_screen(language_correction=False, also_sweep=True)`` (
534
534
  the Top Hit header must be in the same read as the label). The match
535
535
  stays exact either way. Long names keep the exact original
536
536
  read/sleep sequence. ``deadline`` (a ``clock()`` value) is checked
537
537
  before every read; once reached, no further read happens.
538
- ``ambiguous`` is handed to every choose_app_hit() call (Y6).
538
+ ``ambiguous`` is handed to every choose_app_hit() call.
539
539
  """
540
540
  short = len(_norm_label(name)) <= 2
541
541
 
@@ -544,7 +544,7 @@ def find_app_hit(read_screen, name, attempts=2, delay_s=1.0, sleep=time.sleep,
544
544
 
545
545
  reads = [{}]
546
546
  if short:
547
- # F35: the sweep finds the one-letter label, but choose_app_hit also
547
+ # The sweep finds the one-letter label, but choose_app_hit also
548
548
  # needs the "Top Hit" header from the SAME frame — the last read uses
549
549
  # both the default pass and the sweep (also_sweep), not the sweep alone.
550
550
  reads += [{"language_correction": False},
@@ -571,7 +571,7 @@ SPOTLIGHT_ICON_ABOVE_LABEL = 0.052
571
571
  # Top Hit 卡片的纵向范围:卡片内的行在 "Top Hit" 标题下方、且距标题不超过这个
572
572
  # 窗高比例。2026-11-05(macOS 27.2 / iOS 27)实测:标题 0.136,卡片内标签 0.24,
573
573
  # 下一个分区标题 "Suggestions" 0.294,第一条建议行 0.336 —— 0.15 落在卡片与
574
- # 建议区之间。choose_app_hit()(F35)与 open_app() 的图标兜底共用这一个值。
574
+ # 建议区之间。choose_app_hit()与 open_app() 的图标兜底共用这一个值。
575
575
  TOP_HIT_CARD_SPAN = 0.15
576
576
 
577
577
  # 待真机标定:打开 App 前后整窗 luma 帧差下限。
@@ -580,10 +580,10 @@ OPEN_MIN_DIFF = 12.0
580
580
  # open_app's own time budget (seconds). The server stops `open` at 45 s from outside; a run
581
581
  # that is killed there can leave Spotlight open with the name typed in. open_app checks this
582
582
  # budget before every read pass and tap and, once it is spent, goes back to the Home Screen
583
- # and reports "deadline" instead (F39).
583
+ # and reports "deadline" instead.
584
584
  OPEN_DEADLINE_S = 38.0
585
585
 
586
- # F42 (2026-11-05 real-device): a paste reached the phone anywhere from 1.5 s to more than 10 s
586
+ # 2026-11-05 real-device: a paste reached the phone anywhere from 1.5 s to more than 10 s
587
587
  # after Cmd+V — the text travels to the iPhone only when it pastes. When type_text did not see
588
588
  # the paste arrive, open_app keeps reading Spotlight, one pass a second, for up to this long
589
589
  # (within its budget). Once the search field shows the name, the query is in, and one more pass
@@ -632,7 +632,7 @@ OCR_MIN_CONFIDENCE, OCR_MIN_CONFIDENCE_PROBLEM = _min_confidence(os.environ.get(
632
632
 
633
633
 
634
634
  def _field_echo(hits, name) -> bool:
635
- """True when the search field shows ``name`` (F42).
635
+ """True when the search field shows ``name``.
636
636
 
637
637
  The field is the bottom zone (ny >= SEARCH_FIELD_NY); OCR may read the
638
638
  magnifier glyph in front of the text as a "Q". Compared after
@@ -711,7 +711,8 @@ def _top_field_for(hits, name):
711
711
  def _spotlight_up(hits, name=None) -> bool:
712
712
  """Spotlight is on screen: a "Top Hit" header near the top, or (top-field layout) the empty
713
713
  field's "Search or Ask", or a field line completed with a SPOTLIGHT_UP_ACTIONS word whose
714
- query is exactly ``name`` — or, without a name (the F43 check), completed with "Open" AND
714
+ query is ``name`` (as the field echo matches it: a letter or two that OCR misread still count —
715
+ taking Spotlight for gone reports an app open that is not) — or, without a name (the check), completed with "Open" AND
715
716
  with that query's label in the label band under it. Any other line in that zone (the
716
717
  notification strip: a banner can read "X - Y" or even "X - Open") is no evidence."""
717
718
  header = _tophit_header(hits)
@@ -722,12 +723,12 @@ def _spotlight_up(hits, name=None) -> bool:
722
723
  if query == "search or ask":
723
724
  return True
724
725
  if want is not None:
725
- if action in SPOTLIGHT_UP_ACTIONS and query == want:
726
+ if action in SPOTLIGHT_UP_ACTIONS and _echo_matches(query, want):
726
727
  return True
727
728
  elif action in OPEN_COMPLETION_ACTIONS and any(
728
729
  _norm_label(h.text) == query and ny + TOP_FIELD_LABEL_MIN < h.ny <= ny + TOP_FIELD_CARD_SPAN
729
730
  for h in hits):
730
- # without a name to match (the F43 check after Home), an "Open" completion counts
731
+ # without a name to match (the check after Home), an "Open" completion counts
731
732
  # only with Spotlight's own structure under it — that query's label in the label band;
732
733
  # a banner that happens to read "Calendar - Open" has none
733
734
  return True
@@ -740,10 +741,13 @@ def _tophit_header(hits):
740
741
  Matched exactly after _norm_label (case-folding, trailing
741
742
  punctuation) against TOP_HIT_LABELS, so a list row that merely
742
743
  contains the words can never pose as the card header. Several
743
- matches → the first in reading order (the topmost).
744
+ matches → the first in reading order (the topmost). Only in the
745
+ top part of the screen (SPOTLIGHT_HEADER_MAX_NY), where Spotlight
746
+ draws the card: the same words further down — a row of a list, a
747
+ line of a page — are not the header, for any caller.
744
748
  """
745
749
  for hit in hits:
746
- if _norm_label(hit.text) in TOP_HIT_LABELS:
750
+ if _norm_label(hit.text) in TOP_HIT_LABELS and hit.ny < SPOTLIGHT_HEADER_MAX_NY:
747
751
  return hit
748
752
  return None
749
753
 
@@ -759,7 +763,7 @@ def home_via_menu(timeout: float = TIDY_OSASCRIPT_TIMEOUT_S) -> bool:
759
763
 
760
764
 
761
765
  def _tap_and_confirm_open(nx, ny, *, luma, sleep, tap, read_screen, name=None):
762
- """Tap (nx, ny) and confirm the app actually opened (F24 ②).
766
+ """Tap (nx, ny) and confirm the app actually opened.
763
767
 
764
768
  One luma frame before the tap, one after a 1.0s settle, then one
765
769
  OCR read. The tap counts as opened only when BOTH hold: the
@@ -801,21 +805,21 @@ def open_app(name: str, *, spotlight_open: bool = False,
801
805
  menu command silently failed, clear_text() (Cmd+A + Delete) would
802
806
  land in whatever focused text field the frontmost app shows (a
803
807
  note body, a message draft…) and wipe it — so on a failed gate
804
- this does nothing at all: no clearing, no typing, no taps (F17
808
+ this does nothing at all: no clearing, no typing, no taps (the
805
809
  safety gate).
806
810
 
807
811
  The search field is cleared (Cmd+A + Delete) before typing: iOS
808
812
  keeps the previous Spotlight query, so the new name would be
809
- appended to it and no result row would match (F17). Results are
813
+ appended to it and no result row would match. Results are
810
814
  then read up to twice (find_app_hit) because they can lag the
811
815
  keystrokes — or, when type_text did not see the paste arrive, once a
812
- second for up to OPEN_LATE_PASTE_S (F42): once the search field shows
816
+ second for up to OPEN_LATE_PASTE_S: once the search field shows
813
817
  the name, one more pass.
814
818
 
815
819
  The top hit is never opened with Return — it may belong to a
816
820
  different app than the requested one.
817
821
 
818
- F24 (2026-11-03 real-device retest): a tapped row is not an
822
+ 2026-11-03 real-device retest: a tapped row is not an
819
823
  opened app. On iOS 27 Spotlight the OCR hit can be the Top Hit
820
824
  card's label UNDER the app icon, and tapping that label text
821
825
  does nothing — the screen stays on Spotlight while the caller
@@ -824,11 +828,12 @@ def open_app(name: str, *, spotlight_open: bool = False,
824
828
  ① stability — wait 0.5s, re-read, re-pick with choose_app_hit.
825
829
  When the row moved by more than 0.02 the results were still
826
830
  reflowing: the second read wins, with at most one more read
827
- (still moving → the last read is authoritative).
831
+ (still moving → the last read is authoritative; the name gone from
832
+ that read → nothing is tapped, "gone").
828
833
  ② tap the row, then confirm via _tap_and_confirm_open (frame
829
834
  diff ≥ OPEN_MIN_DIFF and the "Top Hit" header gone).
830
835
  ③ when that tap did nothing and the post-tap read still shows the
831
- exact label inside the Top Hit card (choose_app_hit, F35), tap the
836
+ exact label inside the Top Hit card (choose_app_hit), tap the
832
837
  icon SPOTLIGHT_ICON_ABOVE_LABEL above THAT label and confirm the
833
838
  same way. Otherwise NO second tap: an upward offset from a stale
834
839
  position could land on a different app's row.
@@ -836,7 +841,7 @@ def open_app(name: str, *, spotlight_open: bool = False,
836
841
  Home Screen), reported as not_confirmed.
837
842
 
838
843
  A capture failure after the hit is found (WindowError /
839
- CaptureError, F25) counts as unconfirmed — no further taps.
844
+ CaptureError) counts as unconfirmed — no further taps.
840
845
 
841
846
  Returns "opened"; "not_found" (a Top Hit card was seen, but never
842
847
  with exactly this name; back on the Home Screen); "no_top_hit" (no
@@ -853,9 +858,9 @@ def open_app(name: str, *, spotlight_open: bool = False,
853
858
  Top Hit card and the search field alike, so whether it was typed or
854
859
  the app exists is unknown — nothing was tapped; back on the Home Screen);
855
860
  "deadline" (the OPEN_DEADLINE_S budget ran out before a tap; back on
856
- the Home Screen); "ambiguous" (Y6: the Top Hit card showed the name at
861
+ the Home Screen); "ambiguous" (the Top Hit card showed the name at
857
862
  two or more spots and no read showed it at one — nothing was tapped;
858
- back on the Home Screen); "low_confidence" (NORACU_OCR_MIN_CONFIDENCE is set and the label was read below it: nothing tapped; back on the Home Screen); "focus_lost" (another app came to the front
863
+ back on the Home Screen); "gone" (the card showed the name, then no longer did — at two more reads, or at the read after the row moved: nothing tapped; back on the Home Screen); "low_confidence" (NORACU_OCR_MIN_CONFIDENCE is set and the label was read below it: nothing tapped; back on the Home Screen); "focus_lost" (another app came to the front
859
864
  during type_text's wait after the clipboard write: the paste was called
860
865
  off and nothing was tapped; Spotlight is left as it is — going Home
861
866
  would pull the mirror forward again); "clipboard_changed" (another app or
@@ -892,7 +897,7 @@ def open_app(name: str, *, spotlight_open: bool = False,
892
897
  pending: list = []
893
898
  if type_text is None:
894
899
  def type_text(text):
895
- # F42: never give the clipboard back here — the name can reach the phone more
900
+ # Never give the clipboard back here — the name can reach the phone more
896
901
  # than 10 s after Cmd+V, and Spotlight can show it in its own suggestions before
897
902
  # that; a restore in between would paste the user's clipboard into the search
898
903
  return inp.type_text(text, pending=pending, restore=False)
@@ -900,18 +905,18 @@ def open_app(name: str, *, spotlight_open: bool = False,
900
905
  deadline = None if deadline_s is None else clock() + deadline_s
901
906
  saw_top_hit = [False]
902
907
  saw_echo = [False]
903
- ambiguous: list = [] # Y6: a read showed the name at two or more spots in the card
908
+ ambiguous: list = [] # a read showed the name at two or more spots in the card
904
909
 
905
910
  def read_screen(**kwargs):
906
- # F33: every later read is also evidence for a clipboard restore an
907
- # injected type_text may have handed over (the default never does: F42).
911
+ # Every later read is also evidence for a clipboard restore an
912
+ # injected type_text may have handed over (the default never does).
908
913
  hits = raw_read(**kwargs)
909
914
  for restore in pending:
910
915
  restore.offer(hits)
911
916
  if _tophit_header(hits) is not None:
912
917
  saw_top_hit[0] = True # tells "not_found" apart from "no_top_hit"
913
918
  if _field_echo(hits, name):
914
- saw_echo[0] = True # F42: the name is in the search field — the paste arrived
919
+ saw_echo[0] = True # the name is in the search field — the paste arrived
915
920
  return hits
916
921
 
917
922
  def out_of_time():
@@ -920,15 +925,15 @@ def open_app(name: str, *, spotlight_open: bool = False,
920
925
  short = len(_norm_label(name)) <= 2
921
926
 
922
927
  def reread():
923
- # F32: the default pass alone keeps missing a one-letter label, and
928
+ # The default pass alone keeps missing a one-letter label, and
924
929
  # a missed row looked like a moved row — the tap then went to a
925
930
  # different row ("X" opened a Chrome search). Short names read the
926
931
  # same frame with the sweep too.
927
932
  return read_screen(also_sweep=True) if short else read_screen()
928
933
 
929
- # F34: one retry — on the device the Spotlight command was once ignored
934
+ # One retry — on the device the Spotlight command was once ignored
930
935
  # right after an app closed. Each try goes Home first; when Home lands back in
931
- # Spotlight (iOS 27, F43) the gate reports it open instead of toggling it shut.
936
+ # Spotlight (iOS 27) the gate reports it open instead of toggling it shut.
932
937
  if not spotlight_open and not (open_spotlight_checked()
933
938
  or open_spotlight_checked()):
934
939
  return "spotlight_unavailable"
@@ -937,11 +942,18 @@ def open_app(name: str, *, spotlight_open: bool = False,
937
942
  # NORACU_PHONE_TIMEOUT_MS, or a slow start) — do not clear or type at all
938
943
  tidy()
939
944
  return "deadline"
940
- clear_text() # iOS kept the last query; new input would append (F17)
945
+ clear_text() # iOS kept the last query; new input would append
941
946
  sleep(0.3)
942
947
  try:
943
948
  typed = type_text(name)
944
- except inp.PasteFocusLost:
949
+ except (WindowError, vision.CaptureError) as exc:
950
+ # the capture before ⌘V failed: open_app's caller reports capture_failed — with the clipboard's state
951
+ if report is not None and getattr(exc, "restore_failed", False):
952
+ report["restore_failed"] = exc.restore_failed
953
+ raise
954
+ except inp.PasteFocusLost as exc:
955
+ if report is not None and getattr(exc, "restore_failed", False):
956
+ report["restore_failed"] = exc.restore_failed
945
957
  # 0.2.7: another app came to the front during the wait after the clipboard write;
946
958
  # the paste was called off. No trip Home: that would pull the mirror forward again, the
947
959
  # very thing the paste refused to do (Spotlight closes by itself when left idle).
@@ -960,7 +972,7 @@ def open_app(name: str, *, spotlight_open: bool = False,
960
972
  hit = find_app_hit(read_screen, name, attempts=2, sleep=sleep,
961
973
  deadline=deadline, clock=clock, ambiguous=ambiguous)
962
974
  if hit is None and not saw_echo[0]:
963
- # F33/F42: the name is not in the search field yet — the paste may still be on its
975
+ # The name is not in the search field yet — the paste may still be on its
964
976
  # way, whether type_text missed it or took another change for it (a clear that
965
977
  # landed late redraws the results: seen on the device after a back-to-back open)
966
978
  limit = clock() + (OPEN_LATE_SHORT_S if short else OPEN_LATE_PASTE_S)
@@ -993,13 +1005,13 @@ def open_app(name: str, *, spotlight_open: bool = False,
993
1005
  if out_of_time():
994
1006
  return "deadline"
995
1007
  if ambiguous:
996
- return "ambiguous" # Y6: the card showed the name at more than one spot
1008
+ return "ambiguous" # the card showed the name at more than one spot
997
1009
  if short:
998
1010
  # OCR misses one- and two-letter text in the card and in the field alike: neither
999
1011
  # "not typed" nor "not found" is known — say that instead (2026-11-06 device run)
1000
1012
  return "short_unreadable"
1001
1013
  if not saw_echo[0]:
1002
- return "not_typed" # F42: the name never showed up in the search field
1014
+ return "not_typed" # the name never showed up in the search field
1003
1015
  return "not_found" if saw_top_hit[0] else "no_top_hit"
1004
1016
 
1005
1017
  try:
@@ -1012,9 +1024,24 @@ def open_app(name: str, *, spotlight_open: bool = False,
1012
1024
  split: list = []
1013
1025
  again = choose_app_hit(reread(), name, split)
1014
1026
  if split:
1015
- # Y6: this read shows the name at two or more spots — tap none of them
1027
+ # This read shows the name at two or more spots — tap none of them
1016
1028
  tidy()
1017
1029
  return "ambiguous"
1030
+ if again is None:
1031
+ # The card does not show the name at this read. One missed read is common with OCR; a
1032
+ # row that moved away or was replaced is what this re-read is for. So read once more,
1033
+ # and tap nothing unless the name is back in the card: the first position is old by
1034
+ # then, and a tap on whatever sits there now could open another app.
1035
+ if out_of_time():
1036
+ tidy()
1037
+ return "deadline"
1038
+ again = choose_app_hit(reread(), name, split)
1039
+ if split:
1040
+ tidy()
1041
+ return "ambiguous"
1042
+ if again is None:
1043
+ tidy()
1044
+ return "gone"
1018
1045
  if again is not None:
1019
1046
  if math.hypot(again.nx - hit.nx, again.ny - hit.ny) > 0.02:
1020
1047
  # the row moved: the second read wins, with at most
@@ -1024,9 +1051,13 @@ def open_app(name: str, *, spotlight_open: bool = False,
1024
1051
  if split:
1025
1052
  tidy()
1026
1053
  return "ambiguous"
1027
- if (once_more is not None
1028
- and math.hypot(once_more.nx - hit.nx,
1029
- once_more.ny - hit.ny) > 0.02):
1054
+ if once_more is None:
1055
+ # the results were still moving and this read does not show the name: the second
1056
+ # read's position is old by now, and a tap on whatever sits there could open another
1057
+ # app — tap nothing, as when the second read missed the name
1058
+ tidy()
1059
+ return "gone"
1060
+ if math.hypot(once_more.nx - hit.nx, once_more.ny - hit.ny) > 0.02:
1030
1061
  hit = once_more
1031
1062
  # else: the two reads agree — the first hit stands
1032
1063
 
@@ -1042,7 +1073,7 @@ def open_app(name: str, *, spotlight_open: bool = False,
1042
1073
  return "low_confidence" # opt-in: a label read below the minimum is not tapped
1043
1074
  # ② tap the row (the label inside the Top Hit card) and confirm.
1044
1075
  # The post-tap read uses reread(): for a short name it also sweeps,
1045
- # so ③ can find the label again (F32/F35).
1076
+ # so ③ can find the label again.
1046
1077
  opened, hits = _tap_and_confirm_open(
1047
1078
  hit.nx, hit.ny, luma=luma, sleep=sleep, tap=tap,
1048
1079
  read_screen=reread, name=name)
@@ -1051,7 +1082,7 @@ def open_app(name: str, *, spotlight_open: bool = False,
1051
1082
 
1052
1083
  # ③ the label tap did nothing → tap the icon above the label, but
1053
1084
  # only where the post-tap read shows that label inside the Top Hit
1054
- # card NOW (choose_app_hit, F35) — never the first read's position:
1085
+ # card NOW (choose_app_hit) — never the first read's position:
1055
1086
  # the results may have changed. No such label → no second tap.
1056
1087
  again = choose_app_hit(hits, name)
1057
1088
  if (again is not None and OCR_MIN_CONFIDENCE is not None
@@ -1068,7 +1099,7 @@ def open_app(name: str, *, spotlight_open: bool = False,
1068
1099
  except Exception as exc:
1069
1100
  if not verify.is_capture_error(exc):
1070
1101
  raise
1071
- # F25: an unreadable screen is not evidence the app opened —
1102
+ # An unreadable screen is not evidence the app opened —
1072
1103
  # no further taps; wrap up unconfirmed below.
1073
1104
 
1074
1105
  # ④ leave the phone tidy and say the taps were not confirmed
@@ -1087,7 +1118,7 @@ def status() -> dict:
1087
1118
  Keys: running; and when running: window {x,y,w,h} (AX bounds), window_id, onscreen, frontmost,
1088
1119
  live (True/False/null — is the phone stream up), overlay (text shown over the stream when not
1089
1120
  live, e.g. a paused/connecting notice), paused (True/False, or null when the state is unknown),
1090
- setup (True when the overlay is a setup / welcome screen the user must finish — F37; then
1121
+ setup (True when the overlay is a setup / welcome screen the user must finish; then
1091
1122
  paused is False: there is no Resume control to press).
1092
1123
  """
1093
1124
  from .window import (
@@ -1129,7 +1160,7 @@ def launch() -> bool | None:
1129
1160
  """Ensure iPhone Mirroring is running, frontmost, and not paused.
1130
1161
 
1131
1162
  Returns the stream state afterwards: True live, False still paused or connecting,
1132
- None unknown. F29: resume()'s result used to be dropped, so phone_launch reported
1163
+ None unknown. resume()'s result used to be dropped, so phone_launch reported
1133
1164
  "ready" while the overlay was still up.
1134
1165
  """
1135
1166
  ensure_running()