Skip to content

Conversation

@schiller-manuel
Copy link
Contributor

@schiller-manuel schiller-manuel commented Dec 30, 2025

Summary by CodeRabbit

  • New Features

    • Support for escaped underscore segments in file-based routes (bracket notation like [_]auth) with preserved original path metadata to enable consistent escape detection.
    • Virtual-mounted physical routes now maintain aligned original path information for correct routing behavior.
  • Tests

    • Added test scenarios and generated route snapshots exercising virtual routes with escaped underscores and corresponding example routes (e.g., /nested/_auth, /api/_hello, /api/_auth).

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

Adds tracking of original (bracketed) route segments by introducing and propagating an originalRoutePath alongside escaped routePath through virtual and physical route-node generation; updates tests and fixtures to cover escaped-underscore scenarios.

Changes

Cohort / File(s) Summary
Route node generation
packages/router-generator/src/filesystem/virtual/getRouteNodes.ts, packages/router-generator/src/filesystem/physical/getRouteNodes.ts
Compute escaped and original segments via determineInitialRoutePath in virtual generator; inject and propagate originalRoutePath into created RouteNode objects and align physical-side prefixing for virtual-derived nodes.
Tests: test runner config
packages/router-generator/tests/generator.test.ts
Add virtual-with-escaped-underscore case to rewriteConfigByFolderName to exercise virtual-mounted physical routes with escaped underscores.
Test fixture: virtual-with-escaped-underscore
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx, .../routes/index.tsx, .../routes/physical-routes/[_]auth.route.tsx, .../routes/physical-routes/[_]hello.tsx, .../routes/physical-routes/index.tsx, packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
Add physical route files using escaped bracket names and a generated route-tree snapshot representing /api/, /api/_hello, /api/_auth.
Test fixture: virtual-inside-with-escaped-underscore
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx, .../routes/index.tsx, .../routes/nested/__virtual.ts, .../routes/nested/auth.tsx, .../routes/nested/callback.tsx, .../routes/nested/home.tsx, packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
Add virtual subtree nested with index('home.tsx') and escaped routes [_]auth, [_]callback, plus generated snapshot and typed route mappings.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • nlynzaad
  • Sheraff

Poem

🐰 Brackets on my whiskers, underscore in tow,

I hop through nodes where original paths grow.
Escaped and honest, both now side by side,
Routes dance neatly down the filesystem wide.
🥕✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding escape sequence handling for routes in __virtual.ts files, which is the core focus across the modified implementation files.
✨ Finishing touches
  • 📝 Generate docstrings

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

@nx-cloud
Copy link

nx-cloud bot commented Dec 30, 2025

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 406838a

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 16m 15s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-30 01:35:12 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 30, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6250

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6250

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6250

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6250

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6250

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6250

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6250

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6250

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6250

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6250

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6250

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6250

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6250

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6250

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6250

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6250

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6250

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6250

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6250

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6250

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6250

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6250

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6250

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6250

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6250

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6250

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6250

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6250

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6250

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6250

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6250

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6250

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6250

@tanstack/vue-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6250

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6250

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6250

@tanstack/vue-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6250

@tanstack/vue-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6250

@tanstack/vue-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6250

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6250

commit: 406838a

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 325c356 and a32416c.

📒 Files selected for processing (16)
  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator.test.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript strict mode with extensive type safety for all code

Files:

  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx
  • packages/router-generator/tests/generator.test.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx
  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Implement ESLint rules for router best practices using the ESLint plugin router

Files:

  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx
  • packages/router-generator/tests/generator.test.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx
  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
