Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d4b4c16
S00: prove the Sonnet highlighter and freeze the spelling adapter
latentoperator Sep 29, 2026
8692d4d
S00: record confirmed decisions and add an interactive playground
latentoperator Sep 29, 2026
e736048
S01: attach the optional spelling adapter to the composer body
latentoperator Sep 29, 2026
f790ee6
S01: draw the spelling underline ourselves; check only finished words
latentoperator Sep 29, 2026
ee1b776
S01: record the underline redesign and supersede S00 D1
latentoperator Sep 29, 2026
94ae441
S01: suggestions in the right-click menu and at the caret (Ctrl+.)
latentoperator Sep 29, 2026
1f9f498
S01: reach the end of the word with the underline
latentoperator Sep 29, 2026
f485bf4
S02: guard corrections against a stale draft and mark them as edits
latentoperator Sep 29, 2026
caa24a5
S04: add spelling settings, personal dictionary persistence, and grac…
latentoperator Sep 29, 2026
500b553
S04: Fix spelling persistence, language tracking, and stale corrections
latentoperator Sep 29, 2026
8a595a4
S04: recheck underlines after a valid-to-valid dictionary switch
latentoperator Sep 29, 2026
c32dcfa
fix: Keep spelling actions from dirtying unchanged drafts
latentoperator Sep 30, 2026
39d4dd5
docs: Record spelling review fixes and validation limits
latentoperator Sep 30, 2026
8fcb750
Merge remote-tracking branch 'origin/main' into task/S04-spelling-set…
latentoperator Sep 30, 2026
ba7e537
Drop internal task references from source comments
latentoperator Sep 30, 2026
8455b70
Tell the user to restart after installing a spelling dictionary
latentoperator Sep 30, 2026
97a57c2
Move the personal spelling words into their own component
latentoperator Sep 30, 2026
811e99a
Skip composer spelling tests cleanly when Sonnet is missing
latentoperator Sep 30, 2026
a045713
Let the spelling preview's Add to dictionary clear the underline
Oct 1, 2026
7328974
Merge remote-tracking branch 'origin/main' into s04-merge-main
Oct 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
QMLLINT := /usr/lib/qt6/bin/qmllint
.DEFAULT_GOAL := test
QML_FILES := ui/Service.qml ui/BarWidget.qml ui/App.qml ui/compose/RecoveryController.qml \
ui/compose/SpellcheckAdapter.qml ui/compose/PersonalWords.qml \
ui/backend/Backend.qml ui/backend/Runtime.qml ui/diagnostics/Diagnostics.qml \
ui/components/BackendSetup.qml ui/components/OmamailLogo.qml \
ui/account/MailAccount.qml ui/account/BackendSync.qml ui/account/SendQueue.qml ui/account/Intents.qml ui/account/BatchAction.qml ui/account/Rsvp.qml ui/account/LabelActions.qml ui/account/Unsubscribe.qml ui/account/NewMailNotification.qml \
Expand Down
2 changes: 1 addition & 1 deletion app/qml/StandaloneShell.qml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ QtObject {
}

function writeConfig(name, text, callback) {
var allowed = ["credentials.json", "window.json", "window-size.json", "calendars.json"]
var allowed = ["credentials.json", "window.json", "window-size.json", "calendars.json", "spelling.json"]
if (allowed.indexOf(String(name || "")) < 0 || !fileStore
|| typeof fileStore.write !== "function") {
if (typeof callback === "function") callback(false, "Invalid configuration file")
Expand Down
3 changes: 2 additions & 1 deletion app/src/file_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const QSet<QString> &allowedSettings()
QStringLiteral("oauthPort"), QStringLiteral("undoSendSeconds"),
QStringLiteral("unifiedCalendarView"), QStringLiteral("openOnClick"),
QStringLiteral("showBarIcon"), QStringLiteral("suggestEvents"),
QStringLiteral("unifiedMailboxes")};
QStringLiteral("unifiedMailboxes"), QStringLiteral("spellingEnabled"),
QStringLiteral("spellingLanguage")};
return keys;
}

Expand Down
14 changes: 14 additions & 0 deletions app/tests/native/tst_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SettingsTest : public QObject {
private slots:
void initTestCase();
void atomicSettingsRoundTrip();
void acceptsSpellingSettings();
void invalidJsonIsPreserved();
void rejectsCredentialAndUnknownFields();
void fileStoreReadsWritesAndWatches();
Expand Down Expand Up @@ -62,6 +63,19 @@ void SettingsTest::atomicSettingsRoundTrip()
#endif
}

