Repository navigation
Move dictionary lookup into a resident service process - #12
Closed
ArnauvGilotra wants to merge 4 commits into
Closed
ArnauvGilotra wants to merge 4 commits into
ArnauvGilotra wants to merge 4 commits into
Conversation
The dictionary was parsed on every switch into the IME. Introduce canto-dictd.exe: a per-user, windowless, resident process that loads the dictionary once and answers candidate-resolution requests over a per-user named pipe. The IME becomes a thin client. - CandidateEngine: the romanization -> candidate segmentation logic, factored out of the text service so it runs where the dictionary lives. - DictProtocol: a small message-framed pipe protocol (SETDICT / RESOLVE / PING) shared by client and service. - DictService: loads the user's dictionary at startup and serves lookups; single instance per user via a named mutex. - DictClient: connects (spawning the service if absent), pushes the dictionary selection, resolves buffers. Falls back to an in-process load if the service is unreachable, so the IME never breaks. - TextService no longer loads/holds the dictionary; BuildCandidates asks the client. Async-load plumbing removed. - Installer ships the service, starts it at each user's logon (HKLM Run), and stops it on uninstall. Loading now happens once per logon session (at startup or first use), not per activation.
The service should run only for users who have added CantoIME, not for everyone at logon. - Drop the unconditional HKLM logon autostart. - The IME registers a per-user logon autostart (HKCU Run) when it activates, i.e. when the keyboard has been added and used. Users who never add CantoIME never get it, so the service never starts for them. The IME also starts the service on demand at activation. - On update, the installer restarts the service only if that per-user marker already exists (keyboard added before), running it as the original user; a fresh install does not start it. - The installer stops any running service before copying files so an update swaps the executable cleanly, and removes the autostart marker on uninstall.
First-switch start was too late. Now the service starts early (at every user's logon, via HKLM Run) but self-gates: at startup it checks via TSF whether any CantoIME variant is enabled for the user (IsEnabledLanguage- Profile across all five variants) and exits immediately if not, so it never stays resident for users who have not added the keyboard. - Service: KeyboardIsAdded() check before loading; inconclusive -> run. - Installer: HKLM Run autostart for all users; start it once post-install (self-gates, so a fresh not-yet-added install just exits, an already- added update stays); still kills the old instance before an update. - Dropped the IME per-user autostart marker and the installer's ServiceWasEnabled logic (superseded by the self-gate).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The dictionary was parsed on every switch into the IME. This introduces
canto-dictd.exe: a per-user, windowless, resident process that loads the dictionary once and answers candidate-resolution requests over a per-user named pipe. The IME becomes a thin client, so loading happens once per logon session (at startup or first use), not per activation.Pieces
SETDICT/RESOLVE/PING), header-only, shared by client and service. Per-user pipe name (derived from the user SID).canto-dictd.exe) — loads the user's selected dictionary at startup and serves lookups; single instance per user via a named mutex; windowless (WIN32subsystem).SETDICT), resolves buffers. Falls back to an in-process load if the service is unreachable, so the IME never breaks.BuildCandidatesasks the client. The old background-load plumbing (WM_CANTO_DICT_READY/BeginLoadDictionary/OnDictionaryLoaded) is removed.Run, running as that user so it reads their settings), and stops it on uninstall.Design notes / open questions
SETDICTis authoritative and corrects it (e.g. a Simplified variant) on first activation.CI-verified compiling only. The real latency win + the service lifecycle (logon autostart, on-demand spawn, reconnect, uninstall kill) need testing on the VM.
🤖 Generated with Claude Code