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
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-17 02:37:51 +09:00
1 parent 485c6d50da
commit 93a7bbb185
1 file changed
+7
+7
View File
@@ -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);