aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorppggff <pgf00a@gmail.com>2026-07-05 08:25:47 +0800
committerGitHub <noreply@github.com>2026-07-05 03:25:47 +0300
commit2bc1724c2dae72184a5d2ec070e30c70dc519f9b (patch)
tree573a960e82f832455d303ca97ea1783587482ad6 /src/client
parente713949ca51facf1e40c584b271f812f527bc522 (diff)
fix: switch prefix ASCII input source on the foreground client (#1016)
* fix: switch prefix ASCII input source on the foreground client The macOS prefix ASCII-switch ran in the headless server, whose TISCopyCurrentKeyboardInputSource read is a stale per-process cache (refreshed only via a main-run-loop notification the server never pumps), so prefix could leave the terminal on the wrong input source. Forward it to the foreground client, like clipboard: sync_prefix_input_source emits AppEvent::PrefixInputSource as an intent; the server forwards it to the foreground client and the monolithic app applies it in-process via RealPrefixInputSource, which pumps its main run loop before the stale TIS read. Key it on Mode::wants_ascii_input so multi-level prefix commands keep ASCII until returning to the terminal, and restore the IME for rename text entry. Adds ServerMessage::PrefixInputSource to the already-unreleased protocol 15. refs #774 * fix: keep prefix input-source switch out of the headless server process An App-internal drain (the exhaustive drain at the top of handle_api_request, reachable from prefix-key runtime mutations) can consume a queued PrefixInputSource intent before the server's forwarding drain sees it, applying the TIS switch in the headless server process and stranding the restore state. Gate the in-process switch on App.local_input_source_switch, disabled by the headless server alongside the other local side effects, so a swallowed intent degrades to a skipped switch. Widen the forwarding-bypass maintenance test to the handle_internal_event_with_prefix_sync wrapper. refs #774 * docs: clarify prefix input-source comments and flag docs refs #774 * fix: bump protocol for prefix input source refs #774 --------- Co-authored-by: Ogulcan Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/client')
-rw-r--r--src/client/mod.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs
index 6a70c79c..da0e4e53 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -1354,6 +1354,10 @@ async fn run_client_loop(
.set_nonblocking(false)
.map_err(ClientError::ConnectionFailed)?;
+ // This (foreground) client owns the prefix ASCII input-source switch; a no-op on non-macOS.
+ use crate::platform::PrefixInputSource;
+ let mut prefix_input_source = crate::platform::RealPrefixInputSource::default();
+
// Main event loop.
while !should_quit.load(Ordering::Acquire) {
let event = tokio::select! {
@@ -1560,6 +1564,13 @@ async fn run_client_loop(
host_mouse_capture_active.store(desired, Ordering::Release);
}
}
+ ServerMessage::PrefixInputSource { active } => {
+ if active {
+ prefix_input_source.switch_to_ascii();
+ } else {
+ prefix_input_source.restore();
+ }
+ }
ServerMessage::Welcome { .. } => {
debug!("received unexpected Welcome in main loop");
}