Goose recover (#5450)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
+39
-14
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user