diff --git a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua index c75bae13..816357ba 100644 --- a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua +++ b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua @@ -2119,6 +2119,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1016188706"] = "Are you sure -- Move chat UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1133040906"] = "Move chat" +-- Unnamed workspace +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1307384014"] = "Unnamed workspace" + -- Delete UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1469573738"] = "Delete" @@ -2164,6 +2167,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T3045856778"] = "Move Chat to -- Please enter a new or edit the name for your workspace '{0}': UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T323280982"] = "Please enter a new or edit the name for your workspace '{0}':" +-- Unnamed chat +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T3310482275"] = "Unnamed chat" + -- Rename UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T3355849203"] = "Rename" @@ -5692,5 +5698,8 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T497939286"] = -- Please select a model. UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T818893091"] = "Please select a model." +-- Unnamed workspace +UI_TEXT_CONTENT["AISTUDIO::TOOLS::WORKSPACEBEHAVIOUR::T1307384014"] = "Unnamed workspace" + -- Delete Chat UI_TEXT_CONTENT["AISTUDIO::TOOLS::WORKSPACEBEHAVIOUR::T2244038752"] = "Delete Chat" diff --git a/app/MindWork AI Studio/Components/Workspaces.razor.cs b/app/MindWork AI Studio/Components/Workspaces.razor.cs index cbce4fdd..beb10a24 100644 --- a/app/MindWork AI Studio/Components/Workspaces.razor.cs +++ b/app/MindWork AI Studio/Components/Workspaces.razor.cs @@ -112,9 +112,30 @@ public partial class Workspaces : MSGComponentBase // Enumerate the chat directories: foreach (var tempChatDirPath in Directory.EnumerateDirectories(temporaryDirectories)) { - // Read the `name` file: + // Read or create the `name` file (self-heal): var chatNamePath = Path.Join(tempChatDirPath, "name"); - var chatName = await File.ReadAllTextAsync(chatNamePath, Encoding.UTF8); + string chatName; + try + { + if (!File.Exists(chatNamePath)) + { + chatName = T("Unnamed chat"); + await File.WriteAllTextAsync(chatNamePath, chatName, Encoding.UTF8); + } + else + { + chatName = await File.ReadAllTextAsync(chatNamePath, Encoding.UTF8); + if (string.IsNullOrWhiteSpace(chatName)) + { + chatName = T("Unnamed chat"); + await File.WriteAllTextAsync(chatNamePath, chatName, Encoding.UTF8); + } + } + } + catch + { + chatName = T("Unnamed chat"); + } // Read the last change time of the chat: var chatThreadPath = Path.Join(tempChatDirPath, "thread.json"); @@ -158,9 +179,30 @@ public partial class Workspaces : MSGComponentBase // Enumerate the workspace directories: foreach (var workspaceDirPath in Directory.EnumerateDirectories(workspaceDirectories)) { - // Read the `name` file: + // Read or create the `name` file (self-heal): var workspaceNamePath = Path.Join(workspaceDirPath, "name"); - var workspaceName = await File.ReadAllTextAsync(workspaceNamePath, Encoding.UTF8); + string workspaceName; + try + { + if (!File.Exists(workspaceNamePath)) + { + workspaceName = T("Unnamed workspace"); + await File.WriteAllTextAsync(workspaceNamePath, workspaceName, Encoding.UTF8); + } + else + { + workspaceName = await File.ReadAllTextAsync(workspaceNamePath, Encoding.UTF8); + if (string.IsNullOrWhiteSpace(workspaceName)) + { + workspaceName = T("Unnamed workspace"); + await File.WriteAllTextAsync(workspaceNamePath, workspaceName, Encoding.UTF8); + } + } + } + catch + { + workspaceName = T("Unnamed workspace"); + } workspaces.Add(new TreeItemData { @@ -194,9 +236,30 @@ public partial class Workspaces : MSGComponentBase // Enumerate the workspace directory: foreach (var chatPath in Directory.EnumerateDirectories(workspacePath)) { - // Read the `name` file: + // Read or create the `name` file (self-heal): var chatNamePath = Path.Join(chatPath, "name"); - var chatName = await File.ReadAllTextAsync(chatNamePath, Encoding.UTF8); + string chatName; + try + { + if (!File.Exists(chatNamePath)) + { + chatName = T("Unnamed chat"); + await File.WriteAllTextAsync(chatNamePath, chatName, Encoding.UTF8); + } + else + { + chatName = await File.ReadAllTextAsync(chatNamePath, Encoding.UTF8); + if (string.IsNullOrWhiteSpace(chatName)) + { + chatName = T("Unnamed chat"); + await File.WriteAllTextAsync(chatNamePath, chatName, Encoding.UTF8); + } + } + } + catch + { + chatName = T("Unnamed chat"); + } // Read the last change time of the chat: var chatThreadPath = Path.Join(chatPath, "thread.json"); diff --git a/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua b/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua index c1777807..948e6972 100644 --- a/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua +++ b/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua @@ -2121,6 +2121,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1016188706"] = "Möchten Sie -- Move chat UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1133040906"] = "Chat verschieben" +-- Unnamed workspace +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1307384014"] = "Unbenannter Arbeitsbereich" + -- Delete UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1469573738"] = "Löschen" @@ -2166,6 +2169,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T3045856778"] = "Chat in den -- Please enter a new or edit the name for your workspace '{0}': UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T323280982"] = "Bitte geben Sie einen neuen Namen für ihren Arbeitsbereich „{0}“ ein oder bearbeiten Sie ihn:" +-- Unnamed chat +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T3310482275"] = "Unbenannter Chat" + -- Rename UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T3355849203"] = "Umbenennen" @@ -5694,5 +5700,8 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T497939286"] = -- Please select a model. UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T818893091"] = "Bitte wählen Sie ein Modell aus." +-- Unnamed workspace +UI_TEXT_CONTENT["AISTUDIO::TOOLS::WORKSPACEBEHAVIOUR::T1307384014"] = "Unbenannter Arbeitsbereich" + -- Delete Chat UI_TEXT_CONTENT["AISTUDIO::TOOLS::WORKSPACEBEHAVIOUR::T2244038752"] = "Chat löschen" diff --git a/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua b/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua index d7104563..017b5e0c 100644 --- a/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua +++ b/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua @@ -2121,6 +2121,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1016188706"] = "Are you sure -- Move chat UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1133040906"] = "Move chat" +-- Unnamed workspace +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1307384014"] = "Unnamed workspace" + -- Delete UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T1469573738"] = "Delete" @@ -2166,6 +2169,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T3045856778"] = "Move Chat to -- Please enter a new or edit the name for your workspace '{0}': UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T323280982"] = "Please enter a new or edit the name for your workspace '{0}':" +-- Unnamed chat +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T3310482275"] = "Unnamed chat" + -- Rename UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::WORKSPACES::T3355849203"] = "Rename" @@ -5694,5 +5700,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T497939286"] = -- Please select a model. UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T818893091"] = "Please select a model." +-- Unnamed workspace +UI_TEXT_CONTENT["AISTUDIO::TOOLS::WORKSPACEBEHAVIOUR::T1307384014"] = "Unnamed workspace" + -- Delete Chat UI_TEXT_CONTENT["AISTUDIO::TOOLS::WORKSPACEBEHAVIOUR::T2244038752"] = "Delete Chat" + diff --git a/app/MindWork AI Studio/Tools/WorkspaceBehaviour.cs b/app/MindWork AI Studio/Tools/WorkspaceBehaviour.cs index 00a6d68f..66d665ca 100644 --- a/app/MindWork AI Studio/Tools/WorkspaceBehaviour.cs +++ b/app/MindWork AI Studio/Tools/WorkspaceBehaviour.cs @@ -83,7 +83,33 @@ public static class WorkspaceBehaviour var workspacePath = Path.Join(SettingsManager.DataDirectory, "workspaces", workspaceId.ToString()); var workspaceNamePath = Path.Join(workspacePath, "name"); - return await File.ReadAllTextAsync(workspaceNamePath, Encoding.UTF8); + + try + { + // If the name file does not exist or is empty, self-heal with a default name. + if (!File.Exists(workspaceNamePath)) + { + var defaultName = TB("Unnamed workspace"); + Directory.CreateDirectory(workspacePath); + await File.WriteAllTextAsync(workspaceNamePath, defaultName, Encoding.UTF8); + return defaultName; + } + + var name = await File.ReadAllTextAsync(workspaceNamePath, Encoding.UTF8); + if (string.IsNullOrWhiteSpace(name)) + { + var defaultName = TB("Unnamed workspace"); + await File.WriteAllTextAsync(workspaceNamePath, defaultName, Encoding.UTF8); + return defaultName; + } + + return name; + } + catch + { + // On any error, return a localized default without throwing. + return TB("Unnamed workspace"); + } } public static async Task DeleteChat(IDialogService dialogService, Guid workspaceId, Guid chatId, bool askForConfirmation = true) @@ -124,13 +150,30 @@ public static class WorkspaceBehaviour private static async Task EnsureWorkspace(Guid workspaceId, string workspaceName) { var workspacePath = Path.Join(SettingsManager.DataDirectory, "workspaces", workspaceId.ToString()); - - if(Path.Exists(workspacePath)) - return; - - Directory.CreateDirectory(workspacePath); var workspaceNamePath = Path.Join(workspacePath, "name"); - await File.WriteAllTextAsync(workspaceNamePath, workspaceName, Encoding.UTF8); + + if(!Path.Exists(workspacePath)) + Directory.CreateDirectory(workspacePath); + + try + { + // When the name file is missing or empty, write it (self-heal). + // Otherwise, keep the existing name: + if (!File.Exists(workspaceNamePath)) + { + await File.WriteAllTextAsync(workspaceNamePath, workspaceName, Encoding.UTF8); + } + else + { + var existing = await File.ReadAllTextAsync(workspaceNamePath, Encoding.UTF8); + if (string.IsNullOrWhiteSpace(existing)) + await File.WriteAllTextAsync(workspaceNamePath, workspaceName, Encoding.UTF8); + } + } + catch + { + // Ignore IO issues to avoid interrupting background initialization. + } } public static async Task EnsureBiasWorkspace() => await EnsureWorkspace(KnownWorkspaces.BIAS_WORKSPACE_ID, "Bias of the Day"); diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.51.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.51.md index 2b70b396..63b7c673 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.51.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.51.md @@ -6,3 +6,4 @@ - Improved plugin management for configuration plugins so that hot reload detects when a provider or chat template has been removed. - Changed the configuration plugin setting name for how often to check for updates from `UpdateBehavior` to `UpdateInterval`. - Fixed a bug in various assistants where some text fields were not reset when resetting. +- Fixed a rare chat-related bug that could occur when a workspace was not created correctly. Thank you, Naomi, for reporting this issue. \ No newline at end of file