Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
chore: remove discord setup
Faisal Amir25e92c16490d
diff --git a/web-app/src/containers/dialogs/DiscordWizardDialog.tsx b/web-app/src/containers/dialogs/DiscordWizardDialog.tsxdeleted file mode 100644index f30b09566..000000000--- a/web-app/src/containers/dialogs/DiscordWizardDialog.tsx+++ /dev/null@@ -1,428 +0,0 @@-import { useState, useEffect } from 'react'-import { useTranslation } from '@/i18n/react-i18next-compat'-import { invoke } from '@tauri-apps/api/core'-import { toast } from 'sonner'-import {- IconBrandDiscord,- IconCheck,- IconArrowRight,- IconArrowLeft,- IconLoader2,- IconAlertCircle,-} from '@tabler/icons-react'-import {- Dialog,- DialogContent,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,-} from '@/components/ui/dialog'-import { Button } from '@/components/ui/button'-import { Input } from '@/components/ui/input'--// Types mirroring Rust backend-interface DiscordTokenValidation {- valid: boolean- bot_username: string | null- bot_discriminator: string | null- error: string | null-}--export interface DiscordConfig {- account_id: string- bot_token: string- bot_username: string | null- bot_discriminator: string | null- connected: boolean- guilds_count: number- channels_count: number-}--interface DiscordWizardDialogProps {- isOpen: boolean- onOpenChange: (open: boolean) => void- onConnected?: (config: DiscordConfig) => void-}--type WizardStep = 'instructions' | 'token' | 'configure' | 'success'--const TOTAL_STEPS = 4--export function DiscordWizardDialog({- isOpen,- onOpenChange,-}: DiscordWizardDialogProps) {- const { t } = useTranslation()- const [step, setStep] = useState<WizardStep>('instructions')- const [token, setToken] = useState('')- const [validation, setValidation] = useState<DiscordTokenValidation | null>(null)- const [isValidating, setIsValidating] = useState(false)- const [isConfiguring, setIsConfiguring] = useState(false)- const [config, setConfig] = useState<DiscordConfig | null>(null)-- // Reset state when dialog closes- useEffect(() => {- if (!isOpen) {- setStep('instructions')- setToken('')- setValidation(null)- setConfig(null)- }- }, [isOpen])-- const getStepNumber = (): number => {- const stepMap: Record<WizardStep, number> = {- instructions: 1,- token: 2,- configure: 3,- success: 4,- }- return stepMap[step]- }-- const handleValidateToken = async () => {- if (!token.trim()) {- toast.error(t('settings:remoteAccess.discordWizard.errors.tokenRequired'))- return- }-- setIsValidating(true)- try {- const result = await invoke<DiscordTokenValidation>('discord_validate_token', {- token: token.trim(),- })- setValidation(result)- if (result.valid) {- toast.success(- t('settings:remoteAccess.discordWizard.step2.validToken', {- username: result.bot_username,- })- )- } else {- toast.error(- result.error || t('settings:remoteAccess.discordWizard.step2.invalidToken')- )- }- } catch (error) {- console.error('Token validation error:', error)- toast.error(t('settings:remoteAccess.discordWizard.errors.networkError'))- } finally {- setIsValidating(false)- }- }-- const handleConfigure = async () => {- if (!validation?.valid) return-- setIsConfiguring(true)- try {- const result = await invoke<DiscordConfig>('discord_configure', {- token: token.trim(),- })- setConfig(result)- setStep('success')- toast.success(t('settings:remoteAccess.discordWizard.step3.success'))- } catch (error) {- console.error('Configure error:', error)- toast.error(- t('settings:remoteAccess.discordWizard.step3.error', {- error: error instanceof Error ? error.message : String(error),- })- )- } finally {- setIsConfiguring(false)- }- }-- const handleDisconnect = async () => {- try {- await invoke('discord_disconnect')- setConfig(null)- setToken('')- setValidation(null)- setStep('instructions')- toast.success(t('settings:remoteAccess.discordWizard.status.notConnected'))- } catch (error) {- console.error('Disconnect error:', error)- }- }-- const renderStepIndicator = () => {- const currentStep = getStepNumber()- return (- <div className="flex items-center justify-center gap-2 mb-6">- {Array.from({ length: TOTAL_STEPS }, (_, i) => (- <div- key={i}- className={`flex items-center justify-center w-8 h-8 rounded-full text-sm font-medium ${- i + 1 < currentStep- ? 'bg-green-500 text-white'- : i + 1 === currentStep- ? 'bg-primary text-primary-foreground'- : 'bg-secondary text-muted-foreground'- }`}- >- {i + 1 < currentStep ? (- <IconCheck size={16} />- ) : (- i + 1- )}- </div>- ))}- </div>- )- }-- const renderInstructionsStep = () => (- <div className="space-y-4">- <DialogDescription className="text-center">- {t('settings:remoteAccess.discordWizard.description')}- </DialogDescription>-- <div className="bg-secondary/50 rounded-lg p-4 space-y-3">- <h4 className="font-medium text-foreground">- {t('settings:remoteAccess.discordWizard.step1.title')}- </h4>- <ol className="list-decimal list-inside space-y-2 text-sm text-muted-foreground">- <li>{t('settings:remoteAccess.discordWizard.step1.instruction1')}</li>- <li>{t('settings:remoteAccess.discordWizard.step1.instruction2')}</li>- <li>{t('settings:remoteAccess.discordWizard.step1.instruction3')}</li>- <li>{t('settings:remoteAccess.discordWizard.step1.instruction4')}</li>- <li>{t('settings:remoteAccess.discordWizard.step1.instruction5')}</li>- </ol>- </div>-- <div className="flex justify-center">- <Button- variant="outline"- onClick={() => window.open('https://discord.com/developers/applications', '_blank')}- className="gap-2"- >- <IconBrandDiscord size={18} />- Open Discord Developer Portal- </Button>- </div>- </div>- )-- const renderTokenStep = () => (- <div className="space-y-4">- <DialogDescription className="text-center">- {t('settings:remoteAccess.discordWizard.step2.title')}- </DialogDescription>-- <div className="space-y-2">- <Input- type="password"- value={token}- onChange={(e) => {- setToken(e.target.value)- setValidation(null)- }}- placeholder={t('settings:remoteAccess.discordWizard.step2.placeholder')}- className="font-mono"- onKeyDown={(e) => {- if (e.key === 'Enter' && !isValidating) {- handleValidateToken()- }- }}- />- </div>-- {validation?.valid && (- <div className="flex items-center gap-2 text-green-500 text-sm">- <IconCheck size={16} />- <span>- {t('settings:remoteAccess.discordWizard.step2.validToken', {- username: validation.bot_username,- })}- </span>- </div>- )}-- {validation && !validation.valid && (- <div className="flex items-center gap-2 text-red-500 text-sm">- <IconAlertCircle size={16} />- <span>{validation.error}</span>- </div>- )}-- <Button- onClick={handleValidateToken}- disabled={isValidating || !token.trim()}- className="w-full"- >- {isValidating ? (- <>- <IconLoader2 className="animate-spin mr-2 h-4 w-4" />- {t('settings:remoteAccess.discordWizard.step2.validating')}- </>- ) : (- t('settings:remoteAccess.discordWizard.step2.validate')- )}- </Button>- </div>- )-- const renderConfigureStep = () => (- <div className="space-y-4">- <DialogDescription className="text-center">- {t('settings:remoteAccess.discordWizard.step3.title')}- </DialogDescription>-- <div className="flex flex-col items-center justify-center py-8">- <IconBrandDiscord size={48} className="text-indigo-500 mb-4" />- <p className="text-muted-foreground">- {isConfiguring- ? t('settings:remoteAccess.discordWizard.step3.connecting')- : validation?.bot_username- ? validation.bot_username- : ''}- </p>- </div>-- {isConfiguring && (- <div className="flex justify-center">- <IconLoader2 className="animate-spin h-8 w-8 text-primary" />- </div>- )}- </div>- )-- const renderSuccessStep = () => (- <div className="space-y-4">- <div className="flex flex-col items-center justify-center py-4">- <div className="w-16 h-16 rounded-full bg-green-500/20 flex items-center justify-center mb-4">- <IconCheck size={32} className="text-green-500" />- </div>- <DialogTitle className="text-center">- {t('settings:remoteAccess.discordWizard.step4.success')}- </DialogTitle>- </div>-- <DialogDescription className="text-center">- {t('settings:remoteAccess.discordWizard.step4.instruction')}- </DialogDescription>-- <div className="bg-secondary/50 rounded-lg p-4 text-center space-y-2">- {config?.bot_username && (- <p className="text-foreground">- {t('settings:remoteAccess.discordWizard.step4.botUsername', {- username: config.bot_username,- })}- </p>- )}- </div>-- <Button variant="outline" onClick={handleDisconnect} className="w-full">- {t('settings:remoteAccess.discordWizard.buttons.disconnect')}- </Button>- </div>- )-- const renderStep = () => {- switch (step) {- case 'instructions':- return renderInstructionsStep()- case 'token':- return renderTokenStep()- case 'configure':- return renderConfigureStep()- case 'success':- return renderSuccessStep()- default:- return null- }- }-- const handleNext = () => {- switch (step) {- case 'instructions':- setStep('token')- break- case 'token':- if (validation?.valid) {- setStep('configure')- handleConfigure()- }- break- case 'configure':- // Handled by configure function- break- case 'success':- onOpenChange(false)- break- }- }-- const handleBack = () => {- switch (step) {- case 'token':- setStep('instructions')- break- case 'configure':- setStep('token')- setValidation(null)- break- case 'success':- // Cannot go back from success- break- }- }-- const canGoNext = (): boolean => {- switch (step) {- case 'instructions':- return true- case 'token':- return validation?.valid ?? false- case 'configure':- return false // Auto-progresses- case 'success':- return true- default:- return false- }- }-- const canGoBack = (): boolean => {- return step !== 'instructions' && step !== 'success' && step !== 'configure'- }-- return (- <Dialog open={isOpen} onOpenChange={onOpenChange}>- <DialogContent className="sm:max-w-[480px] max-w-[90vw]">- <DialogHeader>- <div className="flex items-center justify-center gap-2 mb-2">- <IconBrandDiscord size={24} className="text-indigo-500" />- <DialogTitle>{t('settings:remoteAccess.discordWizard.title')}</DialogTitle>- </div>- </DialogHeader>-- {renderStepIndicator()}-- {renderStep()}-- {step !== 'configure' && step !== 'success' && (- <DialogFooter className="gap-2 sm:gap-0">- {canGoBack() && (- <Button variant="outline" onClick={handleBack} className="gap-1">- <IconArrowLeft size={16} />- {t('settings:remoteAccess.discordWizard.buttons.back')}- </Button>- )}- <Button- onClick={handleNext}- disabled={!canGoNext()}- className="gap-1"- >- {t('settings:remoteAccess.discordWizard.buttons.next')}- <IconArrowRight size={16} />- </Button>- </DialogFooter>- )}- </DialogContent>- </Dialog>- )-}\ No newline at end of filediff --git a/web-app/src/routes/settings/remote-access.tsx b/web-app/src/routes/settings/remote-access.tsxindex 6303e5840..37faada51 100644--- a/web-app/src/routes/settings/remote-access.tsx+++ b/web-app/src/routes/settings/remote-access.tsx@@ -6,7 +6,6 @@ import { Button } from '@/components/ui/button'import { Card, CardItem } from '@/containers/Card'import { TelegramWizard as TelegramWizardDialog } from '@/containers/dialogs/TelegramWizardDialog'import { WhatsAppWizardDialog, WhatsAppConfig } from '@/containers/dialogs/WhatsAppWizardDialog'-import { DiscordWizardDialog, DiscordConfig } from '@/containers/dialogs/DiscordWizardDialog'import { AddChannelDialog, ChannelType } from '@/containers/dialogs/AddChannelDialog'import { TailscaleSetupDialog } from '@/containers/dialogs/TailscaleSetupDialog'import { SecurityConfigDialog } from '@/containers/dialogs/SecurityConfigDialog'@@ -113,19 +112,6 @@ const convertWhatsAppConfig = (config: WhatsAppConfig | null): ChannelWhatsAppCo}}-const convertDiscordConfig = (config: DiscordConfig | null): ChannelDiscordConfig | null => {- if (!config) return null- return {- account_id: config.account_id,- bot_token: config.bot_token,- bot_username: config.bot_username,- bot_discriminator: config.bot_discriminator,- connected: config.connected,- guilds_count: config.guilds_count,- channels_count: config.channels_count,- }-}-function RemoteAccess() {const { t } = useTranslation()const [status, setStatus] = useState<OpenClawStatus | null>(null)@@ -135,7 +121,6 @@ function RemoteAccess() {const [isInstalling, setIsInstalling] = useState(false)const [isTelegramWizardOpen, setIsTelegramWizardOpen] = useState(false)const [isWhatsAppWizardOpen, setIsWhatsAppWizardOpen] = useState(false)- const [isDiscordWizardOpen, setIsDiscordWizardOpen] = useState(false)const [isAddChannelDialogOpen, setIsAddChannelDialogOpen] = useState(false)const [isTailscaleDialogOpen, setIsTailscaleDialogOpen] = useState(false)const [isSecurityDialogOpen, setIsSecurityDialogOpen] = useState(false)@@ -144,7 +129,6 @@ function RemoteAccess() {const [, setSecurityStatus] = useState<SecurityStatus | null>(null)const [telegramConfig, setTelegramConfig] = useState<TelegramConfig | null>(null)const [whatsappConfig, setWhatsAppConfig] = useState<WhatsAppConfig | null>(null)- const [discordConfig, setDiscordConfig] = useState<DiscordConfig | null>(null)// Fetch status on mountconst fetchStatus = useCallback(async () => {@@ -194,24 +178,6 @@ function RemoteAccess() {setWhatsAppConfig(config)}, [])- // Fetch Discord config on mount- const fetchDiscordConfig = useCallback(async () => {- try {- const config = await invoke<DiscordConfig>('discord_get_config')- setDiscordConfig(config)- } catch (error) {- console.error('Failed to fetch Discord config:', error)- }- }, [])-- useEffect(() => {- fetchDiscordConfig()- }, [fetchDiscordConfig])-- const handleDiscordWizardConnected = useCallback((config: DiscordConfig) => {- setDiscordConfig(config)- }, [])-// Fetch WhatsApp config on mountconst fetchWhatsAppConfig = useCallback(async () => {try {@@ -380,9 +346,6 @@ function RemoteAccess() {case 'whatsapp':setIsWhatsAppWizardOpen(true)break- case 'discord':- setIsDiscordWizardOpen(true)- break}}@@ -401,10 +364,6 @@ function RemoteAccess() {await invoke('whatsapp_disconnect')setWhatsAppConfig(null)break- case 'discord':- await invoke('discord_disconnect')- setDiscordConfig(null)- break}toast.success(t('settings:remoteAccess.channelDisconnected', { channel: getChannelName(channel) })@@ -420,7 +379,6 @@ function RemoteAccess() {const channels: ChannelType[] = []if (telegramConfig?.connected) channels.push('telegram')if (whatsappConfig?.connected) channels.push('whatsapp')- if (discordConfig?.connected) channels.push('discord')return channels}@@ -478,8 +436,7 @@ function RemoteAccess() {{isRunning? String((telegramConfig?.paired_users ?? 0) +- (whatsappConfig?.contacts_count ?? 0) +- (discordConfig?.guilds_count ?? 0)+ (whatsappConfig?.contacts_count ?? 0)): '0'}</span>@@ -595,13 +552,6 @@ function RemoteAccess() {onDisconnect={() => handleDisconnectChannel('whatsapp')}OCIsInstalled={isInstalled}/>- <ChannelCard- type="discord"- config={convertDiscordConfig(discordConfig)}- onSettings={() => handleChannelSettings('discord')}- onDisconnect={() => handleDisconnectChannel('discord')}- OCIsInstalled={isInstalled}- /></div>{/* Share Access */}@@ -684,13 +634,6 @@ function RemoteAccess() {onConnected={handleWhatsAppWizardConnected}/>- {/* Discord Wizard Dialog */}- <DiscordWizardDialog- isOpen={isDiscordWizardOpen}- onOpenChange={setIsDiscordWizardOpen}- onConnected={handleDiscordWizardConnected}- />-{/* Add Channel Dialog */}<AddChannelDialogisOpen={isAddChannelDialogOpen}