What's New
fix(smart-switch): restore per-app language on app entry, not from an AX pass
Since 95af7cd, Smart Switch ran only inside the AX pass the app-switch block
schedules. AX passes are last-writer-wins: any newer one drops the pass in
flight. The switch clears the confirmed injection method, so the first keystroke
in the new app asks the tap for a detection pass, and that pass superseded the
app-switch one without publishing any app context. A click's focus check, or a
title-change pass with an unchanged title, did the same. In Electron apps (Slack,
Claude Desktop), whose AX round-trips run up to the 0.25s messaging timeout, the
user nearly always types or clicks before the pass lands, so the saved language
was never restored for that activation. Native apps finish the pass first, which
is why the feature looked intermittent.
Split AppContext into entries and refinements with appliesSmartSwitch:
- Entries (TapEventSource.start, app activation, overlay open and close) are
published synchronously from the bundle ID alone. Only an entry restores or
records an app's language, reloads the per-app map, and sets
smartSwitchHandledBundleId.
- Every AX pass publishes a refinement that re-applies the exclusion and
window-title rules. That includes the detection pass, a focus check with no
focused element, and a title pass whose title did not change, so a superseded
pass no longer loses the rules either. A pass that lands while a launcher is
open describes the launcher, not the app beneath it. Re-evaluating after the
Window Title Rules hotkey is a refinement too.
- An entry has no window title, so it cannot tell that no rule covers the window.
AppPolicyRuntime.inputSourceRuleAction now decides the target-input-source rule
and only restores the pre-rule source from a context that has the title.
Restoring from the entry flipped the source out and back on every Spotlight
close in a rule-switched window. App-wide rules still switch at entry.
Two sticky decisions also left typing broken:
.restoreVietnamese stayed the handler's decision, so the user's next toggle
changed the menu bar but not the typing. It is now applied once.
- A disabled input source stored
.disableTransformation, and switching back to
ABC never cleared it. It is now a separate inputSourceEnabled gate. The gate
is read for overlays too, since the source is global, and
handleInputSourceChange updates it. Under such a source the rules still apply,
but no app's language is restored or recorded. handleInputSourceChange then
restores the language from a freshly loaded map, because returning from
XKeyIM there was no entry to reload it.
Remove what this left dead, and what was already dead:
- AppDelegate's handleSmartSwitch, restoreLanguageForCurrentApp,
enableVietnameseForOverlay, saveLanguageForOverlay and overlayNameToBundleId.
- VNEngine's checkSmartSwitchForApp, checkSmartSwitch, handleAppSwitch and
getCurrentAppBundleId.
- SmartSwitchManager's saveToPlist (a whole-map write that dropped the other
process's entries), removeApp, clearAll and getAllApps, plus
SharedSettings.setSmartSwitchData.
- TapEventSource's focusCheckObserver, which observed an NSWorkspace
notification on NotificationCenter.default and so never fired.
Bump the build number to 20260929.