feat(desktop): add toggle to disable auto-update checks (#1126)

<!-- Please read
https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before
submitting your pull request -->

### Description

<!-- Please include a summary of the change. Please also include
relevant motivation and context. List any dependencies that are required
for this change. -->

Fixes #

#### Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings

### AI disclosure:

- [ ] Partially AI assisted (clarify which code was AI assisted and
briefly explain what it does).
- [ ] Fully AI generated (explain what all the generated code does in
moderate detail).
<!-- Write any explanation required here, but do not generate the
explanation using AI!! You must prove you understand what the code in
this PR does. -->
This commit is contained in:
7w1 authored and GitHub committed 2026-07-19 20:02:26 +00:00
commit c973b3917c
4 files changed
+45 -2

No files matched your search

@@ -93,7 +93,7 @@ describe('Desktop', () => {
'Show a system tray icon while Sable is running. Disable this if you want Sable to stay available without a tray icon.'
)
).toBeInTheDocument();
expect(container.getElementsByClassName(SequenceCardStyle)).toHaveLength(2);
expect(container.getElementsByClassName(SequenceCardStyle)).toHaveLength(3);
});
it('shows fallback copy while the tray icon is enabled but unavailable', () => {
@@ -1,5 +1,7 @@
import { isTauri } from '@tauri-apps/api/core';
import { useAtom } from 'jotai';
import { Box, Text, Scroll, Switch, color } from 'folds';
import { autoUpdateCheckAtom } from '$state/autoUpdateCheck';
import { PageContent } from '$components/page';
import { SequenceCard } from '$components/sequence-card';
import { SettingTile } from '$components/setting-tile';
@@ -26,6 +28,7 @@ export function Desktop({ requestBack, requestClose }: DesktopProps) {
'closeToBackgroundOnClose'
);
const [showSystemTrayIcon, setShowSystemTrayIcon] = useDesktopSetting('showSystemTrayIcon');
const [autoUpdateCheck, setAutoUpdateCheck] = useAtom(autoUpdateCheckAtom);
if (!isTauri() || !ready) return null;
@@ -93,6 +96,28 @@ export function Desktop({ requestBack, requestClose }: DesktopProps) {
</SequenceCard>
)}
</Box>
<Box direction="Column" gap="100">
<Text size="L400">Updates</Text>
<SequenceCard
className={SequenceCardStyle}
variant="SurfaceVariant"
direction="Column"
gap="400"
>
<SettingTile
title="Automatically check for updates"
focusId="auto-update-check"
description="Check GitHub for a new release on launch. Turn off to avoid contacting GitHub."
after={
<Switch
aria-label="auto-update-check"
value={autoUpdateCheck}
onChange={setAutoUpdateCheck}
/>
}
/>
</SequenceCard>
</Box>
</Box>
</PageContent>
</Scroll>
+6 -1
View File
@@ -1,6 +1,8 @@
import { useEffect } from 'react';
import { useAtomValue } from 'jotai';
import { isTauri } from '@tauri-apps/api/core';
import { type as osType } from '@tauri-apps/plugin-os';
import { autoUpdateCheckAtom } from '$state/autoUpdateCheck';
import { createLogger } from '$utils/debug';
const log = createLogger('DesktopUpdater');
@@ -37,10 +39,13 @@ async function checkForDesktopUpdate(): Promise<void> {
}
export function DesktopUpdater() {
const autoUpdateCheck = useAtomValue(autoUpdateCheckAtom);
useEffect(() => {
if (!isDesktopTauri()) return;
if (!autoUpdateCheck) return;
checkForDesktopUpdate().catch((err) => log.error('update check failed', err));
}, []);
}, [autoUpdateCheck]);
return null;
}
+13
View File
@@ -0,0 +1,13 @@
import {
atomWithLocalStorage,
getLocalStorageItem,
setLocalStorageItem,
} from './utils/atomWithLocalStorage';
const AUTO_UPDATE_CHECK_KEY = 'autoUpdateCheck';
export const autoUpdateCheckAtom = atomWithLocalStorage<boolean>(
AUTO_UPDATE_CHECK_KEY,
(key) => getLocalStorageItem<boolean>(key, true),
(key, value) => setLocalStorageItem(key, value)
);