mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 03:41:38 +00:00
Improved error handling, logging, and code quality (#584)
Some checks failed
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
Some checks failed
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
This commit is contained in:
parent
7fecbec0d5
commit
0aff45eca3
@ -1,5 +1,3 @@
|
|||||||
using System.Text;
|
|
||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
using AIStudio.Dialogs;
|
using AIStudio.Dialogs;
|
||||||
using AIStudio.Dialogs.Settings;
|
using AIStudio.Dialogs.Settings;
|
||||||
|
|||||||
@ -29,31 +29,49 @@ public partial class ReadFileContent : MSGComponentBase
|
|||||||
{
|
{
|
||||||
var selectedFile = await this.RustService.SelectFile(T("Select file to read its content"));
|
var selectedFile = await this.RustService.SelectFile(T("Select file to read its content"));
|
||||||
if (selectedFile.UserCancelled)
|
if (selectedFile.UserCancelled)
|
||||||
|
{
|
||||||
|
this.Logger.LogInformation("User cancelled the file selection");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!File.Exists(selectedFile.SelectedFilePath))
|
if(!File.Exists(selectedFile.SelectedFilePath))
|
||||||
|
{
|
||||||
|
this.Logger.LogWarning("Selected file does not exist: '{FilePath}'", selectedFile.SelectedFilePath);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var ext = Path.GetExtension(selectedFile.SelectedFilePath).TrimStart('.');
|
var ext = Path.GetExtension(selectedFile.SelectedFilePath).TrimStart('.');
|
||||||
if (Array.Exists(FileTypeFilter.Executables.FilterExtensions, x => x.Equals(ext, StringComparison.OrdinalIgnoreCase)))
|
if (Array.Exists(FileTypeFilter.Executables.FilterExtensions, x => x.Equals(ext, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
|
this.Logger.LogWarning("User attempted to load executable file: {FilePath} with extension: {Extension}", selectedFile.SelectedFilePath, ext);
|
||||||
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.AppBlocking, T("Executables are not allowed")));
|
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.AppBlocking, T("Executables are not allowed")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.Exists(FileTypeFilter.AllImages.FilterExtensions, x => x.Equals(ext, StringComparison.OrdinalIgnoreCase)))
|
if (Array.Exists(FileTypeFilter.AllImages.FilterExtensions, x => x.Equals(ext, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
|
this.Logger.LogWarning("User attempted to load image file: {FilePath} with extension: {Extension}", selectedFile.SelectedFilePath, ext);
|
||||||
await MessageBus.INSTANCE.SendWarning(new(Icons.Material.Filled.ImageNotSupported, T("Images are not supported yet")));
|
await MessageBus.INSTANCE.SendWarning(new(Icons.Material.Filled.ImageNotSupported, T("Images are not supported yet")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.Exists(FileTypeFilter.AllVideos.FilterExtensions, x => x.Equals(ext, StringComparison.OrdinalIgnoreCase)))
|
if (Array.Exists(FileTypeFilter.AllVideos.FilterExtensions, x => x.Equals(ext, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
|
this.Logger.LogWarning("User attempted to load video file: {FilePath} with extension: {Extension}", selectedFile.SelectedFilePath, ext);
|
||||||
await MessageBus.INSTANCE.SendWarning(new(Icons.Material.Filled.FeaturedVideo, this.T("Videos are not supported yet")));
|
await MessageBus.INSTANCE.SendWarning(new(Icons.Material.Filled.FeaturedVideo, this.T("Videos are not supported yet")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileContent = await UserFile.LoadFileData(selectedFile.SelectedFilePath, this.RustService, this.DialogService);
|
try
|
||||||
await this.FileContentChanged.InvokeAsync(fileContent);
|
{
|
||||||
|
var fileContent = await UserFile.LoadFileData(selectedFile.SelectedFilePath, this.RustService, this.DialogService);
|
||||||
|
await this.FileContentChanged.InvokeAsync(fileContent);
|
||||||
|
this.Logger.LogInformation("Successfully loaded file content: {FilePath}", selectedFile.SelectedFilePath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.Logger.LogError(ex, "Failed to load file content: {FilePath}", selectedFile.SelectedFilePath);
|
||||||
|
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Error, T("Failed to load file content")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,10 +33,21 @@ public partial class DocumentCheckDialog : MSGComponentBase
|
|||||||
{
|
{
|
||||||
if (firstRender && !string.IsNullOrWhiteSpace(this.FilePath))
|
if (firstRender && !string.IsNullOrWhiteSpace(this.FilePath))
|
||||||
{
|
{
|
||||||
var fileContent = await UserFile.LoadFileData(this.FilePath, this.RustService, this.DialogService);
|
try
|
||||||
this.FileContent = fileContent;
|
{
|
||||||
this.StateHasChanged();
|
var fileContent = await UserFile.LoadFileData(this.FilePath, this.RustService, this.DialogService);
|
||||||
|
this.FileContent = fileContent;
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.Logger.LogError(ex, "Failed to load file content from '{FilePath}'", this.FilePath);
|
||||||
|
this.FileContent = string.Empty;
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (firstRender)
|
||||||
|
this.Logger.LogWarning("Document check dialog opened without a valid file path");
|
||||||
}
|
}
|
||||||
|
|
||||||
private CodeBlockTheme CodeColorPalette => this.SettingsManager.IsDarkMode ? CodeBlockTheme.Dark : CodeBlockTheme.Default;
|
private CodeBlockTheme CodeColorPalette => this.SettingsManager.IsDarkMode ? CodeBlockTheme.Dark : CodeBlockTheme.Default;
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public static class UserFile
|
|||||||
/// Attempts to load the content of a file at the specified path, ensuring Pandoc is installed and available before proceeding.
|
/// Attempts to load the content of a file at the specified path, ensuring Pandoc is installed and available before proceeding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filePath">The full path to the file to be read. Must not be null or empty.</param>
|
/// <param name="filePath">The full path to the file to be read. Must not be null or empty.</param>
|
||||||
/// <param name="rustService">Rustservice used to read file content.</param>
|
/// <param name="rustService">Rust service used to read file content.</param>
|
||||||
/// <param name="dialogService">Dialogservice used to display the Pandoc installation dialog if needed.</param>
|
/// <param name="dialogService">Dialogservice used to display the Pandoc installation dialog if needed.</param>
|
||||||
public static async Task<string> LoadFileData(string filePath, RustService rustService, IDialogService dialogService)
|
public static async Task<string> LoadFileData(string filePath, RustService rustService, IDialogService dialogService)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,4 +4,5 @@
|
|||||||
- Improved the document analysis assistant (in preview) by adding descriptions to the different sections.
|
- Improved the document analysis assistant (in preview) by adding descriptions to the different sections.
|
||||||
- Improved the document preview dialog for the document analysis assistant (in preview), providing Markdown and plain text views for attached files.
|
- Improved the document preview dialog for the document analysis assistant (in preview), providing Markdown and plain text views for attached files.
|
||||||
- Improved the ID handling for configuration plugins.
|
- Improved the ID handling for configuration plugins.
|
||||||
|
- Improved error handling, logging, and code quality.
|
||||||
- Fixed a bug in the local data sources info dialog (preview feature) for data directories that could cause the app to crash. The error was caused by a background thread producing data while the frontend attempted to display it.
|
- Fixed a bug in the local data sources info dialog (preview feature) for data directories that could cause the app to crash. The error was caused by a background thread producing data while the frontend attempted to display it.
|
||||||
Loading…
Reference in New Issue
Block a user