Add support for changing working dir and extensions in same window/session (#6057)

This commit is contained in:
Zane
2026-01-08 16:48:15 -08:00
committed by GitHub
parent 4a60f026d5
commit 9a01fcb740
49 changed files with 1865 additions and 1204 deletions
+34 -7
View File
@@ -1,5 +1,11 @@
import { Session, startAgent } from './api';
import { Session, startAgent, ExtensionConfig } from './api';
import type { setViewType } from './hooks/useNavigation';
import {
getExtensionConfigsWithOverrides,
clearExtensionOverrides,
hasExtensionOverrides,
} from './store/extensionOverrides';
import type { FixedExtensionEntry } from './components/ConfigContext';
export function resumeSession(session: Session, setView: setViewType) {
setView('pair', {
@@ -8,16 +14,22 @@ export function resumeSession(session: Session, setView: setViewType) {
});
}
export async function createSession(options?: {
recipeId?: string;
recipeDeeplink?: string;
}): Promise<Session> {
export async function createSession(
workingDir: string,
options?: {
recipeId?: string;
recipeDeeplink?: string;
extensionConfigs?: ExtensionConfig[];
allExtensions?: FixedExtensionEntry[];
}
): Promise<Session> {
const body: {
working_dir: string;
recipe_id?: string;
recipe_deeplink?: string;
extension_overrides?: ExtensionConfig[];
} = {
working_dir: window.appConfig.get('GOOSE_WORKING_DIR') as string,
working_dir: workingDir,
};
if (options?.recipeId) {
@@ -26,22 +38,37 @@ export async function createSession(options?: {
body.recipe_deeplink = options.recipeDeeplink;
}
if (options?.extensionConfigs && options.extensionConfigs.length > 0) {
body.extension_overrides = options.extensionConfigs;
} else if (options?.allExtensions) {
const extensionConfigs = getExtensionConfigsWithOverrides(options.allExtensions);
if (extensionConfigs.length > 0) {
body.extension_overrides = extensionConfigs;
}
if (hasExtensionOverrides()) {
clearExtensionOverrides();
}
}
const newAgent = await startAgent({
body,
throwOnError: true,
});
return newAgent.data;
}
export async function startNewSession(
workingDir: string,
initialText: string | undefined,
setView: setViewType,
options?: {
recipeId?: string;
recipeDeeplink?: string;
allExtensions?: FixedExtensionEntry[];
}
): Promise<Session> {
const session = await createSession(options);
const session = await createSession(workingDir, options);
setView('pair', {
disableAnimation: true,