Kept the inputs of assistants when you leave them (#1209)

Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
Peer HogeterpandThorsten Sommer authored and GitHub committed 2026-11-28 11:52:17 +01:00
1 parent 1fbc1f4796
commit 7e2f83b19b
83 files changed
+1924 -347

No files matched your search

@@ -0,0 +1,18 @@
using AIStudio.Tools.AssistantSessions;
namespace AIStudio.Tools.Imports;
/// <summary>Identifies the chat, assistant, or visual briefing that owns an import, e.g., the transcription of a media file.</summary>
public readonly record struct ImportOwner(ImportOwnerKind Kind, string Id)
{
public static ImportOwner ForChat(Guid chatId) => new(ImportOwnerKind.CHAT, chatId.ToString("N"));
public static ImportOwner ForAssistant(AssistantSessionKey key) => new(ImportOwnerKind.ASSISTANT, key.ToString());
/// <summary>
/// Creates a persistent import owner for a visual briefing.
/// </summary>
/// <param name="briefingId">The stable briefing identifier.</param>
/// <returns>The import owner.</returns>
public static ImportOwner ForVisualBriefing(Guid briefingId) => new(ImportOwnerKind.VISUAL_BRIEFING, briefingId.ToString("D"));
}
@@ -0,0 +1,21 @@
namespace AIStudio.Tools.Imports;
/// <summary>The kinds of owners of an import, see ImportOwner.</summary>
public enum ImportOwnerKind
{
CHAT,
ASSISTANT,
/// <summary>
/// Identifies persistent media transcripts owned by a visual briefing.
/// </summary>
/// <remarks>
/// A visual briefing cannot use <see cref="ASSISTANT"/>: that kind is keyed by an assistant
/// session, which ends when the user navigates away or closes the app. A briefing is a stored
/// document that outlives both, and its transcripts are stored next to it. The owner is
/// therefore keyed by the briefing ID, see <see cref="ImportOwner.ForVisualBriefing"/>.
/// This is what lets AI Studio re-associate transcripts with the right briefing after a
/// restart, and what lets the UI show a running import on the briefing it belongs to.
/// </remarks>
VISUAL_BRIEFING,
}
@@ -0,0 +1,22 @@
namespace AIStudio.Tools.Imports;
/// <summary>Capabilities of an import owner kind.</summary>
public static class ImportOwnerKindExtensions
{
/// <param name="kind">The owner kind to look up.</param>
extension(ImportOwnerKind kind)
{
/// <summary>
/// Gets whether the owner stores its own source list and transcripts.
/// </summary>
/// <remarks>
/// Owners that persist their own sources take the attached media over immediately and keep it
/// next to the stored document, see <see cref="ImportOwnerKind.VISUAL_BRIEFING"/>. The
/// attachment control must therefore neither wait for the transcription to finish before showing
/// the file, nor deliver the completed transcripts back into its own list afterwards, because
/// the owner already holds them. All other owners rely on that delivery instead.
/// </remarks>
/// <value><c>true</c> when the owner persists its own sources.</value>
public bool PersistsOwnSources => kind is ImportOwnerKind.VISUAL_BRIEFING;
}
}
@@ -0,0 +1,4 @@
namespace AIStudio.Tools.Imports;
/// <summary>Identifies the concrete field inside an owner which an import fills, e.g., an attachment list or a file-content field.</summary>
public readonly record struct ImportTarget(ImportOwner Owner, string TargetId);