Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: turn on spell checking in Linux Desktop (#16380)

Daniel Hand01c6635e47e
diff --git a/studio/frontend/tests/spellcheck-preference.test.ts b/studio/frontend/tests/spellcheck-preference.test.ts
index 75252c70727..efa6bbc013f 100644
--- a/studio/frontend/tests/spellcheck-preference.test.ts
+++ b/studio/frontend/tests/spellcheck-preference.test.ts
@@ -8,6 +8,7 @@ import test from "node:test";
import {
installLocalStorageFake,
readSrc,
+ readText,
registerBundlerResolver,
} from "./helpers/kit.ts";
@@ -90,3 +91,13 @@ test("Reset all preferences turns spell check back on", () => {
)?.[1];
assert.match(prefsKeys ?? "", /^\s*SPELLCHECK_STORAGE_KEY,$/m);
});
+
+test("Linux Desktop turns WebKitGTK's checker on, or the attribute does nothing", () => {
+ // Off by default with no dictionary loaded; the languages call is what loads one.
+ const linuxSetup = readText("../../src-tauri/src/main.rs").match(
+ /fn setup_linux_media_permissions[\s\S]*?\r?\n\}\r?\n/,
+ )?.[0];
+ assert.match(linuxSetup ?? "", /\.set_spell_checking_enabled\(true\)/);
+ assert.match(linuxSetup ?? "", /\.set_spell_checking_languages\(/);
+ assert.match(linuxSetup ?? "", /appimage_webkit::bundled_runtime\(/);
+});
diff --git a/studio/src-tauri/src/main.rs b/studio/src-tauri/src/main.rs
index 060dd7853b8..cd730b2d39d 100644
--- a/studio/src-tauri/src/main.rs
+++ b/studio/src-tauri/src/main.rs
@@ -1068,10 +1068,13 @@ fn keep_resizable_across_first_configure(
// WebKitGTK disables media streams and denies unhandled permission requests by default, which
// breaks dictation. Allow only user-media requests; every other kind keeps the default deny.
+// It also ships with spell checking off and no dictionary loaded (wry turns neither on), so the
+// DOM spellcheck attribute behind Settings > Spell check did nothing on Linux.
#[cfg(target_os = "linux")]
fn setup_linux_media_permissions(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
use webkit2gtk::{
- glib::Cast, PermissionRequestExt, SettingsExt, UserMediaPermissionRequest, WebViewExt,
+ glib::Cast, PermissionRequestExt, SettingsExt, UserMediaPermissionRequest, WebContextExt,
+ WebViewExt,
};
let window = app.get_webview_window("main").ok_or_else(|| {
@@ -1082,6 +1085,14 @@ fn setup_linux_media_permissions(app: &tauri::App) -> Result<(), Box<dyn std::er
if let Some(settings) = webview.settings() {
settings.set_enable_media_stream(true);
}
+ // Process-wide in WebKit. An empty list = the locale's dictionary, else the first one
+ // installed; deferred because loading it blocks ~40 ms. Not on a bundled AppImage: its
+ // libenchant would load the host's ABI-incompatible provider plugins.
+ let bundled = crate::appimage_webkit::bundled_runtime(|name| std::env::var_os(name));
+ if let Some(context) = webview.context().filter(|_| !bundled) {
+ context.set_spell_checking_enabled(true);
+ glib::idle_add_local_once(move || context.set_spell_checking_languages(&[]));
+ }
webview.connect_permission_request(|_webview, request| {
match request.downcast_ref::<UserMediaPermissionRequest>() {
Some(request) => {