aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-10-25 06:41:34 +0200
committerIgor Soarez <igor@soarez.org>2026-10-25 06:41:34 +0200
commitb77427190408cbe3ebea5677cd67bce53e73f313 (patch)
treeacffe9de5554747d0ff505e4428a748e2c40ae7d /tests
parentdd3462c3cd0a7ff8dbb31c5b4e6d133a04506419 (diff)
terminals: ask Ghostty only once focus has settled
across a Space switch (a full screen window) tmux sees the new client focused about 0.3 s before Ghostty's front window changes, so learn paired the client with the terminal that had focus. live, raising a full screen window and back crossed the two pairings, and from then on every jump raised the wrong window (old binary: 0 of 10 jumps right). learn now waits a second before asking Ghostty, then still requires the client to be focused. it also drops pairings of clients no longer attached, which piled up with every closed window. e2e step 20: Ghostty lagging behind tmux's focus, crossed pairings healing, pruning; the old learn fails all five. live, two Ghostty windows, one full screen: 16 of 16 jumps right, starting from crossed pairings.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/e2e.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/e2e.sh b/tests/e2e.sh
index f874c15..13a698f 100755
--- a/tests/e2e.sh
+++ b/tests/e2e.sh
@@ -737,6 +737,26 @@ r switch-client -c "$TTY1" -t '=elsewhere'
renv "$DINGGER" focus --pane "$AG"
expect "a window already on the agent's session wins over a more recent one" "tail -1 $DIR/ghostty-raised" BBBB-2222 50
expect "and the other window is not moved" "client_session $TTY1" elsewhere
+# Across a Space switch Ghostty still names the terminal that had focus
+# for a moment: the other window's.
+focus_out viewer; focus_in viewer2 AAAA-1111
+sleep 0.5; echo BBBB-2222 >"$DIR/ghostty-focused"
+sleep 1
+expect "Ghostty lagging behind tmux's focus: the right terminal" "paired $TTY2" BBBB-2222 50
+expect "and the other window keeps its own" "paired $TTY1" AAAA-1111
+# Pairings crossed (as the lag used to leave them): Ghostty's lagging
+# answer is then the client's own wrong terminal.
+r set -g "@dingger_terminal_$(basename "$TTY1")" "1 BBBB-2222 $FAKE_APP"
+r set -g "@dingger_terminal_$(basename "$TTY2")" "1 AAAA-1111 $FAKE_APP"
+focus_out viewer2; focus_in viewer2 AAAA-1111
+sleep 0.5; echo BBBB-2222 >"$DIR/ghostty-focused"
+expect "crossed pairings heal: the focused client's" "paired $TTY2" BBBB-2222 50
+expect "and the other's wrong one is dropped" "paired $TTY1" ""
+focus_out viewer2; focus_in viewer AAAA-1111
+expect "until its next focus" "paired $TTY1" AAAA-1111 50
+r set -g @dingger_terminal_ttysgone "1 DDDD-4444 $FAKE_APP"
+focus_out viewer; focus_in viewer2 BBBB-2222
+expect "a client no longer attached loses its pairing" "r show -gv @dingger_terminal_ttysgone 2>/dev/null" "" 50
echo viewer >"$DIR/ghostty-race"; : >"$DIR/ghostty-queries"
focus_in viewer CCCC-3333
expect "Ghostty asked" "wc -l <$DIR/ghostty-queries | tr -d ' '" 1 50