void SettingsTest::acceptsSpellingSettings()
{
QTemporaryDir directory;
const QString path = directory.filePath(QStringLiteral("settings.json"));
SettingsStore store(path);
QString error;
const QVariantMap settings{{QStringLiteral("spellingEnabled"), false},
{QStringLiteral("spellingLanguage"), QStringLiteral("en_US")}};
QVERIFY2(store.replace(settings, &error), qPrintable(error));
QCOMPARE(store.load(&error), settings);
QVERIFY(error.isEmpty());
}

void SettingsTest::invalidJsonIsPreserved()
{
QTemporaryDir directory;
Expand Down
7 changes: 7 additions & 0 deletions app/tests/qml/tst_standalone_composition.qml
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,13 @@ TestCase {
verify(composition.shell.writeConfig("calendars.json", "{}", function(ok) { called = ok }))
verify(called)
compare(host.files["/fixture/config/omamail/calendars.json"], "{}")
// The personal spelling dictionary goes through the same host boundary; a
// name the shell refuses silently loses an added word at restart.
called = false
verify(composition.shell.writeConfig("spelling.json", "{\"words\":[\"blorptar\"]}",
function(ok) { called = ok }))
verify(called)
compare(host.files["/fixture/config/omamail/spelling.json"], "{\"words\":[\"blorptar\"]}")
verify(!composition.shell.writeConfig("../outside", "secret", function() {}))
verify(!Object.prototype.hasOwnProperty.call(host.files, "/fixture/config/omamail/../outside"))
}
Expand Down
18 changes: 17 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
"unifiedCalendarView": false,
"openOnClick": "Window",
"showBarIcon": true,
"suggestEvents": false
"suggestEvents": false,
"spellingEnabled": true,
"spellingLanguage": "en_US"
},
"schema": [
{
Expand Down Expand Up @@ -162,6 +164,20 @@
],
"defaultValue": "Window",
"description": "The full window, or a small card with the most recent unread mail."
},
{
"key": "spellingEnabled",
"type": "boolean",
"label": "Spell-check while composing",
"defaultValue": true,
"description": "Underline misspelled words in the message body with corrections, Ignore, and Add to dictionary. Uses the local Hunspell engine; nothing is sent anywhere."
},
{
"key": "spellingLanguage",
"type": "string",
"label": "Spelling dictionary language",
"defaultValue": "en_US",
"description": "The Hunspell dictionary code used for spell-checking, for example en_US. Requires the matching hunspell dictionary package to be installed."
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/config-store.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ set -eu

name=${1:-}
case "$name" in
credentials.json|accounts.json|window.json|calendars.json|compose.json) ;;
credentials.json|accounts.json|window.json|calendars.json|compose.json|spelling.json) ;;
*)
printf '%s\n' 'usage: config-store.sh credentials.json|accounts.json|window.json|calendars.json|compose.json' >&2
printf '%s\n' 'usage: config-store.sh credentials.json|accounts.json|window.json|calendars.json|compose.json|spelling.json' >&2
exit 2
;;
esac
Expand Down
63 changes: 63 additions & 0 deletions tests/spellcheck/composer-preview.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import QtQuick
import "../../ui/components" as Omamail

