Skip to content

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

@IsraelAraujo70

Description

@IsraelAraujo70

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

cc @Brendonovich

Metadata

Metadata

Assignees

Labels

webRelates to opencode on web / desktop

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions