feat(details): attach clipboard image on Ctrl+V in the task description
Extracts the clipboard bitmap read into a shared ClipboardBitmap helper (also used by the terminal view); the description TextBox now routes an image paste through AddFilesAsync as a unique paste-*.png attachment. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
d8f78056c1
commit
393e59460d
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Media.Imaging;
|
||||
|
||||
namespace ClaudeDo.Ui.Services;
|
||||
|
||||
/// <summary>Reads a bitmap off the clipboard; shared by the terminal view and the description editor.</summary>
|
||||
public static class ClipboardBitmap
|
||||
{
|
||||
/// <summary>The clipboard bitmap (caller disposes), or null if there is none or the read failed.</summary>
|
||||
public static async Task<Bitmap?> TryGetAsync(TopLevel? topLevel)
|
||||
{
|
||||
if (topLevel?.Clipboard is not { } clipboard) return null;
|
||||
try
|
||||
{
|
||||
using var data = await clipboard.TryGetDataAsync();
|
||||
return data is null ? null : await AsyncDataTransferExtensions.TryGetBitmapAsync(data);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,11 @@ public static class ClipboardImageTempStore
|
||||
|
||||
/// <summary>Test seam for <see cref="NewPngPath(DateTime)"/> — takes the target dir explicitly
|
||||
/// instead of the real app data root.</summary>
|
||||
internal static string NewPngPath(string dir, DateTime utcNow) =>
|
||||
Path.Combine(dir, $"paste-{utcNow:yyyyMMdd-HHmmssfff}-{Guid.NewGuid():N}.png");
|
||||
internal static string NewPngPath(string dir, DateTime utcNow) => Path.Combine(dir, NewPngFileName(utcNow));
|
||||
|
||||
/// <summary>A fresh, collision-free <c>paste-….png</c> file name (also used as an attachment name).</summary>
|
||||
public static string NewPngFileName(DateTime utcNow) =>
|
||||
$"paste-{utcNow:yyyyMMdd-HHmmssfff}-{Guid.NewGuid():N}.png";
|
||||
|
||||
/// <summary>Test seam for <see cref="DeleteOlderThan(TimeSpan,DateTime)"/> — takes the target dir
|
||||
/// explicitly instead of the real app data root.</summary>
|
||||
|
||||
Reference in New Issue
Block a user