refactor: remove legacy Tauri desktop support

Electron updater now uses Electron release metadata only
Removed legacy Tauri package and migration workflow
Replaced Tauri shim usage with the desktop bridge
This commit is contained in:
Bohdan Triapitsyn
2026-06-03 02:42:00 +03:00
parent e80bd15dd9
commit c7bc026b4b
81 changed files with 269 additions and 16914 deletions
@@ -1,5 +1,5 @@
import React from 'react';
import { isDesktopShell, isTauriShell, startDesktopWindowDrag } from '@/lib/desktop';
import { isDesktopShell, requestFileAccess, startDesktopWindowDrag } from '@/lib/desktop';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { Icon } from "@/components/icon/Icon";
@@ -116,7 +116,7 @@ export function ChooserScreen({ onCliAvailable }: ChooserScreenProps) {
}, []);
const persistFirstChoice = React.useCallback(async (choice: 'local' | 'remote') => {
if (!isTauriShell()) return;
if (!isDesktopApp) return;
const config = await desktopHostsGet();
await desktopHostsSet({
@@ -124,14 +124,14 @@ export function ChooserScreen({ onCliAvailable }: ChooserScreenProps) {
...(choice === 'local' ? { defaultHostId: 'local' } : {}),
initialHostChoiceCompleted: true,
});
}, []);
}, [isDesktopApp]);
const announceAvailable = React.useCallback(async () => {
if (isTauriShell()) {
if (isDesktopApp) {
await persistFirstChoice('local');
}
onCliAvailable?.();
}, [onCliAvailable, persistFirstChoice]);
}, [isDesktopApp, onCliAvailable, persistFirstChoice]);
// Background polling: while the local tab is visible, periodically check
// whether the OpenCode CLI is reachable. As soon as it is, transition
@@ -179,30 +179,23 @@ export function ChooserScreen({ onCliAvailable }: ChooserScreenProps) {
const handleBrowse = React.useCallback(async () => {
if (typeof window === 'undefined') return;
if (!isDesktopApp || !isTauriShell()) return;
const tauri = (window as unknown as { __TAURI__?: { dialog?: { open?: (opts: Record<string, unknown>) => Promise<unknown> } } }).__TAURI__;
if (!tauri?.dialog?.open) return;
if (!isDesktopApp) return;
try {
const selected = await tauri.dialog.open({
title: t('onboarding.localSetup.dialog.selectOpencodeBinary'),
multiple: false,
directory: false,
});
if (typeof selected === 'string' && selected.trim().length > 0) {
setOpencodeBinary(selected.trim());
const selected = await requestFileAccess();
if (selected.success && selected.path && selected.path.trim().length > 0) {
setOpencodeBinary(selected.path.trim());
}
} catch {
// ignore
}
}, [isDesktopApp, t]);
}, [isDesktopApp]);
const handleApplyPath = React.useCallback(async () => {
setIsApplyingPath(true);
try {
await updateDesktopSettings({ opencodeBinary: opencodeBinary.trim() });
if (isTauriShell()) {
if (isDesktopApp) {
await persistFirstChoice('local');
await restartDesktopApp();
return;
@@ -211,7 +204,7 @@ export function ChooserScreen({ onCliAvailable }: ChooserScreenProps) {
} finally {
setTimeout(() => setIsApplyingPath(false), 1000);
}
}, [opencodeBinary, persistFirstChoice]);
}, [isDesktopApp, opencodeBinary, persistFirstChoice]);
const handleCopy = React.useCallback(async () => {
const result = await copyTextToClipboard(INSTALL_COMMAND);
@@ -231,7 +224,7 @@ export function ChooserScreen({ onCliAvailable }: ChooserScreenProps) {
? '/home/you/.bun/bin/opencode'
: '/Users/you/.bun/bin/opencode';
const showLocal = !isDesktopApp || !isTauriShell() || activeTab === 'local';
const showLocal = !isDesktopApp || activeTab === 'local';
return (
<div
@@ -248,7 +241,7 @@ export function ChooserScreen({ onCliAvailable }: ChooserScreenProps) {
</p>
</header>
{isDesktopApp && isTauriShell() && (
{isDesktopApp && (
<div className="app-region-no-drag flex gap-1.5">
<button
type="button"
@@ -277,7 +270,7 @@ export function ChooserScreen({ onCliAvailable }: ChooserScreenProps) {
</div>
)}
{isDesktopApp && isTauriShell() && activeTab === 'remote' ? (
{isDesktopApp && activeTab === 'remote' ? (
<div className="app-region-no-drag">
<RemoteConnectionForm
onBack={() => setActiveTab('local')}
@@ -394,7 +387,7 @@ export function ChooserScreen({ onCliAvailable }: ChooserScreenProps) {
variant="secondary"
size="sm"
onClick={handleBrowse}
disabled={isApplyingPath || !isDesktopApp || !isTauriShell()}
disabled={isApplyingPath || !isDesktopApp}
>
{t('onboarding.localSetup.actions.browse')}
</Button>
@@ -1,5 +1,5 @@
import React from 'react';
import { isDesktopShell, isTauriShell } from '@/lib/desktop';
import { isDesktopShell, requestFileAccess, startDesktopWindowDrag } from '@/lib/desktop';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { Icon } from "@/components/icon/Icon";
@@ -122,14 +122,8 @@ export function LocalSetupScreen({
return;
}
if (e.button !== 0) return;
if (isDesktopApp && isTauriShell()) {
try {
const { getCurrentWindow } = await import('@tauri-apps/api/window');
const window = getCurrentWindow();
await window.startDragging();
} catch (error) {
console.error('Failed to start window dragging:', error);
}
if (isDesktopApp) {
await startDesktopWindowDrag();
}
}, [isDesktopApp]);
@@ -148,37 +142,28 @@ export function LocalSetupScreen({
if (typeof window === 'undefined') {
return;
}
if (!isDesktopApp || !isTauriShell()) {
return;
}
const tauri = (window as unknown as { __TAURI__?: { dialog?: { open?: (opts: Record<string, unknown>) => Promise<unknown> } } }).__TAURI__;
if (!tauri?.dialog?.open) {
if (!isDesktopApp) {
return;
}
try {
const selected = await tauri.dialog.open({
title: t('onboarding.localSetup.dialog.selectOpencodeBinary'),
multiple: false,
directory: false,
});
if (typeof selected === 'string' && selected.trim().length > 0) {
setOpencodeBinary(selected.trim());
const selected = await requestFileAccess();
if (selected.success && selected.path && selected.path.trim().length > 0) {
setOpencodeBinary(selected.path.trim());
}
} catch {
// ignore
}
}, [isDesktopApp, t]);
}, [isDesktopApp]);
const handleApplyPath = React.useCallback(async () => {
setIsRetrying(true);
try {
await updateDesktopSettings({ opencodeBinary: opencodeBinary.trim() });
// In desktop boot flow, always restart the entire Tauri app so Rust
// can re-evaluate the boot outcome with the updated binary path.
if (isTauriShell()) {
// In desktop boot flow, restart the app so the native host can
// re-evaluate the boot outcome with the updated binary path.
if (isDesktopApp) {
await restartDesktopApp();
return;
}
@@ -187,7 +172,7 @@ export function LocalSetupScreen({
} finally {
setTimeout(() => setIsRetrying(false), 1000);
}
}, [opencodeBinary]);
}, [isDesktopApp, opencodeBinary]);
const handleCopy = React.useCallback(async () => {
const result = await copyTextToClipboard(INSTALL_COMMAND);
@@ -321,7 +306,7 @@ export function LocalSetupScreen({
type="button"
variant="secondary"
onClick={handleBrowse}
disabled={isRetrying || !isDesktopApp || !isTauriShell()}
disabled={isRetrying || !isDesktopApp}
>
{t('onboarding.localSetup.actions.browse')}
</Button>
@@ -1,5 +1,5 @@
import React from 'react';
import { isTauriShell, restartDesktopApp } from '@/lib/desktop';
import { isDesktopShell, restartDesktopApp } from '@/lib/desktop';
import { DesktopConnectionRecovery, type RecoveryVariant } from './DesktopConnectionRecovery';
import { RemoteConnectionForm } from './RemoteConnectionForm';
import { resolveRecoveryNextStep } from './desktopRecoveryRouting';
@@ -43,7 +43,7 @@ export function RecoveryScreen({
}: RecoveryScreenProps) {
// Persist the user's first choice (local or remote)
const persistFirstChoice = React.useCallback(async (choice: 'local' | 'remote') => {
if (!isTauriShell()) return;
if (!isDesktopShell()) return;
const config = await desktopHostsGet();
await desktopHostsSet({
@@ -56,9 +56,9 @@ export function RecoveryScreen({
}, []);
const handleRecoveryRetry = React.useCallback(async () => {
// In desktop boot flow, always restart the entire Tauri app so Rust
// can re-evaluate the boot outcome.
if (isTauriShell()) {
// In desktop boot flow, restart the app so the native host can
// re-evaluate the boot outcome.
if (isDesktopShell()) {
await restartDesktopApp();
return;
}
@@ -77,7 +77,7 @@ export function RecoveryScreen({
// switch-default-to-local → persist local choice and restart
await persistFirstChoice('local');
if (isTauriShell()) {
if (isDesktopShell()) {
await restartDesktopApp();
return;
}
@@ -105,7 +105,7 @@ export function RecoveryScreen({
isRecoveryMode={true}
onSwitchToLocal={onSwitchToLocalFromRemote || (() => {
persistFirstChoice('local').then(() => {
if (isTauriShell()) {
if (isDesktopShell()) {
restartDesktopApp();
} else {
onEnterLocalSetup?.();
@@ -8,7 +8,7 @@ import {
} from '@/lib/desktopHosts';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { isTauriShell } from '@/lib/desktop';
import { isDesktopShell, restartDesktopApp } from '@/lib/desktop';
import { useI18n } from '@/lib/i18n';
type ConnectionState = 'idle' | 'testing' | 'success' | 'error';
@@ -153,9 +153,8 @@ export function RemoteConnectionForm({
return;
}
if (isTauriShell()) {
const tauri = (window as unknown as { __TAURI__?: { core?: { invoke?: (cmd: string, args?: Record<string, unknown>) => Promise<unknown> } } }).__TAURI__;
await tauri?.core?.invoke?.('desktop_restart');
if (isDesktopShell()) {
await restartDesktopApp();
}
} catch (err) {
setError(err instanceof Error ? err.message : t('onboarding.remoteConnection.errors.failedToSaveConnection'));