Skip to content

fix(codemod): migrate verified selected context aliases - #3055

Merged
domgan-oai merged 4 commits into
octanejs:mainfrom
openai-oss-forks:fix/codemod-selected-context-alias
Nov 18, 2026
Merged

domgan-oai merged 4 commits into
octanejs:mainfrom
openai-oss-forks:fix/codemod-selected-context-alias

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A selected local context imported through a TypeScript path alias kept its React Provider/Consumer members after the exporter migrated to Octane, while ordinary provider objects could be mistaken for contexts by name. Promote only a direct source-backed migrated context reached through one unambiguous alias target, preserve proven ordinary objects, and block uncertain or retained React ownership before writing.

Fixes #2608.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • targeted tests: 15 alias controls passed, including Provider/Consumer conversion, ordinary and third-party member preservation, wildcard unresolved imports, and unchanged writes for fallback, overlapping, competing, attributed, and unselected cases.
  • Write-mode client DOM and SSR with Octane's server-runtime request resolver both produced <b title="original">night</b>.
  • Codemod TypeScript build, changed-file Prettier check, and pnpm sync passed; sync left no tracked changes.
  • perf-review: not applicable (codemod-only diff).
  • concise-code: src +59 −18 (runtime +0 −0); new files and exports: patch changeset only, no new module export; existing internal typedFile is reused by the context owner to retain ambiguity blockers; alternatives: promote every typed alias (~5 lines) or rewrite aliases to relative imports (~15 lines), rejected because they misclassify competing targets or alter the import contract; bytes: not applicable.

Risk / follow-ups

Promotion is limited to a single direct selected context and one alias target. Reexports, fallback mappings, attributes, runtime siblings, and retained React contexts remain explicit review boundaries.

Provenance

  • An agent produced this diff (agent-authored)

Originating task: Codex task, host com-79386.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Changes codemod classification of imports through tsconfig paths; misclassification could skip migration or alter Provider/Consumer rewriting, though guards limit auto-migration to narrow verified cases.

Overview
The codemod now auto-migrates React Provider/Consumer usage for contexts imported via TypeScript path aliases when the alias is unambiguous: one matching pattern, one target, typed resolution matches the runtime source, and the export is a verified selected createContext (not a const object “provider”).

Context detection now tracks alias targets alongside patterns, uses typedFile vs localFile to separate type resolution from runtime, and treats const-object exports, retained React contexts, wildcard/unresolved imports, fallback targets, and overlapping aliases as non-context or context-path-alias review errors that block writes.

Tests cover successful alias migration (including DOM verification), preserved ordinary/third-party contexts, and unchanged output for blocked cases.

Reviewed by Cursor Bugbot for commit a8db817. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Nov 18, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review November 18, 2026 21:04

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 24ca182. Configure here.

Comment thread packages/codemod/src/project.ts Resolved
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares 22d39dbf0, the merge commit's first parent with 026f1e069 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.667 2.508 ±0.0% −0.0% … +3.9% ⚪ within noise
octane-tsrx replace 4.883 4.925 +1.0% −2.0% … +4.0% ⚪ within noise
octane-tsrx add 2.092 2.133 ±0.0% −0.0% … +0.0% ⚪ within noise
octane-tsrx update 0.087 0.086 −0.2% −1.4% … +0.5% ⚪ within noise
octane-tsrx select 0.005 0.005 −1.3% −2.6% … −0.5% ⚪ within noise
octane-tsrx swap 0.015 0.015 −1.4% −2.3% … −0.9% ⚪ within noise
octane-tsrx remove 0.014 0.013 −2.7% −3.7% … −1.0% ⚪ within noise
octane-tsrx runlots 20.858 20.875 +5.8% +2.0% … +9.5% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 +1.4% −1.9% … +3.6% ⚪ within noise
octane-tsrx clear 46.675 49.083 −0.2% −7.0% … +5.0% ⚪ within noise
octane-jsx run 3.850 3.717 −1.4% −4.8% … +2.7% ⚪ within noise
octane-jsx replace 6.450 7.100 +0.7% −5.9% … +12.3% ⚪ within noise
octane-jsx add 3.367 3.525 +3.3% +0.0% … +8.1% ⚪ within noise
octane-jsx update 0.182 0.178 ±0.0% −6.2% … +2.0% ⚪ within noise
octane-jsx select 0.085 0.084 −1.6% −5.0% … +1.4% ⚪ within noise
octane-jsx swap 0.127 0.128 −1.1% −1.5% … +1.1% ⚪ within noise
octane-jsx remove 0.123 0.124 −0.7% −2.1% … +0.7% ⚪ within noise
octane-jsx runlots 34.367 35.917 +1.1% −7.2% … +5.9% ⚪ within noise
octane-jsx select_lots 1.175 1.233 −2.7% −9.9% … +14.2% ⚪ within noise
octane-jsx clear 63.667 64.208 +6.3% −1.7% … +17.9% ⚪ within noise

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.

@domgan-oai
domgan-oai merged commit 195d29d into octanejs:main Nov 18, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codemod guesses local Context.Provider ownership from export names

1 participant