fix: Update capability checks and enhance search functionality in Semantic Search#604
Draft
surajkumar-08 wants to merge 1 commit into
Draft
fix: Update capability checks and enhance search functionality in Semantic Search#604surajkumar-08 wants to merge 1 commit into
surajkumar-08 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates the WCRAPIs Application Content Search (ACS) sample to align with the latest
AppContentIndexerIDL and apispec. Adds live text + image suggestions, renders region-of-interest overlays on image matches, fixes a mis-mapped capability check, and resolves several crash / NRE bugs surfaced during testing.Changes
AIDevGallery/Samples/WCRAPIs/AppIndexCapability.xaml.cs(+2 / −2)IndexCapability.ImageSemanticand the Semantic-Image row was readingIndexCapability.ImageOcr. Now each row reflects its intendedIndexCapabilityvalue.AIDevGallery/Samples/WCRAPIs/SemanticSearch.xaml(+57 / −16)SearchBox: addedTextChangedhandler,TextMemberPath="QueryText", and anItemTemplatethat renders live suggestion text with wrapping.ImageResultsBox: new item template renders each result image at scaled display size with a caption and an accent-colored region-of-interest overlay (Canvas + Border) whenRegionOfInterestis present.AIDevGallery/Samples/WCRAPIs/SemanticSearch.xaml.cs(+654 / −107)Live suggestions (text + image)
_suggestionTextQuerySession(AppIndexTextQuerySession) and_suggestionImageQuerySession(AppIndexImageQuerySession)._suggestionTextQueryOptionsSignature,_suggestionImageQueryOptionsSignature,_currentSuggestionQueryText) so sessions are only restarted when the relevant options actually change._lastTextSuggestionItemsand_lastImageSuggestionItems, merged into the AutoSuggestBox viaUpdateCombinedSuggestions.SearchBox_TextChangedhandler creates / updates both sessions viaGetOrCreateSuggestionTextQuerySessionandGetOrCreateSuggestionImageQuerySession, subscribing toResultChangedfor incremental updates.StopSuggestionTextQuerySession,StopSuggestionImageQuerySession,StopSuggestionQuerySession, plusGetTextMatchSuggestionItems,GetImageMatchSuggestionItems,GetTextQueryOptionsSignature,GetImageQueryOptionsSignature.Image results with region-of-interest overlay
ImageDisplayItem(ImageSource,Caption,DisplayWidth/Height,RegionLeft/Top/Width/Height,RegionVisibility).GetImageMatchDisplayItemsconsumesAppManagedImageQueryMatch.RegionOfInterest(IReference<Rect>⇒Rect?) and computes display-coordinate overlays scaled to a max width._imageDimensionsdictionary captures originalPixelWidth/PixelHeightat index time insideIndexImageData, so overlays scale correctly regardless of display size.Bug fixes
Enter("Failed to search indexed content.") inSearchBox_QuerySubmitted:StopSuggestionQuerySession()beforeTask.Run— stopping the image session immediately before invokingindexer.CreateImageQuery(...)on the same indexer was the crash trigger. Sessions now stay alive and are recycledby the nextTextChanged/CleanUp(), matching the apispec's interactive-search pattern (sessions only, no mixing one-shots on the same indexer mid-flight).IVectorView<TextQueryMatch>/IVectorView<ImageQueryMatch>intoList<T>insideTask.Runto avoid cross-apartment COM enumeration on the UI thread.ShowException(ex)(nooptionalMessage) and writesex.MessageintoResultStatusTextBlockso the real failure surfaces instead of a generic message.await _indexer?.WaitForIndexingIdleAsync(...)(which becomesawait null⇒ NRE) with a local capture + null-check inTextData_TextChanged,ImageData_ImageOpened, andIndexAll.SearchSuggestionItem.NoResultsplaceholder injection;QuerySubmittednow ignoresIsPlaceholderchosen suggestions.Cleanup
CleanUp()now stops both suggestion sessions (text + image) and clears suggestion caches.Validation
dotnet build AIDevGallery -r win-x64 -f net9.0-windows10.0.26100.0 …→ 0 errors.References
Microsoft.Windows.Search-Lib/AppContentIndex/AppContentIndexer.idlCreateTextQuery/CreateImageQueryare synchronous, no cancellation (lines 218-235).AppIndexImageQuerySessionmirrorsAppIndexTextQuerySession(lines 900-942).IndexCapabilityenum (lines 1122-1142).ApplicationContentIndexer-apispec.md§1627-1690 — canonical interactive-search pattern (sessions only).