winui-search: batched CLI, background refresh, ranking + Gallery/Toolkit fetch upgrades#83
winui-search: batched CLI, background refresh, ranking + Gallery/Toolkit fetch upgrades#83lei9444 wants to merge 7 commits into
Conversation
…kit fetch upgrades
There was a problem hiding this comment.
Pull request overview
This PR significantly upgrades the src/tools/winui-search CLI to be faster on the hot path (embedded-first), more resilient (background cache refresh), and more useful to agents (grouped/batched results plus richer scenario metadata extracted from Gallery/Toolkit sources).
Changes:
- Refactors Gallery/Toolkit fetching to serve embedded snapshots immediately and move GitHub refresh into an explicit
updatepath (and background refresh). - Adds batched CLI behavior (
search/get) and grouped ranking output with improved BM25 weighting, stopword/synonym handling, and scenario/metadata formatting. - Extends Toolkit metadata with curated
keywords(embedded resource + frontmatter extraction) and adds a unified cache schema version (CacheVersion.cs).
Reviewed changes
Copilot reviewed 19 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tools/winui-search/Program.cs | Batched CLI commands, background refresh hook, updated update flow |
| src/tools/winui-search/BackgroundUpdater.cs | New stale-while-revalidate background refresh + lock/backoff/logging |
| src/tools/winui-search/SearchEngine.cs | Grouped search + ranking/formatting changes and new fallback behavior |
| src/tools/winui-search/GalleryFetcher.cs | Embedded-first load + GitHub refresh path; richer Gallery extraction incl. code-behind extraction |
| src/tools/winui-search/ToolkitFetcher.cs | Embedded-first load + GitHub refresh path; frontmatter keywords + description extraction |
| src/tools/winui-search/CacheVersion.cs | Single cache schema/version source of truth |
| src/tools/winui-search/DataLoader.cs | Loads embedded Toolkit keywords dictionary |
| src/tools/winui-search/Models.cs | Scenario schema extended with description/metadata fields |
| src/tools/winui-search/BM25.cs | Tokenization tweaks + coverage gate support (CountHits) |
| src/tools/winui-search/StopWords.cs | Expanded stopwords + tag-dictionary cleaning helpers |
| src/tools/winui-search/winui-search.csproj | Embeds new toolkit-keywords.json resource |
| src/tools/winui-search/Data/toolkit-keywords.json | New embedded curated keywords payload |
| src/tools/winui-search/README.md, DATA_SOURCES.md | Documentation updates for new behavior and data sources |
| plugins/winui/skills/winui-design/SKILL.md | Skill guidance updated to match new batched CLI usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Coverage
Findings
DetailsH1 — Non-atomic cache writes
// GalleryFetcher.cs:107-123 (RefreshFromGitHub)
File.WriteAllText(scenarioCache, JsonSerializer.Serialize(scenarios, JsonContext.Default.ScenarioArray));
File.WriteAllText(tagCache, JsonSerializer.Serialize(tags, JsonContext.Default.DictionaryStringStringArray));
File.WriteAllText(timestampFile, DateTime.UtcNow.ToString("o"));
File.WriteAllText(versionFile, CacheVersion.Current);Recommendation: Use temp-file + H2 — Foreground
|
Description
search/gettake multiple args; results grouped by control with up to 3 scenarios each..xaml.csand emits per-example code-behind (event handlers,x:Bindtargets,x:DataType) instead of empty stubs.keywordsfield from.mdfrontmatter,#if WINAPPSDKfolding, per-sample header/description extraction.BackgroundUpdater.cs): hot-path commands never block on GitHub. Detached child refreshes if cache > 7 d; atomic lock, 10-min TTL, 1-h failure backoff.WINUI_SEARCH_NO_BACKGROUND=1to opt out.CacheVersion.cs: single source of truth; mismatch → embedded JSON.Type of Change
Affected area
Checklist
README.mdupdatedAdditional Notes
AI Description
This section is auto-generated by AI when the PR is opened or updated. To opt out, delete this entire section including the marker comments.