Skip to content

Conversation

@weiyuanyue
Copy link
Contributor

Fixes a bug where searching for and selecting API models (like OCR) from the search results leads to a blank page #517 . This PR also fixes the same issue in other navigation paths that use ModelDetails.

Root Cause:

The navigation logic had hardcoded assumptions that all models should go to the "Models" page, without checking if they are API models (WCRAPIs) that should go to the "APIs" page instead.

Solution:

1. Search Result Handler Upgrade (Core Fix)

Changed from hardcoded routing:

Navigate("models", modelType);  // Always goes to Models page

To intelligent routing:

NavigateToApiOrModelPage(modelType);  // Routes based on type classification

2. ID-to-Type Resolution

var modelTypeList = App.FindSampleItemById(modelDetails.Id);
if (modelTypeList.Count > 0)
{
    NavigateToApiOrModelPage(modelTypeList[0]);
}
  • Converts ModelDetails.IdModelType by searching across all registered samples, model families, model groups, and API definitions
  • Delegates to existing NavigateToApiOrModelPage() logic that correctly classifies WCR APIs vs. regular models
  • Maintains consistent routing behavior across all entry points (search, direct links, external activation)

3. Navigation Performance Optimization

Added SetSelectedModelInMenu() to ModelSelectionPage to avoid unnecessary page reloads:

  • When already on the target page, updates the selected menu item without re-navigation
  • Mirrors existing APISelectionPage behavior for consistency

Testing

Core Navigation Tests

  • Search for "OCR" → Select "Text Recognition OCR" → Navigates to APIs page (not Models page)
  • Search for "Phi" → Select "Phi-3.5" → Navigates to Models page correctly
  • Download a model → Click download progress button → Click "Go to model page" → Navigates to Models page

API Navigation Tests

  • Navigate to APIs page → Click any API card (e.g., "Image Description") → Opens correct API details page
  • Already on APIs page → Search for another API → Page updates without reload, menu selection updates correctly

Recently Used (MRU) Tests

  • Visit WCR API (e.g., "Text Recognition OCR") → Return to Home → Click from "Recently Used" → Navigates to APIs page
  • Visit Chat sample (e.g., "Chat") → Return to Home → Click from "Recently Used" → Navigates to Samples page

Navigation Menu Tests

  • Direct navigation via left menu: Home, Samples, Models, APIs, Settings → All navigate correctly
  • Navigate to Samples → Select scenario (e.g., "Chat") → Select specific sample → Loads and runs correctly

End-to-End Flow

  • Search "Phi" → Select result → Download model → View progress → Click "Go to model page" → Use model in sample → All steps work correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants