Skip to content

refactor(core): align state ownership with React Compiler - #525

Open
IzumiSy wants to merge 26 commits into
mainfrom
refactor/react-compiler-state-ownership
Open

IzumiSy wants to merge 26 commits into
mainfrom
refactor/react-compiler-state-ownership

Conversation

@IzumiSy

@IzumiSy IzumiSy commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Motivation

Update the repository's pinned oxlint version to 1.82.0 while keeping every configured lint rule enabled. Align the affected React components and hooks with React Compiler-compatible state, effect, and ref usage.

Design Decision

Make reactive state explicit

Values that influence rendering or represent pending work are modeled as props or React state, rather than being read from mutable refs during render. User interactions update that state at their source; components then derive their UI from the current render. This gives React Compiler a clear data flow and makes update ordering easier to reason about.

Limit refs and effects to imperative boundaries

Refs remain for resources React does not own directly: DOM nodes, timers, abort controllers, observer handles, and similar imperative integration state. Effects are retained only where they synchronize with those external resources or perform their cleanup, rather than mirroring state or notifying callbacks after the fact.

Preserve public behavior during local migrations

Each change is scoped to the smallest owner of the behavior, retaining existing component contracts and interaction semantics. Tests exercise the resulting behavior directly—using renderHook for hook state where appropriate—rather than relying on effect-populated test snapshots. The DataTable selection addition is the only intentional public API expansion.

Keep the lint configuration authoritative

The upgrade is addressed by changing implementation ownership, not by disabling rules, adding suppressions, or weakening the lint configuration. This leaves the codebase with one consistent direction for future components and hooks.

Summary

  • Pin oxlint 1.82.0 and resolve all resulting lint errors without suppressions or lint configuration changes.
  • Define ownership boundaries for async loading, action registration, attachments, responsive subscriptions, DataTable state, and date controls.
  • Add controlled and uncontrolled DataTable row selection support with a minor changeset.

@IzumiSy

IzumiSy commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

…er-state-ownership

# Conflicts:
#	packages/core/src/components/data-table/data-table.test.tsx

Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>
Copilot AI and others added 3 commits September 11, 2026 07:09
Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>
Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>
Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>
@IzumiSy

IzumiSy commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix CI error

Copilot AI commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved and pushed in 685b465.

Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>

Copilot AI commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

@copilot fix CI error

Fixed and pushed in 3dacba2.

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Code Metrics Report

main (6b0e0d6) #525 (636fa81) +/-
Coverage 87.2% 87.1% -0.1%
Test Execution Time 2m5s 1m56s -9s
Details
  |                     | main (6b0e0d6) | #525 (636fa81) |  +/-  |
  |---------------------|----------------|----------------|-------|
- | Coverage            |          87.2% |          87.1% | -0.1% |
  |   Files             |            198 |            198 |     0 |
  |   Lines             |           5840 |           5876 |   +36 |
+ |   Covered           |           5093 |           5123 |   +30 |
+ | Test Execution Time |           2m5s |          1m56s |   -9s |

Code coverage of files in pull request scope (85.4% → 85.3%, patch 94.3%)

Files Coverage +/- Patch Coverage Status
packages/core/src/ai/use-ai-chat.ts 90.6% 0.0% 95.5% modified
packages/core/src/components/ai-chat/composer.tsx 100.0% 0.0% - modified
packages/core/src/components/attachment/use-attachment.ts 100.0% 0.0% 100.0% modified
packages/core/src/components/csv-importer/CsvImporter.tsx 0.5% 0.0% 0.0% modified
packages/core/src/components/csv-importer/i18n-labels.ts 100.0% 0.0% - modified
packages/core/src/components/data-table/data-table.tsx 90.9% +0.0% 100.0% modified
packages/core/src/components/data-table/index.ts 0.0% 0.0% - modified
packages/core/src/components/data-table/use-data-table.ts 98.8% +0.0% 100.0% modified
packages/core/src/components/data-table/use-persistent-column-state.ts 94.5% -5.5% 91.4% modified
packages/core/src/components/date-field/date-field.tsx 100.0% 0.0% 100.0% modified
packages/core/src/components/date-field/date-input-group.tsx 81.5% 0.0% - modified
packages/core/src/components/date-field/date-range-input-group.tsx 100.0% 0.0% - modified
packages/core/src/components/date-field/date-range-picker.tsx 97.7% +0.0% 100.0% modified
packages/core/src/components/date-field/use-date-field-bridge.ts 93.9% -0.5% 91.3% modified
packages/core/src/components/description-card/field-renderers.tsx 83.9% -0.2% 50.0% modified
packages/core/src/components/select/select-standalone.tsx 95.5% -0.3% 100.0% modified
packages/core/src/components/sidebar/default-sidebar.tsx 97.5% 0.0% - modified
packages/core/src/components/sidebar/sidebar-item.tsx 95.4% 0.0% - modified
packages/core/src/components/timeline/timeline.tsx 98.6% 0.0% 100.0% modified
packages/core/src/contexts/auth-context.tsx 95.7% 0.0% - modified
packages/core/src/contexts/command-palette-context.tsx 98.3% +0.2% 100.0% modified
packages/core/src/hooks/use-async-items.ts 100.0% 0.0% 100.0% modified
packages/core/src/hooks/use-mobile.ts 87.5% -2.5% 85.7% modified
packages/core/src/hooks/use-tablet.ts 88.8% -2.1% 85.7% modified
packages/core/src/index.ts 0.0% 0.0% - modified
packages/core/tests/rhf-test-utils.tsx 72.7% -16.2% 40.0% modified

