Skip to content

feat(react-native): put registry refresh on the models namespace - #720

Open
ayaangazali wants to merge 1 commit into
RunanywhereAI:mainfrom
ayaangazali:feat/rn-models-refresh
Open

feat(react-native): put registry refresh on the models namespace#720
ayaangazali wants to merge 1 commit into
RunanywhereAI:mainfrom
ayaangazali:feat/rn-models-refresh

Conversation

@ayaangazali

@ayaangazali ayaangazali commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

What is wrong

React Native has no public way to refresh the model registry.

#605 aligned the public API across all eight SDKs and gave Swift models.refresh(rescanLocal:includeRemoteCatalog:pruneOrphans:) (ModelsNamespace.swift:389). Kotlin and Flutter were missed; #712 closed those two yesterday. RN is the one left.

Evidence

Every piece of the native path is already there on RN:

  • specs/RunAnywhereCore.nitro.ts:274 declares refreshModelRegistry(includeRemoteCatalog, rescanLocal, pruneOrphans)
  • cpp/HybridRunAnywhereCore+Registry.cpp:443 encodes those three flags into a ModelRegistryRefreshRequest (fields 1/2/3, matching idl/model_types.proto:411) and runs the same discovery pre-pass Swift does
  • Public/Extensions/Models/RunAnywhere+ModelRegistry.ts:1046 wraps it with the same defaults Swift uses, and its own comment says "Matches Swift"

Nothing surfaces it. src/index.ts:13 exports only the RunAnywhere object, that object is namespaces plus initialize/reset/capabilities, and models (Public/Api/Models.ts:194) has no refresh. storage (Public/Api/Platform.ts:25) has no refresh either, which is where the Web SDK put its equivalent.

So refreshModelRegistry is reachable from inside the package and from nowhere else.

This is not a documented omission: capabilities() lists the things RN deliberately does not ship (agents, wakeword, realtime) with a reason attached to each. Registry refresh is not among them.

The practical effect is that models.list() reads the registry as it stands and never rescans, so an artifact that changed on disk out from under the SDK stays wrong for the life of the process.

What this does

Adds models.refresh(options?), forwarding to the existing extension function. Forwarding rather than reimplementing keeps the non-throwing best-effort behaviour and the three defaults in one place, and matches how the rest of the namespace delegates.

Placed after state() to match Swift's ordering.

Verification

Ran on this branch:

  • tsc --noEmit for @runanywhere/core: clean
  • tsc -p tsconfig.test.json --noEmit: clean
  • eslint src/Public/Api/Models.ts --max-warnings 0: clean
  • jest for @runanywhere/core: 75 passed, 15 suites, 0 failed

The two typechecks needed the full generated proto tree, so I ran idl/codegen/generate_ts.sh, generate_ts_convenience.py, generate_defaults_pool.py and generate_streams.sh first. None of that output is committed here; git status shows only the one file.

Also compiled a scratch caller against the public entry point to confirm the verb is actually reachable and the option shapes are right:

import { RunAnywhere } from '../src';
await RunAnywhere.models.refresh();
await RunAnywhere.models.refresh({ rescanLocal: false, pruneOrphans: true });

No test added: this is a one-line delegation to a function that already has its behaviour defined elsewhere, and a test here would assert that a forwarder forwards.

I checked the C++ flag ordering against the proto field numbers while I was in there, in case the two adjacent booleans had been swapped across the bridge. They line up correctly.

Summary by CodeRabbit

  • New Features
    • Added a model refresh capability to reconcile locally available models.
    • Supports optional local rescanning, remote catalog inclusion, and removal of orphaned models.
    • Refresh operations return a promise, enabling apps to track completion.
    • If refreshing fails, the existing model registry remains unchanged.

Copilot AI lite review requested due to automatic review settings August 16, 2026 17:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d743e837-da4c-4e76-b860-7b097679443d

📥 Commits

Reviewing files that changed from the base of the PR and between c2091a8 and f08f731.

