Skip to content

Conversation

@avivkeller
Copy link
Member

This PR simplfiies our usage of useXYZ hooks. In the process, it moves useCopyToClipboard to a similar useCopy hook in @node-core/ui-components, so that CodeBox performs it's copy logic internally. (This allows for less code to duplicate in doc-kit)

Copilot AI review requested due to automatic review settings January 3, 2026 22:28
@avivkeller avivkeller requested a review from a team as a code owner January 3, 2026 22:28
@vercel
Copy link

vercel bot commented Jan 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nodejs-org Ready Ready Preview Jan 3, 2026 10:33pm

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2026

👋 Codeowner Review Request

The following codeowners have been identified for the changed files:

Team reviewers: @nodejs/nodejs-website

Please review the changes when you have a chance. Thank you! 🙏

@codecov
Copy link

codecov bot commented Jan 3, 2026

Codecov Report

❌ Patch coverage is 86.30137% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.70%. Comparing base (8dd60ff) to head (d552462).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/ui-components/src/hooks/useCopy.ts 82.35% 6 Missing ⚠️
apps/site/hooks/client/useClientContext.ts 88.88% 1 Missing ⚠️
apps/site/providers/matterProvider.tsx 0.00% 1 Missing ⚠️
packages/ui-components/src/Common/Select/index.tsx 80.00% 1 Missing ⚠️
packages/ui-components/src/Common/Select/utils.ts 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8516      +/-   ##
==========================================
+ Coverage   74.22%   74.70%   +0.48%     
==========================================
  Files         106      102       -4     
  Lines        9102     8956     -146     
  Branches      308      305       -3     
==========================================
- Hits         6756     6691      -65     
+ Misses       2344     2263      -81     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR simplifies the codebase by consolidating hook functionality and reorganizing the hooks directory structure. The main change moves copy-to-clipboard functionality from useCopyToClipboard to a new useCopy hook in the @node-core/ui-components package, allowing BaseCodeBox to handle copying internally.

  • Consolidates useCopyToClipboard into a new useCopy hook in ui-components package
  • Reorganizes hooks directory from react-client/react-server/react-generic to client/server/generic
  • Moves array utility functions from shared location to Select-specific utils file

Reviewed changes

Copilot reviewed 36 out of 41 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/ui-components/src/hooks/useCopy.ts New hook consolidating copy-to-clipboard functionality
packages/ui-components/src/hooks/__test__/useCopy.test.jsx Test file updated to use new useCopy hook with import path changes
packages/ui-components/src/Common/BaseCodeBox/index.tsx Now uses useCopy internally, accepts label props instead of callback/content props
packages/ui-components/src/Common/Select/utils.ts Array utility functions moved here from shared util/array.ts
packages/ui-components/src/Common/Select/index.tsx Updated to use mapValues from local utils file
packages/ui-components/src/Common/Select/StatelessSelect/index.tsx Updated to use mapValues from parent utils file
packages/ui-components/package.json Version bumped from 1.5.0 to 1.5.1
apps/site/hooks/client/* Hooks reorganized from react-client to client directory
apps/site/hooks/server/* New server hooks directory with useClientContext
apps/site/hooks/generic/* New generic hooks directory with useSiteNavigation
apps/site/components/Common/CodeBox.tsx Simplified to use BaseCodeBox's internal copy handling
Various component files Import paths updated to reflect new hooks directory structure
Comments suppressed due to low confidence (2)

packages/ui-components/src/hooks/test/useCopy.test.jsx:9

  • The test is missing a mock setup for navigator.clipboard.writeText. The code at line 9 assigns a function that returns a Promise, but the test expects a mock object with mock.callCount() and mock.calls. The test should use t.mock.method to properly set up the mock, similar to what was removed in the diff.
    packages/ui-components/src/hooks/test/useCopy.test.jsx:11
  • The test description says 'useCopyToClipboard' but the hook has been renamed to 'useCopy'. The test description should be updated to match the new hook name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2026

📦 Build Size Comparison

Summary

Metric Value
Old Total Size 3.75 MB
New Total Size 3.74 MB
Delta -8.38 KB (-0.22%)

Changes

➕ Added Assets (14)
Name Size
.next/static/chunks/59f4fe3fd9fe6d8e.js 9.70 KB
.next/static/chunks/ef6b6bba261ac87f.js 48.06 KB
.next/static/chunks/f900f9d427969f3f.js 114.16 KB
.next/static/chunks/a93c16b4c886a4f8.js 28.16 KB
.next/static/chunks/5346383eb492b84a.js 420.04 KB
.next/static/chunks/40f6ea0b40b1a638.js 420.04 KB
.next/static/chunks/900563ac635ad58e.js 114.16 KB
.next/static/chunks/15252d771a46147e.js 28.16 KB
.next/static/chunks/88395e0f0be96814.js 29.39 KB
.next/static/chunks/42510da964a460a5.js 420.04 KB
.next/static/chunks/25e24e3f3b057667.js 563.88 KB
.next/static/chunks/cef85869883c2655.js 114.16 KB
.next/static/chunks/7e844f9aaf3c585b.js 563.88 KB
.next/static/chunks/08197815e6cbb624.js 114.16 KB
➖ Removed Assets (14)
Name Size
.next/static/chunks/9bb4d9276d1e8856.js 9.46 KB
.next/static/chunks/98fb60ebbc2a4053.js 48.30 KB
.next/static/chunks/11c1f897b45e364a.js 118.27 KB
.next/static/chunks/fa902b7424333aac.js 27.87 KB
.next/static/chunks/64abd550e7ac0ca3.js 419.13 KB
.next/static/chunks/718e2ff5e8abb975.js 419.13 KB
.next/static/chunks/a3b35c965ded5708.js 118.27 KB
.next/static/chunks/9535f1c5871f095c.js 27.87 KB
.next/static/chunks/6887091e29724a9c.js 29.28 KB
.next/static/chunks/96f7a6f942e912ae.js 561.55 KB
.next/static/chunks/b5d845a9a413f73e.js 419.13 KB
.next/static/chunks/976ea1c2d37f9b6c.js 118.27 KB
.next/static/chunks/e83f9b582cff293c.js 561.55 KB
.next/static/chunks/77ba8236ea91ca33.js 118.27 KB

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Member

@araujogui araujogui left a comment

Choose a reason for hiding this comment

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

LGTM

@avivkeller avivkeller added this pull request to the merge queue Jan 5, 2026
Merged via the queue into main with commit 65e1378 Jan 5, 2026
12 checks passed
@avivkeller avivkeller deleted the chore/simplify-hooks-patch-ui branch January 5, 2026 17:24
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