Goose recover (#5450)

Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
Douwe Osinga
2025-10-30 18:12:46 -04:00
committed by GitHub
parent 6ea0594fb4
commit 4201e80e8e
8 changed files with 95 additions and 78 deletions
+2 -23
View File
@@ -19,7 +19,7 @@ import ChatInput from './ChatInput';
import { ChatState } from '../types/chatState';
import 'react-toastify/dist/ReactToastify.css';
import { View, ViewOptions } from '../utils/navigationUtils';
import { startAgent } from '../api';
import { startNewSession } from '../sessions';
export default function Hub({
setView,
@@ -37,28 +37,7 @@ export default function Hub({
const combinedTextFromInput = customEvent.detail?.value || '';
if (combinedTextFromInput.trim()) {
if (process.env.ALPHA) {
const newAgent = await startAgent({
body: {
working_dir: window.appConfig.get('GOOSE_WORKING_DIR') as string,
},
throwOnError: true,
});
const session = newAgent.data;
setView('pair', {
disableAnimation: true,
initialMessage: combinedTextFromInput,
resumeSessionId: session.id,
});
} else {
// Navigate to pair page with the message to be submitted
// Pair will handle creating the new chat session
resetChat();
setView('pair', {
disableAnimation: true,
initialMessage: combinedTextFromInput,
});
}
await startNewSession(combinedTextFromInput, resetChat, setView);
e.preventDefault();
}
};
+2 -2
View File
@@ -1,5 +1,4 @@
import { useEffect, useState } from 'react';
import { View, ViewOptions } from '../utils/navigationUtils';
import BaseChat from './BaseChat';
import { useRecipeManager } from '../hooks/useRecipeManager';
import { useIsMobile } from '../hooks/use-mobile';
@@ -10,6 +9,7 @@ import { cn } from '../utils';
import { ChatType } from '../types/chat';
import { useSearchParams } from 'react-router-dom';
import type { setViewType } from '../hooks/useNavigation';
export interface PairRouteState {
resumeSessionId?: string;
@@ -19,7 +19,7 @@ export interface PairRouteState {
interface PairProps {
chat: ChatType;
setChat: (chat: ChatType) => void;
setView: (view: View, viewOptions?: ViewOptions) => void;
setView: setViewType;
setIsGoosehintsModalOpen: (isOpen: boolean) => void;
setFatalError: (value: ((prevState: string | null) => string | null) | string | null) => void;
setAgentWaitingMessage: (msg: string | null) => void;
@@ -31,6 +31,7 @@ import { SearchView } from '../conversation/SearchView';
import BackButton from '../ui/BackButton';
import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/Tooltip';
import { Message, Session } from '../../api';
import { useNavigation } from '../../hooks/useNavigation';
// Helper function to determine if a message is a user message (same as useChatEngine)
const isUserMessage = (message: Message): boolean => {
@@ -150,6 +151,8 @@ const SessionHistoryView: React.FC<SessionHistoryViewProps> = ({
const messages = session.conversation || [];
const setView = useNavigation();
useEffect(() => {
const savedSessionConfig = localStorage.getItem('session_sharing_config');
if (savedSessionConfig) {
@@ -212,15 +215,14 @@ const SessionHistoryView: React.FC<SessionHistoryViewProps> = ({
});
};
const handleLaunchInNewWindow = () => {
const handleResumeSession = () => {
try {
resumeSession(session);
resumeSession(session, setView);
} catch (error) {
toast.error(`Could not launch session: ${error instanceof Error ? error.message : error}`);
}
};
// Define action buttons
const actionButtons = showActionButtons ? (
<>
<Tooltip>
@@ -254,7 +256,7 @@ const SessionHistoryView: React.FC<SessionHistoryViewProps> = ({
</TooltipContent>
) : null}
</Tooltip>
<Button onClick={handleLaunchInNewWindow} size="sm" variant="outline">
<Button onClick={handleResumeSession} size="sm" variant="outline">
<Sparkles className="w-4 h-4" />
Resume
</Button>
@@ -13,6 +13,7 @@ import {
SessionInsights as ApiSessionInsights,
} from '../../api';
import { resumeSession } from '../../sessions';
import { useNavigation } from '../../hooks/useNavigation';
export function SessionInsights() {
const [insights, setInsights] = useState<ApiSessionInsights | null>(null);
@@ -21,6 +22,7 @@ export function SessionInsights() {
const [isLoading, setIsLoading] = useState(true);
const [isLoadingSessions, setIsLoadingSessions] = useState(true);
const navigate = useNavigate();
const setView = useNavigation();
useEffect(() => {
let loadingTimeout: ReturnType<typeof setTimeout>;
@@ -86,9 +88,7 @@ export function SessionInsights() {
const handleSessionClick = async (session: Session) => {
try {
resumeSession(session, (sessionId: string) => {
navigate(`/pair?resumeSessionId=${sessionId}`);
});
resumeSession(session, setView);
} catch (error) {
console.error('Failed to start session:', error);
navigate('/sessions', {
@@ -32,11 +32,17 @@ export async function addToAgent(
toastService.dismiss(toastId);
}
const errMsg = errorMessage(error);
const recoverHints =
`Explain the following error: ${errMsg}. ` +
'This happened while trying to install an extension. Look out for issues that the ' +
"extension tried to run something faulty, didn't exist or there was trouble with " +
'the network configuration - VPNs like WARP often cause issues.';
const msg = errMsg.length < 70 ? errMsg : `Failed to add extension`;
toastService.error({
title: extensionName,
msg: msg,
traceback: errMsg,
recoverHints,
});
throw error;
}