📒 Files selected for processing (1)
  • bindings/react-native/packages/core/src/Public/Api/Models.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • bindings/react-native/packages/core/src/Public/Api/Models.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The React Native models API adds models.refresh(options?). It supports local rescanning, remote catalog inclusion, and orphan pruning through the model registry.

Changes

React Native model refresh

Layer / File(s) Summary
Expose model registry refresh
bindings/react-native/packages/core/src/Public/Api/Models.ts
The public models API imports refreshModelRegistry and adds models.refresh(options?) with configurable local rescanning, remote catalog inclusion, and orphan pruning.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to f08f7

This adds the React Native models.refresh API by forwarding to existing registry-refresh behavior, with no actionable merge-blocking risk remaining after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives a detailed explanation of the problem, implementation, and verification results. However, it does not use the repository template and omits the required Type of Change, platform-… Update the description to include the template sections. Mark the change as a new feature, record applicable React Native iOS and Android testing, add the React Native SDK label, complete the code and review checklist, and state whether scr…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding registry refresh to the React Native models namespace.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description gives a detailed explanation of the problem, implementation, and verification results. However, it does not use the repository template and omits the required Type of Change, platform-specific testing, labels, checklist, and screenshots sections.

Resolution

Update the description to include the template sections. Mark the change as a new feature, record applicable React Native iOS and Android testing, add the React Native SDK label, complete the code and review checklist, and state whether screenshots are not applicable.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Correction to one line in the description. I wrote that React Native is the only SDK still missing this; that is not quite right, and I would rather say so than have you find it.

Checking the remaining bindings after opening this: Electron has it as assets.refresh (src/api/assets.ts:563), Web has it as storage.refresh, and Python has it nowhere. Python is a different situation from RN though, which is why it is not in this PR: RN already had the whole native path and simply never surfaced it, whereas bindings/python/native/module.cpp has no binding for rac_model_registry_refresh_proto at all, so Python needs native work rather than a forwarder. Happy to open that separately if you want it.

The claim this PR actually rests on is unchanged: RN is the only SDK where the capability is fully wired natively and unreachable from the public API.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Rebased onto 0105aed1d, diff unchanged, checks green.

Still reproduces on main: bindings/react-native/packages/core/src/Public/Api/Models.ts has no refresh member at all, so RunAnywhere.models.refresh(...) is a runtime undefined on React Native while Swift and Kotlin both expose it on the same namespace.

One nuance I confirmed since opening this, in case it looks like an inconsistency: Web deliberately does not have models.refresh either, because it puts the equivalent on storage.refresh() and documents that namespace as "Not part of the cross-SDK spec" (re-reading OPFS is a browser persistence concern there). So this is React Native being the odd one out among the SDKs that do model this as a registry operation, not a four-way gap.

Happy to rework it if you would rather this verb not spread further.

@ayaangazali
ayaangazali force-pushed the feat/rn-models-refresh branch from c3fd3bf to 8bda9f8 Compare August 24, 2026 18:44
RunanywhereAI#605 aligned the public API across all eight SDKs and gave Swift
`models.refresh(rescanLocal:includeRemoteCatalog:pruneOrphans:)`. Kotlin and
Flutter were missed and RunanywhereAI#712 fixed those two. React Native is the one left.

The whole native path already exists on RN: the Nitro spec declares
`refreshModelRegistry`, the C++ HybridObject encodes the three flags into a
ModelRegistryRefreshRequest, and `RunAnywhere+ModelRegistry.ts` wraps it with
the same defaults Swift uses. Nothing surfaces it. `index.ts` exports only the
`RunAnywhere` object, that object exposes namespaces, and `models` has no
refresh, so there is no public way to reconcile the registry on RN.

`models.list()` reads the registry as it stands and never rescans, so an
artifact that changed on disk out from under the SDK stays wrong until the
process restarts.

Forwards to the existing extension function rather than reimplementing it, so
the non-throwing best-effort behaviour and the defaults stay in one place.
@ayaangazali
ayaangazali force-pushed the feat/rn-models-refresh branch from 8bda9f8 to f08f731 Compare August 25, 2026 19:03
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

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