From 1f4d07d1d8dbdabc542105c3318d382e7644498f Mon Sep 17 00:00:00 2001 From: Zane Staggs Date: Thu, 17 Jul 2025 16:18:36 -0700 Subject: [PATCH 1/2] Fix resume session in new window not allowing resume chat and cleaned up console logs --- ui/desktop/src/App.tsx | 28 +++++++++++++++++++ ui/desktop/src/agent/index.ts | 8 ++++++ .../providers/ProviderSettingsPage.tsx | 22 +++++++++++---- ui/desktop/src/hooks/useMessageStream.ts | 8 ------ ui/desktop/src/utils/providerUtils.ts | 4 +-- 5 files changed, 53 insertions(+), 17 deletions(-) diff --git a/ui/desktop/src/App.tsx b/ui/desktop/src/App.tsx index 6f05bafbc468..ebd32050d0a3 100644 --- a/ui/desktop/src/App.tsx +++ b/ui/desktop/src/App.tsx @@ -763,6 +763,34 @@ export default function App() { // Check for session resume first - this takes priority over other navigation if (resumeSessionId) { console.log('Session resume detected, letting useChat hook handle navigation'); + + // Even when resuming a session, we need to initialize the system + const initializeForSessionResume = async () => { + try { + await initConfig(); + await readAllConfig({ throwOnError: true }); + + const config = window.electron.getConfig(); + const provider = (await read('GOOSE_PROVIDER', false)) ?? config.GOOSE_DEFAULT_PROVIDER; + const model = (await read('GOOSE_MODEL', false)) ?? config.GOOSE_DEFAULT_MODEL; + + if (provider && model) { + await initializeSystem(provider as string, model as string, { + getExtensions, + addExtension, + }); + } else { + throw new Error('No provider/model configured for session resume'); + } + } catch (error) { + console.error('Failed to initialize system for session resume:', error); + setFatalError( + `Failed to initialize system for session resume: ${error instanceof Error ? error.message : 'Unknown error'}` + ); + } + }; + + initializeForSessionResume(); return; } diff --git a/ui/desktop/src/agent/index.ts b/ui/desktop/src/agent/index.ts index 5e980570d378..13fdb383021f 100644 --- a/ui/desktop/src/agent/index.ts +++ b/ui/desktop/src/agent/index.ts @@ -17,5 +17,13 @@ export async function initializeAgent({ model, provider }: initializeAgentProps) model: model, }), }); + + if (!response.ok) { + const responseText = await response.text(); + throw new Error( + `Failed to initialize agent: ${response.status} ${response.statusText} - ${responseText}` + ); + } + return response; } diff --git a/ui/desktop/src/components/settings/providers/ProviderSettingsPage.tsx b/ui/desktop/src/components/settings/providers/ProviderSettingsPage.tsx index 7b92b967dfa2..816cb4f7a62c 100644 --- a/ui/desktop/src/components/settings/providers/ProviderSettingsPage.tsx +++ b/ui/desktop/src/components/settings/providers/ProviderSettingsPage.tsx @@ -73,15 +73,25 @@ export default function ProviderSettings({ onClose, isOnboarding }: ProviderSett getExtensions, addExtension, }); + + toastService.configure({ silent: false }); + toastService.success({ + title: 'Success!', + msg: `Started goose with ${model} by ${provider.metadata.display_name}. You can change the model via the lower right corner.`, + }); + + onClose(); } catch (error) { console.error(`Failed to initialize with provider ${provider_name}:`, error); + + // Show error toast + toastService.configure({ silent: false }); + toastService.error({ + title: 'Initialization Failed', + msg: `Failed to initialize with ${provider.metadata.display_name}: ${error instanceof Error ? error.message : String(error)}`, + traceback: error instanceof Error ? error.stack || '' : '', + }); } - toastService.configure({ silent: false }); - toastService.success({ - title: 'Success!', - msg: `Started goose with ${model} by ${provider.metadata.display_name}. You can change the model via the lower right corner.`, - }); - onClose(); }, [onClose, upsert, getExtensions, addExtension] ); diff --git a/ui/desktop/src/hooks/useMessageStream.ts b/ui/desktop/src/hooks/useMessageStream.ts index 1f300f0c5cf6..e4db0ac4372e 100644 --- a/ui/desktop/src/hooks/useMessageStream.ts +++ b/ui/desktop/src/hooks/useMessageStream.ts @@ -449,12 +449,6 @@ export function useMessageStream({ // Filter out messages where sendToLLM is explicitly false const filteredMessages = requestMessages.filter((message) => message.sendToLLM !== false); - // Log request details for debugging - console.log('Request details:', { - messages: filteredMessages, - body: extraMetadataRef.current.body, - }); - // Send request to the server const response = await fetch(api, { method: 'POST', @@ -529,8 +523,6 @@ export function useMessageStream({ // If a string is passed, convert it to a Message object const messageToAppend = typeof message === 'string' ? createUserMessage(message) : message; - console.log('Appending message:', JSON.stringify(messageToAppend, null, 2)); - const currentMessages = [...messagesRef.current, messageToAppend]; mutate(currentMessages, false); await sendRequest(currentMessages); diff --git a/ui/desktop/src/utils/providerUtils.ts b/ui/desktop/src/utils/providerUtils.ts index e79435dff07c..4c01006a81cc 100644 --- a/ui/desktop/src/utils/providerUtils.ts +++ b/ui/desktop/src/utils/providerUtils.ts @@ -206,6 +206,7 @@ export const initializeSystem = async ( : desktopPrompt, }), }); + if (!response.ok) { console.warn(`Failed to extend system prompt: ${response.statusText}`); } else { @@ -229,8 +230,6 @@ export const initializeSystem = async ( }); if (!sessionConfigResponse.ok) { console.warn(`Failed to configure session: ${sessionConfigResponse.statusText}`); - } else { - console.log('Configured session with response schema'); } } @@ -244,7 +243,6 @@ export const initializeSystem = async ( const configVersion = localStorage.getItem('configVersion'); const shouldMigrateExtensions = !configVersion || parseInt(configVersion, 10) < 3; - console.log(`shouldMigrateExtensions is ${shouldMigrateExtensions}`); if (shouldMigrateExtensions) { await migrateExtensionsToSettingsV3(); } From ad0ba6feef5953caa8e2c3f910c9b78ae3723c61 Mon Sep 17 00:00:00 2001 From: Zane Staggs Date: Thu, 17 Jul 2025 18:47:17 -0700 Subject: [PATCH 2/2] Removed launch session in current window option until we can debug more --- .../components/schedule/ScheduleDetailView.tsx | 16 ---------------- .../components/sessions/SessionHistoryView.tsx | 9 +-------- .../src/components/sessions/SessionsView.tsx | 12 ------------ 3 files changed, 1 insertion(+), 36 deletions(-) diff --git a/ui/desktop/src/components/schedule/ScheduleDetailView.tsx b/ui/desktop/src/components/schedule/ScheduleDetailView.tsx index 171f0ed61899..e8bfd92e2596 100644 --- a/ui/desktop/src/components/schedule/ScheduleDetailView.tsx +++ b/ui/desktop/src/components/schedule/ScheduleDetailView.tsx @@ -449,21 +449,6 @@ const ScheduleDetailView: React.FC = ({ scheduleId, onN loadAndShowSessionDetails(sessionIdFromCard); }; - const handleResumeViewedSession = () => { - if (selectedSessionDetails) { - const { session_id, metadata } = selectedSessionDetails; - if (metadata.working_dir) { - console.log( - `Resuming session ID ${session_id} in new chat window. Dir: ${metadata.working_dir}` - ); - window.electron.createChatWindow(undefined, metadata.working_dir, undefined, session_id); - } else { - console.error('Cannot resume session: working directory is missing.'); - toastError({ title: 'Cannot Resume Session', msg: 'Working directory is missing.' }); - } - } - }; - if (selectedSessionDetails) { return ( = ({ scheduleId, onN setSelectedSessionDetails(null); setSessionDetailsError(null); }} - onResume={handleResumeViewedSession} onRetry={() => loadAndShowSessionDetails(selectedSessionDetails.session_id)} showActionButtons={true} /> diff --git a/ui/desktop/src/components/sessions/SessionHistoryView.tsx b/ui/desktop/src/components/sessions/SessionHistoryView.tsx index 9d058f8fd4b2..e2bc544d7478 100644 --- a/ui/desktop/src/components/sessions/SessionHistoryView.tsx +++ b/ui/desktop/src/components/sessions/SessionHistoryView.tsx @@ -10,7 +10,6 @@ import { Target, LoaderCircle, AlertCircle, - ExternalLink, } from 'lucide-react'; import { type SessionDetails } from '../../sessions'; import { Button } from '../ui/button'; @@ -53,7 +52,6 @@ interface SessionHistoryViewProps { isLoading: boolean; error: string | null; onBack: () => void; - onResume: () => void; onRetry: () => void; showActionButtons?: boolean; } @@ -148,7 +146,6 @@ const SessionHistoryView: React.FC = ({ isLoading, error, onBack, - onResume, onRetry, showActionButtons = true, }) => { @@ -271,14 +268,10 @@ const SessionHistoryView: React.FC = ({ )} - - ) : null; diff --git a/ui/desktop/src/components/sessions/SessionsView.tsx b/ui/desktop/src/components/sessions/SessionsView.tsx index 1d41ab4bd21a..9fa3eb1848e6 100644 --- a/ui/desktop/src/components/sessions/SessionsView.tsx +++ b/ui/desktop/src/components/sessions/SessionsView.tsx @@ -63,17 +63,6 @@ const SessionsView: React.FC = ({ setView }) => { setError(null); }; - const handleResumeSession = () => { - if (selectedSession) { - console.log('Resuming session in current window:', selectedSession.session_id); - - // Navigate to pair view with the session data - setView('pair', { - resumedSession: selectedSession, - }); - } - }; - const handleRetryLoadSession = () => { if (selectedSession) { loadSessionDetails(selectedSession.session_id); @@ -99,7 +88,6 @@ const SessionsView: React.FC = ({ setView }) => { isLoading={isLoadingSession} error={error} onBack={handleBackToSessions} - onResume={handleResumeSession} onRetry={handleRetryLoadSession} /> ) : (