Skip to content

Commit 9cfbc37

Browse files
committed
Refactor OnRunningNodeChanged to fix UI bug in video gen UI improve progress update handling in InferenceGenerationViewModelBase
1 parent 05a418d commit 9cfbc37

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

StabilityMatrix.Avalonia/ViewModels/Base/InferenceGenerationViewModelBase.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected async Task<FilePath> WriteOutputImageAsync(
143143
{
144144
GenerationParameters = args.Parameters,
145145
ProjectType = args.Project?.ProjectType,
146-
ProjectName = ProjectFile?.NameWithoutExtension
146+
ProjectName = ProjectFile?.NameWithoutExtension,
147147
};
148148

149149
// Parse to format
@@ -260,7 +260,7 @@ public async Task RunCustomGeneration(
260260
Project = InferenceProjectDocument.FromLoadable(this),
261261
FilesToTransfer = args.FilesToTransfer,
262262
Parameters = new GenerationParameters(),
263-
ClearOutputImages = true
263+
ClearOutputImages = true,
264264
};
265265

266266
await RunGeneration(generationArgs, cancellationToken);
@@ -410,7 +410,7 @@ await notificationService.ShowAsync(
410410
{
411411
Title = "Prompt Completed",
412412
Body = $"Prompt [{promptTask.Id[..7].ToLower()}] completed successfully",
413-
BodyImagePath = notificationImage?.FullPath
413+
BodyImagePath = notificationImage?.FullPath,
414414
}
415415
);
416416
}
@@ -521,14 +521,14 @@ private async Task<List<ImageSource>> ProcessOutputImages(
521521
var opts = new JsonSerializerOptions
522522
{
523523
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
524-
Converters = { new JsonStringEnumConverter() }
524+
Converters = { new JsonStringEnumConverter() },
525525
};
526526
var paramsJson = JsonSerializer.Serialize(parameters, opts);
527527
var smProject = JsonSerializer.Serialize(project, opts);
528528
var metadata = new Dictionary<ExifTag, string>
529529
{
530530
{ ExifTag.ImageDescription, paramsJson },
531-
{ ExifTag.Software, smProject }
531+
{ ExifTag.Software, smProject },
532532
};
533533

534534
var bytesWithMetadata = ImageMetadata.AddMetadataToWebp(imageArray, metadata);
@@ -779,7 +779,7 @@ out var localSemVersion
779779
{
780780
ShowDialogOnStart = true,
781781
ModificationCompleteTitle = "Extensions Installed",
782-
ModificationCompleteMessage = "Finished installing required extensions"
782+
ModificationCompleteMessage = "Finished installing required extensions",
783783
};
784784
EventManager.Instance.OnPackageInstallProgressAdded(runner);
785785

@@ -859,8 +859,14 @@ private void AttachRunningNodeChangedHandler(ComfyTask comfyTask)
859859
/// </summary>
860860
protected virtual void OnRunningNodeChanged(object? sender, string? nodeName)
861861
{
862-
// Ignore if regular progress updates started
863-
if (sender is not ComfyTask { HasProgressUpdateStarted: false })
862+
var task = sender as ComfyTask;
863+
if (task == null)
864+
{
865+
return;
866+
}
867+
868+
// Ignore if regular progress updates started, unless the running node is different from the one reporting progress
869+
if (task.HasProgressUpdateStarted && task.LastProgressUpdate?.RunningNode == nodeName)
864870
{
865871
return;
866872
}
@@ -906,7 +912,7 @@ public ModuleApplyStepEventArgs ToModuleApplyStepEventArgs()
906912
{
907913
Builder = Builder,
908914
IsEnabledOverrides = overrides,
909-
FilesToTransfer = FilesToTransfer
915+
FilesToTransfer = FilesToTransfer,
910916
};
911917
}
912918

0 commit comments

Comments
 (0)