🧠 Learnings (11)
📓 Common learnings
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/src/routes/non-nested/named/$baz_.bar.tsx:3-5
Timestamp: 2025-09-22T00:56:49.237Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments (e.g., `$baz_` becomes `baz` in generated types) but should be preserved in base path segments. This is the correct behavior as of the fix in PR #5182.
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/tests/non-nested-paths.spec.ts:167-172
Timestamp: 2025-09-22T00:56:53.426Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments during path parsing, but preserved in base path segments. This is the expected behavior implemented in PR #5182.
Learnt from: Sheraff
Repo: TanStack/router PR: 6171
File: packages/router-core/src/new-process-route-tree.ts:898-898
Timestamp: 2025-12-21T12:52:35.231Z
Learning: In `packages/router-core/src/new-process-route-tree.ts`, the matching logic intentionally allows paths without trailing slashes to match index routes with trailing slashes (e.g., `/a` can match `/a/` route), but not vice-versa (e.g., `/a/` cannot match `/a` layout route). This is implemented via the condition `!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX` and is a deliberate design decision to provide better UX by being permissive with missing trailing slashes.
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6120
File: packages/router-generator/src/generator.ts:654-657
Timestamp: 2025-12-17T02:17:55.086Z
Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.

Applied to files:

  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx
  • packages/router-generator/tests/generator.test.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx
  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-12-17T02:17:55.086Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6120
File: packages/router-generator/src/generator.ts:654-657
Timestamp: 2025-12-17T02:17:55.086Z
Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.

Applied to files:

  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx
  • packages/router-generator/tests/generator.test.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx
  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-12-06T15:03:07.223Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-06T15:03:07.223Z
Learning: Applies to **/*.{js,ts,tsx} : Implement ESLint rules for router best practices using the ESLint plugin router

Applied to files:

  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx
  • packages/router-generator/tests/generator.test.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-12-21T12:52:35.231Z
Learnt from: Sheraff
Repo: TanStack/router PR: 6171
File: packages/router-core/src/new-process-route-tree.ts:898-898
Timestamp: 2025-12-21T12:52:35.231Z
Learning: In `packages/router-core/src/new-process-route-tree.ts`, the matching logic intentionally allows paths without trailing slashes to match index routes with trailing slashes (e.g., `/a` can match `/a/` route), but not vice-versa (e.g., `/a/` cannot match `/a` layout route). This is implemented via the condition `!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX` and is a deliberate design decision to provide better UX by being permissive with missing trailing slashes.

Applied to files:

  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator.test.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61
Timestamp: 2025-10-01T18:31:35.420Z
Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.

Applied to files:

  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-09-22T00:56:49.237Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/src/routes/non-nested/named/$baz_.bar.tsx:3-5
Timestamp: 2025-09-22T00:56:49.237Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments (e.g., `$baz_` becomes `baz` in generated types) but should be preserved in base path segments. This is the correct behavior as of the fix in PR #5182.

Applied to files:

  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx
  • packages/router-generator/tests/generator.test.ts
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
📚 Learning: 2025-12-06T15:03:07.223Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-06T15:03:07.223Z
Learning: Use file-based routing in `src/routes/` directories or code-based routing with route definitions

Applied to files:

  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts
  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-10-14T18:59:33.990Z
Learnt from: FatahChan
Repo: TanStack/router PR: 5475
File: e2e/react-start/basic-prerendering/src/routes/redirect/$target/via-beforeLoad.tsx:8-0
Timestamp: 2025-10-14T18:59:33.990Z
Learning: In TanStack Router e2e test files, when a route parameter is validated at the route level (e.g., using zod in validateSearch or param validation), switch statements on that parameter do not require a default case, as the validation ensures only expected values will reach the switch.

Applied to files:

  • packages/router-generator/tests/generator.test.ts
📚 Learning: 2025-11-02T16:16:24.898Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5732
File: packages/start-client-core/src/client/hydrateStart.ts:6-9
Timestamp: 2025-11-02T16:16:24.898Z
Learning: In packages/start-client-core/src/client/hydrateStart.ts, the `import/no-duplicates` ESLint disable is necessary for imports from `#tanstack-router-entry` and `#tanstack-start-entry` because both aliases resolve to the same placeholder file (`fake-start-entry.js`) in package.json during static analysis, even though they resolve to different files at runtime.

Applied to files:

  • packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts
📚 Learning: 2025-10-01T18:30:26.591Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: packages/router-core/src/router.ts:2231-2245
Timestamp: 2025-10-01T18:30:26.591Z
Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.

Applied to files:

  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
🧬 Code graph analysis (9)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (8)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx (9)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
  • Route (3-3)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (8)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
  • Route (3-3)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (4)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (9)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx (1)
  • Route (1-1)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
  • Route (3-3)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (9)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx (1)
  • Route (1-1)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
  • Route (3-3)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (6)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
  • Route (3-3)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (7)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)
  • Route (2-2)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
  • Route (3-3)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)
  • Route (3-5)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts (1)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts (6)
  • FileRoutesByFullPath (39-44)
  • FileRoutesByTo (45-50)
  • FileRoutesById (51-57)
  • FileRouteTypes (58-65)
  • RootRouteChildren (66-71)
  • routeTree (112-114)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Preview
  • GitHub Check: Test
🔇 Additional comments (16)
packages/router-generator/src/filesystem/physical/getRouteNodes.ts (1)

117-120: LGTM! Correct alignment of originalRoutePath with routePath.

The conditional prefixing of originalRoutePath with /${dir} mirrors the routePath transformation on line 111, ensuring consistent path metadata for escape-detection logic when processing virtual route nodes.

packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/index.tsx (1)

1-2: LGTM! Well-formed test route definition.

This root route definition is correctly structured and aligns with the test suite objectives for escaped underscore handling in virtual routes.

packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]auth.route.tsx (1)

1-5: LGTM! Correctly structured test for escaped underscore handling.

The filename [_]auth.route.tsx properly maps to route path /api/_auth, demonstrating that the escape sequence [_] preserves the underscore as a literal path segment rather than treating it as a pathless layout indicator.

packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/__virtual.ts (1)

1-11: LGTM! Virtual subtree configuration correctly exercises escape sequence handling.

This virtual configuration properly defines routes with escaped underscores ([_]auth and [_]callback), which is essential for testing the PR's core objective of fixing escape sequence handling in __virtual.ts files.

packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/[_]hello.tsx (1)

1-5: LGTM! Consistent test fixture for escaped underscore routes.

The route definition correctly demonstrates the [_] escape sequence mapping to a literal underscore in the path /api/_hello.

packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/callback.tsx (1)

1-2: LGTM! Properly structured route for virtual escaped underscore test.

This route definition correctly corresponds to the route('[_]callback', 'callback.tsx') entry in the virtual subtree configuration, testing that escaped underscores in virtual routes are properly handled.

packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/home.tsx (1)

1-2: LGTM! Correct index route definition for nested virtual path.

This index route properly corresponds to the index('home.tsx') entry in the virtual subtree configuration.

packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/nested/auth.tsx (1)

1-2: LGTM! Correct escaped underscore route for virtual subtree.

This route definition properly corresponds to the route('[_]auth', 'auth.tsx') entry in the virtual subtree, ensuring that the escaped underscore is treated as a literal path segment in /nested/_auth.

packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)

1-3: LGTM!

Standard root route definition following TanStack Router conventions. This test fixture correctly imports and uses createRootRoute.

packages/router-generator/tests/generator.test.ts (1)

107-117: LGTM!

The new test case correctly validates escaped underscore handling in physical routes mounted via virtual configuration. The setup follows the established pattern and includes helpful documentation.

packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/index.tsx (1)

1-5: LGTM!

Standard index route definition with an inline component. Follows TanStack Router conventions correctly.

packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/physical-routes/index.tsx (1)

1-5: LGTM!

Physical route definition follows TanStack Router conventions correctly. The /api/ path and inline component are properly configured for the test scenario.

packages/router-generator/src/filesystem/virtual/getRouteNodes.ts (4)

3-3: LGTM!

The determineInitialRoutePath import is correctly added to support escape sequence handling in route paths.


160-163: LGTM!

Correctly propagates originalRoutePath for physical subtree nodes when it exists. The conditional check appropriately handles the optional nature of this property, and the path concatenation mirrors the routePath logic.


194-223: LGTM!

The route type handling correctly uses determineInitialRoutePath to process escape sequences and maintains both routePath (escaped) and originalRoutePath (with brackets) for detection purposes. The implementation consistently applies this to both file-based and virtual route nodes.


253-269: LGTM!

Layout type handling mirrors the route type implementation consistently. The escape sequence processing and originalRoutePath tracking are correctly applied to pathless_layout routes.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/router-generator/src/filesystem/virtual/getRouteNodes.ts (1)

178-188: Consider adding originalRoutePath to index nodes for consistency.

Index routes don't have escape sequences, but downstream processing in physical/getRouteNodes.ts checks node.originalRoutePath existence before prefixing. If index nodes from virtual configs get merged, they'll have undefined for originalRoutePath while other node types have it set.

This shouldn't cause functional issues since index routes have no escapable segments, but setting originalRoutePath: routePath would provide consistency across all node types.

🔎 Optional: Add originalRoutePath for consistency
         case 'index': {
           const { filePath, variableName, fullPath } = getFile(node.file)
           const routePath = `${parentRoutePath}/`
           return {
             filePath,
             fullPath,
             variableName,
             routePath,
+            originalRoutePath: routePath,
             _fsRouteType: 'static',
           } satisfies RouteNode
         }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a32416c and 406838a.

📒 Files selected for processing (3)
  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript strict mode with extensive type safety for all code

Files:

  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Implement ESLint rules for router best practices using the ESLint plugin router

Files:

  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
🧠 Learnings (10)
📓 Common learnings
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/src/routes/non-nested/named/$baz_.bar.tsx:3-5
Timestamp: 2025-09-22T00:56:49.237Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments (e.g., `$baz_` becomes `baz` in generated types) but should be preserved in base path segments. This is the correct behavior as of the fix in PR #5182.
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6120
File: packages/router-generator/src/generator.ts:654-657
Timestamp: 2025-12-17T02:17:55.086Z
Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/tests/non-nested-paths.spec.ts:167-172
Timestamp: 2025-09-22T00:56:53.426Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments during path parsing, but preserved in base path segments. This is the expected behavior implemented in PR #5182.
Learnt from: Sheraff
Repo: TanStack/router PR: 6171
File: packages/router-core/src/new-process-route-tree.ts:898-898
Timestamp: 2025-12-21T12:52:35.231Z
Learning: In `packages/router-core/src/new-process-route-tree.ts`, the matching logic intentionally allows paths without trailing slashes to match index routes with trailing slashes (e.g., `/a` can match `/a/` route), but not vice-versa (e.g., `/a/` cannot match `/a` layout route). This is implemented via the condition `!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX` and is a deliberate design decision to provide better UX by being permissive with missing trailing slashes.
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.
📚 Learning: 2025-12-17T02:17:55.086Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6120
File: packages/router-generator/src/generator.ts:654-657
Timestamp: 2025-12-17T02:17:55.086Z
Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.

Applied to files:

  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-12-21T12:52:35.231Z
Learnt from: Sheraff
Repo: TanStack/router PR: 6171
File: packages/router-core/src/new-process-route-tree.ts:898-898
Timestamp: 2025-12-21T12:52:35.231Z
Learning: In `packages/router-core/src/new-process-route-tree.ts`, the matching logic intentionally allows paths without trailing slashes to match index routes with trailing slashes (e.g., `/a` can match `/a/` route), but not vice-versa (e.g., `/a/` cannot match `/a` layout route). This is implemented via the condition `!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX` and is a deliberate design decision to provide better UX by being permissive with missing trailing slashes.

Applied to files:

  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.

Applied to files:

  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-10-01T18:30:26.591Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: packages/router-core/src/router.ts:2231-2245
Timestamp: 2025-10-01T18:30:26.591Z
Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.

Applied to files:

  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61
Timestamp: 2025-10-01T18:31:35.420Z
Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.

Applied to files:

  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-12-06T15:03:07.223Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-06T15:03:07.223Z
Learning: Applies to **/*.{js,ts,tsx} : Implement ESLint rules for router best practices using the ESLint plugin router

