Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions ui/desktop/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,23 @@ const PairRouteWrapper = ({

const resumeSessionId = searchParams.get('resumeSessionId') ?? undefined;
const recipeDeeplinkFromConfig = window.appConfig?.get('recipeDeeplink') as string | undefined;
const recipeIdFromConfig = window.appConfig?.get('recipeId') as string | undefined;
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(() => {
if ((initialMessage || recipeDeeplinkFromConfig) && !resumeSessionId && !isCreatingSession) {
if (
(initialMessage || recipeDeeplinkFromConfig || recipeIdFromConfig) &&
!resumeSessionId &&
!isCreatingSession
) {
setIsCreatingSession(true);

(async () => {
try {
const newSession = await createSession(getInitialWorkingDir(), {
recipeDeeplink: recipeDeeplinkFromConfig,
recipeId: recipeIdFromConfig,
allExtensions: extensionsList,
});

Expand Down Expand Up @@ -126,7 +132,14 @@ const PairRouteWrapper = ({
// Note: isCreatingSession is intentionally NOT in the dependency array
// It's only used as a guard to prevent concurrent session creation
// 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
useEffect(() => {
Expand Down Expand Up @@ -450,7 +463,7 @@ export function AppInner() {
if ((isMac ? event.metaKey : event.ctrlKey) && event.key === 'n') {
event.preventDefault();
try {
window.electron.createChatWindow(undefined, getInitialWorkingDir());
window.electron.createChatWindow({ dir: getInitialWorkingDir() });
} catch (error) {
console.error('Error creating new window:', error);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/desktop/src/components/LauncherView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions ui/desktop/src/components/Layout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion ui/desktop/src/components/ParameterInputModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 3 additions & 18 deletions ui/desktop/src/components/recipes/CreateEditRecipeModal.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 3 additions & 11 deletions ui/desktop/src/components/recipes/CreateRecipeFromSessionModal.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down
34 changes: 15 additions & 19 deletions ui/desktop/src/components/recipes/RecipesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
});
Expand All @@ -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);
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
12 changes: 5 additions & 7 deletions ui/desktop/src/components/sessions/SessionListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading
Loading