Repository navigation
fix(codemod): fix what migrating Memos and T3 Code found - #2280
Conversation
Migrating two popular open-source React apps (Memos, T3 Code) and type-checking the output with octane-tsc turned up these codemod gaps: - shadcn-style Input/Textarea wrappers spread rest props onto the field, so React's per-edit onChange became Octane's commit-time change; take it out of the rest and pass it as onInput before the spread - React's global namespace types (React.ReactNode with no import) and forwardRef type arguments kept their React types - e.target in a handler a component passes on to a control, typed by the project (React 19.2's ChangeEvent<C, T> included), and in onFocus/onBlur - .d.ts files were skipped; JSX custom-element augmentations now target octane/jsx-runtime - packages were reported as needing a binding by name when their export map hid package.json, or by a React peer only their ./react entry uses - added imports follow the module's quote style Memos: 85 -> 61 codemod errors (all bindings, createRef, one class), 262 -> 68 octane-tsc errors. T3 Code: 251 -> 248 codemod errors. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 7ff56c4 | Commit Preview URL Branch Preview URL |
Oct 29 2026, 12:01 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 7ff56c4 | Commit Preview URL Branch Preview URL |
Oct 29 2026, 12:00 PM |
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 111 measured values. Public-import reachability bundles (bytes)No changes across 141 measured values. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Augmentation files lose module imports
- Side-effect imports (no importClause) of React modules are now rewritten in place with replaceSpecifier instead of being deferred to finishImports, which was silently dropping them because it skips clause-less imports.
Or push these changes by commenting:
@cursor push 9435062c8e
Preview (9435062c8e)
diff --git a/packages/codemod/src/transform.js b/packages/codemod/src/transform.js
--- a/packages/codemod/src/transform.js
+++ b/packages/codemod/src/transform.js
@@ -1117,6 +1117,10 @@
);
}
if (module in REACT_MODULES) {
+ if (!node.importClause) {
+ this.count(RULE.import);
+ return this.replaceSpecifier(node, node.moduleSpecifier, REACT_MODULES[module]);
+ }
this.importSlots.push(node);
return `\u0000IMPORT${this.importSlots.length - 1}\u0000`;
}
diff --git a/packages/codemod/tests/project.test.js b/packages/codemod/tests/project.test.js
--- a/packages/codemod/tests/project.test.js
+++ b/packages/codemod/tests/project.test.js
@@ -183,6 +183,7 @@
"import type { HTMLAttributes } from 'octane';\ndeclare module 'octane/jsx-runtime' {\n\tnamespace JSX {\n\t\tinterface IntrinsicElements { 'x-clock': HTMLAttributes<HTMLElement> }\n\t}\n}\n",
);
const css = result.files.find((f) => f.file === 'src/css.d.ts');
+ expect(code('src/css.d.ts')).toContain("import 'octane'");
expect(css?.notes.map((note) => note.rule)).toEqual(['unsupported-api']);
expect(css?.diagnostics).toEqual([]);
expect(code('src/Chart.tsx')).toContain("from '@octanejs/visx/hierarchy'");You can send follow-ups to the cloud agent here.
Running the migrated Memos app against its own backend crashed the memo
list as soon as a memo was saved: a component passed its `children` to
Base UI's `render` prop, which clones an element, but Octane passes JSX
children as a compiled render body.
Components whose own `children` reach `render={…}`, `cloneElement`,
`Children.*` or `isValidElement` are now wrapped in `descriptorChildren`,
so callers pass element descriptors as React does. A function declaration
becomes a marked `const` unless module-load code reads it first, in which
case it is reported. Call sites in the module keep their conditional
children as expressions: an `@if` there handed Base UI a fragment, so the
trigger props never reached the link and the tooltip never opened.
Also records the Memos runtime results in the plan.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A declaration file whose only import is `import 'react'` imports it so its
`declare module` augments the module. Dropping that import made the file a
script, where `declare module` declares the module instead: a JSX
custom-element file then replaced octane/jsx-runtime's types (even `<div>`
stopped typechecking), and a CSSProperties file would redefine `react`. When
the React imports leave nothing behind and nothing else makes the file a
module, `export {};` takes their place.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-ups for the descriptor-children rule: - A function with overload signatures stays as it is and is reported: turning its implementation into a `const` left the signatures behind as `function` declarations. - The hoisting check walked only direct reads. It now follows what runs while the module loads before the declaration: a callback or IIFE that code runs, and any call of a binding the module declares, which might reach the component. A function that is only defined runs nothing. - Only module-level components are marked, since the compiler reads the marker from module-level `const` bindings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rtions
- A declaration file with no import or export is a script, where `declare
module` declares the module instead of adding to it. When the codemod
retargets such a file's JSX augmentation to octane/jsx-runtime, it now adds
`export {};`, as it already did when dropping a React import; otherwise the
file replaced Octane's JSX types. A React augmentation it only reports is
left as written.
- `render={children as ReactElement}`, `cloneElement(children!)` and
`satisfies` around `children` now mark the component too.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Hoist check skips nested runners
- The
runscheck now walks up through ParenthesizedExpression, PropertyAssignment, ObjectLiteralExpression, ArrayLiteralExpression, and SpreadElement before testing whether the ancestor is a CallExpression/NewExpression, so parenthesized IIFEs and methods/arrows inside object arguments are correctly recognized as running at load time.
- The
Or push these changes by commenting:
@cursor push 625694007b
Preview (625694007b)
diff --git a/packages/codemod/src/transform.js b/packages/codemod/src/transform.js
--- a/packages/codemod/src/transform.js
+++ b/packages/codemod/src/transform.js
@@ -863,10 +863,20 @@
const visit = (/** @type {ts.Node} */ node) => {
if (!safe) return;
if (isFunctionLike(node)) {
- const call = node.parent;
+ let wrapped = /** @type {ts.Node} */ (node);
+ while (
+ ts.isParenthesizedExpression(wrapped.parent) ||
+ ts.isPropertyAssignment(wrapped.parent) ||
+ ts.isObjectLiteralExpression(wrapped.parent) ||
+ ts.isArrayLiteralExpression(wrapped.parent) ||
+ ts.isSpreadElement(wrapped.parent)
+ ) {
+ wrapped = wrapped.parent;
+ }
+ const call = wrapped.parent;
const runs =
(ts.isCallExpression(call) || ts.isNewExpression(call)) &&
- (call.expression === node || call.arguments?.includes(/** @type {any} */ (node)));
+ (call.expression === wrapped || call.arguments?.includes(/** @type {any} */ (wrapped)));
if (!runs) return;
} else if (ts.isIdentifier(node) && node !== fn.name) {
const declaration = this.declarationOf(node);You can send follow-ups to the cloud agent here.
The descriptor-children hoisting check walked a nested function only when it was a direct callee or argument, so a parenthesized IIFE, or a method on an object handed to an imported call, slipped through. It now assumes every function in load-time code runs, except one that is only defined there (a declaration, or a variable's value through `memo` or `forwardRef`), and treats handing a local binding to a call like calling it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Optional React peer skips binding detection
- Removed the standalone
peerDependenciesMeta?.react?.optionaldisjunct from the early-return condition so that only an actual./reactexport triggers the skip, allowing packages with optional React peers on their root entry to be correctly flagged as missing bindings.
- Removed the standalone
Or push these changes by commenting:
@cursor push 4f588c4a2d
Preview (4f588c4a2d)
diff --git a/packages/codemod/src/project.js b/packages/codemod/src/project.js
--- a/packages/codemod/src/project.js
+++ b/packages/codemod/src/project.js
@@ -443,9 +443,8 @@
/**
* Whether a package renders through React: it declares `react` as a peer or
* dependency when installed, or its name says so when it is not. A package
- * with a `./react` entry (`@pierre/trees/react`), or an optional React peer
- * for one, renders through React there, which the caller matches by subpath;
- * its other entries need no binding.
+ * with a `./react` entry (`@pierre/trees/react`) renders through React there,
+ * which the caller matches by subpath; its other entries need no binding.
*
* @param {string} name
* @param {string} from
@@ -454,7 +453,7 @@
if (name === 'octane' || name.startsWith('@octanejs/') || name.startsWith('node:')) return false;
const manifest = readInstalled(path.dirname(from), name)?.manifest;
if (!manifest) return REACT_PACKAGE.test(name);
- if (manifest.exports?.['./react'] || manifest.peerDependenciesMeta?.react?.optional) return false;
+ if (manifest.exports?.['./react']) return false;
return ['peerDependencies', 'dependencies'].some((field) => manifest[field]?.react !== undefined);
}You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit e9d6c1c. Configure here.
…ional peer An optional React peer does not say which entries use React: a package can use it in its root entry when React is installed. Only a dedicated `./react` export now marks the other entries as React-free; a package with an optional peer and no such entry is reported as needing a binding again. Co-Authored-By: Claude Opus 5.5 <[email protected]>


Summary
Fixes from migrating two popular open-source React apps with
@octanejs/codemod --strong:Memos (React 19, Vite, React Router, TanStack Query, Base UI; 458 modules) and
T3 Code (React 19, Vite, TanStack Router, Base UI, Tiptap, Effect; 968 modules).
I type-checked the output with
octane-tscagainst this branch's packages. t3.chat itself is closed source, so T3 Code is the T3 team's open-source app.Every fix has a test that fails without it. A new
app-shapesgolden fixture collects the real shapes the two apps hit, and its output is compiled as part of the test.octane-tscerrors before → afterThe remaining codemod errors are missing bindings (
react-hot-toast,@effect/atom-react,@legendapp/list,@clerk/react, ...),createRefin tests, and one class error boundary per app.Changes
Text-field wrappers (
native-text-change). A shadcn-styleInput/Textareathat spreads its rest props onto the field passed React's per-keystrokeonChangethrough as Octane's nativechange, which fires on blur, so every controlled field in Memos stopped updating as you type. The codemod now destructuresonChangeout of the rest and passesonInput={onChange}before the spread, so a caller's ownonInputstill wins. It only does this when every other read of the rest is a member other thanonChange. Anything else (<input {...props}>with whole props, or a rest also spread elsewhere) is reported.React's global namespace (
imports).React.ReactNode,React.FC,React.ChangeEventwritten with no import (29 Memos and 31 T3 Code modules) now map to Octane's types.forwardReftype arguments were copied as text, soReact.ComponentPropsWithoutRef<"div">survived in every shadcn component. They are now emitted through the rewriter.e.target→e.currentTarget(event-object). This now also applies:<Input onChange={(e) => …}>), including React 19.2's two-argumentChangeEvent<C, T>;onFocus/onBlur.Declaration files were skipped entirely.
declare module "react" { namespace JSX { … } }custom-element typing now targetsoctane/jsx-runtime, and other augmentations of React's own types are reported..d.tsfiles are never compiled. A file whose only import wasimport 'react'keepsexport {};, so itsdeclare modulestill augments rather than replaces.Binding detection. A package was flagged as needing a binding:
package.json(@vitejs/plugin-react);./reactentry uses (@usememos/editor,@pierre/trees,@clerk/electron).The codemod now reads the manifest through
readInstalled, newly exported from@octanejs/cli, which walksnode_modulesby hand.Children read as elements (
descriptor-children, found by running Memos). A component that hands itschildrento Base UI'srenderprop crashed the memo list when the first memo was saved: React passes JSX children as elements, Octane as a compiled render body. Components whose ownchildrenreachrender={…},cloneElement,Children.*orisValidElementare now wrapped indescriptorChildren, so callers pass elements. Their call sites in the module keep conditional children as expressions, because an@ifthere handed Base UI a fragment and the tooltip never opened. A function declaration becomes a markedconstunless module-load code reads it first, in which case it is reported.Added imports use the module's own quote style.
docs/octane-codemod-plan.mdgains a "Memos and T3 Code" section. The README rules table lists the new rewrites.Validation
pnpm vitest run --project codemod, 60/60. Each new test was checked to fail with its fix reverted.octane-tsc -p packages/codemod/tsconfig.typecheck.jsonand-p packages/cli/tsconfig.typecheck.jsonpnpm format:files:check, andpnpm sync(no generated changes)pnpm test,pnpm typecheck,pnpm format:check(repo-wide; not run, per the local test load rule; CI covers them)@octanejs/vite-plugin, and the original React app beside it on the same server for comparison.react-hot-toast;@usememos/editor/reactmigrated by the codemod itself; a react-leaflet placeholder; the class error boundary hand-ported to@try/@catch.Inputfields kept each keystroke while focused.descriptor-childrenfix above was verified there: memos save, and the timestamp tooltip opens with Base UI's trigger props on the link.**bold**in memo bodies renders identically in the React original.perf-review: not applicable. Developer tooling only; no runtime, compiler output, or binding hot path.concise-code: src +236 −55, all inpackages/codemod/srcexcept the one-linereadInstalledexport (and its declaration) in@octanejs/cli, which reuses the CLI's existing manifest walk instead of a second one.attributeOfreplaces four copies of a find-attribute-by-name lambda, andprojectTypeis shared bytypeOfand the event check.app-shapesfixture pair and a changeset. New export:readInstalled, whose caller is the codemod.@octanejs/base-ui/dialogexists" warnings: about +110 kB on a 243 kB file.Risk / follow-ups
Owned elsewhere, found by this run and not fixed here:
.tsrxkeeps type-only import names (blocks running any migrated app). TypeScript drops an import of a name used only as a type; the Octane compiler keeps it, so 30 Memos modules fail to link (does not provide an export named 'InstanceProfile') and the app is a blank page. I marked themtypeby hand to keep going. This is the existing proposed session ".tsrx keeps imports of type-only names"..tsrxTypeScript view (compileToVolarMappings), fixed by fix(compiler): typecheck generic arrows and directive arm exits in the .tsrx type view #2284 and merged into this branch:<T,>(…) =>as<T>, which TypeScript reads as JSX.return nullin an@forrow, which the compiler and the authoring rules allow..tsrxfile.useRef<T>(null)anduseRef<T>(undefined)had no overload (31 Memos errors; React 19 has both). Fixed by fix: type useRef<T>(null) and useRef<T>(undefined) like React 19 #2281, merged into this branch.ComponentProps<"div">spread onto a host in a Strong module failedStrongIntrinsicProps(12 Memos wrappers). Fixed by fix(octane): type Strong host prop wrappers against Strong hosts #2282, merged into this branch.children: ReactElementprop can't take template children.evaluateRenderPropcalls a compiled children body as a render function (an opaqueparentNodecrash) instead of guarding withisChildrenBlocklike its other render-prop sites.descriptorChildrencomponent used from another module still gets@ifchildren at those call sites.@octanejs/remix-routerlacksLinkPropsand typesLink'srefmore narrowly than React Router.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Migration rewrites affect form event wiring, children semantics, and type augmentations—easy to miss edge cases despite broad tests, but scope is codemod/CLI tooling rather than production runtime paths.
Overview
Hardens
@octanejs/codemodusing defects found migrating Memos and T3 Code, with goldenapp-shapescoverage and expanded tests.Controlled inputs and events: shadcn-style
Input/Textareawrappers that spread rest props now pullonChangeout and wireonInput={onChange}before the spread so Octane does not treat React’s per-keystroke handler as native commit-timechange. Unsafe spreads are warned instead of silently breaking forms.e.targetrewrites toe.currentTargetalso apply when project types say the handler is forwarded from a wrapper control, for union-typed controls, and ononFocus/onBlur.Types and imports: unimported
React.*global namespace types map to Octane equivalents;forwardRefgeneric arguments are emitted through the type rewriter (not left as rawReact.text)..d.tsfiles are migrated: JSX intrinsic augmentations move fromdeclare module 'react'tooctane/jsx-runtime, other React augmentations are reported, and script-style declaration files getexport {}so augmentations still merge.Children and bindings: components that treat
childrenas elements (render={children},cloneElement,Children.*,isValidElement) are wrapped withdescriptorChildren, and their in-module call sites keep conditional children as expressions (not@iffragments). Missing-binding detection reads installedpackage.jsonvia newly exportedreadInstalledfrom@octanejs/cli, so export-map-hidden packages and./react-only peers are not mis-flagged. New imports match the file’s quote style.Docs/changeset record corpus numbers and remaining follow-ups outside this PR.
Reviewed by Cursor Bugbot for commit 7ff56c4. Bugbot is set up for automated code reviews on this repo. Configure here.