Applied to files:

  • packages/router-generator/src/filesystem/physical/getRouteNodes.ts
  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-09-22T00:56:49.237Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5182
File: e2e/react-router/basic-file-based/src/routes/non-nested/named/$baz_.bar.tsx:3-5
Timestamp: 2025-09-22T00:56:49.237Z
Learning: In TanStack Router, underscores are intentionally stripped from route segments (e.g., `$baz_` becomes `baz` in generated types) but should be preserved in base path segments. This is the correct behavior as of the fix in PR #5182.

Applied to files:

  • packages/router-generator/src/filesystem/virtual/getRouteNodes.ts
📚 Learning: 2025-11-02T16:16:24.898Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5732
File: packages/start-client-core/src/client/hydrateStart.ts:6-9
Timestamp: 2025-11-02T16:16:24.898Z
Learning: In packages/start-client-core/src/client/hydrateStart.ts, the `import/no-duplicates` ESLint disable is necessary for imports from `#tanstack-router-entry` and `#tanstack-start-entry` because both aliases resolve to the same placeholder file (`fake-start-entry.js`) in package.json during static analysis, even though they resolve to different files at runtime.

Applied to files:

  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
📚 Learning: 2025-09-28T21:41:45.233Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5284
File: e2e/react-start/basic/server.js:50-0
Timestamp: 2025-09-28T21:41:45.233Z
Learning: In Express v5, catch-all routes must use named wildcards. Use `/*splat` to match everything except root path, or `/{*splat}` (with braces) to match including root path. The old `*` syntax is not allowed and will cause "Missing parameter name" errors. This breaking change requires explicit naming of wildcard parameters.

