Skip to content

fix: stop cross-window iTerm2 jumps from failing with Invalid index - #10

Merged
Lee-W merged 1 commit into
mainfrom
fix/iterm2-cross-window-focus
Jul 25, 2026
Merged

fix: stop cross-window iTerm2 jumps from failing with Invalid index#10
Lee-W merged 1 commit into
mainfrom
fix/iterm2-cross-window-focus

Conversation

@Lee-W

@Lee-W Lee-W commented Jul 25, 2026

Copy link
Copy Markdown
Owner

The iTerm2 focuser walked windows with repeat with w in windows, whose loop variable is a positional reference (item M of every window). When window order shifted mid-scan — which happens right after another jump, or when you click a different window — the next access raised AppleScript error -1719 and the jump failed outright. Measured: jumping back and forth between two iTerm2 windows failed 3/3 on the return jump.

The scan now addresses windows by index inside a retry: if the order moves under it, it rescans instead of failing. After select, the tab and session are re-located relative to current window rather than the stale scan position, and the result is verified against current session of current window before reporting success — a jump that cannot raise the window (a window on another Space, for example) now reports "找不到⋯沒浮到前景" instead of silently claiming it jumped.

Every jump attempt is now logged to ~/.config/ring/focus.jsonl with each focuser's answer, so an intermittent "it didn't jump" can be attributed afterwards instead of relying on a toast nobody kept.

The iTerm2 focuser walked windows with `repeat with w in windows`, whose loop
variable is a positional reference (`item M of every window`). When window
order shifted mid-scan — which happens right after another jump, or when you
click a different window — the next access raised AppleScript error -1719 and
the jump failed outright. Measured: jumping back and forth between two iTerm2
windows failed 3/3 on the return jump.

The scan now addresses windows by index inside a retry: if the order moves
under it, it rescans instead of failing. After `select`, the tab and session
are re-located relative to `current window` rather than the stale scan
position, and the result is verified against `current session of current
window` before reporting success — a jump that cannot raise the window (a
window on another Space, for example) now reports "找不到⋯沒浮到前景" instead
of silently claiming it jumped.

Every jump attempt is now logged to `~/.config/ring/focus.jsonl` with each
focuser's answer, so an intermittent "it didn't jump" can be attributed
afterwards instead of relying on a toast nobody kept.
@Lee-W
Lee-W merged commit cba7851 into main Jul 25, 2026
4 checks passed
@Lee-W
Lee-W deleted the fix/iterm2-cross-window-focus branch July 25, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant