From 2bc1724c2dae72184a5d2ec070e30c70dc519f9b Mon Sep 17 00:00:00 2001 From: ppggff Date: Sun, 5 Jul 2026 08:25:47 +0800 Subject: 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 --- docs/next/CHANGELOG.md | 1 + docs/next/api/herdr-api.schema.json | 2 +- docs/next/website/src/content/docs/configuration.mdx | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/next/CHANGELOG.md b/docs/next/CHANGELOG.md index 27249ac6..cf684726 100644 --- a/docs/next/CHANGELOG.md +++ b/docs/next/CHANGELOG.md @@ -13,6 +13,7 @@ - Added `ui.hide_tab_bar_when_single_tab` to hide the tab row when a workspace has one tab. (#448) ### Changed +- Bumped the client/server protocol version to 16 for foreground-client prefix input-source switching. - Bumped the client/server protocol version to 15 for socket API placement mutation event and response compatibility. ### Fixed diff --git a/docs/next/api/herdr-api.schema.json b/docs/next/api/herdr-api.schema.json index c061e482..4b33e750 100644 --- a/docs/next/api/herdr-api.schema.json +++ b/docs/next/api/herdr-api.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "protocol": 15, + "protocol": 16, "schema_version": 1, "schemas": { "error_response": { diff --git a/docs/next/website/src/content/docs/configuration.mdx b/docs/next/website/src/content/docs/configuration.mdx index 0305a670..b17107df 100644 --- a/docs/next/website/src/content/docs/configuration.mdx +++ b/docs/next/website/src/content/docs/configuration.mdx @@ -500,14 +500,14 @@ The trade-off when enabled: an extra hardware cursor is visible in the outer ter On macOS, prefix-mode commands can be hard to use while a non-ASCII input source is active because prefix commands are still interpreted through the host input source. -Set `switch_ascii_input_source_in_prefix = true` to switch the host input source to the system ASCII-capable input source while prefix mode is active: +Set `switch_ascii_input_source_in_prefix = true` to switch the host input source to the system ASCII-capable input source while prefix commands and prefix-launched navigation are active: ```toml [experimental] switch_ascii_input_source_in_prefix = false ``` -When enabled, Herdr switches input sources only after prefix mode is entered, then restores the previous input source when prefix mode exits. The setting is macOS-only and is a no-op on other platforms or when the system input-source switch fails. +When enabled, Herdr switches input sources after prefix mode is entered, keeps the ASCII source across prefix-launched modes such as navigation, menus, resize, and copy mode, and restores the previous input source when returning to the terminal or entering a text field such as a rename dialog. The setting is macOS-only and is a no-op on other platforms or when the system input-source switch fails. You can also toggle it from Settings > Experiments > switch to ascii input source in prefix (macOS). -- cgit v1.2.3