From 671c886c75b238e18e37366a18c7eb4c5cea5431 Mon Sep 17 00:00:00 2001 From: mika kuns Date: Fri, 24 Jul 2026 11:18:06 +0200 Subject: [PATCH] fix(ui): diagnostic error surfacing on attachment drop Opening the dropped IStorageFile stream ran outside the try, so a first-drop failure escaped the async-void handler as an unobserved fault (generic "An error occurred"). Wrap the stream-open loop and surface the exception type via DropStatus; include the exception type in the generic add-file failure too, so the intermittent case is analyzable. --- .../Islands/DetailsIslandViewModel.cs | 3 ++- .../Views/Islands/DetailsIslandView.axaml.cs | 22 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs b/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs index 64f87d60..d7a1b8f0 100644 --- a/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs +++ b/src/ClaudeDo.Ui/ViewModels/Islands/DetailsIslandViewModel.cs @@ -1099,7 +1099,8 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase, IDisposable } catch (Exception ex) { - failures.Add($"{fileName}: {ex.Message}"); + // Keep the exception type in the message so an intermittent failure is analyzable. + failures.Add($"{fileName}: {ex.GetType().Name}: {ex.Message}"); } } diff --git a/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml.cs b/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml.cs index decd3fa2..52f95286 100644 --- a/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml.cs +++ b/src/ClaudeDo.Ui/Views/Islands/DetailsIslandView.axaml.cs @@ -81,14 +81,28 @@ public partial class DetailsIslandView : UserControl if (items is null) return; var files = new List<(string FileName, System.IO.Stream Content)>(); - foreach (var item in items) + try { - if (item is IStorageFile sf) + foreach (var item in items) { - var stream = await sf.OpenReadAsync(); - files.Add((sf.Name, stream)); + if (item is IStorageFile sf) + { + var stream = await sf.OpenReadAsync(); + files.Add((sf.Name, stream)); + } } } + catch (Exception ex) + { + // Opening the dropped stream can fail (shell IO, file lock) before AddFilesAsync + // ever runs; surface it with the exception type so the next occurrence is analyzable + // instead of vanishing as an unobserved async-void fault. + _vm.DropStatus = string.Format( + ClaudeDo.Ui.Localization.Loc.T("details.attachments.dropReadError"), + $"{ex.GetType().Name}: {ex.Message}"); + foreach (var (_, s) in files) await s.DisposeAsync(); + return; + } if (files.Count == 0) return;