refactor: change open recipe in new window to pass recipe id (#7392)

This commit is contained in:
Zane
2026-02-23 07:24:00 -08:00
committed by GitHub
parent 33af64406b
commit ffed9dfc4f
12 changed files with 162 additions and 198 deletions
+17 -4
View File
@@ -84,17 +84,23 @@ const PairRouteWrapper = ({
const resumeSessionId = searchParams.get('resumeSessionId') ?? undefined; const resumeSessionId = searchParams.get('resumeSessionId') ?? undefined;
const recipeDeeplinkFromConfig = window.appConfig?.get('recipeDeeplink') as string | undefined; const recipeDeeplinkFromConfig = window.appConfig?.get('recipeDeeplink') as string | undefined;
const recipeIdFromConfig = window.appConfig?.get('recipeId') as string | undefined;
const initialMessage = routeState.initialMessage; const initialMessage = routeState.initialMessage;
// Create session if we have an initialMessage or recipeDeeplink but no sessionId // Create session if we have an initialMessage, recipeDeeplink, or recipeId but no sessionId
useEffect(() => { useEffect(() => {
if ((initialMessage || recipeDeeplinkFromConfig) && !resumeSessionId && !isCreatingSession) { if (
(initialMessage || recipeDeeplinkFromConfig || recipeIdFromConfig) &&
!resumeSessionId &&
!isCreatingSession
) {
setIsCreatingSession(true); setIsCreatingSession(true);
(async () => { (async () => {
try { try {
const newSession = await createSession(getInitialWorkingDir(), { const newSession = await createSession(getInitialWorkingDir(), {
recipeDeeplink: recipeDeeplinkFromConfig, recipeDeeplink: recipeDeeplinkFromConfig,
recipeId: recipeIdFromConfig,
allExtensions: extensionsList, allExtensions: extensionsList,
}); });
@@ -126,7 +132,14 @@ const PairRouteWrapper = ({
// Note: isCreatingSession is intentionally NOT in the dependency array // Note: isCreatingSession is intentionally NOT in the dependency array
// It's only used as a guard to prevent concurrent session creation // It's only used as a guard to prevent concurrent session creation
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [initialMessage, recipeDeeplinkFromConfig, resumeSessionId, setSearchParams, extensionsList]); }, [
initialMessage,
recipeDeeplinkFromConfig,
recipeIdFromConfig,
resumeSessionId,
setSearchParams,
extensionsList,
]);
// Add resumed session to active sessions if not already there // Add resumed session to active sessions if not already there
useEffect(() => { useEffect(() => {
@@ -450,7 +463,7 @@ export function AppInner() {
if ((isMac ? event.metaKey : event.ctrlKey) && event.key === 'n') { if ((isMac ? event.metaKey : event.ctrlKey) && event.key === 'n') {
event.preventDefault(); event.preventDefault();
try { try {
window.electron.createChatWindow(undefined, getInitialWorkingDir()); window.electron.createChatWindow({ dir: getInitialWorkingDir() });
} catch (error) { } catch (error) {
console.error('Error creating new window:', error); console.error('Error creating new window:', error);
} }
+1 -1
View File
@@ -10,7 +10,7 @@ export default function LauncherView() {
if (query.trim()) { if (query.trim()) {
const initialMessage = query; const initialMessage = query;
setQuery(''); setQuery('');
window.electron.createChatWindow(initialMessage, getInitialWorkingDir()); window.electron.createChatWindow({ query: initialMessage, dir: getInitialWorkingDir() });
setTimeout(() => { setTimeout(() => {
window.electron.closeWindow(); window.electron.closeWindow();
}, 200); }, 200);
@@ -84,10 +84,9 @@ const AppLayoutContent: React.FC<AppLayoutContentProps> = ({ activeSessions }) =
}; };
const handleNewWindow = () => { const handleNewWindow = () => {
window.electron.createChatWindow( window.electron.createChatWindow({
undefined, dir: window.appConfig.get('GOOSE_WORKING_DIR') as string | undefined,
window.appConfig.get('GOOSE_WORKING_DIR') as string | undefined });
);
}; };
return ( return (
@@ -75,7 +75,7 @@ const ParameterInputModal: React.FC<ParameterInputModalProps> = ({
if (option === 'new-chat') { if (option === 'new-chat') {
try { try {
const workingDir = getInitialWorkingDir(); const workingDir = getInitialWorkingDir();
window.electron.createChatWindow(undefined, workingDir); window.electron.createChatWindow({ dir: workingDir });
window.electron.hideWindow(); window.electron.hideWindow();
} catch (error) { } catch (error) {
console.error('Error creating new window:', error); console.error('Error creating new window:', error);
@@ -1,12 +1,6 @@
import React, { useState, useEffect, useCallback } from 'react'; import React, { useState, useEffect, useCallback } from 'react';
import { useForm } from '@tanstack/react-form'; import { useForm } from '@tanstack/react-form';
import { import { Recipe, generateDeepLink, Parameter } from '../../recipe';
Recipe,
generateDeepLink,
Parameter,
encodeRecipe,
stripEmptyExtensions,
} from '../../recipe';
import { Check, ExternalLink, Play, Save, X } from 'lucide-react'; import { Check, ExternalLink, Play, Save, X } from 'lucide-react';
import { Geese } from '../icons/Geese'; import { Geese } from '../icons/Geese';
import Copy from '../icons/Copy'; import Copy from '../icons/Copy';
@@ -333,21 +327,12 @@ export default function CreateEditRecipeModal({
try { try {
const recipe = getCurrentRecipe(); const recipe = getCurrentRecipe();
await saveRecipe(recipe, recipeId); const savedId = await saveRecipe(recipe, recipeId);
// Close modal first // Close modal first
onClose(true); onClose(true);
// Encode the recipe as a deeplink before passing to the new window window.electron.createChatWindow({ recipeId: savedId });
const encodedRecipe = await encodeRecipe(stripEmptyExtensions(recipe));
window.electron.createChatWindow(
undefined,
undefined,
undefined,
undefined,
undefined,
encodedRecipe
);
toastSuccess({ toastSuccess({
title: recipe.title, title: recipe.title,
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { useForm } from '@tanstack/react-form'; import { useForm } from '@tanstack/react-form';
import { Recipe, encodeRecipe, stripEmptyExtensions } from '../../recipe'; import { Recipe } from '../../recipe';
import { Geese } from '../icons/Geese'; import { Geese } from '../icons/Geese';
import { X, Save, Play, Loader2 } from 'lucide-react'; import { X, Save, Play, Loader2 } from 'lucide-react';
import { Button } from '../ui/button'; import { Button } from '../ui/button';
@@ -182,21 +182,13 @@ export default function CreateRecipeFromSessionModal({
: undefined, : undefined,
}; };
await saveRecipe(recipe, null); const recipeId = await saveRecipe(recipe, null);
onRecipeCreated?.(recipe); onRecipeCreated?.(recipe);
onClose(); onClose();
if (runAfterSave) { if (runAfterSave) {
const encodedRecipe = await encodeRecipe(stripEmptyExtensions(recipe)); window.electron.createChatWindow({ recipeId });
window.electron.createChatWindow(
undefined,
undefined,
undefined,
undefined,
undefined,
encodedRecipe
);
} }
} catch (error) { } catch (error) {
console.error('Failed to create recipe:', error); console.error('Failed to create recipe:', error);
@@ -32,7 +32,7 @@ import {
} from '../../api'; } from '../../api';
import ImportRecipeForm, { ImportRecipeButton } from './ImportRecipeForm'; import ImportRecipeForm, { ImportRecipeButton } from './ImportRecipeForm';
import CreateEditRecipeModal from './CreateEditRecipeModal'; import CreateEditRecipeModal from './CreateEditRecipeModal';
import { generateDeepLink, encodeRecipe, Recipe, stripEmptyExtensions } from '../../recipe'; import { generateDeepLink } from '../../recipe';
import { useNavigation } from '../../hooks/useNavigation'; import { useNavigation } from '../../hooks/useNavigation';
import { CronPicker } from '../schedule/CronPicker'; import { CronPicker } from '../schedule/CronPicker';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/dialog'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/dialog';
@@ -139,12 +139,12 @@ export default function RecipesView() {
} }
}; };
const handleStartRecipeChat = async (recipe: Recipe) => { const handleStartRecipeChat = async (recipeId: string) => {
try { try {
const newAgent = await startAgent({ const newAgent = await startAgent({
body: { body: {
working_dir: getInitialWorkingDir(), working_dir: getInitialWorkingDir(),
recipe: stripEmptyExtensions(recipe) as Recipe, recipe_id: recipeId,
}, },
throwOnError: true, throwOnError: true,
}); });
@@ -165,17 +165,13 @@ export default function RecipesView() {
} }
}; };
const handleStartRecipeChatInNewWindow = async (recipe: Recipe) => { const handleStartRecipeChatInNewWindow = async (recipeId: string) => {
try { try {
const encodedRecipe = await encodeRecipe(stripEmptyExtensions(recipe) as Recipe); window.electron.createChatWindow({
window.electron.createChatWindow( dir: getInitialWorkingDir(),
undefined, viewType: 'pair',
getInitialWorkingDir(), recipeId,
undefined, });
undefined,
'pair',
encodedRecipe
);
trackRecipeStarted(true, undefined, true); trackRecipeStarted(true, undefined, true);
} catch (error) { } catch (error) {
console.error('Failed to open recipe in new window:', error); console.error('Failed to open recipe in new window:', error);
@@ -509,9 +505,9 @@ export default function RecipesView() {
<div className="flex items-center gap-2 shrink-0"> <div className="flex items-center gap-2 shrink-0">
<Button <Button
onClick={(e) => { onClick={async (e) => {
e.stopPropagation(); e.stopPropagation();
handleStartRecipeChat(recipe); await handleStartRecipeChat(recipeManifestResponse.id);
}} }}
size="sm" size="sm"
className="h-8 w-8 p-0" className="h-8 w-8 p-0"
@@ -520,9 +516,9 @@ export default function RecipesView() {
<Play className="w-4 h-4" /> <Play className="w-4 h-4" />
</Button> </Button>
<Button <Button
onClick={(e) => { onClick={async (e) => {
e.stopPropagation(); e.stopPropagation();
handleStartRecipeChatInNewWindow(recipe); await handleStartRecipeChatInNewWindow(recipeManifestResponse.id);
}} }}
variant="outline" variant="outline"
size="sm" size="sm"
@@ -532,9 +528,9 @@ export default function RecipesView() {
<ExternalLink className="w-4 h-4" /> <ExternalLink className="w-4 h-4" />
</Button> </Button>
<Button <Button
onClick={(e) => { onClick={async (e) => {
e.stopPropagation(); e.stopPropagation();
handleEditRecipe(recipeManifestResponse); await handleEditRecipe(recipeManifestResponse);
}} }}
variant="outline" variant="outline"
size="sm" size="sm"
@@ -536,13 +536,11 @@ const SessionListView: React.FC<SessionListViewProps> = React.memo(
const handleOpenInNewWindow = useCallback((session: Session, e: React.MouseEvent) => { const handleOpenInNewWindow = useCallback((session: Session, e: React.MouseEvent) => {
e.stopPropagation(); e.stopPropagation();
window.electron.createChatWindow( window.electron.createChatWindow({
undefined, dir: session.working_dir,
session.working_dir, resumeSessionId: session.id,
undefined, viewType: 'pair',
session.id, });
'pair'
);
}, []); }, []);
const SessionItem = React.memo(function SessionItem({ const SessionItem = React.memo(function SessionItem({
+94 -106
View File
@@ -158,17 +158,12 @@ if (process.platform !== 'darwin') {
const deeplinkData = parseRecipeDeeplink(protocolUrl); const deeplinkData = parseRecipeDeeplink(protocolUrl);
const scheduledJobId = parsedUrl.searchParams.get('scheduledJob'); const scheduledJobId = parsedUrl.searchParams.get('scheduledJob');
createChat( await createChat(app, {
app, dir: openDir || undefined,
undefined, recipeDeeplink: deeplinkData?.config,
openDir || undefined, scheduledJobId: scheduledJobId || undefined,
undefined, recipeParameters: deeplinkData?.parameters,
undefined, });
undefined,
deeplinkData?.config,
scheduledJobId || undefined,
deeplinkData?.parameters
);
}); });
return; // Skip the rest of the handler return; // Skip the rest of the handler
} }
@@ -217,7 +212,7 @@ async function handleProtocolUrl(url: string) {
const targetWindow = const targetWindow =
existingWindows.length > 0 existingWindows.length > 0
? existingWindows[0] ? existingWindows[0]
: await createChat(app, undefined, openDir || undefined); : await createChat(app, { dir: openDir || undefined });
await processProtocolUrl(parsedUrl, targetWindow); await processProtocolUrl(parsedUrl, targetWindow);
} else { } else {
// For other URL types, reuse existing window if available // For other URL types, reuse existing window if available
@@ -229,7 +224,7 @@ async function handleProtocolUrl(url: string) {
} }
firstOpenWindow.focus(); firstOpenWindow.focus();
} else { } else {
firstOpenWindow = await createChat(app, undefined, openDir || undefined); firstOpenWindow = await createChat(app, { dir: openDir || undefined });
} }
if (firstOpenWindow) { if (firstOpenWindow) {
@@ -258,17 +253,12 @@ async function processProtocolUrl(parsedUrl: URL, window: BrowserWindow) {
const scheduledJobId = parsedUrl.searchParams.get('scheduledJob'); const scheduledJobId = parsedUrl.searchParams.get('scheduledJob');
// Create a new window and ignore the passed-in window // Create a new window and ignore the passed-in window
createChat( await createChat(app, {
app, dir: openDir || undefined,
undefined, recipeDeeplink: deeplinkData?.config,
openDir || undefined, scheduledJobId: scheduledJobId || undefined,
undefined, recipeParameters: deeplinkData?.parameters,
undefined, });
undefined,
deeplinkData?.config,
scheduledJobId || undefined,
deeplinkData?.parameters
);
pendingDeepLink = null; pendingDeepLink = null;
} }
} }
@@ -296,17 +286,12 @@ app.on('open-url', async (_event, url) => {
} }
const scheduledJobId = parsedUrl.searchParams.get('scheduledJob'); const scheduledJobId = parsedUrl.searchParams.get('scheduledJob');
await createChat( await createChat(app, {
app, dir: openDir || undefined,
undefined, recipeDeeplink: deeplinkData?.config,
openDir || undefined, scheduledJobId: scheduledJobId || undefined,
undefined, recipeParameters: deeplinkData?.parameters,
undefined, });
undefined,
deeplinkData?.config,
scheduledJobId || undefined,
deeplinkData?.parameters
);
windowDeeplinkURL = null; windowDeeplinkURL = null;
return; return;
} }
@@ -329,7 +314,7 @@ app.on('open-url', async (_event, url) => {
} }
} else { } else {
openUrlHandledLaunch = true; openUrlHandledLaunch = true;
firstOpenWindow = await createChat(app, undefined, openDir || undefined); firstOpenWindow = await createChat(app, { dir: openDir || undefined });
} }
} }
}); });
@@ -380,7 +365,7 @@ async function handleFileOpen(filePath: string) {
addRecentDir(targetDir); addRecentDir(targetDir);
// Create new window for the directory // Create new window for the directory
const newWindow = await createChat(app, undefined, targetDir); const newWindow = await createChat(app, { dir: targetDir });
// Focus the new window // Focus the new window
if (newWindow) { if (newWindow) {
@@ -478,17 +463,28 @@ const windowPowerSaveBlockers = new Map<number, number>(); // windowId -> blocke
// Track pending initial messages per window // Track pending initial messages per window
const pendingInitialMessages = new Map<number, string>(); // windowId -> initialMessage const pendingInitialMessages = new Map<number, string>(); // windowId -> initialMessage
const createChat = async ( interface CreateChatOptions {
app: App, initialMessage?: string;
initialMessage?: string, dir?: string;
dir?: string, resumeSessionId?: string;
_version?: string, viewType?: string;
resumeSessionId?: string, recipeDeeplink?: string;
viewType?: string, recipeId?: string;
recipeDeeplink?: string, // Raw deeplink decoded on server scheduledJobId?: string;
scheduledJobId?: string, // Scheduled job ID if applicable recipeParameters?: Record<string, string>;
recipeParameters?: Record<string, string> // Recipe parameter values from deeplink URL }
) => {
const createChat = async (app: App, options: CreateChatOptions = {}) => {
const {
initialMessage,
dir,
resumeSessionId,
viewType,
recipeDeeplink,
recipeId,
scheduledJobId,
recipeParameters,
} = options;
const settings = getSettings(); const settings = getSettings();
const serverSecret = getServerSecret(settings); const serverSecret = getServerSecret(settings);
@@ -548,6 +544,7 @@ const createChat = async (
GOOSE_BASE_URL_SHARE: baseUrlShare, GOOSE_BASE_URL_SHARE: baseUrlShare,
GOOSE_VERSION: version, GOOSE_VERSION: version,
recipeDeeplink: recipeDeeplink, recipeDeeplink: recipeDeeplink,
recipeId: recipeId,
recipeParameters: recipeParameters, recipeParameters: recipeParameters,
scheduledJobId: scheduledJobId, scheduledJobId: scheduledJobId,
SECURITY_ML_MODEL_MAPPING: process.env.SECURITY_ML_MODEL_MAPPING, SECURITY_ML_MODEL_MAPPING: process.env.SECURITY_ML_MODEL_MAPPING,
@@ -590,7 +587,7 @@ const createChat = async (
} }
}); });
mainWindow.destroy(); mainWindow.destroy();
return createChat(app, initialMessage, dir); return createChat(app, { initialMessage, dir });
} }
} else { } else {
dialog.showMessageBoxSync({ dialog.showMessageBoxSync({
@@ -720,7 +717,10 @@ const createChat = async (
if (viewType) { if (viewType) {
appPath = routeMap[viewType] || '/'; appPath = routeMap[viewType] || '/';
} }
if (appPath === '/' && (recipeDeeplink !== undefined || initialMessage)) { if (
appPath === '/' &&
(recipeDeeplink !== undefined || recipeId !== undefined || initialMessage)
) {
appPath = '/pair'; appPath = '/pair';
} }
@@ -931,7 +931,7 @@ const showWindow = async () => {
log.info('No windows are open, creating a new one...'); log.info('No windows are open, creating a new one...');
const recentDirs = loadRecentDirs(); const recentDirs = loadRecentDirs();
const openDir = recentDirs.length > 0 ? recentDirs[0] : null; const openDir = recentDirs.length > 0 ? recentDirs[0] : null;
await createChat(app, undefined, openDir || undefined); await createChat(app, { dir: openDir || undefined });
return; return;
} }
@@ -963,8 +963,8 @@ const buildRecentFilesMenu = () => {
const recentDirs = loadRecentDirs(); const recentDirs = loadRecentDirs();
return recentDirs.map((dir) => ({ return recentDirs.map((dir) => ({
label: dir, label: dir,
click: () => { click: async () => {
createChat(app, undefined, dir); await createChat(app, { dir });
}, },
})); }));
}; };
@@ -1052,18 +1052,11 @@ const openDirectoryDialog = async (): Promise<OpenDialogReturnValue> => {
if (windowDeeplinkURL) { if (windowDeeplinkURL) {
deeplinkData = parseRecipeDeeplink(windowDeeplinkURL); deeplinkData = parseRecipeDeeplink(windowDeeplinkURL);
} }
// Create a new window with the selected directory await createChat(app, {
await createChat( dir: dirToAdd,
app, recipeDeeplink: deeplinkData?.config,
undefined, recipeParameters: deeplinkData?.parameters,
dirToAdd, });
undefined,
undefined,
undefined,
deeplinkData?.config,
undefined,
deeplinkData?.parameters
);
} }
return result; return result;
}; };
@@ -1615,7 +1608,7 @@ ipcMain.handle('get-allowed-extensions', async () => {
const createNewWindow = async (app: App, dir?: string | null) => { const createNewWindow = async (app: App, dir?: string | null) => {
const recentDirs = loadRecentDirs(); const recentDirs = loadRecentDirs();
const openDir = dir || (recentDirs.length > 0 ? recentDirs[0] : undefined); const openDir = dir || (recentDirs.length > 0 ? recentDirs[0] : undefined);
return await createChat(app, undefined, openDir); return await createChat(app, { dir: openDir });
}; };
const focusWindow = () => { const focusWindow = () => {
@@ -2032,48 +2025,43 @@ async function appMain() {
} }
}); });
ipcMain.on( ipcMain.on('create-chat-window', (event, options = {}) => {
'create-chat-window', const { query, dir, resumeSessionId, viewType, recipeId } = options;
(event, query, dir, version, resumeSessionId, viewType, recipeDeeplink) => {
if (!dir?.trim()) {
const recentDirs = loadRecentDirs();
dir = recentDirs.length > 0 ? recentDirs[0] : undefined;
}
const isFromLauncher = query && !resumeSessionId && !viewType && !recipeDeeplink; let resolvedDir = dir;
if (!resolvedDir?.trim()) {
if (isFromLauncher) { const recentDirs = loadRecentDirs();
const senderWindow = BrowserWindow.fromWebContents(event.sender); resolvedDir = recentDirs.length > 0 ? recentDirs[0] : undefined;
const launcherWindowId = senderWindow?.id;
const allWindows = BrowserWindow.getAllWindows();
const existingWindows = allWindows.filter(
(win) => !win.isDestroyed() && win.id !== launcherWindowId
);
if (existingWindows.length > 0) {
const targetWindow = existingWindows[0];
targetWindow.show();
targetWindow.focus();
targetWindow.webContents.send('set-initial-message', query);
return;
}
}
// Otherwise, create a new window
createChat(
app,
query,
dir,
version,
resumeSessionId,
viewType,
recipeDeeplink,
undefined,
undefined
);
} }
);
const isFromLauncher = query && !resumeSessionId && !viewType && !recipeId;
if (isFromLauncher) {
const senderWindow = BrowserWindow.fromWebContents(event.sender);
const launcherWindowId = senderWindow?.id;
const allWindows = BrowserWindow.getAllWindows();
const existingWindows = allWindows.filter(
(win) => !win.isDestroyed() && win.id !== launcherWindowId
);
if (existingWindows.length > 0) {
const targetWindow = existingWindows[0];
targetWindow.show();
targetWindow.focus();
targetWindow.webContents.send('set-initial-message', query);
return;
}
}
createChat(app, {
initialMessage: query,
dir: resolvedDir,
resumeSessionId,
viewType,
recipeId,
});
});
ipcMain.on('close-window', (event) => { ipcMain.on('close-window', (event) => {
const window = BrowserWindow.fromWebContents(event.sender); const window = BrowserWindow.fromWebContents(event.sender);
+12 -25
View File
@@ -89,6 +89,15 @@ interface UpdaterEvent {
data?: unknown; data?: unknown;
} }
export interface CreateChatWindowOptions {
query?: string;
dir?: string;
version?: string;
resumeSessionId?: string;
viewType?: string;
recipeId?: string;
}
// Define the API types in a single place // Define the API types in a single place
type ElectronAPI = { type ElectronAPI = {
platform: string; platform: string;
@@ -96,14 +105,7 @@ type ElectronAPI = {
getConfig: () => Record<string, unknown>; getConfig: () => Record<string, unknown>;
hideWindow: () => void; hideWindow: () => void;
directoryChooser: () => Promise<Electron.OpenDialogReturnValue>; directoryChooser: () => Promise<Electron.OpenDialogReturnValue>;
createChatWindow: ( createChatWindow: (options?: CreateChatWindowOptions) => void;
query?: string,
dir?: string,
version?: string,
resumeSessionId?: string,
viewType?: string,
recipeDeeplink?: string
) => void;
logInfo: (txt: string) => void; logInfo: (txt: string) => void;
showNotification: (data: NotificationData) => void; showNotification: (data: NotificationData) => void;
showMessageBox: (options: MessageBoxOptions) => Promise<MessageBoxResponse>; showMessageBox: (options: MessageBoxOptions) => Promise<MessageBoxResponse>;
@@ -188,23 +190,8 @@ const electronAPI: ElectronAPI = {
}, },
hideWindow: () => ipcRenderer.send('hide-window'), hideWindow: () => ipcRenderer.send('hide-window'),
directoryChooser: () => ipcRenderer.invoke('directory-chooser'), directoryChooser: () => ipcRenderer.invoke('directory-chooser'),
createChatWindow: ( createChatWindow: (options?: CreateChatWindowOptions) =>
query?: string, ipcRenderer.send('create-chat-window', options || {}),
dir?: string,
version?: string,
resumeSessionId?: string,
viewType?: string,
recipeDeeplink?: string
) =>
ipcRenderer.send(
'create-chat-window',
query,
dir,
version,
resumeSessionId,
viewType,
recipeDeeplink
),
logInfo: (txt: string) => ipcRenderer.send('logInfo', txt), logInfo: (txt: string) => ipcRenderer.send('logInfo', txt),
showNotification: (data: NotificationData) => ipcRenderer.send('notify', data), showNotification: (data: NotificationData) => ipcRenderer.send('notify', data),
showMessageBox: (options: MessageBoxOptions) => ipcRenderer.invoke('show-message-box', options), showMessageBox: (options: MessageBoxOptions) => ipcRenderer.invoke('show-message-box', options),
+2 -1
View File
@@ -1,10 +1,11 @@
import { Recipe, saveRecipe as saveRecipeApi, listRecipes, RecipeManifest } from '../api'; import { Recipe, saveRecipe as saveRecipeApi, listRecipes, RecipeManifest } from '../api';
import { stripEmptyExtensions } from '.';
export const saveRecipe = async (recipe: Recipe, recipeId?: string | null): Promise<string> => { export const saveRecipe = async (recipe: Recipe, recipeId?: string | null): Promise<string> => {
try { try {
let response = await saveRecipeApi({ let response = await saveRecipeApi({
body: { body: {
recipe, recipe: stripEmptyExtensions(recipe),
id: recipeId, id: recipeId,
}, },
throwOnError: true, throwOnError: true,
+6 -1
View File
@@ -38,6 +38,7 @@ export async function createSession(
workingDir: string, workingDir: string,
options?: { options?: {
recipeDeeplink?: string; recipeDeeplink?: string;
recipeId?: string;
extensionConfigs?: ExtensionConfig[]; extensionConfigs?: ExtensionConfig[];
allExtensions?: FixedExtensionEntry[]; allExtensions?: FixedExtensionEntry[];
} }
@@ -45,12 +46,15 @@ export async function createSession(
const body: { const body: {
working_dir: string; working_dir: string;
recipe?: Recipe; recipe?: Recipe;
recipe_id?: string;
extension_overrides?: ExtensionConfig[]; extension_overrides?: ExtensionConfig[];
} = { } = {
working_dir: workingDir, working_dir: workingDir,
}; };
if (options?.recipeDeeplink) { if (options?.recipeId) {
body.recipe_id = options.recipeId;
} else if (options?.recipeDeeplink) {
body.recipe = await decodeRecipe(options.recipeDeeplink); body.recipe = await decodeRecipe(options.recipeDeeplink);
} }
@@ -79,6 +83,7 @@ export async function startNewSession(
workingDir: string, workingDir: string,
options?: { options?: {
recipeDeeplink?: string; recipeDeeplink?: string;
recipeId?: string;
allExtensions?: FixedExtensionEntry[]; allExtensions?: FixedExtensionEntry[];
} }
): Promise<Session> { ): Promise<Session> {