From b1bf9d7173aea9c41cc59ac9114801e709719792 Mon Sep 17 00:00:00 2001 From: Zaki Ali Date: Fri, 11 Apr 2025 17:27:58 -0700 Subject: [PATCH] fix: recipe deeplinks --- ui/desktop/src/components/ChatView.tsx | 29 ++++++++++--------- .../src/components/more_menu/MoreMenu.tsx | 21 ++++++++++---- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/ui/desktop/src/components/ChatView.tsx b/ui/desktop/src/components/ChatView.tsx index 3ec4e01d..6bd272e3 100644 --- a/ui/desktop/src/components/ChatView.tsx +++ b/ui/desktop/src/components/ChatView.tsx @@ -72,8 +72,8 @@ export default function ChatView({ const [isGeneratingRecipe, setIsGeneratingRecipe] = useState(false); const scrollRef = useRef(null); - // Get botConfig directly from appConfig - const botConfig = window.appConfig.get('botConfig') as Recipe | null; + // Get recipeConfig directly from appConfig + const recipeConfig = window.appConfig.get('recipeConfig') as Recipe | null; const { messages, @@ -125,8 +125,8 @@ export default function ChatView({ // Create recipe directly from chat messages const createRecipeRequest = { messages: messages, - title: 'Custom Recipe', - description: 'Created from chat session', + title: '', + description: '', }; const response = await createRecipe(createRecipeRequest); @@ -138,14 +138,13 @@ export default function ChatView({ window.electron.logInfo('Created recipe:'); window.electron.logInfo(JSON.stringify(response.recipe, null, 2)); - // Create a new window for the recipe editor - console.log('Opening recipe editor with config:', response.recipe); - // First, verify the recipe data - if (!response.recipe || !response.recipe.title) { - throw new Error('Invalid recipe data received'); + if (!response.recipe) { + throw new Error('No recipe data received'); } + // Create a new window for the recipe editor + console.log('Opening recipe editor with config:', response.recipe); window.electron.createChatWindow( undefined, // query undefined, // dir @@ -368,11 +367,13 @@ export default function ChatView({ - {botConfig?.title && messages.length > 0 && ( + {recipeConfig?.title && messages.length > 0 && ( { // Handle profile change @@ -383,8 +384,8 @@ export default function ChatView({ {messages.length === 0 ? ( append(createUserMessage(text))} - activities={Array.isArray(botConfig?.activities) ? botConfig.activities : null} - title={botConfig?.title} + activities={Array.isArray(recipeConfig?.activities) ? recipeConfig.activities : null} + title={recipeConfig?.title} /> ) : ( diff --git a/ui/desktop/src/components/more_menu/MoreMenu.tsx b/ui/desktop/src/components/more_menu/MoreMenu.tsx index 973efd45..e0c29ed9 100644 --- a/ui/desktop/src/components/more_menu/MoreMenu.tsx +++ b/ui/desktop/src/components/more_menu/MoreMenu.tsx @@ -224,18 +224,29 @@ export default function MoreMenu({ Configure .goosehints - {/* Make Agent from Chat */} + {/* Make Agent from Chat - disabled if already in a recipe */} { - setOpen(false); - // Signal to ChatView that we want to make an agent from the current chat - window.electron.logInfo('Make Agent button clicked'); - window.dispatchEvent(new CustomEvent('make-agent-from-chat')); + const recipeConfig = window.appConfig.get('recipeConfig'); + if (!recipeConfig) { + setOpen(false); + // Signal to ChatView that we want to make an agent from the current chat + window.electron.logInfo('Make Agent button clicked'); + window.dispatchEvent(new CustomEvent('make-agent-from-chat')); + } }} subtitle="Make a custom agent you can share or reuse with a link" icon={} + className={ + window.appConfig.get('recipeConfig') ? 'opacity-50 cursor-not-allowed' : '' + } > Make Agent from this session + {window.appConfig.get('recipeConfig') && ( +
+ (Not available while using a recipe/botling) +
+ )}