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
+1 -1
View File
@@ -10,7 +10,7 @@ export default function LauncherView() {
if (query.trim()) {
const initialMessage = query;
setQuery('');
window.electron.createChatWindow(initialMessage, getInitialWorkingDir());
window.electron.createChatWindow({ query: initialMessage, dir: getInitialWorkingDir() });
setTimeout(() => {
window.electron.closeWindow();
}, 200);
@@ -84,10 +84,9 @@ const AppLayoutContent: React.FC<AppLayoutContentProps> = ({ activeSessions }) =
};
const handleNewWindow = () => {
window.electron.createChatWindow(
undefined,
window.appConfig.get('GOOSE_WORKING_DIR') as string | undefined
);
window.electron.createChatWindow({
dir: window.appConfig.get('GOOSE_WORKING_DIR') as string | undefined,
});
};
return (
@@ -75,7 +75,7 @@ const ParameterInputModal: React.FC<ParameterInputModalProps> = ({
if (option === 'new-chat') {
try {
const workingDir = getInitialWorkingDir();
window.electron.createChatWindow(undefined, workingDir);
window.electron.createChatWindow({ dir: workingDir });
window.electron.hideWindow();
} catch (error) {
console.error('Error creating new window:', error);
@@ -1,12 +1,6 @@
import React, { useState, useEffect, useCallback } from 'react';
import { useForm } from '@tanstack/react-form';
import {
Recipe,
generateDeepLink,
Parameter,
encodeRecipe,
stripEmptyExtensions,
} from '../../recipe';
import { Recipe, generateDeepLink, Parameter } from '../../recipe';
import { Check, ExternalLink, Play, Save, X } from 'lucide-react';
import { Geese } from '../icons/Geese';
import Copy from '../icons/Copy';
@@ -333,21 +327,12 @@ export default function CreateEditRecipeModal({
try {
const recipe = getCurrentRecipe();
await saveRecipe(recipe, recipeId);
const savedId = await saveRecipe(recipe, recipeId);
// Close modal first
onClose(true);
// Encode the recipe as a deeplink before passing to the new window
const encodedRecipe = await encodeRecipe(stripEmptyExtensions(recipe));
window.electron.createChatWindow(
undefined,
undefined,
undefined,
undefined,
undefined,
encodedRecipe
);
window.electron.createChatWindow({ recipeId: savedId });
toastSuccess({
title: recipe.title,
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import { useForm } from '@tanstack/react-form';
import { Recipe, encodeRecipe, stripEmptyExtensions } from '../../recipe';
import { Recipe } from '../../recipe';
import { Geese } from '../icons/Geese';
import { X, Save, Play, Loader2 } from 'lucide-react';
import { Button } from '../ui/button';
@@ -182,21 +182,13 @@ export default function CreateRecipeFromSessionModal({
: undefined,
};
await saveRecipe(recipe, null);
const recipeId = await saveRecipe(recipe, null);
onRecipeCreated?.(recipe);
onClose();
if (runAfterSave) {
const encodedRecipe = await encodeRecipe(stripEmptyExtensions(recipe));
window.electron.createChatWindow(
undefined,
undefined,
undefined,
undefined,
undefined,
encodedRecipe
);
window.electron.createChatWindow({ recipeId });
}
} catch (error) {
console.error('Failed to create recipe:', error);
@@ -32,7 +32,7 @@ import {
} from '../../api';
import ImportRecipeForm, { ImportRecipeButton } from './ImportRecipeForm';
import CreateEditRecipeModal from './CreateEditRecipeModal';
import { generateDeepLink, encodeRecipe, Recipe, stripEmptyExtensions } from '../../recipe';
import { generateDeepLink } from '../../recipe';
import { useNavigation } from '../../hooks/useNavigation';
import { CronPicker } from '../schedule/CronPicker';
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 {
const newAgent = await startAgent({
body: {
working_dir: getInitialWorkingDir(),
recipe: stripEmptyExtensions(recipe) as Recipe,
recipe_id: recipeId,
},
throwOnError: true,
});
@@ -165,17 +165,13 @@ export default function RecipesView() {
}
};
const handleStartRecipeChatInNewWindow = async (recipe: Recipe) => {
const handleStartRecipeChatInNewWindow = async (recipeId: string) => {
try {
const encodedRecipe = await encodeRecipe(stripEmptyExtensions(recipe) as Recipe);
window.electron.createChatWindow(
undefined,
getInitialWorkingDir(),
undefined,
undefined,
'pair',
encodedRecipe
);
window.electron.createChatWindow({
dir: getInitialWorkingDir(),
viewType: 'pair',
recipeId,
});
trackRecipeStarted(true, undefined, true);
} catch (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">
<Button
onClick={(e) => {
onClick={async (e) => {
e.stopPropagation();
handleStartRecipeChat(recipe);
await handleStartRecipeChat(recipeManifestResponse.id);
}}
size="sm"
className="h-8 w-8 p-0"
@@ -520,9 +516,9 @@ export default function RecipesView() {
<Play className="w-4 h-4" />
</Button>
<Button
onClick={(e) => {
onClick={async (e) => {
e.stopPropagation();
handleStartRecipeChatInNewWindow(recipe);
await handleStartRecipeChatInNewWindow(recipeManifestResponse.id);
}}
variant="outline"
size="sm"
@@ -532,9 +528,9 @@ export default function RecipesView() {
<ExternalLink className="w-4 h-4" />
</Button>
<Button
onClick={(e) => {
onClick={async (e) => {
e.stopPropagation();
handleEditRecipe(recipeManifestResponse);
await handleEditRecipe(recipeManifestResponse);
}}
variant="outline"
size="sm"
@@ -536,13 +536,11 @@ const SessionListView: React.FC<SessionListViewProps> = React.memo(
const handleOpenInNewWindow = useCallback((session: Session, e: React.MouseEvent) => {
e.stopPropagation();
window.electron.createChatWindow(
undefined,
session.working_dir,
undefined,
session.id,
'pair'
);
window.electron.createChatWindow({
dir: session.working_dir,
resumeSessionId: session.id,
viewType: 'pair',
});
}, []);
const SessionItem = React.memo(function SessionItem({