diff --git a/app/MindWork AI Studio/Chat/FileAttachment.cs b/app/MindWork AI Studio/Chat/FileAttachment.cs index 1208303f..f364ed8f 100644 --- a/app/MindWork AI Studio/Chat/FileAttachment.cs +++ b/app/MindWork AI Studio/Chat/FileAttachment.cs @@ -84,6 +84,9 @@ public record FileAttachment(FileAttachmentType Type, string FileName, string Fi { var extension = Path.GetExtension(filePath).TrimStart('.').ToLowerInvariant(); + if (FileTypeFilter.Executables.FilterExtensions.Contains(extension)) + return FileAttachmentType.FORBIDDEN; + // Check if it's an image file: if (FileTypeFilter.AllImages.FilterExtensions.Contains(extension)) return FileAttachmentType.IMAGE; @@ -96,7 +99,8 @@ public record FileAttachment(FileAttachmentType Type, string FileName, string Fi if (FileTypeFilter.PDF.FilterExtensions.Contains(extension) || FileTypeFilter.Text.FilterExtensions.Contains(extension) || FileTypeFilter.AllOffice.FilterExtensions.Contains(extension) || - FileTypeFilter.AllSourceCode.FilterExtensions.Contains(extension)) + FileTypeFilter.AllSourceCode.FilterExtensions.Contains(extension) || + FileTypeFilter.IsAllowedSourceLikeFileName(filePath)) return FileAttachmentType.DOCUMENT; // All other file types are forbidden: diff --git a/app/MindWork AI Studio/Tools/Rust/FileTypeFilter.cs b/app/MindWork AI Studio/Tools/Rust/FileTypeFilter.cs index 03232070..d93f44e0 100644 --- a/app/MindWork AI Studio/Tools/Rust/FileTypeFilter.cs +++ b/app/MindWork AI Studio/Tools/Rust/FileTypeFilter.cs @@ -12,6 +12,51 @@ namespace AIStudio.Tools.Rust; public readonly record struct FileTypeFilter(string FilterName, string[] FilterExtensions) { private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(FileTypeFilter).Namespace, nameof(FileTypeFilter)); + + private static string[] AllowedSourceLikeFileNames => + [ + "Dockerfile", + "Containerfile", + "Jenkinsfile", + "Makefile", + "GNUmakefile", + "Procfile", + "Vagrantfile", + "Tiltfile", + "Justfile", + "Brewfile", + "Caddyfile", + "Gemfile", + "Podfile", + "Fastfile", + "Appfile", + "Rakefile", + "Dangerfile", + "BUILD", + "WORKSPACE", + "BUCK", + ]; + + private static string[] AllowedSourceLikeFileNamePrefixes => + [ + "Dockerfile", + "Containerfile", + "Jenkinsfile", + "Procfile", + "Caddyfile", + ]; + + public static bool IsAllowedSourceLikeFileName(string filePath) + { + var fileName = Path.GetFileName(filePath); + if (string.IsNullOrWhiteSpace(fileName)) + return false; + + if (AllowedSourceLikeFileNames.Any(name => string.Equals(name, fileName, StringComparison.OrdinalIgnoreCase))) + return true; + + return AllowedSourceLikeFileNamePrefixes.Any(prefix => fileName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)); + } public static FileTypeFilter PDF => new(TB("PDF Files"), ["pdf"]); diff --git a/app/MindWork AI Studio/wwwroot/changelog/v26.3.1.md b/app/MindWork AI Studio/wwwroot/changelog/v26.3.1.md index 25befa8a..1fc66926 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v26.3.1.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v26.3.1.md @@ -7,5 +7,6 @@ - Improved the user-language logging by limiting language detection logs to a single entry per app start. - Improved the logbook readability by removing non-readable special characters from log entries. - Improved the logbook reliability by significantly reducing duplicate log entries. +- Improved file attachments in chats: configuration and project files such as `Dockerfile`, `Caddyfile`, `Makefile`, or `Jenkinsfile` are now included more reliably when you send them to the AI. - Improved the validation of additional API parameters in the advanced provider settings to help catch formatting mistakes earlier. - Fixed an issue where the app could turn white or appear invisible in certain chats after HTML-like content was shown. Thanks Inga for reporting this issue and providing some context on how to reproduce it. \ No newline at end of file