Skip to content

docs(useLinkify): add hook docs and a comment-thread example block - #9969

Merged
cixzhang merged 4 commits into
meta:mainfrom
LetMeSleep8h:docs/use-linkify-hook
Nov 9, 2026
Merged

cixzhang merged 4 commits into
meta:mainfrom
LetMeSleep8h:docs/use-linkify-hook

Conversation

@LetMeSleep8h

Copy link
Copy Markdown
Contributor

Closes #9560

What

  • packages/core/src/Link/useLinkify.doc.mjs — HookDoc for useLinkify: usage, the text and options params (patterns with its global-regex requirement and first-match-wins overlap rule, hasBuiltins), the ReactNode[] return, and best practices (render nodes as-is, LinkProvider for client-side routing, /g flag on custom patterns). astryx hook useLinkify and astryx search now return it.
  • Link/useLinkifyHookUsage.tsx + .doc.mjs — the issue's scenario: a short comment thread in plain text where the hook turns the URL and the email into Links, and a custom #(\\d+) issue pattern maps the capture onto the tracker URL scheme (#123 → https://example.com/issues/123), showing the patterns option; the comment without matches stays plain text. exampleFor: 'useLinkify'; public entry points only; removing the hook call removes every link (INV28).
  • packages/cli/api/template/use-linkify-hook-usage.test.tsx — jsdom test asserting the four rendered hrefs (external URL, mailto:, two issue links) and zero anchors for the plain note.
  • Changeset in the merged PRs' format.

Verification (run locally)

npx vitest run packages/cli/api/template/use-linkify-hook-usage.test.tsx   # 1 passed
node packages/cli/clients/cli/bin/astryx.mjs search useLinkify             # returns hook AND example block
npx prettier --check <all new files>                                        # clean

AI-assisted (Claude): written with AI assistance, reviewed and verified locally — every command above was actually run.

A HookDoc next to the hook source (usage, text and options params covering
patterns/hasBuiltins, the ReactNode[] return, best practices), so astryx hook
useLinkify and astryx search return it, and a template block naming useLinkify
in exampleFor: the issue's scenario, a short comment thread in plain text
where the URL and the email address become Links and a custom issue-reference
pattern turns meta#123/meta#456 into tracker links, while a comment without matches
stays plain. Removing the hook call removes every link, per INV28. A jsdom
test asserts the four hrefs (url, mailto, two issue links) and that the plain
note renders no anchor.

Closes meta#9560
@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 9, 2026 7:02am UTC

Request Review

@meta-cla

meta-cla Bot commented Nov 4, 2026

Copy link
Copy Markdown

Hi @LetMeSleep8h!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Nov 4, 2026
@astracat-bot

astracat-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 9, 2026, 7:13 AM UTC

@astracat-bot astracat-bot 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.

Changes requested: the hook doc and the comment-thread example fit #9560 well, but four things need fixing before this can merge.

  • The docs build fails: node apps/docsite/scripts/generate-data.mjs stops with "Generated ShadCN names or routes changed" because internal/shadcn-registry/routes.lock.json has no hook-use-linkify and example-use-linkify-links-in-a-comment-thread entries, so refresh it with UPDATE_SHADCN_ROUTE_LOCK=1 node apps/docsite/scripts/generate-data.mjs and commit the two new items.
  • apps/sandbox/src/route-manifest.test.ts fails because apps/sandbox/scripts/next-export-routes.json is missing "/templates/useLinkifyHookUsage/", which belongs between the useKeyboardHintHookUsage and useListFocusHookUsage lines.
  • .changeset/hook-doc-use-linkify.md lacks its opening --- line and a contributor credit line such as @LetMeSleep8h, so pnpm check:changesets fails.
  • The best practice at packages/core/src/Link/useLinkify.doc.mjs:75 says a non-global regex "matches nothing", but without g the hook's scan never advances and the render hangs when the text contains a match, so the doc should say that.

Two smaller points: the overlap wording ("custom before builtins") should say that the earliest match wins and that custom patterns win only at the same start, and the No links here assertion in the test can never fail. #9719 shows the route-list and route-lock lines that a new hook doc and example need.

[Automated review]

Comment thread .changeset/hook-doc-use-linkify.md Resolved
… global-flag and overlap wording

Adds the hook doc and example to the ShadCN route lock and the sandbox export routes, gives the changeset its frontmatter and contributor credit, says a non-global pattern never finishes rendering when the text matches, and says the earliest match wins with custom patterns winning only at the same start. Drops a test assertion that could never fail.
@cixzhang cixzhang added ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) labels Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · e0991be

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
LinkProvider 3.6 kB (0) · 20 B CSS (0) — ✓ · ✓ · ✗
Link 53.2 kB (0) · 7.0 kB CSS (0) — ✓ · ✓ · —

Package size:

  • @astryxdesign/cli 3.52 MB packed (+579 B); no new dependencies
  • @astryxdesign/core 7.20 MB packed (+1.2 kB); no new dependencies

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 34 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot 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.

Approved pending CI: CI has not run on this head yet.

The hook doc and the comment-thread example now meet the repository's requirements for public hook docs, and the four points from the earlier review are fixed: the route-lock and sandbox route entries are in, the changeset passes its check, and the global-flag best practice now says a non-global pattern never finishes rendering.

  • Next step: the ci:run label is already on the pull request, and it takes effect on the next push or when a maintainer closes and reopens the pull request, so CI runs on this head.

One optional, non-blocking suggestion is inline.

[Automated review]

},
relatedComponents: ['Link', 'LinkProvider'],
importPath: '@astryxdesign/core',
category: 'link',

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.

Non-blocking, and missed in the earlier review: category: 'link' gives astryx hook --list a one-entry "Link" heading, while the sibling useLinkComponent is listed under "Utilities", so astryx hook --category Utilities returns one Link hook but not the other. Consider category: 'utilities'.

@cixzhang cixzhang closed this Nov 9, 2026
@cixzhang cixzhang reopened this Nov 9, 2026
The recorded resolution for useLinkify moves from Link.doc.mjs to the new useLinkify.doc.mjs, as other hook-doc additions have done.

@astracat-bot astracat-bot 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.

Approved: the hook doc and the comment-thread example meet the repository's requirements for public hook docs, and CI passes on this head.

The new commit updates the CLI's recorded resolution for useLinkify, which its resolution test needs.

  • The CLA check still needs your signature before this pull request can merge.

The earlier optional suggestion about the hook's category still stands inline.

[Automated review]

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 9, 2026
@cixzhang
cixzhang merged commit c5cc8f4 into meta:main Nov 9, 2026
80 of 81 checks passed

This branch was successfully deployed

1 active deployment
Preview — e0991bea Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) community Authored by a community contributor (not on the eng/design team) needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(useLinkify): add hook docs and a minimal live example

2 participants