mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 02:07:21 +00:00
Fixed assistants undoing your changes while a run you left continues (#1111)
This commit is contained in:
1 parent
31c271eb7b
commit
7f72da628e
8 files changed
+322
-6
No files matched your search
@@ -181,6 +181,7 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
private MediaImportOwner CurrentMediaImportOwner => MediaImportOwner.ForAssistant(this.assistantSessionKey);
|
||||
private Guid? assistantSessionId;
|
||||
private AssistantSessionSnapshot? pendingRenderedAssistantSessionSnapshot;
|
||||
private AssistantSessionSnapshot? lastAttachedAssistantSessionSnapshot;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the Blazor component instance has already been disposed.
|
||||
@@ -1042,13 +1043,21 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
/// <summary>
|
||||
/// Applies an assistant session snapshot to this component instance.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When the user leaves an assistant while it runs and comes back, this component only shows the run.
|
||||
/// The component which started it keeps working out of sight and reports every few seconds, yet its
|
||||
/// form stays as it was when the user left. So once this component has taken over a run, it takes over
|
||||
/// only what the running assistant changed since, such as the progress and the result. What the user
|
||||
/// changes here stays, just as it would in the component which started the run.
|
||||
/// </remarks>
|
||||
/// <param name="snapshot">The snapshot to attach.</param>
|
||||
/// <param name="restoreClientOnlyContent">Whether derived assistants should restore client-only UI state.</param>
|
||||
/// <returns>A task that completes after the component was refreshed.</returns>
|
||||
private async Task AttachAssistantSession(AssistantSessionSnapshot snapshot, bool restoreClientOnlyContent)
|
||||
{
|
||||
this.assistantSessionId = snapshot.SessionId;
|
||||
this.ImportAssistantSessionState(snapshot.State);
|
||||
this.ImportAssistantSessionState(snapshot.StateChangedSince(this.lastAttachedAssistantSessionSnapshot));
|
||||
this.lastAttachedAssistantSessionSnapshot = snapshot;
|
||||
this.ChatThread = snapshot.ChatThread ?? this.ChatThread;
|
||||
this.IsProcessing = snapshot.IsActive;
|
||||
|
||||
|
||||
+14
-1
@@ -217,7 +217,20 @@ public partial class SlideAssistant
|
||||
return;
|
||||
}
|
||||
|
||||
// A variant of another template means nothing for this one, nor do choices for its slides:
|
||||
this.FitChoicesToTemplate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fits the color variant and the choices for the slides to the loaded template.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A variant of another template means nothing for this one, nor do choices for its slides.
|
||||
/// </remarks>
|
||||
private void FitChoicesToTemplate()
|
||||
{
|
||||
if (this.template is null)
|
||||
return;
|
||||
|
||||
if (this.variantLabel is null || !this.template.VariantLabels.Contains(this.variantLabel))
|
||||
this.variantLabel = this.template.VariantLabels.FirstOrDefault();
|
||||
|
||||
|
||||
@@ -346,6 +346,10 @@ public partial class SlideAssistant : AssistantBaseCore<SettingsDialogSlideBuild
|
||||
/// <inheritdoc />
|
||||
protected override void RestoreCustomAssistantSessionState(AssistantSessionStateReader state)
|
||||
{
|
||||
var previousTemplatePath = this.templatePath;
|
||||
var previousSlideDeckAnswer = this.slideDeckAnswer;
|
||||
var previousPictureLibraryPath = this.pictureLibraryPath;
|
||||
|
||||
state.Restore(INPUT_TITLE_STATE_KEY, value => this.inputTitle = value);
|
||||
state.Restore(INPUT_CONTENT_STATE_KEY, value => this.inputContent = value);
|
||||
state.Restore(CUSTOM_TARGET_LANGUAGE_STATE_KEY, value => this.customTargetLanguage = value);
|
||||
@@ -377,10 +381,22 @@ public partial class SlideAssistant : AssistantBaseCore<SettingsDialogSlideBuild
|
||||
state.RestoreDictionary(SLIDE_DECK_BASIS_STATE_KEY, this.slideDeckBasis);
|
||||
state.Restore(PLANNING_STEP_STATE_KEY, value => this.planningStep = value);
|
||||
|
||||
// Neither the template nor the slides are kept themselves, only what they were read from:
|
||||
this.LoadTemplate();
|
||||
this.RestoreSlideDeck();
|
||||
this.StartCountingPictureLibrary();
|
||||
//
|
||||
// Neither the template nor the slides nor the count of the library are kept themselves, only
|
||||
// what they were read from. A running session stores its state every few seconds, and the
|
||||
// template is read on the thread of the renderer, maybe from a network drive. So each one is
|
||||
// read again only when what it was read from has changed:
|
||||
//
|
||||
if (string.Equals(previousTemplatePath, this.templatePath, StringComparison.Ordinal))
|
||||
this.FitChoicesToTemplate();
|
||||
else
|
||||
this.LoadTemplate();
|
||||
|
||||
if (!string.Equals(previousSlideDeckAnswer, this.slideDeckAnswer, StringComparison.Ordinal))
|
||||
this.RestoreSlideDeck();
|
||||
|
||||
if (!string.Equals(previousPictureLibraryPath, this.pictureLibraryPath, StringComparison.Ordinal))
|
||||
this.StartCountingPictureLibrary();
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
Reference in new issue
Block a user