feat: support mobile update checks

This commit is contained in:
Bohdan Triapitsyn
2026-07-07 13:39:50 +03:00
parent d45cae485c
commit 4a62a2aeab
14 changed files with 78 additions and 16 deletions
+24 -7
View File
@@ -4,6 +4,7 @@ import {
DialogContent,
DialogTitle,
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { ScrollableOverlay } from '@/components/ui/ScrollableOverlay';
import { SimpleMarkdownRenderer } from '@/components/chat/MarkdownRenderer';
import { Icon } from "@/components/icon/Icon";
@@ -27,10 +28,10 @@ interface UpdateDialogProps {
onDownload: () => void;
onRestart: () => void;
/** Runtime type to show different UI for desktop vs web */
runtimeType?: 'desktop' | 'web' | 'vscode' | null;
runtimeType?: 'desktop' | 'web' | 'vscode' | 'mobile' | null;
}
const GITHUB_RELEASES_URL = 'https://github.com/btriapitsyn/openchamber/releases';
const GITHUB_RELEASES_URL = 'https://github.com/openchamber/openchamber/releases';
type ChangelogSection = {
version: string;
@@ -206,14 +207,16 @@ export const UpdateDialog: React.FC<UpdateDialogProps> = ({
const [webError, setWebError] = useState<string | null>(null);
const releaseUrl = info?.version
? `${GITHUB_RELEASES_URL}/tag/v${info.version}`
? (info.releaseUrl || `${GITHUB_RELEASES_URL}/tag/v${info.version}`)
: GITHUB_RELEASES_URL;
const mobileUpdateUrl = info?.downloadUrl || releaseUrl;
const progressPercent = progress?.total
? Math.round((progress.downloaded / progress.total) * 100)
: 0;
const isWebRuntime = runtimeType === 'web';
const isMobileRuntime = runtimeType === 'mobile';
const updateCommand = info?.updateCommand || 'openchamber update';
// Reset state when dialog closes
@@ -264,6 +267,10 @@ export const UpdateDialog: React.FC<UpdateDialogProps> = ({
}
}, [info?.currentVersion, t]);
const handleMobileUpdate = useCallback(() => {
void handleOpenExternal(mobileUpdateUrl);
}, [handleOpenExternal, mobileUpdateUrl]);
const isWebUpdating = webUpdateState !== 'idle' && webUpdateState !== 'error';
const changelog = useMemo<ParsedChangelog | null>(() => {
@@ -437,7 +444,7 @@ export const UpdateDialog: React.FC<UpdateDialogProps> = ({
)}
{/* Desktop progress bar */}
{!isWebRuntime && downloading && (
{!isWebRuntime && !isMobileRuntime && downloading && (
<div className="space-y-2 mt-4">
<div className="flex items-center justify-between text-sm">
<span className="text-muted-foreground">{t('updateDialog.status.downloadingPayload')}</span>
@@ -474,7 +481,7 @@ export const UpdateDialog: React.FC<UpdateDialogProps> = ({
<div className="flex-1 flex justify-end">
{/* Desktop Buttons */}
{!isWebRuntime && !downloaded && !downloading && (
{!isWebRuntime && !isMobileRuntime && !downloaded && !downloading && (
<button
onClick={onDownload}
className="flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity"
@@ -484,7 +491,7 @@ export const UpdateDialog: React.FC<UpdateDialogProps> = ({
</button>
)}
{!isWebRuntime && downloading && (
{!isWebRuntime && !isMobileRuntime && downloading && (
<button
disabled
className="flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed"
@@ -494,7 +501,7 @@ export const UpdateDialog: React.FC<UpdateDialogProps> = ({
</button>
)}
{!isWebRuntime && downloaded && (
{!isWebRuntime && !isMobileRuntime && downloaded && (
<button
onClick={onRestart}
className="flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity"
@@ -505,6 +512,16 @@ export const UpdateDialog: React.FC<UpdateDialogProps> = ({
)}
{/* Web Buttons */}
{isMobileRuntime && (
<Button
onClick={handleMobileUpdate}
size="default"
>
<Icon name="external-link" className="h-4 w-4" />
{t('updateDialog.actions.openMobileUpdate')}
</Button>
)}
{isWebRuntime && !isWebUpdating && (
<button
onClick={handleWebUpdate}