Reported by octocov

@IzumiSy
IzumiSy marked this pull request as ready for review September 11, 2026 08:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Controlled expansion callbacks regress their stability contract, while column measurement, storage fallback, and the new public type export remain incomplete.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Aligns React state ownership with React Compiler requirements, upgrades oxlint, and expands DataTable row selection.

Changes:

  • Refactors effects, refs, callbacks, and external-store subscriptions.
  • Adds controlled/uncontrolled DataTable selection.
  • Updates accessibility, tests, examples, and release metadata.
File summaries
File Description
pnpm-workspace.yaml Pins oxlint 1.82.0.
pnpm-lock.yaml Updates resolved dependencies.
packages/core/tests/rhf-test-utils.tsx Uses a hook harness for RHF.
packages/core/src/hooks/use-tablet.ts Uses external-store media subscriptions.
packages/core/src/hooks/use-override-breadcrumb.test.tsx Refactors hook testing.
packages/core/src/hooks/use-mobile.ts Uses external-store media subscriptions.
packages/core/src/hooks/use-async-items.ts Refactors async request ownership.
packages/core/src/contexts/theme-context.test.tsx Tests context through renderHook.
packages/core/src/contexts/scroll-container-context.test.tsx Refactors scroll-context tests.
packages/core/src/contexts/command-palette-context.tsx Separates action registration and updates.
packages/core/src/contexts/auth-context.tsx Corrects effect dependencies.
packages/core/src/contexts/auth-context.test.tsx Consolidates authentication test helpers.
packages/core/src/components/with-guard/with-guard.test.tsx Hoists stable test guards.
packages/core/src/components/tooltip/tooltip.test.tsx Adds an accessible trigger name.
packages/core/src/components/timeline/timeline.tsx Uses non-mutating sorting.
packages/core/src/components/sidebar/sidebar.test.tsx Hoists viewport mocking.
packages/core/src/components/sidebar/sidebar-layout.test.tsx Corrects desktop test width.
packages/core/src/components/sidebar/sidebar-item.tsx Labels external links.
packages/core/src/components/sidebar/default-sidebar.tsx Labels the search trigger.
packages/core/src/components/select/select-standalone.tsx Uses current async callbacks directly.
packages/core/src/components/description-card/field-renderers.tsx Refines copy and truncation behavior.
packages/core/src/components/date-field/use-date-field-bridge.ts Refactors form-validation bridging.
packages/core/src/components/date-field/date-range-picker.tsx Refactors combined range state handling.
packages/core/src/components/date-field/date-range-picker.test.tsx Hoists a calendar test helper.
packages/core/src/components/date-field/date-range-input-group.tsx Uses capture-phase focus events.
packages/core/src/components/date-field/date-input-group.tsx Uses capture-phase focus events.
packages/core/src/components/date-field/date-field.tsx Refactors state and forwarded refs.
packages/core/src/components/date-field/date-field.test.tsx Hoists shared test helpers.
packages/core/src/components/data-table/use-persistent-column-state.ts Adds cached external-store persistence.
packages/core/src/components/data-table/use-data-table.ts Adds row-selection ownership and stores.
packages/core/src/components/data-table/use-data-table.test.ts Tests controlled and default selection.
packages/core/src/components/data-table/types.ts Defines the row-selection API.
packages/core/src/components/data-table/index.ts Exports the selection options type.
packages/core/src/components/data-table/data-table.tsx Updates sorting, animation, and measurement.
packages/core/src/components/data-table/data-table.test.tsx Refactors and expands DataTable tests.
packages/core/src/components/csv-importer/i18n-labels.ts Adds mapping-status labels.
packages/core/src/components/csv-importer/CsvImporter.tsx Improves labels and callback ownership.
packages/core/src/components/command-palette/command-palette-hook.test.tsx Hoists search-source fixtures.
packages/core/src/components/combobox/combobox.test.tsx Hoists timer helpers.
packages/core/src/components/autocomplete/autocomplete.test.tsx Hoists timer helpers.
packages/core/src/components/attachment/use-attachment.ts Tracks owned preview URLs.
packages/core/src/components/attachment/use-attachment.test.ts Tests URL cleanup.
packages/core/src/components/ai-chat/composer.tsx Uses the shared spinner.
packages/core/src/components/ai-chat/ai-chat.test.tsx Consolidates composer fixtures.
packages/core/src/components/action-panel/ActionPanel.test.tsx Hoists the action reader.
packages/core/src/ai/use-ai-chat.ts Removes manual callback memoization.
examples/vite-app/tsconfig.app.json Enables the ES2023 library.
examples/vite-app/src/pages/data-table/page.tsx Refactors loading and toolbar state.
examples/vite-app/src/mock-products.ts Derives loading from result identity.
examples/vite-app/src/mock-orders.ts Derives loading from result identity.
examples/nextjs-app/src/modules/pages/mock-data.ts Derives loading from result identity.
examples/nextjs-app/src/modules/pages/dropdown-demo.tsx Reuses item mapping.
examples/nextjs-app/src/modules/pages/date-range-rhf-demo.tsx Uses useWatch.
examples/nextjs-app/src/app/dashboard/[[...props]]/page.tsx Stabilizes the root component.
.changeset/steady-limes-sort.md Records the selection API release.
Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file
  • Files reviewed: 54/55 changed files
  • Comments generated: 5
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/core/src/components/data-table/use-data-table.ts Outdated
Comment thread packages/core/src/components/data-table/data-table.tsx Outdated
MoneyCellOptions,
NumberCellOptions,
RowAction,
RowSelectionOptions,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in 6caefe3. RowSelectionOptions is now re-exported from the package root.

