From 93a7bbb18594fb0d59f47bc869c3e62a6b3ee80c Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 16 Nov 2026 18:37:51 +0100 Subject: [PATCH] fix: a folder whose terminal working directory is missing loses the first message and leaves an empty chat (#34552) Sending the first message from a folder whose default terminal points at a working directory that does not exist showed "Working directory is unavailable", but it still created an empty New Chat in the folder and switched to it, with the typed message gone from the message box. Now the warning still shows, but no chat is created: the folder page stays open and the message stays in the message box, ready to send once the directory is fixed. Fixes #34367 --- src/lib/components/chat/Chat.svelte | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index d04570cd36..672db53e6b 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -5484,6 +5484,13 @@ ); if (!createdChat?.id) throw new Error($i18n.t('Failed to create chat')); + if (!_history.currentId) { + // A refused first message leaves no empty chat behind. + await initializeTerminalDirectory(createdChat.id, context).catch(async (error) => { + if (await deleteChatById(localStorage.token, createdChat.id).catch(() => null)) + throw error; + }); + } if (history !== _history || $chatId !== _chatId) return ''; chat = createdChat; if (selectedFolderId) updateFolderChatLists(createdChat, selectedFolderId);