tonhowtf/omniget · warning

[omnidisc] device preference not saved

Error message

[omnidisc] device preference not saved

What it means

Logged in setDevice() when the backend call succeeded (device switched) but persisting the preference via updateSettings({ omnidisc: { voice: { [key]: id } } }) failed. The device change is active for this session only; it will not survive restart. Non-fatal warning; null is still returned so the caller treats the switch as successful.

Solutions

  1. Check errorText(e) to see whether the settings write failed due to permissions or parsing.
  2. Verify the settings/config file location is writable by the app user.
  3. Fix or delete a corrupted settings file so the store can rewrite it.
  4. Queue a retry of updateSettings and re-attempt persistence on next app start.
  5. Surface a 'preference not saved' toast so users know the change is session-only.

Example fix

// before
try {
  await updateSettings({ omnidisc: { voice: { [key]: id } } });
} catch (e) {
  console.warn("[omnidisc] device preference not saved", errorText(e));
}
// after
try {
  await updateSettings({ omnidisc: { voice: { [key]: id } } });
} catch (e) {
  console.warn("[omnidisc] device preference not saved", errorText(e));
  toast("Device changed, but the preference could not be saved.");
  scheduleSettingsRetry({ omnidisc: { voice: { [key]: id } } });
}
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure settings store is writable before switching devices
const writable = await settingsStore.canWrite();
if (!writable) toast("Settings are read-only; change will not persist.");

Type guard

function isWriteError(e: unknown): e is { code: string } {
  return typeof e === "object" && e !== null && "code" in e &&
    String((e as { code: unknown }).code).match(/(permission|readonly|access)/i) !== null;
}

Try / catch

try {
  await updateSettings({ omnidisc: { voice: { [key]: id } } });
} catch (e) {
  console.warn("[omnidisc] device preference not saved", errorText(e));
  scheduleSettingsRetry({ omnidisc: { voice: { [key]: id } } });
}

Prevention

When it happens

Trigger: Calling setDevice(kind, id) when updateSettings throws: settings file unwritable, settings store/backend error, disk full, or serialization failure.

Common situations: Read-only config directory or restrictive file permissions; corrupted settings JSON on disk; settings backend temporarily unavailable; disk quota exceeded.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/17eaec08d0b586ec. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/stores/omnidisc-voice-store.svelte.ts:658

    devices = await invoke<AudioDevices>("omnidisc_voice_devices");
  } catch (e) {
    console.warn("[omnidisc] device list failed", errorText(e));
  } finally {
    devicesLoading = false;
  }
}

export async function setDevice(kind: DeviceKind, id: string | null): Promise<string | null> {
  const key = kind === "input" ? "input_device" : "output_device";
  try {
    await invoke("omnidisc_voice_set_device", { kind, id });
  } catch (e) {
    return errorText(e);
  }
  try {
    await updateSettings({ omnidisc: { voice: { [key]: id } } });
  } catch (e) {
    console.warn("[omnidisc] device preference not saved", errorText(e));
  }
  return null;
}

export async function setNoiseSuppression(enabled: boolean): Promise<void> {
  try {
    await invoke("omnidisc_voice_set_noise_suppression", { enabled });
  } catch (e) {
    console.warn("[omnidisc] noise suppression failed", errorText(e));
  }
  await updateSettings({ omnidisc: { voice: { noise_suppression: enabled } } });
}

export async function setPttKey(key: string): Promise<void> {
  await updateSettings({ omnidisc: { voice: { ptt_key: key } } });
  await refreshPttStatus();
  try {
    await invoke("omnidisc_voice_ptt", { pressed: false });

View on GitHub (pinned to 8600b91f42)