Repository navigation
Learn from typing to personalise word prediction - #1030
Merged
Merged
Conversation
A per-computer Learn from my typing setting, on by default and outside the synced schema, lets the isolated prediction worker open a personal SQLite file in this computer's app data. The worker learns each completed sentence once, when the next begins, so a correction after the punctuation is learned corrected. Enter or Tab learns the text so far through a new private End edit. Other context loss learns the completed words but not one in progress. Only verified Switchify keyboard input, the existing prediction buffer, is learned. Changing the setting replaces the worker at the next keyboard update. Forget learned words replaces any worker holding the file and deletes it and its journals, finishing once no worker holds it and before any worker reopens it. A personal file that cannot be opened leaves prediction working unlearned. switchify-prediction is pinned to incremental learning (about 9 ms per sentence instead of about 190 ms). Worker release assets are unchanged. Closes #1029 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Forget learned words now records the request on disk and kills the spare at once. A spare started while forgetting, or after learning changed, never opens the personal file. Deletion finishes once no worker holds it, and a restart finishes it before any worker starts. The page says whether the words are gone. The pending request is main-thread state, like the workers. Replacing a worker after learning changed fails a suggestion being accepted, as a missed deadline does, so the keyboard never waits on the old worker. A full buffer is learned in long pieces up to a word boundary 256 characters from the end, rather than word by word, keeping phrases and leaving recent words correctable. Word boundaries are tested by grapheme, so a combining accent stays with its letter. Refs #1029 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deleting an open file succeeds on macOS, so Forget only deletes when no keyboard worker has the personal file; otherwise the worker is replaced at its next update and the deletion finishes then. A request left by an earlier run finishes at startup. The learning generation, like the forgetting state, is main-thread state, since settings are saved and workers run there. Refs #1029 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each Windows fake worker is a PowerShell process. The new tests started eight, enough to starve the kill-and-reap timing test after a rebuild. Tests that only need an absent or refused worker no longer start one. Refs #1029 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
switchifyapp/switchify-prediction#30 keeps learned counts apart from the baseline. One learned use counts as up to 500 baseline uses, less as more is learned, and a word the baseline lacks or has seen fewer than three times counts once learned twice. On a synthetic person, learned words reach the suggestions for 46% of queries instead of 1%, with no misspelling suggested. The library no longer copies the English model, so the prediction worker's peak memory falls from about 362 MiB to 134 MiB. Worker assets are unchanged. Refs #1029 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #1029 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
enaboapps
marked this pull request as ready for review
October 12, 2026 16:49
This was referenced Oct 12, 2026
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.
Closes #1029
Word prediction now learns from what the person types with the scanning keyboard, so their own words, names and phrases are suggested sooner.
What changes
Setting. Adds Learn from my typing under Scanning › Keyboard › Suggestions, on by default.
AppSettingsbesideautoApproveAccountDevices. It is per computer, excluded from synced settings, and the synced schema is unchanged.Where it is stored. The isolated prediction worker opens
prediction/personal.sqlitein this computer's app config directory and passes it toswitchify-prediction.What is learned. Only the existing prediction buffer is learned from, which is successful Switchify keyboard input:
Edit::End, which keeps the last word, instead of aReset.Changing the setting bumps a learning generation, so the running worker and any spare are replaced at the next keyboard update.
Forget sets a pending flag, replaces any worker holding the file, and deletes the file plus its
-journal,-waland-shm. It finishes as soon as no worker holds them: immediately, onstop(), or before the next worker starts. No worker reopens the file while the delete is pending.Library pin.
switchify-predictionis pinned to Make learned words count, boundedly, without a second baseline copy switchify-prediction#30 (stacked on feat: redesign desktop setup UI #28):The worker release assets (v0.2.1) are unchanged, and
library_revisionwas updated to match.AI slots. The AI slots don't learn themselves. They exclude slots 1–3, so they still offer different words.
Docs.
word-prediction.mdgains a Learning from typing section. The neural, six-slot and keyboard docs are updated, and so is the settings note, which said typing "is not used for learning".Typed text is never logged or synced. The file holds counts, not a transcript, but it is unencrypted, and the settings note says it can include names or passwords.
Validation
All checks from AGENTS.md pass:
npm run prediction-model,lint,test,build,cargo fmt --check,cargo clippy --all-targets -D warnings, andcargo test(754 + 7 tests).New tests, all using fake adapters with no desktop input:
Endkeeps the last word; lost context skips the word in progress; clipped text is learned in whole words.End; a spare started for another personal file isn't adopted; closing passes the personal file to the spare; Forget deletes the file and its journals, only when asked.learnWordPredictiondefaults to true for stored settings, is excluded from the synced document, and survives an incoming sync.The new tests originally started enough PowerShell fake workers to starve
cancellation_kills_and_reaps_a_blocked_workerafter a rebuild. They now start only what they need, and the suite passes on repeated runs straight after a rebuild. One unrelated account-sync UI test flaked once during a concurrent build and passed on three reruns.Manual check still to do: with signed builds (
npm run macos:runon macOS), type sentences and check that learned words rank higher after reopening the keyboard. Then use Forget and check the file is gone.Note: #1026 (docs) edits some of the same doc lines. Whichever merges second needs a small rebase.
🤖 Generated with Claude Code