-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Description
Description
After PR #11971 was merged and shipped in v1.1.56, the "Use native Wayland" toggle in Desktop Settings → Display is not clickable on Linux.
Additionally, even if a user manages to set the value via the Tauri store, the read_wayland() function in linux_display.rs silently fails to read it back due to a structural mismatch between how data is written vs read.
Root Cause
write_wayland() correctly writes to the Tauri store under a nested key:
store.set(
LINUX_DISPLAY_CONFIG_KEY, // "linuxDisplayConfig"
json!(DisplayConfig { wayland: Some(value) }),
);This produces the store file (~/.local/share/ai.opencode.desktop/opencode.settings.dat):
{
"linuxDisplayConfig": {
"wayland": true
}
}However, read_wayland() reads the raw file and tries to deserialize the entire JSON as a flat DisplayConfig:
pub fn read_wayland() -> Option<bool> {
let path = path()?;
let raw = std::fs::read_to_string(path).ok()?;
let config = serde_json::from_str::<DisplayConfig>(&raw).ok()?;
config.wayland // Always None — "wayland" is nested under "linuxDisplayConfig", not at root
}Since serde ignores unknown fields by default, it deserializes successfully but wayland is always None. This means:
get_display_backend()always returnsAutoregardless of saved preferenceconfigure_display_backend()inmain.rsnever detects the user's Wayland preference at startup- The toggle always shows as "off" even after being set
Steps to Reproduce
- Install OpenCode Desktop v1.1.56 on Linux with Wayland
- Open Settings → General → Display
- Try to click the "Use native Wayland" toggle
- Toggle is unresponsive / does not change state
Workaround
Manually edit ~/.local/share/ai.opencode.desktop/opencode.settings.dat and add "wayland": true at the root level so read_wayland() can find it:
{
"linuxDisplayConfig": {
"wayland": true
},
"wayland": true
}Then restart the app. The startup code in main.rs will detect wayland: true and launch with native Wayland.
Suggested Fix
read_wayland() should either:
-
Parse the JSON as a generic
serde_json::Valueand navigate tolinuxDisplayConfig.wayland:pub fn read_wayland() -> Option<bool> { let raw = std::fs::read_to_string(path()?).ok()?; let root = serde_json::from_str::<serde_json::Value>(&raw).ok()?; root.get(LINUX_DISPLAY_CONFIG_KEY)? .get("wayland")? .as_bool() }
-
Or use the Tauri store API for reading as well (though this isn't available in
main.rsbefore app initialization).
Environment
- OpenCode Desktop v1.1.56
- Linux (Wayland session, e.g. Hyprland, GNOME on Wayland, KDE Plasma)
- Store file:
~/.local/share/ai.opencode.desktop/opencode.settings.dat
Related
- PR feat(desktop): add native Wayland toggle on Linux #11971 (feat: add native Wayland toggle on Linux)
- Commit
3d6fb29(fix: correct module name for linux_display in main.rs)