fix: loading shared sessions (#3607)
This commit is contained in:
+22
-40
@@ -535,17 +535,18 @@ const SharedSessionRouteWrapper = ({
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const sessionDetails = location.state?.sessionDetails as SharedSessionDetails | null;
|
||||
const error = location.state?.error || sharedSessionError;
|
||||
const shareToken = location.state?.shareToken;
|
||||
const baseUrl = location.state?.baseUrl;
|
||||
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 (
|
||||
<SharedSessionView
|
||||
session={sessionDetails}
|
||||
isLoading={isLoadingSharedSession}
|
||||
error={error}
|
||||
onBack={() => navigate('/sessions')}
|
||||
onRetry={async () => {
|
||||
if (shareToken && baseUrl) {
|
||||
setIsLoadingSharedSession(true);
|
||||
@@ -1024,51 +1025,32 @@ export default function App() {
|
||||
const handleOpenSharedSession = async (_event: IpcRendererEvent, ...args: unknown[]) => {
|
||||
const link = args[0] as string;
|
||||
window.electron.logInfo(`Opening shared session from deep link ${link}`);
|
||||
setIsLoadingSession(true);
|
||||
setIsLoadingSharedSession(true);
|
||||
setSharedSessionError(null);
|
||||
try {
|
||||
await openSharedSessionFromDeepLink(
|
||||
link,
|
||||
(view: View, _options?: SessionLinksViewOptions) => {
|
||||
// Convert view to route navigation
|
||||
switch (view) {
|
||||
case 'chat':
|
||||
window.history.replaceState({}, '', '/');
|
||||
break;
|
||||
case 'settings':
|
||||
window.history.replaceState({}, '', '/settings');
|
||||
break;
|
||||
case 'sessions':
|
||||
window.history.replaceState({}, '', '/sessions');
|
||||
break;
|
||||
case 'schedules':
|
||||
window.history.replaceState({}, '', '/schedules');
|
||||
break;
|
||||
case 'recipes':
|
||||
window.history.replaceState({}, '', '/recipes');
|
||||
break;
|
||||
case 'permission':
|
||||
window.history.replaceState({}, '', '/permission');
|
||||
break;
|
||||
case 'ConfigureProviders':
|
||||
window.history.replaceState({}, '', '/configure-providers');
|
||||
break;
|
||||
case 'sharedSession':
|
||||
window.history.replaceState({}, '', '/shared-session');
|
||||
break;
|
||||
case 'recipeEditor':
|
||||
window.history.replaceState({}, '', '/recipe-editor');
|
||||
break;
|
||||
default:
|
||||
window.history.replaceState({}, '', '/');
|
||||
(_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);
|
||||
window.history.replaceState({}, '', '/sessions');
|
||||
// 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 {
|
||||
setIsLoadingSession(false);
|
||||
setIsLoadingSharedSession(false);
|
||||
}
|
||||
};
|
||||
window.electron.on('open-shared-session', handleOpenSharedSession);
|
||||
|
||||
Reference in New Issue
Block a user