Desktop App: Spell check shows underlines but right-click suggestions don't work (context menu missing in production)
Problem
In the Craft Agents desktop app (macOS), spell check partially works — misspelled words show red underlines — but right-clicking on them does nothing. There are no spelling suggestions, no \"Add to Dictionary\" option, and no autocorrect.
Root Cause
Two issues in window-manager.ts:
1. context-menu event handler is dev-only
The right-click context menu is only registered when !app.isPackaged:
if (!app.isPackaged) {
window.webContents.on('context-menu', (_event, params) => {
// ...Cut, Copy, Paste only - no spell suggestions
})
}
In the packaged/production app, right-clicking triggers no menu at all.
2. spellcheck missing from webPreferences
Without spellcheck: true in webPreferences, Electron does not populate params.dictionarySuggestions or params.misspelledWord in the context-menu event — so even if the handler ran, there would be no suggestions.
Fix
In window-manager.ts:
Add spellcheck: true to webPreferences:
webPreferences: {
preload: join(__dirname, 'bootstrap-preload.cjs'),
contextIsolation: true,
nodeIntegration: false,
sandbox: false,
webviewTag: false,
spellcheck: true // ← add this
}
Move context-menu handler outside the isPackaged guard and add spell suggestions:
window.webContents.on('context-menu', (_event, params) => {
const menuTemplate = []
if (params.misspelledWord) {
if (params.dictionarySuggestions?.length > 0) {
params.dictionarySuggestions.forEach((suggestion) => {
menuTemplate.push({ label: suggestion, click: () => window.webContents.replaceMisspelling(suggestion) })
})
} else {
menuTemplate.push({ label: 'No suggestions', enabled: false })
}
menuTemplate.push({ type: 'separator' })
menuTemplate.push({
label: 'Add to Dictionary',
click: () => window.webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord)
})
menuTemplate.push({ type: 'separator' })
}
menuTemplate.push({ label: 'Cut', role: 'cut', enabled: params.editFlags.canCut })
menuTemplate.push({ label: 'Copy', role: 'copy', enabled: params.editFlags.canCopy })
menuTemplate.push({ label: 'Paste', role: 'paste', enabled: params.editFlags.canPaste })
if (!app.isPackaged) {
menuTemplate.push({ type: 'separator' })
menuTemplate.push({ label: 'Inspect Element', click: () => window.webContents.inspectElement(params.x, params.y) })
}
Menu.buildFromTemplate(menuTemplate).popup()
})
Expected Behavior
- Right-clicking a red-underlined word shows spelling suggestions
- Clicking a suggestion replaces the misspelled word
- \"Add to Dictionary\" option is available
- Cut / Copy / Paste still work as before
Environment
- macOS (darwin)
- Craft Agents desktop app (packaged/production build)
Related
- #16833 — spell check in VSCode extension (different surface, same underlying gap)
- #35706 — Windows spell check cannot be disabled (different platform/issue)
This fix was discovered and verified locally by patching dist/main.cjs directly — right-click suggestions work correctly after applying both changes.This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