Skip to content

Refactor-signals#6704

Draft
Sheraff wants to merge 78 commits intomainfrom
refactor-signals
Draft

Refactor-signals#6704
Sheraff wants to merge 78 commits intomainfrom
refactor-signals

Conversation

@Sheraff
Copy link
Contributor

@Sheraff Sheraff commented Feb 19, 2026

Benchmarks

Custom benchmarks (separate from the codspeed ones), made to exaggerate the impact of this PR:

  • total_cycle_ms is a Router test, runs on playwright, measures "how long to navigate 100 times" on a rerender-heavy page
  • median_req_per_sec is a Start test, runs on autocannon, using the previously established "minimal", "100 links", "many nested routes" apps

Results:

  • Nav total_cycle_ms (median of trials), lower is better:
Benchmark Base Head Change
React 853.90 265.40 3.2x
Solid 823.55 342.10 2.4x
Vue 1395.15 214.25 6.5x
  • SSR median_req_per_sec (median of rounds), higher is better:
Benchmark Base Head Change
React root_fixed 5022.20 5033.15 +0.22%
React page100_fixed 1170.50 1170.60 +0.01%
React page_random 1185.66 1186.00 +0.03%
Solid root_fixed 1177.84 1178.60 -0.06%
Solid page100_fixed 139.07 139.04 +0.02%
Solid page_random 139.97 139.57 +0.29%
Vue root_fixed 1387.64 1389.57 +0.14%
Vue page100_fixed 328.24 328.64 +0.12%
Vue page_random 284.44 284.80 +0.13%

Summary by CodeRabbit

  • New Features

    • Enhanced server/client reactivity and SSR paths across React, Solid, and Vue; more granular per-route reactivity exposed to UIs and devtools.
  • Bug Fixes

    • Stabilized tests by replacing flaky range assertions with exact expected values; E2E tests adjusted for deterministic renders.
  • Documentation

    • Removed documented pendingMatches field and updated hook wording to reference pending vs active matches.
  • Refactor

    • Router state moved to store-backed match APIs; public RouterState no longer exposes pendingMatches/cachedMatches.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replace the central Router __store with a granular, server-aware RouterStores system; RouterCore now accepts a store factory; public RouterState drops pendingMatches/cachedMatches; adapters, devtools, plugins, and tests updated to use per-store subscriptions and adapter-specific store factories.

Changes

