Skip to content

refactor(mobile): add a robust @/ import alias for apps/mobile/src - #13152

Closed
juliusmarminge wants to merge 2 commits into
mainfrom
agent/mobile-audit-import-alias
Closed

juliusmarminge wants to merge 2 commits into
mainfrom
agent/mobile-audit-import-alias

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

The problem

Audit #8: mobile has 101 imports at ../../../ depth and 15 at ../../../../, while web resolves ~/* against its src (814 uses). Mobile had no tsconfig paths, so every deep import is edit friction and every file move silently breaks relative paths across the app.

The fix

  • apps/mobile/tsconfig.json — "paths": { "@/*": ["./src/*"] }, matching the web ~/* precedent. Expo 57's Metro already resolves tsconfig paths natively (exp.experiments.tsconfigPaths defaults to true in @expo/cli's instantiateMetro), so no Metro config change is needed — and Expo's resolver is importer-scoped (it skips requests originating in node_modules), which a plain prefix hook is not.
  • vite.config.ts (root) — mobile unit tests run under the root vitest config, which has no knowledge of tsconfig paths, so the mapping is mirrored there as a @/ → apps/mobile/src/ alias. The existing web ~ alias is kept byte-for-byte via the array form.

Migrated a bounded, representative set of deep imports rather than all ~200 files, mixing runtime values, type-only imports, .ts and .tsx, across four features (sharing, connection, threads, settings). The rest can migrate incrementally — both styles coexist.

Verification (no UI change → no screenshots)

  • Real bundles, both platforms (expo export --dev, apps/mobile): iOS Bundled apps/mobile/index.ts (3886 modules) and Android Bundled apps/mobile/index.ts (4041 modules) — the full app graph, including the migrated @/ imports, resolves through Expo's tsconfig-paths resolver with no Metro override.
  • TypeScript: tsc --noEmit in apps/mobile — clean with the migrated @/ imports.
  • Vitest (runtime resolution through the root alias): incoming-share-model, incoming-share-inbox, environmentSections, new-task-project-selection — 4 files / 57 tests passed, all resolving @/lib/... value imports at runtime. Web alias regression: browserDefaults.test.ts (~ imports) passes unchanged.

Revisions

Initial head 2efab1e also added a custom config.resolver.resolveRequest hook in metro.config.js. Audit review (and a re-run of both platform exports) confirmed Expo's built-in tsconfig-paths resolution makes the hook redundant, and that it would additionally hijack a dependency's own @/… imports from node_modules, which Expo's importer-scoped resolver correctly leaves alone. 84cc687 removes it; metro.config.js is back to unchanged.

Model: callstack/Apex; harness: Apex in T3 Code (pi).

Summary by CodeRabbit

  • Chores
    • Standardized mobile app import paths with a shared alias, including support in the test tooling.

Mobile has 100+ imports at ../../../ depth and no alias to shorten them,
while web resolves ~/* to its src. Add "@/*" tsconfig paths plus a Metro
resolveRequest alias (extraNodeModules cannot host it: Metro parses
"@/foo" as the scoped package "@/foo"), mirror it for vitest in the root
vite config, and migrate a bounded set of representative deep imports.

Co-authored-by: Apex <noreply@callstack.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 22, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Sep 22, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 84cc687

Macroscope's review found this PR approvable — This is a bounded import-path refactor with matching TypeScript and test-tool configuration; all migrated imports continue to target the same existing modules. It does not add user-facing behavior, alter product defaults, or suppress static-analysis diagnostics.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 49090bd1-a65a-4d5d-8f50-e40363aa1d22

📥 Commits

Reviewing files that changed from the base of the PR and between 2efab1e and 84cc687.

📒 Files selected for processing (1)
  • vite.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • vite.config.ts

Limit details: You’ve used all 10 included reviews currently available.


📝 Walkthrough

Walkthrough

TypeScript and Vite now resolve the mobile @/ alias. Selected imports in connection, settings, sharing, and thread code use that alias.

Changes

Mobile import aliases

Layer / File(s) Summary
Configure mobile alias resolution
apps/mobile/tsconfig.json, vite.config.ts
TypeScript maps @/* to ./src/*. Vite retains the ~ mapping and adds a mapping for @/ to the mobile source directory.
Use aliases in mobile imports
apps/mobile/src/features/connection/*, apps/mobile/src/features/settings/components/SettingsRow.tsx, apps/mobile/src/features/sharing/*, apps/mobile/src/features/threads/new-task-project-selection.ts
Selected imports use @/ paths instead of relative paths.

Priority: ⬇️ Low

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

Change: Refactor

Merge Risk: ⚪ Minimal · up to 84cc6

The mobile alias configuration consistently targets the mobile source directory, so the selected migrated imports are ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a robust @/ import alias for the mobile source directory.
Description check ✅ Passed The description clearly explains the problem, the implementation, the migration scope, and verification results. It does not use the template headings or include the checklist, but it provides the req…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.5 KiB 13.5 KiB +16 B (+0.1%) 15.1 KiB ✅
Codex Thread snapshot wire 7.0 KiB 7.1 KiB +10 B (+0.1%) 7.3 KiB ✅
Codex Live turn WebSocket wire 6.5 KiB 6.5 KiB +6 B (+0.1%) 7.8 KiB ✅
Codex Live turn WebSocket decoded 56.3 KiB 56.3 KiB 0 B (0.0%) 66.4 KiB ✅
Codex Live turn messages 10 10 0 (0.0%) 21 ✅
Claude Total thread wire 13.5 KiB 13.5 KiB −11 B (−0.1%) 15.1 KiB ✅
Claude Thread snapshot wire 7.1 KiB 7.1 KiB −7 B (−0.1%) 7.3 KiB ✅
Claude Live turn WebSocket wire 6.4 KiB 6.4 KiB −4 B (−0.1%) 7.8 KiB ✅
Claude Live turn WebSocket decoded 57.0 KiB 57.0 KiB 0 B (0.0%) 66.4 KiB ✅
Claude Live turn messages 9 9 0 (0.0%) 21 ✅

Baseline: d7819c1 · PR result: 84cc687 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.9 KiB
  • Claude decoded thread snapshot: 114.6 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Expo 57 resolves tsconfig compilerOptions.paths in Metro by default
(exp.experiments.tsconfigPaths defaults to true in @expo/cli's
instantiateMetro), and its resolver is importer-scoped: it skips
requests originating in node_modules, which the plain prefix hook was
not. Verified by exporting both platforms from apps/mobile: iOS Bundled
(3886 modules) and Android Bundled (4041 modules).

Co-authored-by: Apex <noreply@callstack.com>
@macroscopeapp
macroscopeapp Bot dismissed their stale review September 22, 2026 23:31

Dismissing prior approval to re-evaluate 84cc687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant