Fix launching session in new window (#3497)
This commit is contained in:
@@ -763,6 +763,34 @@ export default function App() {
|
|||||||
// Check for session resume first - this takes priority over other navigation
|
// Check for session resume first - this takes priority over other navigation
|
||||||
if (resumeSessionId) {
|
if (resumeSessionId) {
|
||||||
console.log('Session resume detected, letting useChat hook handle navigation');
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,5 +17,13 @@ export async function initializeAgent({ model, provider }: initializeAgentProps)
|
|||||||
model: model,
|
model: model,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const responseText = await response.text();
|
||||||
|
throw new Error(
|
||||||
|
`Failed to initialize agent: ${response.status} ${response.statusText} - ${responseText}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -449,21 +449,6 @@ const ScheduleDetailView: React.FC<ScheduleDetailViewProps> = ({ scheduleId, onN
|
|||||||
loadAndShowSessionDetails(sessionIdFromCard);
|
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) {
|
if (selectedSessionDetails) {
|
||||||
return (
|
return (
|
||||||
<SessionHistoryView
|
<SessionHistoryView
|
||||||
@@ -474,7 +459,6 @@ const ScheduleDetailView: React.FC<ScheduleDetailViewProps> = ({ scheduleId, onN
|
|||||||
setSelectedSessionDetails(null);
|
setSelectedSessionDetails(null);
|
||||||
setSessionDetailsError(null);
|
setSessionDetailsError(null);
|
||||||
}}
|
}}
|
||||||
onResume={handleResumeViewedSession}
|
|
||||||
onRetry={() => loadAndShowSessionDetails(selectedSessionDetails.session_id)}
|
onRetry={() => loadAndShowSessionDetails(selectedSessionDetails.session_id)}
|
||||||
showActionButtons={true}
|
showActionButtons={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
Target,
|
Target,
|
||||||
LoaderCircle,
|
LoaderCircle,
|
||||||
AlertCircle,
|
AlertCircle,
|
||||||
ExternalLink,
|
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { type SessionDetails } from '../../sessions';
|
import { type SessionDetails } from '../../sessions';
|
||||||
import { Button } from '../ui/button';
|
import { Button } from '../ui/button';
|
||||||
@@ -53,7 +52,6 @@ interface SessionHistoryViewProps {
|
|||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
error: string | null;
|
error: string | null;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onResume: () => void;
|
|
||||||
onRetry: () => void;
|
onRetry: () => void;
|
||||||
showActionButtons?: boolean;
|
showActionButtons?: boolean;
|
||||||
}
|
}
|
||||||
@@ -148,7 +146,6 @@ const SessionHistoryView: React.FC<SessionHistoryViewProps> = ({
|
|||||||
isLoading,
|
isLoading,
|
||||||
error,
|
error,
|
||||||
onBack,
|
onBack,
|
||||||
onResume,
|
|
||||||
onRetry,
|
onRetry,
|
||||||
showActionButtons = true,
|
showActionButtons = true,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -271,14 +268,10 @@ const SessionHistoryView: React.FC<SessionHistoryViewProps> = ({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={onResume} size="sm" variant="outline">
|
<Button onClick={handleLaunchInNewWindow} size="sm" variant="outline">
|
||||||
<Sparkles className="w-4 h-4" />
|
<Sparkles className="w-4 h-4" />
|
||||||
Resume
|
Resume
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handleLaunchInNewWindow} size="sm" variant="outline">
|
|
||||||
<ExternalLink className="w-4 h-4" />
|
|
||||||
New Window
|
|
||||||
</Button>
|
|
||||||
</>
|
</>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
|
|||||||
@@ -63,17 +63,6 @@ const SessionsView: React.FC<SessionsViewProps> = ({ setView }) => {
|
|||||||
setError(null);
|
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 = () => {
|
const handleRetryLoadSession = () => {
|
||||||
if (selectedSession) {
|
if (selectedSession) {
|
||||||
loadSessionDetails(selectedSession.session_id);
|
loadSessionDetails(selectedSession.session_id);
|
||||||
@@ -99,7 +88,6 @@ const SessionsView: React.FC<SessionsViewProps> = ({ setView }) => {
|
|||||||
isLoading={isLoadingSession}
|
isLoading={isLoadingSession}
|
||||||
error={error}
|
error={error}
|
||||||
onBack={handleBackToSessions}
|
onBack={handleBackToSessions}
|
||||||
onResume={handleResumeSession}
|
|
||||||
onRetry={handleRetryLoadSession}
|
onRetry={handleRetryLoadSession}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -73,15 +73,25 @@ export default function ProviderSettings({ onClose, isOnboarding }: ProviderSett
|
|||||||
getExtensions,
|
getExtensions,
|
||||||
addExtension,
|
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) {
|
} catch (error) {
|
||||||
console.error(`Failed to initialize with provider ${provider_name}:`, 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]
|
[onClose, upsert, getExtensions, addExtension]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -449,12 +449,6 @@ export function useMessageStream({
|
|||||||
// Filter out messages where sendToLLM is explicitly false
|
// Filter out messages where sendToLLM is explicitly false
|
||||||
const filteredMessages = requestMessages.filter((message) => message.sendToLLM !== 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
|
// Send request to the server
|
||||||
const response = await fetch(api, {
|
const response = await fetch(api, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -529,8 +523,6 @@ export function useMessageStream({
|
|||||||
// If a string is passed, convert it to a Message object
|
// If a string is passed, convert it to a Message object
|
||||||
const messageToAppend = typeof message === 'string' ? createUserMessage(message) : message;
|
const messageToAppend = typeof message === 'string' ? createUserMessage(message) : message;
|
||||||
|
|
||||||
console.log('Appending message:', JSON.stringify(messageToAppend, null, 2));
|
|
||||||
|
|
||||||
const currentMessages = [...messagesRef.current, messageToAppend];
|
const currentMessages = [...messagesRef.current, messageToAppend];
|
||||||
mutate(currentMessages, false);
|
mutate(currentMessages, false);
|
||||||
await sendRequest(currentMessages);
|
await sendRequest(currentMessages);
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ export const initializeSystem = async (
|
|||||||
: desktopPrompt,
|
: desktopPrompt,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.warn(`Failed to extend system prompt: ${response.statusText}`);
|
console.warn(`Failed to extend system prompt: ${response.statusText}`);
|
||||||
} else {
|
} else {
|
||||||
@@ -229,8 +230,6 @@ export const initializeSystem = async (
|
|||||||
});
|
});
|
||||||
if (!sessionConfigResponse.ok) {
|
if (!sessionConfigResponse.ok) {
|
||||||
console.warn(`Failed to configure session: ${sessionConfigResponse.statusText}`);
|
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 configVersion = localStorage.getItem('configVersion');
|
||||||
const shouldMigrateExtensions = !configVersion || parseInt(configVersion, 10) < 3;
|
const shouldMigrateExtensions = !configVersion || parseInt(configVersion, 10) < 3;
|
||||||
|
|
||||||
console.log(`shouldMigrateExtensions is ${shouldMigrateExtensions}`);
|
|
||||||
if (shouldMigrateExtensions) {
|
if (shouldMigrateExtensions) {
|
||||||
await migrateExtensionsToSettingsV3();
|
await migrateExtensionsToSettingsV3();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user