Cohort / File(s) Summary
Core stores & RouterCore
packages/router-core/src/stores.ts, packages/router-core/src/router.ts, packages/router-core/src/index.ts
Add comprehensive RouterStores implementation, per-match stores, store factory types and exports; RouterCore now accepts GetStoreConfig, exposes stores and batch; public RouterState no longer exposes pendingMatches/cachedMatches. Review types, constructor changes, and public-state shape.
Router-core logic & SSR
packages/router-core/src/load-matches.ts, packages/router-core/src/ssr/*, packages/router-core/src/scroll-restoration.ts, packages/router-core/src/createRequestHandler.ts
Migrate all reads/writes from router.state to router.stores.* and snapshots; add hasForcePendingActiveMatch helper; align batching to router.batch; hydration/dehydration use activeMatchesSnapshot. Check batching/scoping and SSR snapshots.
Store factories (framework adapters)
packages/react-router/src/routerStores.ts, packages/solid-router/src/routerStores.ts, packages/vue-router/src/routerStores.ts
Introduce adapter-specific getStoreFactory implementations (server: non-reactive stores, client: reactive stores) and derived stores (e.g., childMatchIdByRouteId, pendingRouteIds). Validate init hooks and derived store correctness.
React adapter
packages/react-router/src/... (Match.tsx, Matches.tsx, Scripts.tsx, Transitioner.tsx, headContentUtils.tsx, link.tsx, not-found.tsx, useMatch.tsx, useLocation.tsx, useCanGoBack.ts, useRouterState.tsx, router.ts)
Replace useRouterState with useStore/router.stores access; add server/client branches, per-match subscriptions, structural sharing, and new asset/head/script helpers. Inspect server branches, per-match store subscriptions, and error/redirect handling.
Solid adapter
packages/solid-router/src/... (Match.tsx, Matches.tsx, Scripts.tsx, Transitioner.tsx, headContentUtils.tsx, link.tsx, useMatch.tsx, useLocation.tsx, useRouterState.tsx, routerStores.ts, store.ts, matchContext.tsx)
Migrate to Solid signals/memos reading router.stores; add routeIdContext/pendingMatchContext, shallow helpers, and SSR-aware non-reactive paths via getStoreFactory. Review memo equality, context propagation, and SSR non-reactive paths.
Vue adapter
packages/vue-router/src/... (Match.tsx, Matches.tsx, Scripts.tsx, Transitioner.tsx, headContentUtils.tsx, link.tsx, useMatch.tsx, useLocation.tsx, useRouterState.tsx, routerStores.ts, matchContext.tsx)
Migrate to useStore/computed reading router.stores; add routeId/pending contexts, SSR branches and derived computed stores (lastMatchRouteFullPath, childMatchIdByRouteId, pendingRouteIds). Validate computed derivations and SSR vs client paths.
Devtools & plugin
packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsx, packages/router-plugin/src/core/route-hmr-statement.ts, packages/router-plugin/tests/add-hmr/snapshots/*
Devtools now consume pending/cached snapshots from stores; plugin/HMR use activeMatchesSnapshot/pendingMatchesSnapshot instead of router.state arrays. Check devtools rendering and HMR detection changes.
Tests & test utilities
packages/router-core/tests/*, packages/router-core/tests/routerTestUtils.ts, e2e/*
Add createTestRouter helper that supplies getStoreConfig; tests updated to use stores/snapshots and tightened exact update counts; add granular-stores tests; minor e2e tweaks (burstClicks, render count). Review test helpers and updated assertions.
Docs & types
docs/router/api/router/RouterStateType.md, docs/router/api/router/useChildMatchesHook.md, docs/router/api/router/useParentMatchesHook.md
Remove pendingMatches from RouterState docs and reword hooks to reference pending vs active matches. Ensure docs match public types.
Package changes & utils
packages/router-core/package.json, packages/solid-router/package.json, packages/router-core/src/utils.ts, packages/router-core/src/utils/batch.ts
Move @tanstack/store to devDeps in router-core; remove @tanstack/solid-store from solid-router deps; add arraysEqual util; delete legacy batch utility (batch.ts). Verify package compat and removed batch usages replaced by router.batch.
Store update report
store-updates-delta.md
Add adapter-specific delta report documenting observed update-count changes across React/Solid/Vue tests. Informational only.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client App
    participant StoreFactory as Store Factory (getStoreFactory)
    participant ReactiveStores as RouterStores (per-adapter)
    participant MatchComp as Match component

    Client->>StoreFactory: initialize Router (isServer: false)
    StoreFactory->>ReactiveStores: create reactive stores + batch + init
    ReactiveStores-->>StoreFactory: return stores

    Client->>MatchComp: render Match
    MatchComp->>ReactiveStores: subscribe to per-match store (useStore/useStore-like)
    ReactiveStores-->>MatchComp: push per-match updates
    MatchComp-->>Client: re-render UI
Loading
sequenceDiagram
    participant Server as SSR
    participant StoreFactory as Store Factory (getStoreFactory)
    participant SSRStores as Non-reactive RouterStores
    participant MatchComp as Match component

    Server->>StoreFactory: initialize Router (isServer: true)
    StoreFactory->>SSRStores: create non-reactive stores (snapshots)
    SSRStores-->>StoreFactory: return stores

    Server->>MatchComp: render Match (read-only)
    MatchComp->>SSRStores: read store.state directly
    SSRStores-->>MatchComp: return snapshot
    MatchComp-->>Server: produce HTML
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Suggested reviewers

  • nlynzaad

Poem

🐰 Hop, hop — the stores split up the load,
Per-match burrows keep each route in code.
SSR naps quiet while client gardens grow,
Batches hum softly, snapshots steal the show.
A rabbit cheers — small hops, big flow!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Refactor-signals' is vague and generic, using a non-descriptive term that doesn't clearly convey the purpose of the changes to someone scanning commit history. Use a more descriptive title that explains the main objective, such as 'Refactor router state management to use granular reactive stores' or 'Replace useRouterState with store-based subscriptions'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor-signals

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

@nx-cloud
Copy link

nx-cloud bot commented Feb 19, 2026

View your CI Pipeline Execution ↗ for commit 1e703e6

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 12m 4s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 33s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-11 12:13:38 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 19, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@6704

@tanstack/eslint-plugin-router

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

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@6704

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@6704

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@6704

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@6704

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@6704

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@6704

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@6704

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@6704

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@6704

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@6704

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@6704

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@6704

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@6704

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@6704

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@6704

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@6704

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@6704

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@6704

commit: 164ae17

Base automatically changed from codex/store-0.9.1-migration to main February 19, 2026 21:27
@birkskyum
Copy link
Member

I'm OK with the changes to the solid/vue packages made here.

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