Repository navigation
Add local spelling checks to the composer body - #4
Merged
Merged
Conversation
- probe: ui/tests/qml/tst_spellcheck_probe.qml (+ SpellcheckProbe.qml) attaches the real Sonnet highlighter through an optional Loader and checks UTF-16 offsets, suggestions, ignore scope, disabling, and undo-safe correction - decision: planning/decisions/S00.md freezes the adapter interface and raises two findings that need supervisor sign-off: misspelledColor is inert (the underline is always Qt's fixed red), and addWordToDictionary writes the global Hunspell dictionary, so personal words must be app-owned and applied via ignoreWord - state: S00 marked READY FOR REVIEW
- S00.md: D1 accept Qt's fixed red underline, D2 app-owned personal words via ignoreWord, D3 keep Sonnet replaceWord with the priming rule (all confirmed) - tests/spellcheck/playground.qml: desktop tool to type, see underlines, and click a suggestion to apply a primed correction - portable suite passes
- ui/compose/SpellcheckAdapter.qml implements the S00 interface (inspect, applyCorrection with the required suggestions priming, ignoreForSession, personalWords) and is the only production file importing org.kde.sonnet - ComposeView loads it through a Loader bound to the body textDocument, exposes spellingAvailable/spellingStatus/spellingAdapter, and unloads it when spelling is disabled; never assigns a null document - tests: adapter contract (7) and composer integration (5) pass; the preview harness shows the real composer for hands-on tuning - Makefile QML_FILES updated
Sonnet's QML highlighter colours the misspelled word red as well as underlining it (unlike the QWidget one), and misspelledColor is inert. So the adapter's highlighter now stays inactive and is used purely as a checker; the composer draws the line itself from completed-word ranges. - spellcheck adapter: adds misspelledRanges(text); a word is marked only once a delimiter follows it, so a word still being typed is never underlined; replaces item icons with the theme error colour - ComposeView: errorColor property, debounced completion check, underline overlay on the body item using positionToRectangle - App.qml passes the theme's urgent role as errorColor - preview: thinner suggestion strip coloured from the composer's theme roles - tests: adapter 9, composer 6, all green
- TextMenu gains a spelling section above Cut/Copy/Paste: up to five suggestions, Ignore for this session, and Add to dictionary, all sharing the existing theme colours and j/k/o keyboard navigation - ComposeView captures the clicked word via TextEdit.positionAt and the caret word via Ctrl+., and routes corrections to the adapter; the fixed bottom strip is retired - keeps the captured UTF-16 position so a correction targets the clicked word even if the caret moved - tests: menu/caret integration 10 in the composer test, text menu 14; full QML suite 1023 passed / 8 pre-existing Qt 6.11 failures; the TextMenu cursor test now names its row instead of assuming index 0
positionToRectangle returns the caret at a position (width 1), not the character's box, so anchoring the width on end-1 stopped the line at the start of the last letter. Use the caret one past the word instead. Measured: 'sentance' drew 47 px before, 53 px after (full advance 52.7 px).
Fix the spelling review findings: - The personal dictionary now reaches both host write boundaries (config-store.sh and StandaloneShell.qml), and a refused write is surfaced in Settings instead of silently staying memory-only. - Personal-word writes queue the latest snapshot and merge a late initial read, so an add during an in-flight write or before the file loads is not lost. - The native settings allowlist accepts spellingEnabled and spellingLanguage, with a SettingsStore round-trip test. - The composer and service probe follow spellingLanguage continuously and report no-dictionary for the requested language rather than falling back to English; availability compares the accepted dictionary with the request because Sonnet keeps the prior language on a missing one. - A spelling correction is refused when the body revision moved under the menu, so a repeated misspelling cannot redirect the edit to the wrong occurrence. - Underline geometry re-measures on width, wrap and font changes. - The spelling bindings move from App.qml into ComposeView, keeping App.qml under the 128 KB source ceiling.
…tings # Conflicts: # planning/STATE.md
Sonnet lists installed dictionaries once per process. A dictionary installed while Omamail runs is not found by reopening Settings or by a new spelling adapter; verified on Qt 6.11.2 and Sonnet 6.29.0 by installing a dictionary under XDG_DATA_HOME mid-run. A fresh process finds it.
Service.qml has a 128 KiB ceiling in tests/test_source.sh. Spelling alone fits under it, but together with message export it does not. The personal-word store (load, merge, queued write, and its FileView) moves unchanged to compose/PersonalWords.qml; Service keeps the same public properties and functions.
Without the Sonnet module the adapter never loads, so waiting for it timed out and failed 27 cases instead of skipping them. The waits now also accept the no-module status and the cases skip. Verified on Qt 6.11.2 both with Sonnet (15 + 16 passed) and with it hidden from the import path (13 + 14 skipped, 0 failed).
The preview's stand-in service had no personal-word store, so Add to dictionary was a silent no-op there. The real service and the composer tests already cover it; this only makes the hands-on preview match.
latentoperator
marked this pull request as ready for review
October 1, 2026 15:14
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.
Outcome
Add local spelling checks to the composer body. Completed misspelled words receive an underline in the theme's error color. Right-click or Ctrl+. opens up to five suggestions, Ignore for this session, and Add to dictionary.
Corrections support undo and mark the draft as edited. Editing the draft invalidates stale correction choices. Settings has an on/off switch and reports missing spelling support or failed personal-word saves. Personal words are stored in the app's private
spelling.json.Sonnet checks words locally. A missing module or dictionary leaves composing available. The composer follows the saved language setting, including when the dictionary changes while a draft is open. Subject and address fields are outside this change.
Status
Draft until a final hands-on check in a real desktop session: typing through an input method or compose key, and the underline and menu in a live window. Base:
4d5e0f0; head:811e99a. The earlier verification below was run at39d4dd5. Since then:ui/compose/PersonalWords.qml, because together with Add original-message export for Outlook and IMAP #3 they pushedui/Service.qmlover its 128 KiB size limit.Verification
Local checks on Linux with Qt 6.11.2, Sonnet 6.29.0, and en_US/en_GB dictionaries:
make validate: QML 1053 passed, 8 failed, no skips. The same eight keyboard-navigation failures reproduce at the pinned baseline. All Rust targets passed; library 555 passed, 11 ignored. JS/shell checks and the separately run app-QML, lint, plugin validation, and diff checks passed.All 14 GitHub checks passed for this candidate.
Combined build with #3
Merged with #3 on top of
4d5e0f0and run on an Arch/Omarchy laptop (Qt 6.11.2, Quickshell 0.3.1, Rust 1.98.1, Sonnet 6.29.0), with isolated home and config directories:make test-rust: 667 passed, 11 ignored.test-js,test-shell,test-backend-process,test-app-qml, andqml-checkpassed.make test-qml: 1066 passed, 8 failed. The failures are the same eightKeyboardReaderNavigationcases that fail on untouchedmainwith this Qt.omamail servewith a synthetic IMAP account on a loopback server saved a multipart message with an 8-bit body and a binary attachment. The file was byte-identical, mode 0600, and parsed independently with the subject, body, and attachment intact. A second save got(2)added to the name. The server saw onlyEXAMINEandUID FETCH … BODY.PEEK[]. Missing messages, unknown accounts, and a missing account were refused.qsprocess added a word throughService, and it was written tospelling.jsonwith mode 0600. A fresh process loaded it and treated the word as correct. Session Ignore did not carry over into the fresh process.Screenshots
Reviewed captures cover body underlines, suggestion menus, Settings, and missing-dictionary guidance in light and dark themes. Images are hosted as GitHub attachments.
The previews use synthetic text and isolated settings. The light composer pairs use identical text. The earlier dark composer examples use different sample text. Settings captures have a small scroll offset. These images show the UI; they do not replace integration tests.
The body comparison shows the new underlines. The menu comparison shows corrections, Ignore for this session, and Add to dictionary.
Settings and additional theme captures
Security
Reviewed and passed for the local spelling, optional loading, and private configuration changes. Independent review and isolated tests found no global dictionary or Sonnet preference writes. Full runtime acceptance remains pending.
Release Notes