Conversation
Co-authored-by: jamesmoore <6506748+jamesmoore@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates SDMetaUI (and a few SDMeta core interfaces/DTOs) to be nullable-aware under <Nullable>enable</Nullable>, aiming to eliminate CS8xxx nullability warnings by tightening annotations, adding guards, and adjusting a couple of APIs.
Changes:
- Annotates component parameters/backing fields and view-model properties with nullable reference types and adds null-safe dereferences/guards.
- Adjusts file-system and loader APIs/events to align with nullable patterns (e.g., nullable
GetImageFileresult, event sender nullability). - Refactors model-filter handling to use a shared
AllModelssentinel and makes query DTOs nullable-friendly records.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| SDMetaUI/Shared/Thumbnail.razor.cs | Makes File required and allows nullable Text. |
| SDMetaUI/Shared/FullScreenView.razor.cs | Marks selectedFile required; uses null-forgiving on modal ref. |
| SDMetaUI/Shared/FullScreenView.razor | Uses null-forgiving on hxModal when hiding. |
| SDMetaUI/Shared/FilePanel.razor.cs | Makes display fields nullable and adjusts prompt assignment. |
| SDMetaUI/Shared/FilePanel.razor | Null-forgiving on promptLines enumeration under HasPrompt. |
| SDMetaUI/Services/FileSystemObserver.cs | Changes FileSystemChanged event type and adjusts Reset() invocation args. |
| SDMetaUI/RetryingFileLoader.cs | Updates loader return type to ImageFile?. |
| SDMetaUI/Pages/Settings.razor | Makes dbPath nullable. |
| SDMetaUI/Pages/Index.razor.cs | Makes several fields nullable, adjusts event signatures, adds null-guards, and simplifies InvokeAsync. |
| SDMetaUI/Pages/Index.razor | Uses null-forgiving for onInputDebounced and fullScreenView call. |
| SDMetaUI/Pages/Error.cshtml.cs | Removes primary constructor from ErrorModel. |
| SDMetaUI/Models/ModelSummaryViewModel.cs | Introduces AllModels sentinel and refactors constructors. |
| SDMetaUI/Models/ImageFileViewModelBuilder.cs | Ensures non-null FullPromptHash passed to VM constructor. |
| SDMetaUI/Models/ImageFileViewModel.cs | Makes SubItems nullable. |
| SDMetaUI/Models/GroupedByPromptList.cs | Initializes internal collections to empty, non-null defaults. |
| SDMetaUI/Models/GalleryViewModel.cs | Makes Filter nullable, adds null-guards, and initializes Rows. |
| SDMetaUI/Models/FilteredList.cs | Uses AllModels sentinel, makes Filter nullable, and updates query construction. |
| SDMeta/ImageFileLoader.cs | Updates return type to ImageFile?. |
| SDMeta/IImageFileLoader.cs | Changes interface to return Task<ImageFile?>. |
| SDMeta/CachedImageFileLoader.cs | Handles nullable loader result and avoids writing null to data source. |
| SDMeta/Cache/IImageFileDataSource.cs | Converts QueryParams/ModelFilter to nullable-capable records. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public record QueryParams(string? Filter, ModelFilter? ModelFilter, QuerySortBy QuerySortBy); | ||
|
|
||
| public class ModelFilter(string model, string modelHash) | ||
| { | ||
| public string Model { get; } = model; | ||
| public string ModelHash { get; } = modelHash; | ||
| } | ||
| public record class ModelFilter(string? Model, string? ModelHash); | ||
|
|
There was a problem hiding this comment.
The PR description mentions needing to pass null! because QueryParams required non-nullable ModelFilter, but the code now defines QueryParams/ModelFilter as nullable records (ModelFilter? and string?). Update the PR description to match the current implementation so reviewers/users aren't misled about runtime null-handling requirements.
| var realFile = imagefileDataSource.ReadImageFile(selectedFile.FileName); | ||
| if (realFile != null) | ||
| { | ||
| fileSize = realFile.Length.GetBytesReadable(); | ||
| lastUpdated = realFile.LastUpdated.ToString(); |
There was a problem hiding this comment.
OnParametersSetAsync() only updates fileSize/lastUpdated/fullPrompt/promptLines/promptFormat when ReadImageFile(...) returns non-null. If the data source returns null (missing DB entry, race during rescan, etc.), the component will keep displaying values from the previously selected file. Clear these fields when realFile == null (or before the lookup) so the UI doesn't show stale metadata.
There was a problem hiding this comment.
Added an else branch in OnParametersSetAsync that sets all display fields (fileSize, lastUpdated, fullPrompt, promptLines, promptFormat) to null when ReadImageFile returns null, so the panel won't show stale metadata from a previously selected file. (commit 13dae6c)
| public event EventHandler? FileSystemChanged; | ||
| private readonly List<string> added = []; |
There was a problem hiding this comment.
Changing FileSystemChanged from FileSystemEventHandler to untyped EventHandler is a breaking public API change and also drops compile-time access to FileSystemEventArgs for subscribers (even though OnCreated/OnDeleted still raise with FileSystemEventArgs). If the intent is just nullable-sender compatibility, consider EventHandler<FileSystemEventArgs> (or a custom args type) instead of erasing the event args type.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…display Co-authored-by: jamesmoore <6506748+jamesmoore@users.noreply.github.com>
Models/FilteredList.cs: makemodelFilterandfilterfields nullable, update property types andRunFilter()Models/ImageFileViewModel.cs: makeSubItemsnullableModels/ImageFileViewModelBuilder.cs: handle nullableFullPromptHashModels/GalleryViewModel.cs: initializeRows, makeModelFilter/Filternullable, fixRemoveFile(), fixMovePrevious()/MoveNext()Models/GroupedByPromptList.cs: change nullable fields to non-nullable with initializationShared/FilePanel.razor.cs: fix parameter default, nullable fields,OnParametersSetAsync()— clear all display fields whenrealFile == nullto avoid stale metadataShared/FilePanel.razor: fix nullablepromptLinesin foreachShared/FullScreenView.razor.cs: fix parameter default,hxModalnull handlingShared/FullScreenView.razor: fixhxModal.HideAsync()callShared/Thumbnail.razor.cs: fixFileparameter default, makeTextnullablePages/Index.razor.cs: fix event handler signatures, nullable fields, null checksPages/Index.razor: fix nullableonInputDebouncedandfullScreenViewusagesServices/FileSystemObserver.cs: fixnullpassed to event invocationPages/Settings.razor: makedbPathnullableRetryingFileLoader.cs: usenull!for return💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.