fix: guard React transition runtime APIs - #569
cursor[bot] wants to merge 1 commit into
Conversation
Co-authored-by: theg1239 <theg1239@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
examcooker | c86e2de | Sep 01 2026, 11:07 AM |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| import React from "react"; | ||
|
|
||
| const repoRoot = process.cwd(); | ||
| const sourceRoots = ["app"]; |
There was a problem hiding this comment.
Transition import guard is not automated
The scanner catches an unsafe ViewTransition import when run directly, but no package script or deployment build path invokes it. The deployment command remains npm run build, which does not run this scanner, so a future direct import of an unavailable React transition API can pass automated checks and restore the runtime crashes this change is intended to prevent. Add a package script for the scanner and invoke it from a required automated check.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Artifacts
Temporary unsafe-import automation harness
- This authored harness adds a disposable unsafe React transition import, runs the direct checker and CI build command before and after it, and removes the probe; the takeaway is a reproducible comparison of enforcement paths.
Checker and CI build output before and after unsafe import
- This captured run shows the checker passes before and fails after the unsafe import while the workflow’s `npm run build` command never invokes it; the takeaway is that CI does not enforce the checker.
- This captured direct invocation exits successfully on the restored clean tree and reports no unsafe direct imports; the takeaway is that the guard works only when explicitly run.
Package and workflow invocation scan
- This captured scan finds build invocations in the deployment workflows but no reference to the transition-import checker, followed by restored-workspace status; the takeaway is that no package or workflow automation calls the guard.
Bug and impact
Several client components imported
addTransitionTypeandViewTransitiondirectly fromreact, but the installedreact@19.2.8runtime exposes both asundefined. Rendering pages with<ViewTransition>or clicking navigation/filter/search controls that calladdTransitionType(...)can crash high-traffic app surfaces such as global navigation, course search, notes search, and past-paper pages.Root cause
The code relied on canary React view-transition APIs present in type definitions / Next docs, but not exported by the installed React runtime.
Fix
Added a shared
react-transitioncompatibility helper that no-ops transition type registration and falls back to plain children whenViewTransitionis unavailable, then routed all existing direct call/render sites through it.Validation
CI=true corepack pnpm exec tsx scripts/test-react-transition-runtime-imports.ts->React runtime: addTransitionType=undefined ViewTransition=undefined Activity=symbol; no unsafe imports found.CI=true corepack pnpm exec tsc --noEmit --pretty false-> passed.CI=true corepack pnpm build-> compiled successfully and finished TypeScript; stopped during page-data collection because localDATABASE_URLis unset.spent a lot of water and tokens to review your slop
Greptile Summary
This change introduces a compatibility layer for React transition APIs and a scanner intended to prevent unsupported direct imports from returning. The scanner correctly rejected a temporary direct
ViewTransitionimport when run manually, but the automated deployment build command does not invoke it. As a result, a future unsupported import can be merged and deployed without the new safeguard running.The transition-import scanner should be added to an automated required check before this change is merged.
Confidence Score: 4/5
Not safe to merge until the new transition-import guard is invoked by an automated required check.
A temporary unsafe import exercised the failure path: the scanner rejected it when run directly, while the deployment build command proceeded without running the scanner. This directly establishes that the intended regression protection is not enforced.
Files Needing Attention:
package.jsonand the deployment workflow commands need to invokescripts/test-react-transition-runtime-imports.ts; the scanner itself is atscripts/test-react-transition-runtime-imports.ts.What T-Rex did
Comments Outside Diff (1)
General comment
scripts/test-react-transition-runtime-imports.tscan detect unsafe direct imports when invoked manually, butpackage.jsonexposes no script for it and neither tracked deployment workflow invokes it. A future unsafe direct React transition import can therefore pass the configured automated path without this guard running.package.jsonscripts or chaining it into the build/check steps used by.github/workflows/deploy-appservice.ymlandazure-pipelines.yml.test:react-transition-runtime-imports: tsx scripts/test-react-transition-runtime-imports.ts, then invoke it in a required CI validation job or prepend it to every build/deployment path that must enforce the rule. Prefer a separate required CI step so its failure is explicit and is not masked by unrelated build prerequisites.Reviews (1): Last reviewed commit: "fix: guard React transition runtime APIs" | Re-trigger Greptile