// Preview: the real ComposeView with the optional spelling adapter, for
// hands-on tuning of the underline and the suggestion menu.
//
// right-click a misspelled word -> suggestions, Ignore, Add to dictionary
// Ctrl+. -> the same, anchored at the caret word
//
// Run it on the desktop (the mock shell imports stand in for the Omarchy shell):
// /usr/lib/qt6/bin/qml -I ui/tests/qml/imports tests/spellcheck/composer-preview.qml
Rectangle {
id: root
width: 1040
height: 780
color: compose.backgroundColor

QtObject {
id: mailService
property bool sendPending: false
property bool sending: false
property int sendSecondsRemaining: 10
property var lastSent: null
property var recipientContacts: []
property var sendAsAliases: []
property var sendIdentities: [
({ email: "me@example.com", accountId: "me@example.com", label: "me" })
]
property string accountEmail: "me@example.com"
property string activeAccountId: "me@example.com"
function preferredSendAs(_r) { return null }
function switchTo(_id) { return true }
function refreshRecipientContacts() {}
function send(_f) { return true }
function copyText(_t) { return true }
function clipboardAttachment(_dir, callback) { callback({ ok: false, error: "no-image" }); return true }
// In-memory stand-in for the service's personal-word store, so Add to
// dictionary clears the underline here. The real store persists to
// spelling.json; this preview forgets the words when it closes.
property var spellingPersonalWords: []
function addPersonalWord(word) {
if (word && spellingPersonalWords.indexOf(word) < 0)
spellingPersonalWords = spellingPersonalWords.concat([word])
}
}

Omamail.ComposeView {
id: compose
anchors.fill: parent
service: mailService
textColor: "#e8e8ee"
backgroundColor: "#101014"
accentColor: "#ff8a3d"
dimColor: "#a9a9ae"
dimmerColor: "#737377"
popupBackgroundColor: "#1a1a1e"
popupBorderColor: "#3c3c41"
panelFontFamily: "sans"
errorColor: "#ff5555"
}

Component.onCompleted: compose.begin("new", null, "", [])
}
91 changes: 91 additions & 0 deletions tests/spellcheck/playground.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.kde.sonnet as Sonnet

// Interactive playground — a throwaway tool for trying the spelling adapter
// contract by hand, outside the composer.
//
// Run it on the desktop (not offscreen):
// /usr/lib/qt6/bin/qml tests/spellcheck/playground.qml
//
// Type in the body: misspelled words get Qt's red underline. Put the caret in
// a word to see Sonnet's suggestions; click one to correct it. The correction
// uses the adapter's correction rule — prime with
// suggestions(position, 0) immediately before replaceWord(word, position) —
// because without the prime Sonnet inserts instead of replacing.
ApplicationWindow {
id: win
width: 860
height: 560
visible: true
title: "Omamail spelling playground"

property var suggestions: []
property string inspectedWord: ""
property bool inspectedMisspelled: false

function inspect() {
var position = body.cursorPosition
suggestions = highlighter.suggestions(position, 5)
inspectedWord = highlighter.wordUnderMouse
inspectedMisspelled = highlighter.wordIsMisspelled
}

function correct(replacement) {
var position = body.cursorPosition
highlighter.suggestions(position, 0) // prime the word length first
highlighter.replaceWord(replacement, position)
inspect()
}

ColumnLayout {
anchors.fill: parent
anchors.margins: 12
spacing: 8

Text {
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: "Type below. Misspelled words get a red underline. Put the caret in a word to see " +
"suggestions; click one to correct it. Press Ctrl+Z to undo a correction."
}

TextEdit {
id: body
Layout.fillWidth: true
Layout.fillHeight: true
textFormat: TextEdit.PlainText
wrapMode: TextEdit.Wrap
selectByMouse: true
font.pixelSize: 18
text: "This sentance has a mispelled wrod and teh rest is fine."
onCursorPositionChanged: win.inspect()
}

Text {
Layout.fillWidth: true
text: win.inspectedWord === ""
? "Caret is not in a word."
: (win.inspectedMisspelled ? "Misspelled: " + win.inspectedWord : "Looks correct: " + win.inspectedWord)
}

Row {
spacing: 6
Repeater {
model: win.suggestions
Button {
text: modelData
onClicked: win.correct(modelData)
}
}
}
}

Sonnet.SpellcheckHighlighter {
id: highlighter
document: body.textDocument
active: true
automatic: false
}
}
13 changes: 13 additions & 0 deletions tests/test_config_store.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ done
printf '%s\n' '{"zoom":1}' | "$store" window.json >/dev/null
grep -q '"zoom":1' "$XDG_CONFIG_HOME/omamail/window.json"

# The app-owned personal spelling dictionary is one of those files. The service
# writes it through the same helper, so a name the writer refused would mean an
# added word never reached disk while the UI said it had.
printf '%s\n' '{"words":["blorptar"]}' | "$store" spelling.json >/dev/null
grep -q '"blorptar"' "$XDG_CONFIG_HOME/omamail/spelling.json"
if stat -c '%a' "$XDG_CONFIG_HOME/omamail/spelling.json" >/dev/null 2>&1; then
spelling_mode=$(stat -c '%a' "$XDG_CONFIG_HOME/omamail/spelling.json")
else
spelling_mode=$(stat -f '%Lp' "$XDG_CONFIG_HOME/omamail/spelling.json")
fi
[ "$spelling_mode" = 600 ] \
|| { echo 'config-store.sh: the personal dictionary must stay owner-only' >&2; exit 1; }

