T3 Code Atlas

@t3tools/mobile-nitro

Stablev0.1.14c0eed7328db2· 2026-12-05
schemas28
process1
Depends on11
Used by0

Blast radius

0 direct · 0 transitive workspaces · 1 app affected

What a change to @t3tools/mobile-nitro can reach, from workspace dependencies, imports, call sites, and protocol edges.

Affected apps (node)
Contracts in its surface1 RPC
Loading map…

README

apps/mobile-nitro/README.md

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 the com.t3tools.nitrotrial App IDs and a relay APNs key from the same team. Universal links are not set up, since they need the app.t3.codes association file. src/connection/cache.ts keeps client-runtime's shell, thread and server-config records as files under Library/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's VoiceInputController like apps/mobile: an AVAudioRecorder (16 kHz mono AAC) and Apple's on-device SpeechTranscriber (iOS 26+), copied from apps/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-components pins, with its native AuthView.
  • T3UIKit: keyboard avoidance, sheets and scroll edge effects, none of which alpha.17 exposes. presentSheet wraps a Nitro ViewController (a separate renderRoot, 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 routes apps/mobile presents as sheets or modals go through src/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 a ModalScreen. 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 by scripts/provider-icons.ts. KeyboardInsetView follows keyboardLayoutGuide in 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. WebView is a WKWebView for HTML renders, MCP apps and the legal pages. It has no API to run script on demand: postToPage delivers a JSON value as a message event, and only the top frame reaches the native bridge, so the MCP relay page (features/thread/McpApp.tsx) keeps apps/mobile's sandboxed-iframe and secret-envelope model unchanged. Android is a stub.
  • T3Markdown: the renderer from the enriched-markdown fork that apps/mobile uses, as a Nitro view. scripts/vendor.sh extracts the fork's iOS and C++ sources from apps/mobile/deps/*.tgz into the module's ignored vendor/ (it is not a pnpm dependency because it peers on react-native), then fetches the pinned tree-sitter runtime and grammars for syntax highlighting with the fork's vendor-grammars.mjs; run it before nitro-ui prepare. native/ replaces the Fabric component with a plain UIView and shims the few React Native helpers the renderer calls. Highlighting compiles the fork's default languages, the set apps/mobile uses. 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 it flex: 1 rather than nesting it in a List; rows go through setRowsJson, not a prop. The PR "Files changed" screens and a thread's Review screen use it with apps/mobile's row building (src/features/review), and its visible-range highlighting (useNativeReviewDiffHighlighting), fed by setOnVisibleRowRange. Android is a stub.
  • T3Highlights: apps/mobile's @pierre/highlights lexer as a C++ HybridObject. lexer/ links apps/mobile/modules/t3-highlights' C sources instead of copying them, and builds them with its podspec's flags (-O2 in every configuration, gnu99, the WASM_RT_* defines). iOS only; on Android code renders as plain text.
  • T3Terminal: apps/mobile's libghostty-vt terminal (modules/t3-terminal/ios and android) as a HybridView. Vendor links that module's ghostty-vt.xcframework as a SwiftPM binary target, and core/ 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 through writeOutput, never a prop; the view keeps its grid above the keyboard itself, and the key bar is the hidden field's inputAccessoryView.

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:8081

It 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 prepare after changing a Modules/*/src/*.nitro.ts spec.

  • Swift receives JS callbacks as any Callback<(Args), Return> and calls them with callAndForget, not as closures. Don't name a spec parameter after a C++ keyword such as template.

  • Clerk needs iOS 17. patches/[email protected] raises the iOS 16 that the CLI writes into its generated app package.

  • patches/[email protected] makes List re-measure a cell whose content changed height (flow layout keeps a cell's first size otherwise) and exports RootLayoutContext. 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 NLSetMeasureCallback on its LayoutNode directly; the renderer's measuring initializer is internal.

  • Simulator builds: nitro-ui ios --build-only passes CODE_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 build
  • Android: 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.ts must stay the first import. It installs the Nitro runtime, crypto and FormData, and it captures fetch. The dev bundle is one unwrapped script, so effect/http's top-level fetch export overwrites globalThis.fetch when 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. Use src/ui/ScrollPage.tsx, which stacks a page's blocks in a List, whose cells are measured unbounded. Short pages can keep ScrollView.
  • Native navigation options are only title and headerShown. src/ui/NavigationBar.tsx (T3UIKit's NavigationBarItems) configures the hosting screen's navigationItem like apps/mobile's headers: inline title, a native search field (iOS 26 integrated button) and a filter UIMenu. Tab roots sit in their own stacks so they have a navigation bar.
  • ScrollView children must be inside a ScrollViewContent. UIScrollView already insets its content for the safe area, so don't pad scroll content by useSafeAreaInsets() as well.
  • List has no inverted mode or scroll-to-end. The thread list flips the list and each cell with scaleY: -1. On iOS 26 the nav bar's scroll edge effect then blurs the whole list, so the screen calls T3UIKit.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.