fix(web): surface native fallbackReason and warnings on LoadedModel (#1041)
SH
9h ago+156+156+012345678901234567890123456789-3-3-0123456789
Summary
- Passes
ModelLoadResultfromSDKCore.loadModelintotoLoadedModelinbindings/web/packages/core/src/Public/API/Namespaces/models.ts. - Surfaces
result.fallbackReason ?? result.warnings?.[0] ?? Runtime.degradedReason ?? undefinedonLoadedModel.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
toLoadedModelunder 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
fallbackReasonwhen present. - Falling back to
warnings[0]whenfallbackReasonis absent. - Proving native
fallbackReasonwins overRuntime.degradedReason. - Proving native
warnings[0]wins overRuntime.degradedReason. - Falling back to
Runtime.degradedReasonwhen native result carries neither. - Leaving
fallbackReasonundefinedwhen neither exists.
- Surfacing native
- 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
ModelLoadResultintotoLoadedModel, preferringresult.fallbackReason, thenresult.warnings[0], thenRuntime.degradedReason. - Exposes
toLoadedModelunder 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.