T3 Code on Nitro UI (trial)
A trial port of the mobile client to Nitro UI 0.3.0, Margelo's
Hermes renderer with UIKit/AndroidX hosts. React Native is not involved. The app reuses
@t3tools/client-runtime unchanged. Only the host layers in src/platform, src/connection and
src/cloud are Nitro-specific.
Scope: pair by link or sign in to T3 Connect; a cross-environment thread list; a thread view with
markdown, collapsed work and a keyboard-following, growing composer with dictation and a model picker;
send a message; pull requests and issues across environments, with merge, approve, state actions and
comments; usage (cost, tokens and limits); agent notifications through T3 Connect; t3nitro:// links
(t3nitro-dev:// for Debug) to the RN app's paths that have a screen here; and the RN app's Settings
list, minus pages that need native work (keyboard, language). Layout follows apps/mobile, and the
colors come from its generated theme. App preferences (theme, follow-up, project grouping) live in preferences.json in the
cache directory, since the RN app keeps them outside client-runtime too.
Native modules in Modules/:
T3Platform: random bytes, digests, P-256 DPoP keys, Keychain storage, cache files, and the app delegate's opened URLs, APNs token and notification taps (ios/T3AppEvents.swift, held until JavaScript listens so a cold-start link or tap still lands). The relay uses the bundle id this app registers as the APNs topic, so pushes need the Push Notifications capability on thecom.t3tools.nitrotrialApp IDs and a relay APNs key from the same team. Universal links are not set up, since they need theapp.t3.codesassociation file.src/connection/cache.tskeeps client-runtime's shell, thread and server-config records as files underLibrary/Caches(the RN app keeps them in SQLite), so a thread opened after a relaunch paints from its cached snapshot during the push. Android stubs the files as empty.T3Voice: the composer's dictation, run by client-runtime'sVoiceInputControllerlikeapps/mobile: anAVAudioRecorder(16 kHz mono AAC) and Apple's on-deviceSpeechTranscriber(iOS 26+), copied fromapps/mobile/modules/t3-voice-transcription. There is no server transcription fallback yet, and pool simulators cannot record (the host has no microphone).T3Clerk: clerk-ios 1.8.0, the version@clerk/expo-native-componentspins, with its nativeAuthView.T3UIKit: keyboard avoidance, sheets and scroll edge effects, none of which alpha.17 exposes.presentSheetwraps a NitroViewController(a separaterenderRoot, given the app's atom registry) in a navigation controller page sheet with a native search field; the model picker reuses one such root. alpha.17's stack only pushes, so the routesapps/mobilepresents as sheets or modals go throughsrc/navigation/createSheetStackNavigator.tsx: our patch exports the library's stack parts, and each presented route, with the cards pushed after it, renders its own native stack inside aModalScreen. React detaches that host's ref before it unmounts the content, which is when the sheet snapshots itself to slide away intact. Provider marks are bundled SVGs written byscripts/provider-icons.ts.KeyboardInsetViewfollowskeyboardLayoutGuidein its own layout pass, which UIKit runs inside the keyboard's animation and during interactive dismissal; the composer and the thread list's inset move there, not from JS keyboard events, which arrive late and with the wrong curve.WebViewis a WKWebView for HTML renders, MCP apps and the legal pages. It has no API to run script on demand:postToPagedelivers a JSON value as amessageevent, and only the top frame reaches the native bridge, so the MCP relay page (features/thread/McpApp.tsx) keepsapps/mobile's sandboxed-iframe and secret-envelope model unchanged. Android is a stub.T3Markdown: the renderer from the enriched-markdown fork thatapps/mobileuses, as a Nitro view.scripts/vendor.shextracts the fork's iOS and C++ sources fromapps/mobile/deps/*.tgzinto the module's ignoredvendor/(it is not a pnpm dependency because it peers onreact-native), then fetches the pinned tree-sitter runtime and grammars for syntax highlighting with the fork'svendor-grammars.mjs; run it beforenitro-ui prepare.native/replaces the Fabric component with a plainUIViewand shims the few React Native helpers the renderer calls. Highlighting compiles the fork's default languages, the setapps/mobileuses. Math, video, block slots, menus and press events are off.T3ReviewDiff:apps/mobile's review diff surface (modules/t3-review-diff/ios), its drawing code copied unchanged behind a HybridView. It scrolls itself, so screens give itflex: 1rather than nesting it in aList; rows go throughsetRowsJson, not a prop. The PR "Files changed" screens and a thread's Review screen use it withapps/mobile's row building (src/features/review), and its visible-range highlighting (useNativeReviewDiffHighlighting), fed bysetOnVisibleRowRange. Android is a stub.T3Highlights:apps/mobile's @pierre/highlights lexer as a C++ HybridObject.lexer/linksapps/mobile/modules/t3-highlights' C sources instead of copying them, and builds them with its podspec's flags (-O2in every configuration, gnu99, theWASM_RT_*defines). iOS only; on Android code renders as plain text.T3Terminal:apps/mobile's libghostty-vt terminal (modules/t3-terminal/iosandandroid) as a HybridView.Vendorlinks that module'sghostty-vt.xcframeworkas a SwiftPM binary target, andcore/holds the view, ported off Expo, in its own target without C++ interop. The xcframework has no x86_64 simulator slice, so the project excludes that architecture for the simulator. Output goes throughwriteOutput, never a prop; the view keeps its grid above the keyboard itself, and the key bar is the hidden field'sinputAccessoryView.
Installing a cached build
A Debug build loads its JavaScript from nitro-ui start, so one native build serves every checkout
whose native inputs match. Install it instead of building:
vp run mobile:install ios [simulator-udid] --app nitro
# Or: vp run mobile:install android [emulator-or-phone-serial] --app nitro
vp run start # in apps/mobile-nitro
xcrun simctl launch <udid> com.t3tools.nitrotrial.dev -NitroUIDevServerURL http://localhost:8081It works like apps/mobile's mobile:install (see that README for the cache, --session,
--prepare and the T3_NATIVE_CLIENT_* switches), with this app's own fingerprint:
node scripts/native-fingerprint.ts <ios|android> hashes ios/ or android/, Modules/ with the
sources it links from apps/mobile, the SVGs under src/ (a Debug app draws them from its own
resources), app.json, the Nitro UI patches and the locked Nitro UI and Hermes versions. Any other
change under src/ or in a shared package keeps the fingerprint, and the installed app. On a miss the Mobile Dev Client workflow builds it once for everyone; a build on
this machine goes to .nitro/build, so the next one is incremental.
Release builds compile part of the JavaScript into the binary, so they are not shared this way.
vp run typecheck and vp run test are cached tasks: they replay when nothing they read changed.
Building
The SDK's Hermes compilers are macOS arm64 only, so native builds need an Apple Silicon Mac with Xcode 27 and Bun. Linux can typecheck and bundle:
vp run typecheck,vp run bundle:check.Run
nitro-ui prepareafter changing aModules/*/src/*.nitro.tsspec.Swift receives JS callbacks as
any Callback<(Args), Return>and calls them withcallAndForget, not as closures. Don't name a spec parameter after a C++ keyword such astemplate.Clerk needs iOS 17.
patches/[email protected]raises the iOS 16 that the CLI writes into its generated app package.patches/[email protected]makesListre-measure a cell whose content changed height (flow layout keeps a cell's first size otherwise) and exportsRootLayoutContext. Layout only runs after a React commit, so a native view whose height changes on its own (the markdown view after an image loads) asks for a pass through it.A view that sizes itself sets
NLSetMeasureCallbackon itsLayoutNodedirectly; the renderer's measuring initializer is internal.Simulator builds:
nitro-ui ios --build-onlypassesCODE_SIGNING_ALLOWED=NO. That drops the simulator's linked entitlements, and Keychain reads then fail with-34018. Build with xcodebuild instead:nitro-ui prepare xcodebuild -project ios/ReactNitro.xcodeproj -scheme ReactNitro -configuration Debug \ -destination 'generic/platform=iOS Simulator' -derivedDataPath .nitro/build \ CODE_SIGN_IDENTITY=- CODE_SIGNING_REQUIRED=NO buildAndroid: the modules have Kotlin implementations, but secure storage and Clerk are stubs.
Running against a dev server on another machine
Debug builds load JS from nitro-ui start. NITRO_DEV_SERVER_URL sets its port. To point a
simulator at it, launch with -NitroUIDevServerURL http://<host>:<port>. The error overlay is
the only place JS errors show up, so it is the way to debug a device that does not stream logs.
Runtime traps
src/platform/globals.tsmust stay the first import. It installs the Nitro runtime,cryptoandFormData, and it capturesfetch. The dev bundle is one unwrapped script, soeffect/http's top-levelfetchexport overwritesglobalThis.fetchwhen it loads.- Alpha.17's layout sizes a
ScrollView's content (and each auto-height container in it) to the screen's height, so long content overflows a screen-tall scroll range and rows past it can't be reached or tapped. Usesrc/ui/ScrollPage.tsx, which stacks a page's blocks in aList, whose cells are measured unbounded. Short pages can keepScrollView. - Native navigation options are only title and headerShown.
src/ui/NavigationBar.tsx(T3UIKit'sNavigationBarItems) configures the hosting screen'snavigationItemlike apps/mobile's headers: inline title, a native search field (iOS 26 integrated button) and a filterUIMenu. Tab roots sit in their own stacks so they have a navigation bar. ScrollViewchildren must be inside aScrollViewContent.UIScrollViewalready insets its content for the safe area, so don't pad scroll content byuseSafeAreaInsets()as well.Listhas no inverted mode or scroll-to-end. The thread list flips the list and each cell withscaleY: -1. On iOS 26 the nav bar's scroll edge effect then blurs the whole list, so the screen callsT3UIKit.hideFlippedScrollEdgeEffects()and draws its own gradient under the bar.- Pushing a screen inside a tab keeps the tab bar visible, and there is no option to hide it. Screens that cover the tab bar (Thread) live on the root stack above the tabs.