Next camp refactor live (#5706)

This commit is contained in:
Zane
2025-11-21 14:10:34 -07:00
committed by GitHub
parent c1c772b267
commit d54a06afda
35 changed files with 1105 additions and 2601 deletions
+42 -38
View File
@@ -2,48 +2,52 @@ import { Session, startAgent } from './api';
import type { setViewType } from './hooks/useNavigation';
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,
undefined, // version
session.id
);
setView('pair', {
disableAnimation: true,
resumeSessionId: session.id,
});
}
export async function createSession(options?: {
recipeId?: string;
recipeDeeplink?: string;
}): Promise<Session> {
const body: {
working_dir: string;
recipe_id?: string;
recipe_deeplink?: string;
} = {
working_dir: window.appConfig.get('GOOSE_WORKING_DIR') as string,
};
if (options?.recipeId) {
body.recipe_id = options.recipeId;
} else if (options?.recipeDeeplink) {
body.recipe_deeplink = options.recipeDeeplink;
}
const newAgent = await startAgent({
body,
throwOnError: true,
});
return newAgent.data;
}
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,
});
setView: setViewType,
options?: {
recipeId?: string;
recipeDeeplink?: string;
}
): Promise<Session> {
const session = await createSession(options);
setView('pair', {
disableAnimation: true,
initialMessage: initialText,
resumeSessionId: session.id,
});
return session;
}