Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce sequencing for 'pane focus' related events #6349

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dzderic
Copy link

@dzderic dzderic commented Nov 2, 2024

Switching between panes (especially over domains where large latencies are involved) can cause a loop where we get stuck repeatedly switching back and forth between two panes. This happens because handlers of PaneFocused events can also produce these events, causing us to get stuck in a loop if we let the GUI process stale PaneFocused events.

The solution is to introduce a 'serial' (AKA 'sequence number') for GUI-initiated pane focus changes. This will be echo'd back by the server, which allows the GUI to avoid processing the response if it has sent a new request in the mean time. CLI-initiated pane focus changes (eg. via wezterm cli activate-pane) will continue to be unconditionally handled by the client.

Inspired by #4737 and #4737 (comment)

Verified activate-pane-direction, activate-pane and activate-tab still work correctly

closes: #4390
closes: #4693

Switching between panes (especially over domains where large latencies
are involved) can cause a loop where we get stuck repeatedly switching
back and forth between two panes. This happens because handlers of
`PaneFocused` events can also produce these events, causing us to get
stuck in a loop if we let the GUI process stale `PaneFocused` events.

The solution is to introduce a 'serial' (AKA 'sequence number') for
GUI-initiated pane focus changes. This will be echo'd back by the
server, which allows the GUI to avoid processing the response if it has
sent a new request in the mean time. CLI-initiated pane focus changes
(eg. via `wezterm cli activate-pane`) will continue to be unconditionally
handled by the client.

closes: wez#4390
closes: wez#4693
@@ -111,6 +116,7 @@ pub struct Mux {
num_panes_by_workspace: RwLock<HashMap<String, usize>>,
main_thread_id: std::thread::ThreadId,
agent: Option<AgentProxy>,
pane_focus_serial: RwLock<InputSerial>,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better place to put this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant