Skip to content

Commit 7aadb66

Browse files
authored
Merge pull request #24 from ThinkOffApp/fix/gemini-gui-nudge-wake
Make GUI wake reliable + fail loud instead of silent no-op
2 parents c47ed75 + 3ec29b1 commit 7aadb66

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

tools/gemini_gui_nudge.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,19 @@ on run argv
6161
-- gone to the wrong app. petrus saw silent wake drops because of
6262
-- this. New: ACTIVATE → SET FRONTMOST → VERIFY → keystroke. Bail
6363
-- without typing if we can't make target frontmost in 5 tries.
64-
do shell script "open -a " & quoted form of appName
64+
-- Use `open -a` first: it forces a launch + focus more reliably than
65+
-- AppleScript's `activate` when the app is hidden/minimized or another
66+
-- app is holding focus (full-screen, Mission Control, modal).
67+
try
68+
do shell script "open -a " & quoted form of appName
69+
end try
70+
tell application appName to activate
6571
delay 0.3
6672
73+
-- Bumped 5x0.2s (1s budget) to 15x0.5s (7.5s budget). Stuck-poller
74+
-- incidents on 2026-05-04 traced to ABORTs that cleared on the very
75+
-- next nudge — the activate path needs more time when the user is
76+
-- across spaces or in another full-screen window.
6777
set focusOk to false
6878
set focusAttempts to 0
6979
repeat while focusAttempts < 15
@@ -89,7 +99,12 @@ on run argv
8999
90100
if not focusOk then
91101
log "gui_nudge: ABORT — could not bring " & appName & " to front after 15 attempts"
92-
return
102+
-- Throw an AppleScript error so osascript exits non-zero and the
103+
-- outer wake.sh can distinguish 'failed silently' from 'nudge sent'.
104+
-- Without this the previous code did `return`, osascript exited 0,
105+
-- and wake.sh logged 'nudge sent' for what was actually a no-op.
106+
-- Confirmed bite on 2026-05-05 (3+ hours of silent ABORTs).
107+
error "gui_nudge could not bring " & appName & " to front" number 100
93108
end if
94109
95110
try

0 commit comments

Comments
 (0)