Comment thread packages/core/src/components/data-table/use-data-table.ts Outdated
Comment on lines +128 to +135
const state = updater(read(tableId, defaults));
writeState(tableId, state);
cache.set(tableId, {
raw: typeof window === "undefined" ? null : JSON.stringify(state),
defaults,
state,
});
notify(tableId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in 6caefe3. Failed storage writes now retain the prior storage marker so the in-memory update persists.

Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>
@IzumiSy

IzumiSy commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

…er-state-ownership

# Conflicts:
#	pnpm-lock.yaml

Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>

Copilot AI commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved and pushed in 4ef30a1.

@IzumiSy

IzumiSy commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

…er-state-ownership

# Conflicts:
#	examples/nextjs-app/src/app/dashboard/[[...props]]/page.tsx
#	examples/nextjs-app/src/modules/pages/date-range-rhf-demo.tsx
#	examples/nextjs-app/src/modules/pages/mock-data.ts
#	examples/vite-app/src/pages/showcase/data-table/page.tsx
#	pnpm-lock.yaml
#	pnpm-workspace.yaml

Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>

Copilot AI commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved and pushed in a262865.

@IzumiSy

IzumiSy commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

…er-state-ownership

# Conflicts:
#	pnpm-lock.yaml

Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>

Copilot AI commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved and pushed in 8571d59.

@IzumiSy

IzumiSy commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

…er-state-ownership

# Conflicts:
#	packages/core/src/components/sidebar/sidebar.test.tsx
#	pnpm-lock.yaml

Co-authored-by: IzumiSy <982850+IzumiSy@users.noreply.github.com>

Copilot AI commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved and pushed in 9752367.

@IzumiSy

IzumiSy commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Code Review completed successfully!

Generated by Code Review for #525

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generated by Code Review for #525 · copilot · gpt54 · 342.4 AIC · ⌖ 6.65 AIC · ⊞ 19.3K
Comment /review to run again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants