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
+39 -14
View File
@@ -1,19 +1,17 @@
import { Session } from './api';
import { Session, startAgent } from './api';
import type { setViewType } from './hooks/useNavigation';
export function resumeSession(
session: Session,
navigateInSameWindow?: (sessionId: string) => void
) {
const workingDir = session.working_dir;
if (!workingDir) {
throw new Error('Cannot resume session: working directory is missing in session');
}
// When ALPHA is true and we have a navigation callback, resume in the same window
// Otherwise, open in a new window (old behavior)
if (process.env.ALPHA && navigateInSameWindow) {
navigateInSameWindow(session.id);
export function resumeSession(session: Session, setView: setViewType) {
if (process.env.ALPHA) {
setView('pair', {
disableAnimation: true,
resumeSessionId: session.id,
});
} else {
const workingDir = session.working_dir;
if (!workingDir) {
throw new Error('Cannot resume session: working directory is missing in session');
}
window.electron.createChatWindow(
undefined, // query
workingDir,
@@ -22,3 +20,30 @@ export function resumeSession(
);
}
}
export async function startNewSession(
initialText: string | undefined,
resetChat: (() => void) | null,
setView: setViewType
) {
if (!resetChat || 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: initialText,
resumeSessionId: session.id,
});
} else {
resetChat();
setView('pair', {
disableAnimation: true,
initialMessage: initialText,
});
}
}