fix(web): surface native fallbackReason and warnings on LoadedModel (#1041)

SH
9h ago
+156-3

Summary

  • Passes ModelLoadResult from SDKCore.loadModel into toLoadedModel in bindings/web/packages/core/src/Public/API/Namespaces/models.ts.
  • Surfaces result.fallbackReason ?? result.warnings?.[0] ?? Runtime.degradedReason ?? undefined on LoadedModel.fallbackReason. This ensures skipped backend preferences and advisory options reach the caller, maintaining honest runtime state parity with React Native (bindings/react-native/packages/core/src/Public/Api/Models.ts:392).
  • Exposes toLoadedModel under the __testing__ seam for focused unit verification.
  • Adds comprehensive unit tests to models.toProgressEvent.test.ts.

Testing & Validation

  • Added 6 dedicated unit test cases in bindings/web/packages/core/tests/unit/Public/API/Namespaces/models.toProgressEvent.test.ts:
    • Surfacing native fallbackReason when present.
    • Falling back to warnings[0] when fallbackReason is absent.
    • Proving native fallbackReason wins over Runtime.degradedReason.
    • Proving native warnings[0] wins over Runtime.degradedReason.
    • Falling back to Runtime.degradedReason when native result carries neither.
    • Leaving fallbackReason undefined when neither exists.
  • Ran tests & linters:
    • npm test -- models.toProgressEvent.test.ts (9/9 passed)
    • npm run typecheck -w packages/core (passed, zero errors)
    • npm run lint -w packages/core (passed, zero warnings)

Closes #1041


Summary by cubic

Fixes LoadedModel.fallbackReason in the web bindings to report the actual reason a model load degraded, instead of only the global runtime degraded reason.

  • Passes the native ModelLoadResult into toLoadedModel, preferring result.fallbackReason, then result.warnings[0], then Runtime.degradedReason.
  • Exposes toLoadedModel under the __testing__ seam and adds unit tests covering precedence and undefined cases.

Summary by CodeRabbit

  • Bug Fixes
    • Model load results now show the most relevant fallback reason available: the specific reason reported during loading takes precedence, followed by the first warning and then the runtime’s degraded-state reason. If none of these reasons is available, no fallback reason is shown. This makes the information displayed after a model loads more accurately reflect the outcome.