diff --git a/ui/desktop/src/App.tsx b/ui/desktop/src/App.tsx index e071e3595ad3..19a683dfe195 100644 --- a/ui/desktop/src/App.tsx +++ b/ui/desktop/src/App.tsx @@ -1,8 +1,6 @@ import { useEffect, useRef, useState } from 'react'; import { IpcRendererEvent } from 'electron'; import { HashRouter, Routes, Route, useNavigate, useLocation } from 'react-router-dom'; -import { openSharedSessionFromDeepLink, type SessionLinksViewOptions } from './sessionLinks'; -import { type SharedSessionDetails } from './sharedSessions'; import { ErrorUI } from './components/ErrorBoundary'; import { ConfirmationModal } from './components/ui/ConfirmationModal'; import { ToastContainer } from 'react-toastify'; @@ -17,7 +15,6 @@ import Hub from './components/hub'; import Pair from './components/pair'; import SettingsView, { SettingsViewOptions } from './components/settings/SettingsView'; import SessionsView from './components/sessions/SessionsView'; -import SharedSessionView from './components/sessions/SharedSessionView'; import SchedulesView from './components/schedule/SchedulesView'; import ProviderSettings from './components/settings/providers/ProviderSettingsPage'; import { useChat } from './hooks/useChat'; @@ -320,48 +317,6 @@ const WelcomeRoute = () => { ); }; -// Wrapper component for SharedSessionRoute to access parent state -const SharedSessionRouteWrapper = ({ - isLoadingSharedSession, - setIsLoadingSharedSession, - sharedSessionError, -}: { - isLoadingSharedSession: boolean; - setIsLoadingSharedSession: (loading: boolean) => void; - sharedSessionError: string | null; -}) => { - const location = useLocation(); - const navigate = useNavigate(); - const setView = createNavigationHandler(navigate); - - const historyState = window.history.state; - const sessionDetails = (location.state?.sessionDetails || - historyState?.sessionDetails) as SharedSessionDetails | null; - const error = location.state?.error || historyState?.error || sharedSessionError; - const shareToken = location.state?.shareToken || historyState?.shareToken; - const baseUrl = location.state?.baseUrl || historyState?.baseUrl; - - return ( - { - if (shareToken && baseUrl) { - setIsLoadingSharedSession(true); - try { - await openSharedSessionFromDeepLink(`goose://sessions/${shareToken}`, setView, baseUrl); - } catch (error) { - console.error('Failed to retry loading shared session:', error); - } finally { - setIsLoadingSharedSession(false); - } - } - }} - /> - ); -}; - const ExtensionsRoute = () => { const navigate = useNavigate(); const location = useLocation(); @@ -404,8 +359,6 @@ export default function App() { const [extensionConfirmTitle, setExtensionConfirmTitle] = useState(''); const [isLoadingSession, setIsLoadingSession] = useState(false); const [isGoosehintsModalOpen, setIsGoosehintsModalOpen] = useState(false); - const [isLoadingSharedSession, setIsLoadingSharedSession] = useState(false); - const [sharedSessionError, setSharedSessionError] = useState(null); // Add separate state for pair chat to maintain its own conversation const [pairChat, setPairChat] = useState({ @@ -452,9 +405,6 @@ export default function App() { case 'ConfigureProviders': window.location.hash = '#/configure-providers'; break; - case 'sharedSession': - window.location.hash = '#/shared-session'; - break; case 'recipeEditor': window.location.hash = '#/recipe-editor'; break; @@ -541,44 +491,6 @@ export default function App() { } }, []); - useEffect(() => { - const handleOpenSharedSession = async (_event: IpcRendererEvent, ...args: unknown[]) => { - const link = args[0] as string; - window.electron.logInfo(`Opening shared session from deep link ${link}`); - setIsLoadingSharedSession(true); - setSharedSessionError(null); - try { - await openSharedSessionFromDeepLink( - link, - (_view: View, _options?: SessionLinksViewOptions) => { - // Navigate to shared session view with the session data - window.location.hash = '#/shared-session'; - if (_options) { - window.history.replaceState(_options, '', '#/shared-session'); - } - } - ); - } catch (error) { - console.error('Unexpected error opening shared session:', error); - // Navigate to shared session view with error - window.location.hash = '#/shared-session'; - const shareToken = link.replace('goose://sessions/', ''); - const options = { - sessionDetails: null, - error: error instanceof Error ? error.message : 'Unknown error', - shareToken, - }; - window.history.replaceState(options, '', '#/shared-session'); - } finally { - setIsLoadingSharedSession(false); - } - }; - window.electron.on('open-shared-session', handleOpenSharedSession); - return () => { - window.electron.off('open-shared-session', handleOpenSharedSession); - }; - }, []); - // Handle recipe decode events from main process useEffect(() => { const handleLoadRecipeDeeplink = (_event: IpcRendererEvent, ...args: unknown[]) => { @@ -1012,18 +924,6 @@ export default function App() { } /> - - - - } - /> = ({ setIsGoosehintsModalOpen } case 'ConfigureProviders': navigate('/configure-providers'); break; - case 'sharedSession': - navigate('/shared-session', { state: viewOptions }); - break; + case 'recipeEditor': navigate('/recipe-editor', { state: viewOptions }); break; diff --git a/ui/desktop/src/components/sessions/SessionHistoryView.tsx b/ui/desktop/src/components/sessions/SessionHistoryView.tsx index c5bce494fc20..463e891b971f 100644 --- a/ui/desktop/src/components/sessions/SessionHistoryView.tsx +++ b/ui/desktop/src/components/sessions/SessionHistoryView.tsx @@ -1,12 +1,9 @@ -import React, { useState, useEffect } from 'react'; +import React from 'react'; import { Calendar, MessageSquareText, Folder, - Share2, Sparkles, - Copy, - Check, Target, LoaderCircle, AlertCircle, @@ -17,21 +14,11 @@ import { toast } from 'react-toastify'; import { MainPanelLayout } from '../Layout/MainPanelLayout'; import { ScrollArea } from '../ui/scroll-area'; import { formatMessageTimestamp } from '../../utils/timeUtils'; -import { createSharedSession } from '../../sharedSessions'; -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, -} from '../ui/dialog'; import ProgressiveMessageList from '../ProgressiveMessageList'; import { SearchView } from '../conversation/SearchView'; import { ChatContextManagerProvider } from '../context_management/ChatContextManager'; import { Message } from '../../types/message'; import BackButton from '../ui/BackButton'; -import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/Tooltip'; // Helper function to determine if a message is a user message (same as useChatEngine) const isUserMessage = (message: Message): boolean => { @@ -150,74 +137,6 @@ const SessionHistoryView: React.FC = ({ onRetry, showActionButtons = true, }) => { - const [isShareModalOpen, setIsShareModalOpen] = useState(false); - const [shareLink, setShareLink] = useState(''); - const [isSharing, setIsSharing] = useState(false); - const [isCopied, setIsCopied] = useState(false); - const [canShare, setCanShare] = useState(false); - - useEffect(() => { - const savedSessionConfig = localStorage.getItem('session_sharing_config'); - if (savedSessionConfig) { - try { - const config = JSON.parse(savedSessionConfig); - if (config.enabled && config.baseUrl) { - setCanShare(true); - } - } catch (error) { - console.error('Error parsing session sharing config:', error); - } - } - }, []); - - const handleShare = async () => { - setIsSharing(true); - - try { - const savedSessionConfig = localStorage.getItem('session_sharing_config'); - if (!savedSessionConfig) { - throw new Error('Session sharing is not configured. Please configure it in settings.'); - } - - const config = JSON.parse(savedSessionConfig); - if (!config.enabled || !config.baseUrl) { - throw new Error('Session sharing is not enabled or base URL is not configured.'); - } - - const shareToken = await createSharedSession( - config.baseUrl, - session.metadata.working_dir, - session.messages, - session.metadata.description || 'Shared Session', - session.metadata.total_tokens - ); - - const shareableLink = `goose://sessions/${shareToken}`; - setShareLink(shareableLink); - setIsShareModalOpen(true); - } catch (error) { - console.error('Error sharing session:', error); - toast.error( - `Failed to share session: ${error instanceof Error ? error.message : 'Unknown error'}` - ); - } finally { - setIsSharing(false); - } - }; - - const handleCopyLink = () => { - navigator.clipboard - .writeText(shareLink) - .then(() => { - setIsCopied(true); - setTimeout(() => setIsCopied(false), 2000); - }) - .catch((err) => { - console.error('Failed to copy link:', err); - toast.error('Failed to copy link to clipboard'); - }); - }; - const handleLaunchInNewWindow = () => { if (session) { console.log('Launching session in new window:', session.session_id); @@ -249,136 +168,63 @@ const SessionHistoryView: React.FC = ({ // Define action buttons const actionButtons = showActionButtons ? ( - <> - - - - - {!canShare ? ( - -

- To enable session sharing, go to Settings {'>'} Session {'>'}{' '} - Session Sharing. -

-
- ) : null} -
- - + ) : null; return ( - <> - -
- -
- {!isLoading && session.messages.length > 0 ? ( - <> -
- - - {formatMessageTimestamp(session.messages[0]?.created)} - - - - {session.metadata.message_count} - - {session.metadata.total_tokens !== null && ( - - - {session.metadata.total_tokens.toLocaleString()} - - )} -
-
+ +
+ +
+ {!isLoading && session.messages.length > 0 ? ( + <> +
+ + + {formatMessageTimestamp(session.messages[0]?.created)} + + + + {session.metadata.message_count} + + {session.metadata.total_tokens !== null && ( - - {session.metadata.working_dir} + + {session.metadata.total_tokens.toLocaleString()} -
- - ) : ( -
- - Loading session details... + )}
- )} -
-
- - -
-
- - - - - - - Share Session (beta) - - - Share this session link to give others a read only view of your goose chat. - - - -
-
- - {shareLink} - - -
+
+ + + {session.metadata.working_dir} + +
+ + ) : ( +
+ + Loading session details... +
+ )}
- - - - -
-
- + + + +
+ ); }; diff --git a/ui/desktop/src/components/sessions/SharedSessionView.tsx b/ui/desktop/src/components/sessions/SharedSessionView.tsx deleted file mode 100644 index 1f39d5cd16e2..000000000000 --- a/ui/desktop/src/components/sessions/SharedSessionView.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import React from 'react'; -import { Calendar, MessageSquareText, Folder, Target, LoaderCircle, Share2 } from 'lucide-react'; -import { type SharedSessionDetails } from '../../sharedSessions'; -import { SessionMessages } from './SessionViewComponents'; -import { formatMessageTimestamp } from '../../utils/timeUtils'; -import { MainPanelLayout } from '../Layout/MainPanelLayout'; - -interface SharedSessionViewProps { - session: SharedSessionDetails | null; - isLoading: boolean; - error: string | null; - onRetry: () => void; -} - -// Custom SessionHeader component matching SessionHistoryView style -const SessionHeader: React.FC<{ - children: React.ReactNode; - title: string; -}> = ({ children, title }) => { - return ( -
-

{title}

-
{children}
-
- ); -}; - -const SharedSessionView: React.FC = ({ - session, - isLoading, - error, - onRetry, -}) => { - return ( - -
-
-
- - Shared Session -
-
- - -
- {!isLoading && session && session.messages.length > 0 ? ( - <> -
- - - {formatMessageTimestamp(session.messages[0]?.created)} - - - - {session.message_count} - - {session.total_tokens !== null && ( - - - {session.total_tokens.toLocaleString()} - - )} -
-
- - - {session.working_dir} - -
- - ) : ( -
- - Loading session details... -
- )} -
-
- - -
-
- ); -}; - -export default SharedSessionView; diff --git a/ui/desktop/src/components/settings/SettingsView.tsx b/ui/desktop/src/components/settings/SettingsView.tsx index e414134e9c1d..dcbed3ab5976 100644 --- a/ui/desktop/src/components/settings/SettingsView.tsx +++ b/ui/desktop/src/components/settings/SettingsView.tsx @@ -2,12 +2,11 @@ import { ScrollArea } from '../ui/scroll-area'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'; import { View, ViewOptions } from '../../utils/navigationUtils'; import ModelsSection from './models/ModelsSection'; -import SessionSharingSection from './sessions/SessionSharingSection'; import AppSettingsSection from './app/AppSettingsSection'; import ConfigSettings from './config/ConfigSettings'; import { ExtensionConfig } from '../../api'; import { MainPanelLayout } from '../Layout/MainPanelLayout'; -import { Bot, Share2, Monitor, MessageSquare } from 'lucide-react'; +import { Bot, Monitor, MessageSquare } from 'lucide-react'; import { useState, useEffect } from 'react'; import ChatSettingsSection from './chat/ChatSettingsSection'; import { CONFIGURATION_ENABLED } from '../../updates'; @@ -37,7 +36,6 @@ export default function SettingsView({ update: 'app', models: 'models', modes: 'chat', - sharing: 'sharing', styles: 'chat', tools: 'chat', app: 'app', @@ -93,14 +91,6 @@ export default function SettingsView({ Chat - - - Session - App @@ -123,13 +113,6 @@ export default function SettingsView({ - - - - ({ status: null, message: '' }); - - // isUrlConfigured is true if the user has configured a baseUrl and it is valid. - const isUrlConfigured = - !envBaseUrlShare && - sessionSharingConfig.enabled && - isValidUrl(String(sessionSharingConfig.baseUrl)); - - // Only load saved config from localStorage if the env variable is not provided. - useEffect(() => { - if (envBaseUrlShare) { - // If env variable is set, save the forced configuration to localStorage - const forcedConfig = { - enabled: true, - baseUrl: typeof envBaseUrlShare === 'string' ? envBaseUrlShare : '', - }; - localStorage.setItem('session_sharing_config', JSON.stringify(forcedConfig)); - } else { - const savedSessionConfig = localStorage.getItem('session_sharing_config'); - if (savedSessionConfig) { - try { - const config = JSON.parse(savedSessionConfig); - setSessionSharingConfig(config); - } catch (error) { - console.error('Error parsing session sharing config:', error); - } - } - } - }, [envBaseUrlShare]); - - // Helper to check if the user's input is a valid URL - function isValidUrl(value: string): boolean { - if (!value) return false; - try { - new URL(value); - return true; - } catch { - return false; - } - } - - // Toggle sharing (only allowed when env is not set). - const toggleSharing = () => { - if (envBaseUrlShare) { - return; // Do nothing if the environment variable forces sharing. - } - setSessionSharingConfig((prev) => { - const updated = { ...prev, enabled: !prev.enabled }; - localStorage.setItem('session_sharing_config', JSON.stringify(updated)); - return updated; - }); - }; - - // Handle changes to the base URL field - const handleBaseUrlChange = (e: React.ChangeEvent) => { - const newBaseUrl = e.target.value; - setSessionSharingConfig((prev) => ({ - ...prev, - baseUrl: newBaseUrl, - })); - - // Clear previous test results when URL changes - setTestResult({ status: null, message: '' }); - - if (isValidUrl(newBaseUrl)) { - setUrlError(''); - const updated = { ...sessionSharingConfig, baseUrl: newBaseUrl }; - localStorage.setItem('session_sharing_config', JSON.stringify(updated)); - } else { - setUrlError('Invalid URL format. Please enter a valid URL (e.g. https://example.com/api).'); - } - }; - - // Test connection to the configured URL - const testConnection = async () => { - const baseUrl = sessionSharingConfig.baseUrl; - if (!baseUrl) return; - - setTestResult({ status: 'testing', message: 'Testing connection...' }); - - try { - // Create an AbortController for timeout - const controller = new AbortController(); - const timeoutId = window.setTimeout(() => controller.abort(), 10000); // 10 second timeout - - const response = await fetch(baseUrl, { - method: 'GET', - headers: { - Accept: 'application/json, text/plain, */*', - }, - signal: controller.signal, - }); - - window.clearTimeout(timeoutId); - - // Consider any response (even 404) as a successful connection - // since it means we can reach the server - if (response.status < 500) { - setTestResult({ - status: 'success', - message: 'Connection successful!', - }); - } else { - setTestResult({ - status: 'error', - message: `Server error: HTTP ${response.status}. The server may not be configured correctly.`, - }); - } - } catch (error) { - console.error('Connection test failed:', error); - let errorMessage = 'Connection failed. '; - - if (error instanceof TypeError && error.message.includes('fetch')) { - errorMessage += - 'Unable to reach the server. Please check the URL and your network connection.'; - } else if (error instanceof Error) { - if (error.name === 'AbortError') { - errorMessage += 'Connection timed out. The server may be slow or unreachable.'; - } else { - errorMessage += error.message; - } - } else { - errorMessage += 'Unknown error occurred.'; - } - - setTestResult({ - status: 'error', - message: errorMessage, - }); - } - }; - - return ( -
- - - Session Sharing - - {(envBaseUrlShare as string) - ? 'Session sharing is configured but fully opt-in — your sessions are only shared when you explicitly click the share button.' - : 'You can enable session sharing to share your sessions with others.'} - - - -
- {/* Toggle for enabling session sharing */} -
- - - {envBaseUrlShare ? ( - - ) : ( - - )} -
- - {/* Base URL field (only visible if enabled) */} - {sessionSharingConfig.enabled && ( -
-
- - {isUrlConfigured && } -
-
- -
- {urlError &&

{urlError}

} - - {(isUrlConfigured || (envBaseUrlShare as string)) && ( -
- - - {/* Test Results */} - {testResult.status && testResult.status !== 'testing' && ( -
- {testResult.status === 'success' ? ( - - ) : ( - - )} - {testResult.message} -
- )} -
- )} -
- )} -
-
-
-
- ); -} diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index 6b8a78f1c9af..7fd5821715c6 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -297,8 +297,6 @@ async function processProtocolUrl(parsedUrl: URL, window: BrowserWindow) { if (parsedUrl.hostname === 'extension') { window.webContents.send('add-extension', pendingDeepLink); - } else if (parsedUrl.hostname === 'sessions') { - window.webContents.send('open-shared-session', pendingDeepLink); } else if (parsedUrl.hostname === 'bot' || parsedUrl.hostname === 'recipe') { const recipeDeeplink = parsedUrl.searchParams.get('config'); const scheduledJobId = parsedUrl.searchParams.get('scheduledJob'); @@ -361,8 +359,6 @@ app.on('open-url', async (_event, url) => { if (parsedUrl.hostname === 'extension') { firstOpenWindow.webContents.send('add-extension', pendingDeepLink); - } else if (parsedUrl.hostname === 'sessions') { - firstOpenWindow.webContents.send('open-shared-session', pendingDeepLink); } } }); @@ -465,16 +461,7 @@ const getGooseProvider = () => { ]; }; -const getSharingUrl = () => { - // checks app env for sharing url - loadShellEnv(app.isPackaged); // will try to take it from the zshrc file - // if GOOSE_BASE_URL_SHARE is found, we will set process.env.GOOSE_BASE_URL_SHARE, otherwise we return what it is set - // to in the env at bundle time - return process.env.GOOSE_BASE_URL_SHARE; -}; - const getVersion = () => { - // checks app env for sharing url loadShellEnv(app.isPackaged); // will try to take it from the zshrc file // to in the env at bundle time return process.env.GOOSE_VERSION; @@ -482,8 +469,6 @@ const getVersion = () => { const [provider, model, predefinedModels] = getGooseProvider(); -const sharingUrl = getSharingUrl(); - const gooseVersion = getVersion(); const SERVER_SECRET = process.env.GOOSE_EXTERNAL_BACKEND @@ -608,7 +593,7 @@ const createChat = async ( GOOSE_PORT: port, // Ensure this specific window gets the correct port GOOSE_WORKING_DIR: working_dir, REQUEST_DIR: dir, - GOOSE_BASE_URL_SHARE: sharingUrl, + GOOSE_VERSION: gooseVersion, recipe: recipe, }), @@ -663,7 +648,7 @@ const createChat = async ( GOOSE_PORT: port, // Ensure this specific window's config gets the correct port GOOSE_WORKING_DIR: working_dir, REQUEST_DIR: dir, - GOOSE_BASE_URL_SHARE: sharingUrl, + recipe: recipe, }; diff --git a/ui/desktop/src/sessionLinks.ts b/ui/desktop/src/sessionLinks.ts deleted file mode 100644 index 565ee9417482..000000000000 --- a/ui/desktop/src/sessionLinks.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { fetchSharedSessionDetails, SharedSessionDetails } from './sharedSessions'; -import { View } from './utils/navigationUtils'; - -export interface SessionLinksViewOptions { - sessionDetails?: SharedSessionDetails | null; - error?: string; - shareToken?: string; - baseUrl?: string; - - [key: string]: unknown; -} - -/** - * Handles opening a shared session from a deep link - * @param url The deep link URL (goose://sessions/:shareToken) - * @param setView Function to set the current view - * @param baseUrl Optional base URL for the session sharing API - * @returns Promise that resolves when the session is opened - */ -export async function openSharedSessionFromDeepLink( - url: string, - setView: (view: View, options?: SessionLinksViewOptions) => void, - baseUrl?: string -): Promise { - try { - if (!url.startsWith('goose://sessions/')) { - throw new Error('Invalid URL: URL must use the goose://sessions/ scheme'); - } - - // Extract the share token from the URL - const shareToken: string = url.replace('goose://sessions/', ''); - - if (!shareToken || shareToken.trim() === '') { - throw new Error('Invalid URL: Missing share token'); - } - - // If no baseUrl is provided, check if there's one in localStorage - if (!baseUrl) { - const savedSessionConfig = localStorage.getItem('session_sharing_config'); - if (savedSessionConfig) { - try { - const config = JSON.parse(savedSessionConfig); - if (config.enabled && config.baseUrl) { - baseUrl = config.baseUrl; - } else { - throw new Error( - 'Session sharing is not enabled or base URL is not configured. Check the settings page.' - ); - } - } catch (error) { - console.error('Error parsing session sharing config:', error); - throw new Error( - 'Session sharing is not enabled or base URL is not configured. Check the settings page.' - ); - } - } else { - throw new Error('Session sharing is not configured'); - } - } - - // Fetch the shared session details - const sessionDetails = await fetchSharedSessionDetails(baseUrl!, shareToken); - - // Navigate to the shared session view - setView('sharedSession', { - sessionDetails, - shareToken, - baseUrl, - }); - - return sessionDetails; - } catch (error) { - const errorMessage = `Failed to open shared session: ${error instanceof Error ? error.message : 'Unknown error'}`; - console.error(errorMessage); - - // Navigate to the shared session view with the error instead of throwing - setView('sharedSession', { - sessionDetails: null, - error: error instanceof Error ? error.message : 'Unknown error', - shareToken: url.replace('goose://sessions/', ''), - baseUrl, - }); - - return null; - } -} diff --git a/ui/desktop/src/sharedSessions.ts b/ui/desktop/src/sharedSessions.ts deleted file mode 100644 index 2dd469aa2ad2..000000000000 --- a/ui/desktop/src/sharedSessions.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { Message } from './types/message'; -import { safeJsonParse } from './utils/jsonUtils'; - -export interface SharedSessionDetails { - share_token: string; - created_at: number; - base_url: string; - description: string; - working_dir: string; - messages: Message[]; - message_count: number; - total_tokens: number | null; -} - -/** - * Fetches details for a specific shared session - * @param baseUrl The base URL for session sharing API - * @param shareToken The share token of the session to fetch - * @returns Promise with shared session details - */ -export async function fetchSharedSessionDetails( - baseUrl: string, - shareToken: string -): Promise { - try { - const response = await fetch(`${baseUrl}/sessions/share/${shareToken}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - // Origin: 'http://localhost:5173', // required to bypass Cloudflare security filter - }, - credentials: 'include', - }); - - if (!response.ok) { - throw new Error(`Failed to fetch shared session: ${response.status} ${response.statusText}`); - } - - const data = await safeJsonParse( - response, - 'Failed to parse shared session' - ); - - if (baseUrl != data.base_url) { - throw new Error(`Base URL mismatch for shared session: ${baseUrl} != ${data.base_url}`); - } - - return { - share_token: data.share_token, - created_at: data.created_at, - base_url: data.base_url, - description: data.description, - working_dir: data.working_dir, - messages: data.messages, - message_count: data.message_count, - total_tokens: data.total_tokens, - }; - } catch (error) { - console.error('Error fetching shared session:', error); - throw error; - } -} - -/** - * Creates a new shared session - * @param baseUrl The base URL for session sharing API - * @param workingDir The working directory for the shared session - * @param messages The messages to include in the shared session - * @param description Description for the shared session - * @param totalTokens Total token count for the session, or null if not available - * @param userName The user name for who is sharing the session - * @returns Promise with the share token - */ -export async function createSharedSession( - baseUrl: string, - workingDir: string, - messages: Message[], - description: string, - totalTokens: number | null -): Promise { - try { - const response = await fetch(`${baseUrl}/sessions/share`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - working_dir: workingDir, - messages, - description: description, - base_url: baseUrl, - total_tokens: totalTokens ?? null, - }), - }); - - if (!response.ok) { - if (response.status === 302) { - throw new Error( - `Failed to create shared session. Please check that you are connected to VPN - ${response.status} ${response.statusText}` - ); - } - throw new Error(`Failed to create shared session: ${response.status} ${response.statusText}`); - } - - const data = await safeJsonParse<{ share_token: string }>( - response, - 'Failed to parse shared session response' - ); - return data.share_token; - } catch (error) { - console.error('Error creating shared session:', error); - throw error; - } -} diff --git a/ui/desktop/src/utils/appInitialization.ts b/ui/desktop/src/utils/appInitialization.ts index 8069352acd6e..d0fcd797c5ae 100644 --- a/ui/desktop/src/utils/appInitialization.ts +++ b/ui/desktop/src/utils/appInitialization.ts @@ -178,7 +178,7 @@ const handleViewTypeDeepLink = (viewType: string, recipeConfig: unknown) => { recipes: '#/recipes', permission: '#/permission', ConfigureProviders: '#/configure-providers', - sharedSession: '#/shared-session', + recipeEditor: '#/recipe-editor', welcome: '#/welcome', }; diff --git a/ui/desktop/src/utils/navigationUtils.ts b/ui/desktop/src/utils/navigationUtils.ts index dd866b0a3b85..59f727ea9cd9 100644 --- a/ui/desktop/src/utils/navigationUtils.ts +++ b/ui/desktop/src/utils/navigationUtils.ts @@ -13,7 +13,6 @@ export type View = | 'settingsV2' | 'sessions' | 'schedules' - | 'sharedSession' | 'loading' | 'recipeEditor' | 'recipes' @@ -61,9 +60,6 @@ export const createNavigationHandler = (navigate: NavigateFunction) => { case 'ConfigureProviders': navigate('/configure-providers', { state: options }); break; - case 'sharedSession': - navigate('/shared-session', { state: options }); - break; case 'recipeEditor': navigate('/recipe-editor', { state: options }); break;