Repository navigation
feat(cli): the swipe codemod defines each swipe once - #11670
Conversation
The deprecations codemod wrote createSwipe(...) inline on each row, with positional ids, so every render built a new swipe. It now defines each swipe once: at module scope, or in useMemo in the enclosing component or hook when a handler reads its props or state. A useState or useReducer setter and a ref stay out of the dependencies. Each new id is named after the action's label, then its handler. On a ListItem, a handler that reads the row's own itemKey value takes itemKey from onActivate instead, so one swipe serves every row. A conditional value keeps its condition on the row, and each of its objects is defined once. A spread of a local constant object with no swipe props gets no TODO. Where the codemod cannot define a swipe once, createSwipe stays on the row with a TODO.
The page built a new swipe for every row on every render. Each case now builds two swipes once, in useMemo: unread rows offer Read and read rows offer Unread. Each handler reads its row from the itemKey that every row now passes, and the row's click shares the same read toggle.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DropdownMenu | 108.8 kB (+3 B) · 18.9 kB CSS (0) | — | — · — · — |
| Item · Storybook | 20.6 kB (+1 B) · 6.2 kB CSS (0) | 958 (0) | ✓ · ✓ · — |
| SelectorOption | 24.2 kB (+1 B) · 6.7 kB CSS (0) | — | — · — · — |
24 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Table | 121.8 kB (+1 B) · 19.8 kB CSS (0) | — | — · — · — |
| TableCell | 104.7 kB (+1 B) · 19.3 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 370.3 kB (+1 B) · 2.4 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 98.0 kB (0) · 13.3 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 80.4 kB (0) · 12.1 kB CSS (0) | — | — · — · — |
| ContextMenu | 103.4 kB (0) · 18.8 kB CSS (0) | — | — · — · — |
| ContextMenuItem | 35.9 kB (0) · 7.1 kB CSS (0) | — | — · — · — |
| DropdownMenuCheckboxItem | 28.8 kB (0) · 7.3 kB CSS (0) | — | — · — · — |
| DropdownMenuItem | 28.0 kB (0) · 6.9 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 78.9 kB (0) · 10.5 kB CSS (0) | — | — · — · — |
| ListItem | 79.5 kB (0) · 12.1 kB CSS (0) | — | — · — · — |
| Pagination | 147.6 kB (0) · 19.1 kB CSS (0) | — | — · — · — |
| RadioListItem | 76.5 kB (0) · 10.7 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 104.5 kB (0) · 19.1 kB CSS (0) | — | — · — · — |
| lab/TabBarMoreList | 102.4 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
| lab/TransferList | 136.4 kB (0) · 1.2 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 145.3 kB (0) · 1.4 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 309.2 kB (0) · 454 B CSS (0) | — | — · — · — |
| DropdownMenuRadioItem | 28.8 kB (−1 B) · 7.3 kB CSS (0) | — | — · — · — |
| Markdown | 205.5 kB (−1 B) · 22.1 kB CSS (0) | — | — · — · — |
| PowerSearch | 310.3 kB (−1 B) · 25.6 kB CSS (0) | — | — · — · — |
| Selector | 114.8 kB (−1 B) · 18.7 kB CSS (0) | — | — · — · — |
| lab/Comments | 377.1 kB (−1 B) · 2.5 kB CSS (0) | — | — · — · — |
| MoreMenu | 109.1 kB (−3 B) · 18.9 kB CSS (0) | — | — · — · — |
Package size:
- @astryxdesign/cli 5.40 MB packed (+14.9 kB); no new dependencies
- @astryxdesign/core 7.66 MB packed (+28 B); no new dependencies
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
|
/approve-spec b38b0b9 |
The shared drag lists the committed options ref that its begin check reads; the ref is stable, so a root keeps one drag. The row-actions record's modality split says what FR4 says: a trackpad's horizontal scroll swipes a row, and a mouse drag or a mouse wheel's notches don't. The record's builder-impact example gives its action the id that every swipe action needs. The pinch-zoom spec's comment says a finger's swipe begins at the 8 px claim.
A row that spreads what an array literal's map callback takes, such as Item's States story, got the codemod's TODO, though every element gives it an object literal with no swipe props. The codemod now proves that case, for the callback's parameter or one place in its array pattern, and keeps the TODO when any element might carry a swipe prop.
There was a problem hiding this comment.
Requesting changes. The define-once output is the direction an engineering owner approved for DEP-0017, but five problems need fixing first:
- The codemod treats a
.maporuseCallbackcallback assigned to a capitalized name (for exampleconst Rows = rows.map(row => …)) as a component and insertsuseMemoinside it, so React throws when the list length changes; climb only amemo(…)orforwardRef(…)call that takes the function as its first argument. - Rewriting
() => remove(row.id)to({itemKey}) => remove(itemKey)makes TypeScript reject the output with TS2345, becauseitemKeyisstring | number | undefined, where the old output compiled; rewrite only key reads used in===/!==comparisons, or keep the closure with the TODO, and typecheck a typed fixture. - Module-scope placement moves render-time calls such as
label: t('archive')to import time, so the label is computed once before the app sets its locale, which contradicts the migration's promise that the panel and every handler behave as before; keep options that call or construct anything outside a handler inline with the TODO. - On a plain
Item, the TODO tells callers to read the row from theitemKeythatonActivatereceives, butItemhas noitemKeyand passesundefined, soItemrows need their own guidance. - Three claims do not hold: the spec allows an inline
createSwipecall, so the old output was valid rather than a defect to fix; the changeset leaves out the side-and-place id fallback; and five output tests do not runexpectStable, although the description says every output test runs twice and parses.
One smaller point: in an expression-bodied component, the second object of a conditional stays inline with a TODO whose reason does not apply. The inline comments point at each location.
Claims and files checked
- Changeset: the codemod rewrites the deprecated swipe props on
ItemandListItemwhere every entry is an object literal. Verified by the tests. - Changeset: it defines each swipe once, at module scope or in
useMemo. Verified, except for callbacks named like components (first finding). - Changeset: an entry with no id is named after its label or handler. False in part: the side-and-place fallback is not mentioned (fifth finding).
- Changeset: a
ListItemhandler that reads its row's key takes it fromonActivate. Verified, but typed handlers stop compiling (second finding). - Changeset: it keeps
createSwipeon the row with a TODO where it cannot define the swipe once, and it reports hidden entries and spreads. Verified by the tests. - Core changeset: the shared drag lists the committed options ref its begin check reads, the ref is stable, and nothing new is exported. Verified in
useSwipeAction.ts. - Description: the old output built a new swipe on each row in every render, with positional ids. Verified against the old transform.
- Description: the spec rejects that pattern. False (fifth finding).
- Description: module scope when the options read only earlier module bindings, else
useMemo, with setters and refs left out of the dependencies. Verified, with the first and third findings. - Description: ids from the label, then the handler, then side and place; conditionals keep their condition; identical options share one definition; spreads proven free of swipe props get no TODO. Verified by the tests.
- Description: the sandbox page defines two swipes per case in
useMemo, with handlers that read the row's key. Verified. - Description: 11 of the 17 tests fail on the old transform, and all 17 pass. Verified by a rerun.
- Description: each output test also runs twice and parses. False (fifth finding).
- Description: the codemod suite (86 files, 1,067 tests), the knowledge and changeset checks, lint and formatting pass. Verified by a rerun.
- Description: the migrated story matches the hand-written lines except for one blank line. Verified by a rerun.
- Description: the CLI, Core and Storybook typechecks, the browser interaction and accessibility specs, the codemod verify run and the sandbox touch script pass. Not rerun.
- Description: the four review-note edits (story comment, drag dependencies, record wording, pinch-zoom test comment). Verified.
- Description: no public or internal API change, and +1201/−155 lines in 9 files. Verified.
.changeset/swipe-codemod.md: fifth finding..changeset/swipe-shared-drag-deps.md: clear.apps/sandbox/src/app/(raw)/pages/swipe-actions-cases/cases.tsx: clear.apps/storybook/stories/Popover.stories.tsx: clear.docs/specs/AST-057-row-actions/spec.md: clear (owner-approved).packages/cli/assets/codemods/transforms/next/__tests__/migrate-item-swipe-actions-to-swipe.test.mjs: fifth finding.packages/cli/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs: first to fourth findings.packages/core/src/Item/__tests__/ItemSwipePinchZoom.a11y.chromium.spec.ts: clear.packages/core/src/Swipe/useSwipeAction.ts: clear.
b38b0b9 to
6c7e4a1
Compare
|
/approve-spec 6c7e4a1 |
There was a problem hiding this comment.
Requesting changes. The define-once output is the direction an engineering owner approved for DEP-0017 on this head, but six problems in the codemod and its description need fixing first:
- The codemod treats a
.map,useCallbackoruseMemocallback assigned to a capitalized name (for exampleconst Rows = rows.map(row => …)) as a component and insertsuseMemoinside it, so the migrated code throws "Rendered more hooks than during the previous render" once the list grows; climb only amemo(…)orforwardRef(…)call that takes the function as its first argument, and add a regression test. - Rewriting
() => remove(row.id)to({itemKey}) => remove(itemKey)makes TypeScript reject the output with TS2345, becauseitemKeyisstring | number | undefined, where the old output compiled; rewrite only key reads used in===/!==comparisons, or keep the closure with the TODO, and typecheck a typed fixture. - Module-scope placement moves render-time expressions such as
label: t('archive')or awindowread to import time, so the label stops following the locale and server rendering can throw; choose module scope only when every value outside a handler is a literal, an import or a JSX element. - On a plain
Item, the TODO tells callers to read the row from theitemKeythatonActivatereceives, butItempassesundefined, soItemrows need their own guidance. - Miss: in an expression-bodied component only the first swipe gets a definition, and the rest stay inline with a TODO that wrongly says their actions read values the codemod cannot move; re-resolve the row's statement after the body is wrapped, and add a test with two rows in an arrow component.
- Three claims do not hold: the spec allows an inline
createSwipecall, so the old output was not a defect to restore; the changeset leaves out the side-and-place fallback id and theuseMemoplacement for props; and five output tests never run the output twice or parse it.
The sandbox page rewrite, the Core dependency-list change and the record wording check out.
Claims and files checked
- Claim: the codemod changeset describes define-once placement, label or handler ids,
itemKeyfromonActivate, inline rows with a TODO and the reports. False in part: it omits the side-and-place fallback anduseMemoplacement for props. - Claim: the Core changeset says the shared drag now lists its committed options ref, which is stable and not exported. Verified (
useSwipeAction.ts:587,:1355; not exported from the package entry points). - Claim: the old output is a pattern the spec rejects, and this restores a defect. False: FR11 allows an inline call, and DEP-0017 specified the old output.
- Claim: the placement, id, conditional, shared-definition and spread rules. Verified by the tests, except that identical options in an arrow component do not share a definition and globals do not block module scope.
- Claim: 11 of the 17 tests fail on the old transform and 17 of 17 pass now. Verified.
- Claim: each output test also runs twice and parses. False for the tests at lines 44, 74, 90, 134 and 220.
- Claim: the codemods suite passes 1,067 tests in 86 files. Verified.
- Claim: the CLI typecheck reports 0 errors after the build. Verified.
- Claim: prettier, the knowledge check and the changeset check pass. Verified; eslint and the repository check were not rerun.
- Claim: the codemod output for the List stories matches the hand-written lines but for one blank line, and the Item story rows with no
itemKeystay inline with a TODO. Verified. - Claim: the sandbox page defines two swipes per case in
useMemo, with handlers that readitemKey. Verified; the file has no type errors. - Claim: the drag dependency change, the record's modality and builder-impact cells and the pinch-zoom comment change no behavior. Verified against FR4, FR1 and the swipe motion constants.
- Claim: no public API changes, and the size is +1193/−150 in 8 files. Verified.
- Claim: Codemod Verify, the Core typecheck, the unit suites and the browser runs passed. Not rerun; CI did not run on this draft, and no finding depends on them.
- File
packages/cli/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs: five findings above. - File
packages/cli/assets/codemods/transforms/next/__tests__/migrate-item-swipe-actions-to-swipe.test.mjs: five output tests lack the stability check. - File
.changeset/swipe-codemod.md: incomplete, as above. - File
docs/specs/AST-057-row-actions/spec.md: clear; the DEP-0017 cells are owner-approved for this head. - File
apps/sandbox/src/app/(raw)/pages/swipe-actions-cases/cases.tsx: clear. - File
packages/core/src/Swipe/useSwipeAction.ts: clear. - File
.changeset/swipe-shared-drag-deps.md: clear. - File
packages/core/src/Item/__tests__/ItemSwipePinchZoom.a11y.chromium.spec.ts: clear.
The swipe codemod defines a swipe only where every value outside a handler stays the same. At module scope that is a literal, a JSX element, an import or a module const. In useMemo it also takes the owner's locals, as dependencies, and calls or property reads on them. Any other call, construction, property read or global stays at render, with createSwipe on the row and a TODO. Only a function declared or assigned under a capitalized or use name, directly or through memo or forwardRef, gets useMemo; a map or useCallback callback does not. A handler reads itemKey from onActivate only where it compares the row's key with === or !==, since itemKey can be undefined, and a typed fixture checks that output with tsc. An Item row's TODO says an Item passes no itemKey. An arrow component with an expression body defines every swipe in the one block it makes.
|
/approve-spec 631873b |
There was a problem hiding this comment.
Requesting changes: the define-once output is the right shape and the record change is approved, but three input shapes now produce output that throws or shows stale labels where the old output worked.
- Miss: each definition is inserted just before the row's top-level statement, so when that statement is a function declaration called earlier (
const rows = buildRows();abovefunction buildRows(), orrows.map(renderRow)abovefunction renderRowin a component), the output throwsReferenceErrorat import or on the first render. - A callback inside the options (
tags.map(tag => t(tag))with an importedt) or a ref's.currentpasses the fixed-value check, souseMemofreezes that label until an unrelated dependency changes; onlyonActivateshould count as a handler, and a ref read outside it should keepcreateSwipeon the row. - Miss: an owner
letcounts as one value, so two identical rows acrosslabel = 'Remove'share the first value, and a row in a loop that reassignslabelreads the value from before the loop; a reassignedletorvarshould keepcreateSwipeon the row.
Please add each shape as a regression test beside the existing ones. The earlier feedback is fixed on this head.
Claims and files checked
- Codemod changeset, swipes defined once at module scope or in
useMemo: verified by the tests, false for the three shapes above. - Codemod changeset, ids from the label, then the handler, else side and place with a TODO: verified (id test).
- Codemod changeset, a
ListItemhandler that compares the key with===or!==readsitemKey: verified (unit and type-level tests). - Codemod changeset, options that call or read something at render keep
createSwipeon the row: false for render-time callbacks and ref reads. - Codemod changeset, an
Itemrow's TODO says anItempasses noitemKey: verified. - Core changeset, the shared drag lists the stable committed options ref and nothing is exported: verified.
- Description, 17 of the 23 transform tests fail on the old transform and all pass now: verified.
- Description, the codemods suite passes 1,075 tests in 87 files: verified.
- Description, every test reruns the codemod on its output and parses it: verified.
- Description, the type-level test passes and its passed-on control fails with TS2345: verified.
- Description, no export, prop, type or default changes: verified (API surface comparison finds no rows).
- Description, the record's migration route keeps every handler behaving as before: false for the three shapes above.
- Description, the drag dependency change, modality row, builder example and pinch-zoom comment change no behavior: verified.
- Description, lint, package typecheck, Codemod Verify and the sandbox touch script: not rerun.
- Files: the transform (three findings); the codemod changeset (render-time claim); the record, both test files, the sandbox page, the Core hook, the Core changeset and the pinch-zoom test comment: clear.
DEP-0017's codemod row said a ListItem handler gets the row's itemKey from onActivate. The codemod does that only for a handler that compares the key with === or !==; any other read keeps its closure. The row now says so.
When a row sits in a hoisted function declaration, its swipe's definition goes right after the last statement that declares a binding it reads when it runs, so a call above the declaration finds it. At module scope a handler's reads do not count, since a handler reads them when its action fires; useMemo reads its dependencies at once. Where code above that point can still reach the function, createSwipe stays on the row with a TODO. Such a row reuses a definition only if that definition already sits that early. Only an entry's onActivate counts as a handler: any other callback in the options runs at render and is checked like any value, and a ref's current or a setter call there stays at render. Rows share one definition only when every local their options read is a const, a parameter, or a function or class declaration.
|
/approve-spec 99ed1fb |
|
/approve-spec da896c6 |
There was a problem hiding this comment.
Changes requested: one conditional shape still changes how a migrated row behaves, and the codemod does not report it.
- Miss: a conditional
swipeActionswhose branches differ by one entry against none on a side, such asisUnread ? {leading: [Read], trailing: [Delete]} : {trailing: [Delete]}, still gets different ids per branch becausesharedIdsgives up when a side's entry counts differ, so a row resting open on Delete closes when the condition flips (with the deprecated props it stayed open, since one id-less entry and an empty side both key as'') and no TODO reports it; compare the branches' deprecated keys instead of their counts, leave such a site's deprecated props in place with a TODO where shared ids cannot keep the keys equal, correct thesharedIdscomment and the test title that say the key changed before, and add a codemod test and anItemflip test for this shape.
The earlier conditional finding is fixed: branches with as many entries on each side now share ids, and the new tests fail on the previous head and pass on this one. The spec:AST-057 record change has an engineering owner's approval for this head.
Claims and files checked
Review mode: same-head; reason: none
- Claims (changesets):
- The codemod rewrites the deprecated props to a swipe defined once with
createSwipe: verified (transform; 49 tests). - Module scope when every value outside a handler is fixed at import: verified (
fixedWhereDefined; test). useMemoin the enclosing component or hook, named capitalized oruse…, directly or throughmemoorforwardRef: verified (placementOf,functionName; tests).- Ids from the label, then the handler, else side and place with a TODO: verified (
entryIds; test). - A
ListItemhandler that compares the row key with===or!==takesitemKeyfromonActivate: verified (readItemKey; type-level test). - Map-callback values, a ref's
current, locals assigned, written through or handed on, and unfixed render-time reads keepcreateSwipeon the row with a TODO: verified (reassigned,written,escapes; tests). - Only
onActivateruns when an action fires; anItemrow's TODO says it passes noitemKey; unseen entries and risky spreads are reported: verified (inActivate, the TODO texts; tests). - The shared drag lists its stable committed options ref, which no package entry exports: verified (
useSwipeAction.ts,Swipe/index.ts).
- The codemod rewrites the deprecated props to a swipe defined once with
- Claims (description):
- The old output called
createSwipeinline with positional ids: verified (base transform). - The cited records and the define-once rules: verified against the current records.
- On main's transform 43 of the 49 tests and the type-level test fail, and all pass now: verified (red-first run; 49 pass at this head).
- The latest round's two conditional tests fail on the previous head: verified (red-first run); earlier rounds' counts were verified at their heads.
- The codemods suite passes 1,109 tests in 88 files; the type-level control fails with TS2345; every test re-runs the codemod on its output and parses it: verified.
- The new
Itemtest keeps an open row open through the flip in both forms, and the previous head's ids close it: verified. - eslint, prettier, the knowledge and changeset checks pass: verified; the repository check and the CLI typecheck were not re-run.
- The Item, Swipe and List unit suites pass: verified for 465 tests in 20 files; the stated 4,908-test total was not reproduced.
- Codemod Verify, the List story comparison and the sandbox touch run: not re-run.
- The follow-ups change no behavior; the record rows match FR4 and FR1; the test comment matches the 8 px claim: verified.
- No public or internal API change; +2,855/−184 in 10 files; no internal context: verified (API surface generator, 0 rows; numstat; scan).
- The old output called
- Files:
migrate-item-swipe-actions-to-swipe.mjs: the finding above, including thesharedIdscomment that says the key changed before.migrate-item-swipe-actions-to-swipe.test.mjs: no test for one entry against none (finding above); its "changed the key before too" title is true only for its own one-against-two input.migrate-item-swipe-actions-to-swipe.tsc.test.mjs,Item.test.tsx,swipe-actions-cases/cases.tsx,spec:AST-057's record, both changesets,useSwipeAction.ts,ItemSwipePinchZoom.a11y.chromium.spec.ts: clear.
One entry with no id and an empty side key alike, as '' in idsKeyOf. So a deprecated condition with one entry against none on a side kept an open row open when it flipped. The codemod stopped sharing ids when a side's counts differed, so the migrated row closed, with no TODO. The codemod now builds each branch's deprecated key as idsKeyOf does, and plans the ids before it writes any. A condition migrates only when its two swipes key alike exactly where the deprecated props did: own ids where the keys differ, shared ids where they match. Otherwise the props stay, with a TODO. That covers one entry against none on a side, and an id in one branch that the other takes from its label. A table test covers every condition with up to two entries a side, each with an id or none. On the previous head it fails for the 32 shapes whose props now stay. An Item test opens a row through the reported shape and flips it: with the props, it stays open, and with the previous output, it closes.
|
/approve-spec b9ba8ec |
There was a problem hiding this comment.
Changes requested: one conditional shape still changes how a migrated row behaves without a TODO, and two description claims need correcting.
- A conditional whose branches carry ids that are not string literals and match in value but not in source (such as
id: READ_IDagainstid: 'read') gets per-branch ids and no TODO, becausesharedIdscompares the branches' keys as source text (migrate-item-swipe-actions-to-swipe.mjs:480,:505-507), so a row resting open closes when the condition flips where the deprecated props kept it open; where the keys differ only at places where both entries carry an id and one is not a string literal, share ids at the id-less places, or keep the props with the TODO, and add such a pair to the table test. - The description's size line gives +3130/−185 with the transform's tests at +996/−36, but the change is +3126/−185 with the tests at +992/−36.
- The description says every test re-runs the codemod on its output, but the table test re-runs it only for the conditions it keeps and not for the 2,369 it migrates (they are stable), so add that check or narrow the sentence.
The one-entry-against-none conditional is handled: it keeps its props with a TODO, and its tests pass. The spec:AST-057 record change has an engineering owner's approval for this head. Optional: the new condition TODO says no ids can keep the keys apart, which is not so when an id only collides with one derived from a label.
Claims and files checked
Review mode: same-head; reason: none
- Claims (changesets):
- The codemod defines each swipe once with
createSwipe, at module scope when every value outside a handler is fixed, else inuseMemoin a capitalized oruse…component or hook: verified (transform; tests pass). - Ids come from the label, then the handler, else side and place with a TODO; a
ListItemhandler that compares the row key with===or!==takesitemKeyfromonActivate: verified (tests; type-level test). - Map-callback values, a ref's
current, locals reassigned, written through or handed on, and unfixed render-time reads keepcreateSwipeon the row with a TODO; onlyonActivateruns when an action fires; anItemrow's TODO says it passes noitemKey; unseen entries and risky spreads are reported: verified (tests pass). - A condition no ids can key as the deprecated props did is left unchanged with a TODO: verified for string-literal ids (transform :2015-2021; tests :310-446); not for non-literal ids (first finding).
- The shared drag lists its stable committed options ref, which no package entry exports: verified.
- The codemod defines each swipe once with
- Claims (description):
- The old output called
createSwipeinline with positional ids: verified (base transform). - The cited records and the define-once rules: verified against the current records.
- A condition's swipes key alike exactly where the deprecated props did, else the props stay with a TODO: false for non-literal ids (first finding).
- On main's transform 46 of the 52 tests fail, and all pass now, the type-level test included: verified.
- The latest round's three tests fail on the revision before it: verified (red-first run).
- The codemods suite passes 1,112 tests in 88 files; the type-level control fails with TS2345: verified.
- Each test re-runs the codemod on its output and parses it: false for the table test's migrated conditions (third finding).
- The second
Itemtest keeps the one-against-none row open: verified; the firstItemtest passes. - eslint and prettier on the changed files: verified for the latest round's files; the knowledge, changeset and repository checks and the CLI typecheck were not re-run.
- Codemod Verify, the sandbox touch run, the story comparison and the Core suite totals: not re-run.
- The follow-ups change no behavior; the record rows match FR4 and FR1; the test comment matches the 8 px claim: verified.
- No public or internal API change and no internal context: verified; the size line: false (second finding).
- The old output called
- Files:
migrate-item-swipe-actions-to-swipe.mjs: first finding; the new condition TODO's wording (optional).migrate-item-swipe-actions-to-swipe.test.mjs: third finding; no non-literal id pair in the table test (first finding)..changeset/swipe-codemod.md: its last sentence holds for string-literal ids only (first finding).Item.test.tsx,migrate-item-swipe-actions-to-swipe.tsc.test.mjs,swipe-actions-cases/cases.tsx,spec:AST-057's record,.changeset/swipe-shared-drag-deps.md,useSwipeAction.ts,ItemSwipePinchZoom.a11y.chromium.spec.ts: clear.
The codemod compared a condition's two deprecated keys as text, so an id that is not a string literal compared by its source. READ_ID against 'read' read as apart, each branch kept its own ids, and an open row closed on a flip where the deprecated props kept it open. An id a branch sets stays as written, so a place where both branches set one keys as before, whatever the values. Now only the places with no id decide. Where the keys could match, those places share one id. Where an entry with no id faces a string literal, it takes a free id, so the keys stay apart. Where it faces no entry, '' or an id that is not a string literal, the props stay with a TODO. The table test adds an imported id that the codemod cannot read. It checks every value those ids may take, and runs the codemod again on every output. An Item test flips the reported shape.
|
/approve-spec c34f4c2 |
There was a problem hiding this comment.
Changes requested: one conditional shape still changes how a migrated row behaves without a TODO.
- Miss: a condition whose entry spreads a shared action that carries an id, such as
{...deleteAction, label: 'Delete'}withdeleteAction.id === 'delete'against an inline{label: 'Delete', …}, getsid: 'delete'in both branches and no TODO, becausekeyedIdreads only anidproperty and the planned id is written before the spread (migrate-item-swipe-actions-to-swipe.mjs:472-482,:682-685), so a row that closed when the condition flipped now stays open; treat an entry with a spread as one whose id the codemod cannot read, keep such a condition's props with the TODO unless the branches are already apart, and add entry spreads to the table test.
The non-literal id case and the TODO wording from the last review are fixed: ids a branch sets now stay as written, and the new table, red-first and Item flip tests pass. The spec:AST-057 record change has an engineering owner's approval for this head.
Claims and files checked
Review mode: full; reason: over-500-lines
- Claims (changesets):
- The codemod defines each swipe once with
createSwipe, at module scope when every value outside a handler is fixed, else inuseMemoin a capitalized oruse…component or hook: verified (transform placement code; tests pass). - Ids come from the label, then the handler, else side and place with a TODO; a
ListItemhandler that compares the row key with===or!==takesitemKeyfromonActivate: verified (tests; type-level test). - Map-callback values, a ref's
current, locals reassigned, written through or handed on, and unfixed render-time reads keepcreateSwipeon the row with a TODO; onlyonActivateruns when an action fires; anItemrow's TODO says it passes noitemKey: verified (tests pass). - A value whose entries it cannot see and a JSX spread that may carry the props are reported and left unchanged: verified (tests).
- A condition is left unchanged with a TODO where it cannot be sure the ids key as before, and an id a branch sets stays: false for an entry with a spread (the finding); verified otherwise (table test; a wider check with null, empty and differing ids).
- The shared drag lists its stable committed options ref, which no package entry exports: verified.
- The codemod defines each swipe once with
- Claims (description):
- The old output called
createSwipeinline with positional ids: verified (base transform). - The cited records and the define-once rules: verified against the current records.
- A condition's swipes key alike exactly where the deprecated props did, else the props stay with a TODO: false for an entry with a spread (the finding).
- On main's transform 48 of the 54 tests fail, as does the type-level test, and all pass now: verified (red-first run).
- This round's four tests fail on the previous revision: verified (a fifth fails there only on the changed TODO wording).
- The table test runs 3,268 conditions over every value an imported id may take, and each test re-runs the codemod on its output: verified.
- The three
Itemflip tests keep the row open: verified; the older outputs closing it follows from the row's id key. - The type-level control fails with TS2345: verified; prettier on the changed files: verified.
- The full codemods suite count, the CLI typecheck, eslint, the knowledge, changeset and repository checks, Codemod Verify, the sandbox touch run, the story comparison and the Core suite totals: not re-run.
- The follow-ups change no behavior; the record rows match the trackpad and id rules; the test comment matches the 8 px claim: verified.
- Only the codemod, its tests, its changeset, one record sentence and three
Itemtests changed since the earlier revision named: verified. - No public or internal API change, the size line, and no internal context: verified.
- The old output called
- Files:
migrate-item-swipe-actions-to-swipe.mjs: the finding.migrate-item-swipe-actions-to-swipe.test.mjs: no entry spread in the table test (the finding)..changeset/swipe-codemod.md: its last claim fails for an entry with a spread (the finding).migrate-item-swipe-actions-to-swipe.tsc.test.mjs,Item.test.tsx,swipe-actions-cases/cases.tsx, thespec:AST-057record,.changeset/swipe-shared-drag-deps.md,useSwipeAction.ts,ItemSwipePinchZoom.a11y.chromium.spec.ts: clear.
An entry that spreads a shared action can carry an id the codemod does not see, and the id it wrote went before the spread. So a condition with such an entry could key its two swipes otherwise than the deprecated props, and no TODO said so. A condition now migrates only when every entry in both branches is a plain object literal whose id is a string literal or absent: no spread, computed key, method or accessor, and one id at most. Then every id is known, so the codemod computes both keys before and after, exactly as idsKeyOf does, and migrates only when they compare alike. That check is the only gate. Any other condition keeps its props, with a TODO. An id that is a name, which the last change shared, now keeps its props too. The table test adds entries with a name id, a spread and a computed key. On the previous head it fails for 2,947 of its 5,920 conditions.
|
/approve-spec ffc7019 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because the pull request is a draft. Mark it ready for review so CI runs; the merge guard waits for the required checks.
The entry-spread case from the last review is fixed: a condition with any id the codemod cannot read now keeps its props with a TODO, and the new spread, name-id and table tests cover it. One optional wording suggestion for the transform's header is inline.
Claims and files checked
Review mode: incremental; reason: none
- Claims (changesets):
- The codemod defines each swipe once with
createSwipe, at module scope when every value outside a handler is fixed at import, else inuseMemoin a component or hook named with a capital oruse…, directly or throughmemoorforwardRef: verified (transform placement code; 55 transform tests pass). - Ids come from the label, then the handler, else side and place with a TODO; a
ListItemhandler that compares the row's key with===or!==takesitemKeyfromonActivate: verified (tests; type-level test). - Map-callback values, a ref's
current, locals reassigned, written through or handed on, and unfixed render-time reads keepcreateSwipeon the row with a TODO; onlyonActivateruns when an action fires; anItemrow's TODO says it passes noitemKey: verified (tests). - A value whose entries it cannot see and a JSX spread that may carry the props are reported and left unchanged: verified (tests).
- A condition migrates only when every id is readable and both swipes key alike exactly where the deprecated props did, else it stays with a TODO: verified (the transform's condition check; table test; extra shapes such as an id before a spread, a method shorthand and
id: null). - The shared drag lists its stable committed options ref, and the package entry does not export it: verified (
useSwipeAction.ts; theSwipeentry exports no such hook).
- The codemod defines each swipe once with
- Claims (description):
- The old output called
createSwipeinline with positional ids: verified (base transform). - The cited records and the define-once, id and condition rules: verified against the current records and the transform.
- On main's transform 49 of the 55 tests fail, as does the type-level test, and all pass now: verified (red-first run).
- This round's three tests (entry spread, name id, table) fail on the previous revision: verified; the earlier rounds' counts: not re-run.
- The table test runs 5,920 conditions of the shapes described, and every test re-runs the codemod on its output and parses it: verified.
- The type-level control fails with TS2345: verified.
- The three
Itemflip tests keep the row open: verified; that the older outputs close it: not re-run. - The codemods suite passes 88 files and 1,115 tests: verified.
- eslint and prettier on the changed files, the knowledge check and the changeset check: verified.
- The CLI typecheck reports 0 errors: verified (after building Core and the themes).
- Core's unit suites over Item, Swipe, List, hooks, gestures, motion, the snap-point drag and utils pass 4,910 tests in 231 files at this head: verified; the earlier revision's Core
tsc, interaction and accessibility runs: not re-run. - The story comparison: verified (the
deleteSwipedefinition and its row match but for one blank line beforeonActivate, and the definition sits before thereturn). - The repository check, Codemod Verify and the sandbox touch run: not re-run (CI does not run on a draft, and the sandbox run needs a device browser).
- The follow-ups change no behavior, the record rows match the trackpad and id rules, and the test comment matches the 8 px claim: verified.
- No public or internal API change: verified (API surface comparison of Core and the seven themes; no CLI command change).
- The size line and the absence of internal context: verified.
- The old output called
- Files:
migrate-item-swipe-actions-to-swipe.mjs: clear (one optional header wording suggestion).migrate-item-swipe-actions-to-swipe.test.mjs,migrate-item-swipe-actions-to-swipe.tsc.test.mjs,Item.test.tsx,ItemSwipePinchZoom.a11y.chromium.spec.ts,useSwipeAction.ts,swipe-actions-cases/cases.tsx, thespec:AST-057record,.changeset/swipe-codemod.md,.changeset/swipe-shared-drag-deps.md: clear.
| * alike exactly where the deprecated props did. Where those keys match, the | ||
| * places with no id share one id. Otherwise the props stay, with a TODO, as | ||
| * with an entry that spreads, or one entry against none on a side. Rows with |
There was a problem hiding this comment.
Optional: "Otherwise the props stay" reads as if a condition whose keys differ keeps its props, but it migrates with each branch's own ids (the test at line 303 of the test file). Suggested: "Where the keys were equal, the places with no id share one id; where they differed, each branch takes its own. Where it cannot read an id or keep the keys so, as with an entry that spreads or one entry against none on a side, the props stay, with a TODO."
There was a problem hiding this comment.
Changes requested: one description fix, no code change.
- Regression: after the merge of
main, the Testing section's counts are no longer true at this head: the codemods run passes 88 files and 1,118 tests (not 1,115, sincemainadded three tests torun-codemod.test.mjs), and theuirun over the eight Core folders passes 231 files and 4,931 tests (not 4,910), so please update both numbers or name the revision they come from.
The code is unchanged since the last review, and every test the pull request cites passes at this head. The optional header wording suggestion in the open inline thread still applies. CI has not run yet because the pull request is a draft.
Claims and files checked
Review mode: incremental; reason: none
- changed rules (1): Whatever the scope, these are computed…: checked: the recipe change, this pull request's history and the whole-pull-request checks it names, no finding.
- Claims (changesets):
- The codemod defines each swipe once with
createSwipe, at module scope when every value outside a handler is fixed at import, else inuseMemoin a component or hook named with a capital oruse…, directly or throughmemoorforwardRef: verified (transform placement code; 55 transform tests pass). - Ids come from the label, then the handler, else side and place with a TODO; a
ListItemhandler that compares the row's key with===or!==takesitemKeyfromonActivate: verified (tests; type-level test). - Map-callback values, a ref's
current, locals reassigned, written through or handed on, and unfixed render-time reads keepcreateSwipeon the row with a TODO; onlyonActivateruns when an action fires; anItemrow's TODO says it passes noitemKey: verified (tests). - A value whose entries it cannot see and a JSX spread that may carry the props are reported and left unchanged: verified (tests).
- A condition migrates only when every id is readable and both swipes key alike exactly where the deprecated props did, else it stays with a TODO: verified (the condition check; table test).
- The shared drag lists its stable committed options ref, and the package entry does not export it: verified (
useSwipeAction.ts; theSwipeentry exports onlycreateSwipeand types).
- The codemod defines each swipe once with
- Claims (description):
- The old output called
createSwipeinline with positional ids: verified (base transform). - The cited records and the define-once, id and condition rules: verified against the current records and the transform.
- On main's transform 49 of the 55 tests fail, as does the type-level test, and all pass now: verified (red-first run on the current base).
- The earlier rounds' red-first counts: not re-run (earlier revisions).
- The table test runs 5,920 conditions, and every test re-runs the codemod on its output and parses it: verified.
- The type-level control fails with TS2345: verified.
- The three
Itemflip tests keep the row open: verified; that the older outputs close it: not re-run. - The codemods suite passes 88 files and 1,115 tests: false at this head (88 files, 1,118 tests pass).
- The CLI typecheck reports 0 errors: verified (after building Core and the themes).
- eslint and prettier on the changed files, the knowledge check and the changeset check pass: verified.
- The repository check passes: partly verified (its steps through the demo-media check pass; the executable-bits step needs a git checkout, which the review tree is not).
- Codemod Verify against an earlier main: not re-run (CI does not run on a draft); no deprecated swipe prop remains in the sandbox or Storybook at this head, so the codemod has nothing to change there.
- The earlier revision's Core typecheck, interaction and accessibility runs: not re-run.
- Core's unit suites over the eight folders pass 4,910 tests in 231 files at this head: false at this head (231 files, 4,931 tests pass).
- The sandbox touch run: not re-run (it needs a device browser).
- The story comparison: verified (the transform is identical to the last reviewed one, and the merge leaves the story file unchanged).
- The follow-ups change no behavior, the record rows match the trackpad and id rules, and the test comment matches the 8 px claim: verified.
- No public or internal API change: verified (API surface comparison of Core and the seven themes; no CLI command change).
- The size line and the absence of internal context: verified.
- The old output called
- Files:
migrate-item-swipe-actions-to-swipe.mjs: clear (the optional header wording suggestion stays open inline).migrate-item-swipe-actions-to-swipe.test.mjs,migrate-item-swipe-actions-to-swipe.tsc.test.mjs,Item.test.tsx,ItemSwipePinchZoom.a11y.chromium.spec.ts,useSwipeAction.ts,swipe-actions-cases/cases.tsx, thespec:AST-057record,.changeset/swipe-codemod.md,.changeset/swipe-shared-drag-deps.md: clear.
|
Fixed in the description: both counts now name |
|
I'll run a full review to re-check this with your note. |
There was a problem hiding this comment.
Approved pending CI: the CI run on this head was turned away because CI was full, so build, test and typecheck have not run yet; re-run all jobs of that run once there is room (the ci:run label is already set).
No blocking findings: an engineering owner approved the record change for this exact revision, and the codemod's tests, its type-level check and the Item flip tests pass on it. The optional header-wording suggestion in the open inline thread still applies.
Claims and files checked
Review mode: same-head; reason: none
- changed rules (0): none since the last review.
- Claims (changesets):
- The codemod rewrites the deprecated swipe props on
ItemandListItemtoswipe={…}and defines each swipe once withcreateSwipe: verified (transform; 55 transform tests). - The definition goes to module scope when every value outside a handler is fixed at import, else into
useMemoin a component or hook named with a capital oruse…, directly or throughmemoorforwardRef: verified (placement code; module-scope,useMemoand wrapper tests). - Ids come from the label, then the handler, else side and place with a TODO; a
ListItemhandler that compares the row's key with===or!==takesitemKeyfromonActivate: verified (id test; type-level test). - Map-callback values, a ref's
current, locals assigned later or written through or handed on, and unfixed render-time reads keepcreateSwipeon the row with a TODO; onlyonActivateruns when an action fires; anItemrow's TODO says it passes noitemKey: verified (one test per shape). - A value whose entries it cannot see and a JSX spread that may carry the props are reported and left unchanged: verified (tests).
- A condition migrates only when every id is readable and both swipes key alike exactly where the deprecated props did, else it stays with a TODO: verified (the condition gate; 5,920-condition table test).
- The shared drag lists its stable committed options ref, and the package entry does not export it: verified (
useSwipeAction.ts; theSwipeentry exports onlycreateSwipeand types).
- The codemod rewrites the deprecated swipe props on
- Claims (description):
- The old output called
createSwipeinline with positional ids: verified (base transform run). - The cited records and the placement, handler, id, condition and
ItemTODO rules: verified against the current records and the transform. - The component naming rule and the rejected alternatives: verified (transform; tests; type-level control).
- On main's transform 49 of the 55 tests fail, as does the type-level test, and all pass now: verified (red-first run).
- The earlier rounds' red-first counts: not re-run (earlier revisions).
- The codemods suite passes 88 files and 1,118 tests: verified.
- The type-level test passes and its control fails with TS2345: verified.
- The table test runs 5,920 conditions with the stated entry kinds, and every test reruns the codemod on its output and parses it: verified.
- The three
Itemflip tests keep the row open: verified; that the older outputs close it: not re-run. - The CLI typecheck reports 0 errors after a build: verified (with CI's build output for this revision).
- eslint, prettier, the knowledge, changeset and repository checks pass: verified (knowledge and changeset checks run here; the lint job passed on this revision).
- Codemod Verify passes: verified (passed on this revision).
- The earlier revision's Core typecheck, interaction and accessibility runs, the sandbox touch run and the story comparison: not re-run.
- Since that revision, only the codemod, its tests, its changeset, one record sentence and three
Itemtests changed: verified (commit history). - Core's unit suites over the eight folders pass 4,931 tests in 231 files: verified.
- The follow-ups change no behavior, the record rows match the trackpad and required-id rules, and the test comment matches the 8 px claim: verified.
- No public or internal API change: verified (CI's API report for this revision; no new module).
- The size line, the writing-rubric edits and the absence of internal context: verified.
- The old output called
- Files:
migrate-item-swipe-actions-to-swipe.mjs: optional header wording note (open inline thread).migrate-item-swipe-actions-to-swipe.test.mjs,migrate-item-swipe-actions-to-swipe.tsc.test.mjs,Item.test.tsx,ItemSwipePinchZoom.a11y.chromium.spec.ts,useSwipeAction.ts,swipe-actions-cases/cases.tsx, thespec:AST-057record,.changeset/swipe-codemod.md,.changeset/swipe-shared-drag-deps.md: clear.
|
/approve-spec 8f48352 |
User need
astryx upgraderewrites the deprecatedswipeActionsofItemandListItem. Its output calledcreateSwipeinline on each row, with ids such as'trailing-0'.spec:AST-057FR11 allows that, but defines a swipe once. So callers moved each swipe by hand.Problem and solution fit
The codemod now writes that definition where the swipe keeps its meaning, and the inline call with a TODO elsewhere.
Current specification
spec:AST-057FR11 and DEC-10: one definition; a handler receives the action's id and the row'sitemKey.spec:AST-057DEP-0017: itsmigrationandcodemodfields describe this output.spec:AST-017FR29c and FR29d: the codemod reports what it cannot rewrite.Public delta and caller burden
The codemod's output only. Only an entry's
onActivateis a handler. A swipe is defined once:const.useMemoin the component or hook whose props or state it reads. A call there calls one of its locals directly, such as a hook'st, not a ref.ListItem, a handler that compares the row's ownitemKeywith===or!==takes({itemKey}).Otherwise
createSwipestays on the row with a TODO. AnItemrow's TODO says anItempasses noitemKey.Design and alternatives
usename, directly or throughmemoorforwardRef, never amapcallback.t('archive')or a local reassigned, written through or handed on. Rejected too: a definition that a call above it reads before it runs.itemKeypassed on, as inremove(itemKey), which failstscwhere the row's own key passed.Evidence
Scope
Components: the
migrate-item-swipe-actions-to-swipecodemod, and the sandbox's Swipe Actions Cases page, which defines its swipes once.Testing
pnpm exec vitest run --project node packages/cli/assets/codemodsat8f48352a6d: 88 files, 1,118 tests pass.6c7e4a1692, with the id test, and five on631873b89d. Then four on99ed1fbcfb, nine on9761889d52, three on66ae73835d, two on5df4f01179, three onda896c643c, four onb9ba8ec2b6and three onc34f4c2ae1. The two on5df4f01179compare a condition's two swipes, which now carry the same ids, so an open row stays open when it flips. The three cover the reported shape, an id matching another branch's label, and every condition up to two entries a side. The four cover a free id, imported ids in the table, and an id that is not a string literal. That id faces a literal in one test and no id in another. The three onc34f4c2ae1cover an entry spread, a name id now kept, and the table.tscover typed fixtures after the codemod. The migrated rows pass, and a hand-writtenremove(itemKey)control fails with TS2345.5df4f01179, it closes.da896c643c, it closes.pnpm -F @astryxdesign/cli typecheck, afterpnpm build: 0 errors.pnpm check:knowledge,pnpm check:changesetsandpnpm check:repopass.1addd72da4, which has feat(core): swipe actions come from createSwipe on the shared drag path #8690. It passes with no exception, and the codemod changes nothing in the sandbox or in Storybook.6c7e4a1692: Core'stscreports 0 errors. The unit suites of Item, Swipe, List and the shared drag pass 4,905 tests in 231 files. The swipe interaction spec passes 27 in Chromium (8 skipped) and 28 in WebKit (7 skipped), and the Item accessibility specs pass 37. Since then, this pull request changes only the codemod, its tests, its changeset, one record sentence and three Item tests. At8f48352a6d,pnpm exec vitest run --project uioverItem,Swipe,List,hooks,gestures,motion,dragToSnapPointsandutilsinpackages/core/srcpasses 4,931 tests in 231 files.4b4aede2c4, an earlier version of this page commit on an older base. It was built bypnpm buildandpnpm -F @astryxdesign/sandbox build, then served byvite preview. A touch script in Chromium at 390 px passes 13 of 13 checks over its three cases. They cover the read toggle, a drag from the open row's Delete, a tapped Delete and a commit release. The page before this change passes the same 13.git show a4fe0154fb:apps/storybook/stories/List.stories.tsx > /tmp/List.stories.tsx, thenpnpm -F @astryxdesign/cli exec jscodeshift --parser=tsx -t assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs /tmp/List.stories.tsx. Format the result withpnpm exec prettier --stdin-filepath apps/storybook/stories/List.stories.tsx < /tmp/List.stories.tsx, so the repo's config applies. Thendiffit againstapps/storybook/stories/List.stories.tsx. ThedeleteSwipedefinition and its row match, but for one blank line beforeonActivate. The definition sits before thereturn, not abovecontainerRef.Review notes from #8690
useSwipeAction.tsaddslatestRef, the options ref its begin check reads, to an effect's dependency list. A ref's identity is stable, so behavior does not change, and no device run is needed.spec:AST-057's modality split row says what FR4 says: a trackpad's horizontal scroll swipes a row, and a mouse drag or a mouse wheel's notches don't. Its builder-impact example gives the action theidevery swipe action needs.Public and internal API delta
None. No export, prop, type or default changes, and the transform adds no shared module.
Size: +3295/−186 in 10 files. Shipped: the transform +1828/−62, and
useSwipeAction.ts+3/−3. Tests: the transform's +1086/−36, its type-level test +140, and Item's flip tests +137. The record +20/−20: two DEP-0017 cells, the modality row and the builder-impact example; prettier re-pads the DEP-0017 table. The changesets +8/−1 (swipe-codemod.mdand Core's new internal entry); the sandbox page +71/−63; the pinch-zoom spec's comment +2/−1.Writing rubric results
Edited:
spec:AST-057DEP-0017'smigrationandcodemodfields, its modality split row, and its builder-impact example.R1 narration: none; each field describes the codemod or the input split in the present tense.
R2 research: none.
R3 evidence: no evidence cell changed.
R4 rejected alternatives: none added.
R5 change references: none.
R6 open questions: none touched.
R7 project status: none.