feat: add OpenCode update notification setting

Adds a setting to show or hide OpenCode update notifications
Dismisses the active update toast when notifications are disabled
Adds localized settings labels
This commit is contained in:
Bohdan Triapitsyn
2026-05-15 21:38:57 +03:00
parent 59bc0c6c06
commit 040b6a9dc6
10 changed files with 52 additions and 2 deletions
@@ -1,11 +1,13 @@
import * as React from 'react';
import { Button } from '@/components/ui/button';
import { Checkbox } from '@/components/ui/checkbox';
import { Input } from '@/components/ui/input';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import { Icon } from "@/components/icon/Icon";
import { isDesktopShell, isTauriShell } from '@/lib/desktop';
import { updateDesktopSettings } from '@/lib/persistence';
import { reloadOpenCodeConfiguration } from '@/stores/useAgentsStore';
import { useUIStore } from '@/stores/useUIStore';
import { useI18n } from '@/lib/i18n';
export const OpenCodeCliSettings: React.FC = () => {
@@ -13,6 +15,8 @@ export const OpenCodeCliSettings: React.FC = () => {
const [value, setValue] = React.useState('');
const [isLoading, setIsLoading] = React.useState(true);
const [isSaving, setIsSaving] = React.useState(false);
const showOpenCodeUpdateNotifications = useUIStore((state) => state.showOpenCodeUpdateNotifications);
const setShowOpenCodeUpdateNotifications = useUIStore((state) => state.setShowOpenCodeUpdateNotifications);
React.useEffect(() => {
let cancelled = false;
@@ -148,6 +152,17 @@ export const OpenCodeCliSettings: React.FC = () => {
</div>
</div>
<label className="flex cursor-pointer items-center gap-2 py-1.5">
<Checkbox
checked={showOpenCodeUpdateNotifications}
onChange={setShowOpenCodeUpdateNotifications}
ariaLabel={t('settings.openchamber.opencodeCli.field.showUpdateNotificationsAria')}
/>
<span className="typography-ui-label text-foreground">
{t('settings.openchamber.opencodeCli.field.showUpdateNotifications')}
</span>
</label>
<div className="flex justify-start py-1.5">
<Button
type="button"
@@ -2,6 +2,7 @@ import * as React from 'react';
import { Icon } from '@/components/icon/Icon';
import { toast } from '@/components/ui/toast';
import { reloadOpenCodeConfiguration } from '@/stores/useAgentsStore';
import { useUIStore } from '@/stores/useUIStore';
import { useI18n } from '@/lib/i18n';
type OpenCodeUpdateAvailableEvent = CustomEvent<{ version?: unknown }>;
@@ -17,9 +18,16 @@ const CHECK_RETRY_DELAYS_MS = [10_000, 60_000];
export const OpenCodeUpdateToast: React.FC = () => {
const { t } = useI18n();
const showOpenCodeUpdateNotifications = useUIStore((state) => state.showOpenCodeUpdateNotifications);
const seenVersionsRef = React.useRef(new Set<string>());
const upgradingRef = React.useRef(false);
React.useEffect(() => {
if (!showOpenCodeUpdateNotifications) {
toast.dismiss(UPDATE_TOAST_ID);
}
}, [showOpenCodeUpdateNotifications]);
const reloadOpenCode = React.useCallback(() => {
toast.dismiss(UPGRADE_TOAST_ID);
void reloadOpenCodeConfiguration({
@@ -79,6 +87,10 @@ export const OpenCodeUpdateToast: React.FC = () => {
React.useEffect(() => {
const showUpdateAvailableToast = (version: string) => {
if (!useUIStore.getState().showOpenCodeUpdateNotifications) {
toast.dismiss(UPDATE_TOAST_ID);
return;
}
if (!version) {
return;
}
@@ -125,7 +137,9 @@ export const OpenCodeUpdateToast: React.FC = () => {
}
};
timeoutIds.push(setTimeout(() => { void checkForUpdate(0); }, INITIAL_CHECK_DELAY_MS));
if (showOpenCodeUpdateNotifications) {
timeoutIds.push(setTimeout(() => { void checkForUpdate(0); }, INITIAL_CHECK_DELAY_MS));
}
window.addEventListener('openchamber:opencode-update-available', onUpdateAvailable);
return () => {
@@ -133,7 +147,7 @@ export const OpenCodeUpdateToast: React.FC = () => {
for (const timeoutId of timeoutIds) clearTimeout(timeoutId);
window.removeEventListener('openchamber:opencode-update-available', onUpdateAvailable);
};
}, [runUpgrade, t]);
}, [runUpgrade, showOpenCodeUpdateNotifications, t]);
return null;
};