Applied to files:

  • packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx
🧬 Code graph analysis (1)
packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx (1)
packages/router-generator/tests/generator/virtual-with-escaped-underscore/routes/__root.tsx (1)
  • Route (3-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Preview
🔇 Additional comments (6)
packages/router-generator/src/filesystem/physical/getRouteNodes.ts (1)

117-120: LGTM! Consistent alignment of originalRoutePath with routePath.

The conditional prefix logic correctly mirrors the routePath construction on line 111, ensuring both paths stay synchronized for downstream escape detection. The guard prevents undefined concatenation.

packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routes/__root.tsx (1)

1-2: LGTM! Test fixture correctly structured.

The import is now included, and the pattern matches the existing virtual-with-escaped-underscore test fixture. Based on learnings, test fixture files verify generator output and are intentionally preserved as-is.

packages/router-generator/src/filesystem/virtual/getRouteNodes.ts (4)

2-9: LGTM! Import correctly added for escape detection utility.


160-163: LGTM! Consistent propagation of originalRoutePath for physical subtrees.

The alignment logic correctly uses the same prefix pattern as routePath (line 159), ensuring escape detection works correctly for nested physical routes within virtual configurations.


194-223: LGTM! Escape detection correctly implemented for route nodes.

The two-step processing via determineInitialRoutePath properly separates the escaped segment (for URL matching) from the original segment (for escape detection). Both file-backed and virtual route nodes receive originalRoutePath.


253-269: LGTM! Layout nodes correctly receive escape detection support.

The implementation mirrors the route case, ensuring pathless layouts (starting with _) can be distinguished from escaped underscores ([_]). This is essential for the fix described in the PR objectives.

@schiller-manuel schiller-manuel merged commit baa3d1d into main Dec 30, 2025
5 of 6 checks passed
@schiller-manuel schiller-manuel deleted the fix-virtual-escape branch December 30, 2025 01:36
@coderabbitai coderabbitai bot mentioned this pull request Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants