bug(desktop): Wayland toggle unclickable + read_wayland() ignores Tauri store structure #9022

Closed
opened 2026-02-16 18:11:25 -05:00 by yindo · 0 comments
Owner

Originally created by @IsraelAraujo70 on GitHub (Feb 10, 2026).

Originally assigned to: @adamdotdevin on GitHub.

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:

  1. get_display_backend() always returns Auto regardless of saved preference
  2. configure_display_backend() in main.rs never detects the user's Wayland preference at startup
  3. The toggle always shows as "off" even after being set

Steps to Reproduce

  1. Install OpenCode Desktop v1.1.56 on Linux with Wayland
  2. Open Settings → General → Display
  3. Try to click the "Use native Wayland" toggle
  4. 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:

  1. Parse the JSON as a generic serde_json::Value and navigate to linuxDisplayConfig.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()
    }
    
  2. Or use the Tauri store API for reading as well (though this isn't available in main.rs before 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 #11971 (feat: add native Wayland toggle on Linux)
  • Commit 3d6fb29 (fix: correct module name for linux_display in main.rs)

cc @Brendonovich

Originally created by @IsraelAraujo70 on GitHub (Feb 10, 2026). Originally assigned to: @adamdotdevin on GitHub. ## 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: ```rust 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`): ```json { "linuxDisplayConfig": { "wayland": true } } ``` However, `read_wayland()` reads the **raw file** and tries to deserialize the **entire JSON** as a flat `DisplayConfig`: ```rust 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: 1. `get_display_backend()` always returns `Auto` regardless of saved preference 2. `configure_display_backend()` in `main.rs` never detects the user's Wayland preference at startup 3. The toggle always shows as "off" even after being set ## Steps to Reproduce 1. Install OpenCode Desktop v1.1.56 on Linux with Wayland 2. Open Settings → General → Display 3. Try to click the "Use native Wayland" toggle 4. 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: ```json { "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: 1. Parse the JSON as a generic `serde_json::Value` and navigate to `linuxDisplayConfig.wayland`: ```rust 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() } ``` 2. Or use the Tauri store API for reading as well (though this isn't available in `main.rs` before 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 #11971 (feat: add native Wayland toggle on Linux) - Commit `3d6fb29` (fix: correct module name for linux_display in main.rs) cc @Brendonovich
yindo added the web label 2026-02-16 18:11:25 -05:00
yindo closed this issue 2026-02-16 18:11:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9022