# An unknown name, an empty payload, and the permissions the files are kept at.
if printf '%s\n' 'x' | "$store" secrets.json >/dev/null 2>&1; then
echo 'config-store.sh: an unknown file name must be refused' >&2
Expand Down
1 change: 1 addition & 0 deletions ui/App.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,7 @@ Item {
popupBackgroundColor: root.popupBackground
popupBorderColor: root.popupBorder
panelFontFamily: root.fontFamily
errorColor: root.urgent
contentDirection: root.service ? root.service.contentDirection : ""
// The stack follows the view: opening pushes, closing pops — and
// the pop is here rather than on `closed`, because a draft parked
Expand Down
54 changes: 52 additions & 2 deletions ui/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "calendar"
import "agent"
import "backend"
import "diagnostics"
import "compose" as Compose
import "agent/Agent.js" as Agent

import "account/Accounts.js" as Accounts
Expand Down Expand Up @@ -140,7 +141,9 @@ Item {
unifiedCalendarView: false,
showBarIcon: true,
unifiedMailboxes: false,
suggestEvents: false
suggestEvents: false,
spellingEnabled: true,
spellingLanguage: "en_US"
})
function normalizedSettings(values) {
var next = ({})
Expand Down Expand Up @@ -424,7 +427,7 @@ Item {
}

function writeConfig(name, text, callback) {
var allowed = ["credentials.json", "window.json", "calendars.json"]
var allowed = ["credentials.json", "window.json", "calendars.json", "spelling.json"]
if (allowed.indexOf(String(name || "")) < 0) {
if (typeof callback === "function") callback(false, "Invalid configuration file")
return false
Expand Down Expand Up @@ -627,6 +630,36 @@ Item {
persistSetting("unifiedMailboxes", value === true)
}

// ------------------------------------------------------------- spelling
//
// Spelling is local and optional: the composer loads the Sonnet adapter
// through a Loader, so a machine without the module or dictionary still
// composes. The enabled flag is the user's request; availability is a
// separate runtime fact reported by the probe, so "off because the user
// turned it off" and "off because en_US is missing" read differently.
readonly property bool spellingEnabled: !settings || settings.spellingEnabled !== false
function setSpellingEnabled(value) { persistSetting("spellingEnabled", value !== false) }
readonly property string spellingLanguage: settings
? String(settings.spellingLanguage || "en_US") : "en_US"
function setSpellingLanguage(value) { persistSetting("spellingLanguage", String(value || "en_US")) }

// Whether Sonnet and the requested dictionary are actually loadable. The
// probe is separate from the per-composer adapter so the settings page can
// explain a missing module or dictionary before any compose window opens.
readonly property bool spellingAvailable: spellingProbe.status === Loader.Ready
&& spellingProbe.item !== null && spellingProbe.item.available
readonly property string spellingStatus: spellingProbe.status === Loader.Error
? "no-module" : (spellingProbe.item ? spellingProbe.item.status : "loading")

// App-owned personal words: compose/PersonalWords.qml stores them in
// spelling.json; the composer applies them.
Compose.PersonalWords { id: personalWords; service: root }
readonly property var spellingWordStore: personalWords
readonly property var spellingPersonalWords: personalWords.words
readonly property string spellingPersonalWordsError: personalWords.error
function addPersonalWord(word) { personalWords.add(word) }
function removePersonalWord(word) { personalWords.remove(word) }

// ---------------------------------------------------------- the accounts

property var accountList: Accounts.emptyList()
Expand Down Expand Up @@ -2692,6 +2725,23 @@ Item {
onLoadFailed: root.applyWindowPrefs("")
}

// Availability probe: loads Sonnet once so the settings page can explain a
// missing module or dictionary without a compose window open. Its language
// follows the setting so the status is about the *requested* dictionary, not
// a default-English fallback.
Loader {
id: spellingProbe
active: true
source: "compose/SpellcheckAdapter.qml"
}

Binding {
target: spellingProbe.item
property: "language"
value: root.spellingLanguage
when: spellingProbe.item !== null
}

Timer {
id: windowPrefsSettling
interval: 500
Expand Down
Loading
Loading