Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

feat(desktop): add spellcheck suggestions to context menu (#500)

(CJ) Chukwudi Nwobodo18b6590d2e49
diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts
index 945f1d279..a23fc8e4a 100644
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@ -1114,6 +1114,34 @@ function createWindow(): BrowserWindow {
},
});
+ window.webContents.on("context-menu", (event, params) => {
+ event.preventDefault();
+
+ const menuTemplate: MenuItemConstructorOptions[] = [];
+
+ if (params.misspelledWord) {
+ for (const suggestion of params.dictionarySuggestions.slice(0, 5)) {
+ menuTemplate.push({
+ label: suggestion,
+ click: () => window.webContents.replaceMisspelling(suggestion),
+ });
+ }
+ if (params.dictionarySuggestions.length === 0) {
+ menuTemplate.push({ label: "No suggestions", enabled: false });
+ }
+ menuTemplate.push({ type: "separator" });
+ }
+
+ menuTemplate.push(
+ { role: "cut", enabled: params.editFlags.canCut },
+ { role: "copy", enabled: params.editFlags.canCopy },
+ { role: "paste", enabled: params.editFlags.canPaste },
+ { role: "selectAll", enabled: params.editFlags.canSelectAll },
+ );
+
+ Menu.buildFromTemplate(menuTemplate).popup({ window });
+ });
+
window.webContents.setWindowOpenHandler(() => ({ action: "deny" }));
window.on("page-title-updated", (event) => {
event.preventDefault();