Skip to content

fix(Comments): a failed comment-link copy shows and announces itself - #10435

Merged
cixzhang merged 12 commits into
mainfrom
fix/comments-copy-link-failure
Nov 15, 2026
Merged

cixzhang merged 12 commits into
mainfrom
fix/comments-copy-link-failure

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Who this helps

People who copy a comment's link in a lab Comments panel. When the clipboard write fails, Copy comment link used to do nothing, so they couldn't tell the link wasn't copied. Now it shows a cross for two seconds, and the button, its tooltip and screen readers say "Failed to copy value to clipboard.", the same behavior as CodeBlock's copy button.

What changed

  • Core, internal only: useClipboardCopy, the hook behind CodeBlock's and Timestamp's copy controls with the failed-write state, is now reachable from Lab as @astryxdesign/core/internal/clipboard-copy. It is an internal entry like internal/committed-ref: never in hooks/index.ts or the package entry, outside the public API, and limited to Core and Lab by the @astryx/no-core-internal-import lint rule. No public API changes.
  • Core useClipboardCopy: a write that settles after its caller unmounts now sets no state, starts no timer and announces nothing. onError still runs. CodeBlock and Timestamp see no visible change.
  • Lab CommentActions: calls useClipboardCopy({announceFailure}) once and drops its own failed flag, timer, unmount Effect and announcement. A failed write shows the close icon, names the button and opens its tooltip with "Failed to copy value to clipboard." for two seconds, and is announced once on the assertive region. data-link-copied no longer says copied while a failure shows. Success is unchanged.
  • Record: architecture:react-component-runtime names the internal entry beside the other internal hooks (a consistency line).
  • Changeset: @astryxdesign/core patch [fix] for the unmount guard, which CodeBlock and Timestamp ship. Lab is private and the internal entry is not public API, so neither gets an entry.
  • Tests: the two Comments tests ("names, shows and announces a failed link copy", "stops the failed-copy reset when the comment unmounts") and a new useClipboardCopy case: a write that settles after unmount sets no state, starts no timer and announces nothing, while onError still runs.

Verification

  • Red first: both new tests fail without the change and pass with it (the unmount case in the full suite and alone).
  • Suites: useClipboard.test.tsx, Lab Comments, CodeBlock and Timestamp pass (546).
  • Other checks: lint, check:changesets and check:knowledge pass.

Changeset: @astryxdesign/core patch for the unmount guard; Lab is private, and the Core catalog message has its own changeset in #11376.

Owner and land path

  • Owner: Astryx maintainers, fix-loop lane 1.
  • Land path: Specs ruled the internal entry is records-decided (spec:AST-017 FR21 internal subpaths); review of this head, a fresh CI run, then merge.

Writing rubric results

  • R1 narration: the new react-component-runtime line states what the hook and entry do, in the present tense.
  • R2 research: none.
  • R3 evidence: none added.
  • R4 rejected alternatives: none.
  • R5 change references: none.
  • R6 open questions: none.
  • R7 project status: none.

Copy comment link uses Core's useClipboardCopy, the hook CodeBlock's copy
button uses, through a new internal entry
(`@astryxdesign/core/internal/clipboard-copy`, not public API). A rejected
write shows a cross for two seconds, names and tooltips the button "Failed
to copy value to clipboard." and announces it once. It used to do nothing.
@vercel

vercel Bot commented Nov 7, 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 14, 2026 6:26pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 7, 2026
@astracat-bot

astracat-bot Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 15, 2026, 8:15 AM UTC

@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 2f3c0f3

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 8bdfe06

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
lab/CommentThread 360.3 kB (+74 B) · 2.4 kB CSS (0) — — · ✓ · —
lab/Comments 367.6 kB (+72 B) · 2.5 kB CSS (0) — — · ✓ · —
Markdown 201.2 kB (+26 B) · 21.7 kB CSS (0) — — · — · —
5 more components
Component Size LoC Visual · A11y · RTL
richtext/RichTextEditor 305.3 kB (+26 B) · 2.6 kB CSS (0) — — · — · —
CodeBlock 80.0 kB (+22 B) · 12.1 kB CSS (0) — — · — · —
lab/CommentComposer 161.8 kB (+19 B) · 1.9 kB CSS (0) — — · ✓ · —
richtext/RichTextView 281.9 kB (+19 B) · 2.3 kB CSS (0) — — · — · —
Timestamp 35.8 kB (+1 B) · 11.0 kB CSS (0) — — · — · —

Package size: @astryxdesign/core 7.58 MB packed (+1014 B); no new dependencies.

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


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.

Changes requested. One blocking finding; the rest of the change checks out.

  • The failed-copy announcement goes to the polite live region (useClipboardCopy at CommentActions.tsx:264 calls announce(announceFailure) with the polite default, and Comments.test.tsx:981 asserts it), but AST-086 FR5 requires errors outside a live container to use the assertive channel, so announce the failure assertively in the shared hook (announce(announceFailure, 'assertive')) and assert the assertive region in the test.

The ./internal/clipboard-copy entry fits Core's reserved internal-subpath rule. The new test fails before the change and passes after it. Lab now shares CodeBlock's failure state through one hook. Two optional comment fixes are inline.

[Automated review]

The internal useClipboardCopy announced a failed write on the polite live
region. Status announcements put errors outside a live container on the
assertive channel, so the failure now goes there. CodeBlock is the one
shipped caller; its record (AR3) says so. Success stays polite.
The failure test reads the assertive region, now that the shared hook
announces failures there. The internal entry's header names its one
caller, and a comment that restated the icon ternary is gone.
@cixzhang
cixzhang changed the base branch from main to fix/copy-failure-assertive November 7, 2026 04:12
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 1b54d5f

@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. It runs once this pull request targets main (after #10448 merges) and is out of draft.

  • The failed-copy announcement now reaches the assertive channel through the shared hook from #10448, and the new test reads the assertive region, so the earlier blocking finding is resolved.
  • The ./internal/clipboard-copy entry fits Core's reserved internal-subpath rule, and the new test fails before the change and passes after it.
  • The Review signal flag job failed on GitHub's changed-file count (13 reported, 8 listed), not on this code.

[Automated review]

@github-actions
github-actions Bot deleted the branch fix/copy-failure-assertive November 10, 2026 06:04
…ed copy through public hooks

Comments takes useClipboard's false result and holds its own two-second failed state, announced assertively through useAnnounce, so no new Core entry is needed: the internal/clipboard-copy entry, its test, and its export wiring are removed. Drops the assertive-failure changeset, which shipped with #10448, and the changeset names the Lab fix.
@cixzhang
cixzhang changed the base branch from fix/copy-failure-assertive to main November 12, 2026 00:48
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 00:49
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 1544925

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 12, 2026

@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 failed-copy state works: the header button shows a cross, names and tooltips the failure, and announces it once on the assertive channel. Three things need fixing before approval:

  • CommentActions keeps its own copy of the failed-copy flag, timer, 2 s duration and assertive announcement (CommentActions.tsx:263-308) that Core's useClipboardCopy already owns for CodeBlock, so extend that shared hook so Comments makes one call (an owner API decision on the public useClipboard or on an internal entry a current record names) and delete the local copy.
  • The failure timer started at CommentActions.tsx:305-308 is never cleared when the component unmounts, which react-component-runtime INV5 requires and the shared hook already does.
  • The description says Copy comment link "uses the shared hook with announceFailure" for "the hook's two seconds", but the code calls useClipboard() with no options and its own LINK_FEEDBACK_MS, so please reword that bullet.

Not blocking: the new test could also pin the cross, the open tooltip, the 2 s reset and the single announcement.

Claims and files checked
  • Claim: the change was stacked on the assertive-failure fix until it merged. Verified: that fix is on main, and this pull request now targets main.
  • Claim: a failed link copy used to do nothing. Verified: the base handler has no failure branch, and the public hook treats a rejection as a silent no-op.
  • Claim: a failed copy now shows a cross for two seconds, and the button, its tooltip and screen readers say the failure text. Verified for the header button (CommentActions.tsx:273-288, :304-308, :484); in the more menu the menu closes on the press, so only the announcement is perceived.
  • Claim: this matches CodeBlock's copy button. Verified, with one difference: CodeBlock drops its copied state while failed (CodeBlock.tsx:1170), and Comments keeps data-link-copied (CommentActions.tsx:491).
  • Claim: public hooks only, with a local two-second failed state announced assertively through useAnnounce. Verified: CommentActions.tsx:262-308.
  • Claim: no new Core entry and no Core code change; Core gains only the catalog message. Verified: only packages/core/locales/en.json changes in Core.
  • Claim: Copy comment link uses the shared hook with announceFailure for the hook's two seconds. False: CommentActions.tsx:262, :41.
  • Claim: the failure is announced once on the assertive region, and success is unchanged. Verified: CommentActions.tsx:296-304.
  • Claim: a new locale key. Verified: en.json:2402-2405.
  • Claim: the new test reads the assertive region. Verified: Comments.test.tsx:979-984.
  • Claim: no knowledge record covers Lab Comments. Verified: there is no Comments record on main.
  • Claim: the new test fails before the change and passes after it. Verified: the base never renders the failure name, and the test passes in CI on this head.
  • Claim: the Comments suite passes. Verified in CI; the stated count of 100 was not confirmed.
  • Claim: lint and the changeset and knowledge checks pass. Verified: the CI lint and validate jobs pass.
  • Changeset claim: a [fix] patch for Core only, because Lab is private, describing the cross, the two-second label and tooltip, the immediate announcement, the old silent failure and the new catalog message. Verified: Lab is private, and the text matches the code for the header button.
  • File .changeset/comments-copy-link-failure.md: clear.
  • File packages/core/locales/en.json: clear.
  • File packages/lab/src/Comments/CommentActions.tsx: blocking (duplicated failure state; timer not cleared on unmount); non-blocking notes at :290-291 and :491.
  • File packages/lab/src/Comments/Comments.test.tsx: clear; coverage gaps are non-blocking.

Automated review (maintainer link)

).toBeTruthy();
});

it('names, shows and announces a failed link copy', async () => {

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: the test checks the name and the assertive region, but not the cross, the open tooltip, the 2 s reset or that the failure is announced once. The announce spy at the top of the file and the fake-timer pattern in the next test can pin those.

The failed-copy reset timer is cleared on unmount (architecture:react-component-runtime INV5). A unit case unmounts a comment while its failure shows and checks that the reset is stopped.
@cixzhang
cixzhang marked this pull request as draft November 12, 2026 08:27
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 08:28
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 3d6d74f

@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 failure feedback works on the header button: a refused copy shows a cross, names the button, holds the tooltip open for two seconds and is announced assertively, and unmounting a comment now clears the reset. Two things need fixing before approval:

  • CommentActions keeps its own failed flag, 2 s timer, unmount Effect and assertive announcement (CommentActions.tsx:263-276, :305-317) for the state Core's useClipboardCopy already owns and already runs underneath the public useClipboard call, so extend that shared hook so Comments makes one call (an owner API decision: isFailed and announceFailure on useClipboard, or a recorded internal entry) and delete the local copy.
  • The description's "Why not a shared hook" paragraph is inaccurate, because the change is not Lab-only (it changes Core's en.json and releases Core), the failed flag, the unmount Effect and the announcement are local besides the timer, and the copy is about 30 lines rather than ten, so please reword it or drop it once the first fix lands.

Not blocking: in the more menu the menu closes on the press, so only the announcement reports a failure; a write still in flight at unmount starts its timer after the cleanup (the shared hook has the same gap); and the tests could also pin the cross, the open tooltip, the 2 s reset and the single announcement.

Claims and files checked
  • Claim: a failed link copy used to do nothing. Verified: the base handler has no failure branch, and the public hook resolves false silently on a rejection.
  • Claim: a failed copy now shows a cross for two seconds, and the button, its tooltip and screen readers say the failure text. Verified for the header button (CommentActions.tsx:282-297, :313-317, :493); in the more menu the menu closes on the press, so only the announcement is perceived.
  • Claim: the same behavior as CodeBlock's copy button. Verified, with two differences: Comments holds its tooltip open, as it does for a copied link, and keeps data-link-copied set when a failure follows a success (CommentActions.tsx:500), which CodeBlock avoids.
  • Claim: public hooks only, with a local two-second failed state announced assertively through useAnnounce. Verified: CommentActions.tsx:262-318.
  • Claim: no new Core entry and no Core code change; Core gains only the catalog message. Verified: only packages/core/locales/en.json changes in Core.
  • Claim: the failure shows the close icon, names the button and opens its tooltip for the same two seconds as a copied link, and is announced once on the assertive region. Verified: CommentActions.tsx:41, :291-292, :313, :493, against the hook's 2000 ms default.
  • Claim: unmounting the comment stops that reset. Verified for a pending reset (CommentActions.tsx:268-276); a write still in flight at unmount starts its reset afterwards.
  • Claim: success is unchanged. Verified: CommentActions.tsx:309-311.
  • Claim: a new locale key. Verified: en.json:2402-2405.
  • Claim: one new test reads the assertive region and the other checks that the reset is cleared. Verified: Comments.test.tsx:979-984, :1012-1017.
  • Claim: no knowledge record covers Lab Comments. Verified: no Comments record exists on main.
  • Claim: the change is Lab-only under the Lab-only rule, with no Core change. False: it changes Core's English catalog and releases Core, which that rule does not treat as Lab-only.
  • Claim: the shared hook is module-internal, and exposing it would need a new internal entry and record. Verified; the local copy it would remove is about 30 lines, not ten.
  • Claim: only the short reset timer is local. False: the failed flag, its timer, the unmount Effect and the assertive announcement are local (CommentActions.tsx:264-276, :305-317).
  • Claim: both new tests fail without the change and pass with it. Verified by reading: the base has no failure name, and without the cleanup two two-second timers stay pending.
  • Claim: the Comments suite passes with 51 tests. The file holds 51 tests, and the CI test legs that run it pass on this head.
  • Claim: lint and the changeset and knowledge checks pass. Verified: the CI lint and repository-check jobs pass on this head.
  • Changeset claim: a [fix] patch for Core only, because Lab is private, describing the cross, the two-second label and tooltip, the immediate announcement, the old silent failure and the new catalog message. Verified: Lab is private, Core ships its locales, and the text matches the code for the header button.
  • File .changeset/comments-copy-link-failure.md: clear.
  • File packages/core/locales/en.json: clear.
  • File packages/lab/src/Comments/CommentActions.tsx: blocking (duplicated failure state with its own unmount Effect); non-blocking notes at :299-300, :302-317 and :500.
  • File packages/lab/src/Comments/Comments.test.tsx: clear; coverage gaps are non-blocking.
  • Description: blocking (the "Why not a shared hook" paragraph).

Automated review (maintainer link)

Main now carries @astryx.comments.linkCopyFailed (#11376), so this branch's identical catalog hunk drops out and its Core changeset goes. A comment in CommentActions says why the failed state lives in Lab (architecture:knowledge-contracts DEC-19).
@cixzhang
cixzhang marked this pull request as draft November 12, 2026 16:41
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 16:42
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec c4ebc16

@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 failure feedback works on the header button: a refused copy shows a cross, names the button, holds the tooltip open for two seconds and is announced assertively, and the pull request is now Lab-only. Three things need fixing before approval:

  • CommentActions keeps its own failed flag, 2 s timer, unmount Effect and assertive announcement (CommentActions.tsx:263-276, :308-320) for the state Core's useClipboardCopy already owns for CodeBlock and Timestamp, so give Comments one call to that shared hook (a public isFailed and announceFailure on useClipboard, or an internal entry that a record defines, either of which needs an owner API decision) and delete the local copy.
  • The new comment at CommentActions.tsx:299-300 cites architecture:knowledge-contracts DEC-19, which the comment-provenance lint forbids in package source, so the Lint job fails on this head ("no-comment-provenance baseline is out of date"); drop the citation and keep only the reason.
  • The description and that comment say DEC-19 limits Lab to Core's public hooks, but DEC-19 only says a Lab-only pull request needs no owner decision, and Lab already imports Core internal entries elsewhere, so please state the real reason (reaching the shared hook needs a Core entry or option that an owner decides) or drop it with the first fix.

Not blocking: in the more menu the menu closes on the press, so only the announcement reports a failure; a write still in flight at unmount starts its reset after cleanup (the shared hook has the same gap); and the tests could also pin the cross, the open tooltip, the 2 s reset and a single announcement.

Claims and files checked
  • Claim: a failed link copy used to do nothing. Verified: the base handler has no failure branch, and the public hook resolves false silently.
  • Claim: a failed copy now shows a cross for two seconds, and the button, its tooltip and screen readers say the failure text. Verified for the header button (CommentActions.tsx:282-297, :316, :496); in the more menu the menu closes on the press, so only the announcement is perceived.
  • Claim: the same behavior as CodeBlock's copy button. Verified, with two differences: Comments holds its tooltip open, and keeps data-link-copied set when a failure follows a success (CommentActions.tsx:503).
  • Claim: Comments reads the public hook's false result and holds its own two-second failed state, announced assertively. Verified: CommentActions.tsx:262-321.
  • Claim: no Core file changes, because the catalog message landed separately. Verified: only two Lab files change, and the message is already in Core's English catalog on the base.
  • Claim: the failure shows the close icon, names the button and opens its tooltip for the same two seconds as a copied link, and is announced once on the assertive region. Verified: CommentActions.tsx:40-41, :291-292, :316-320, :496.
  • Claim: unmounting the comment stops that reset. Verified for a pending reset (CommentActions.tsx:268-276); a write still in flight at unmount starts its reset afterwards.
  • Claim: success is unchanged. Verified: CommentActions.tsx:312-315.
  • Claim: the component reads the new catalog message. Verified: CommentActions.tsx:261.
  • Claim: one new test reads the assertive region and the other checks that the reset is cleared. Verified: Comments.test.tsx:964-985, :987-1023.
  • Claim: no knowledge record covers Lab Comments. Verified: no Comments record exists on main.
  • Claim: the Lab-only decision limits Lab to Core's public hooks and to no Core change. False: that decision only exempts Lab-only pull requests from owner decisions, and Lab already imports Core internal entries.
  • Claim: the public hook reports a failure but has no failure state, and the shared hook is module-internal. Verified: useClipboard.ts:57-60, :90-95, :120-124.
  • Claim: both new tests fail without the change and pass with it. Verified by reading: the base has no failure name, and without the cleanup two two-second timers stay pending.
  • Claim: the Comments suite passes with 51 tests. Verified: the file holds 51 tests, and the CI UI test shards that run it pass on this head.
  • Claim: lint, the Changeset check and the knowledge check pass. False for lint: the CI Lint job fails on this head; the Changeset coverage step passes.
  • Claim: no Changeset, because Lab is private and the catalog message has its own. Verified: Lab is private, and that Changeset is on the base.
  • File packages/lab/src/Comments/CommentActions.tsx: blocking (duplicated failure state; the new comment fails lint and misstates the Lab-only decision); non-blocking notes at :304-320, :494-495, :503.
  • File packages/lab/src/Comments/Comments.test.tsx: clear; coverage gaps are non-blocking.
  • Description: blocking (the Lab-only reason and the lint claim).

Automated review (maintainer link)

…write sets no state after unmount

The failed-copy comment drops its record citation and keeps only the reason; the tooltip comment covers a failed copy too. A clipboard write still in flight when the comment unmounts now sets no state.
@cixzhang
cixzhang marked this pull request as draft November 12, 2026 22:52
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 22:52
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 51102a8

@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. A refused copy on the header button now shows a cross, names the button, holds the tooltip open for two seconds and is announced assertively, and the new tests prove the announcement and the unmount clear. One thing blocks approval:

  • CommentActions keeps its own failed flag, 2 s timer, unmount Effect and assertive announcement (CommentActions.tsx:264-279, :306-326) for the state Core's useClipboardCopy already owns for CodeBlock and Timestamp, and its in-flight guard (:310-312) already exists only in this copy, so give Comments one call to the shared hook (a failure state on the public useClipboard, or an internal entry a record defines, either of which needs an owner API decision), move the guard into the hook, and delete the local copy.

Not blocking: in the more menu the menu closes on the press, so only the announcement reports a failure; data-link-copied stays set when a failure follows a success; the tests could also pin the in-flight guard, the cross, the open tooltip, the 2 s reset and a single announcement; and CI's test job failed only because one node test shard timed out during checkout, so it needs a re-run.

Claims and files checked
  • Claim: a failed link copy used to do nothing. Verified: the base handler ignores the result and the public hook resolves false silently; in Chromium the base button keeps its label and nothing is announced.
  • Claim: a failed copy now shows a cross for two seconds, and the button, its tooltip and screen readers say the failure text, as CodeBlock's copy button does. Verified for the header button (CommentActions.tsx:285-300, :321, :502, and in Chromium); Comments also holds its tooltip open and keeps data-link-copied set when a failure follows a success, and in the more menu only the announcement is perceived.
  • Claim: Comments reads the public hook's false result and holds its own two-second failed state, announced assertively through the public announce hook. Verified: CommentActions.tsx:23, :306-326.
  • Claim: no Core file changes, because the catalog message landed separately. Verified: only two Lab files change, and the message is on the base.
  • Claim: the failure shows the close icon, names the button and opens its tooltip for the same two seconds as a copied link, and is announced once on the assertive region. Verified: CommentActions.tsx:40-41, :294-295, :321-325, :502.
  • Claim: unmounting the comment stops that reset. Verified: CommentActions.tsx:271-279; the second test fails when the clear is removed.
  • Claim: success is unchanged. Verified: CommentActions.tsx:317-320; the existing copy tests pass.
  • Claim: the component reads the new catalog message. Verified: CommentActions.tsx:261.
  • Claim: one new test reads the assertive region and the other checks that the reset is cleared. Verified: Comments.test.tsx:964-985, :987-1023.
  • Claim: no knowledge record covers Lab Comments. Verified: no Comments record exists.
  • Claim: a failure state on the public hook would be a new public API row that needs its own owner decision. Verified: the public hook returns only copy and isCopied, and an API row outside a pull request's scope needs a decision.
  • Claim: both new tests fail without the change and pass with it, the Comments suite passes (51), and lint passes. Verified: both fail against the base component, 51 pass at this head, and lint reports no errors.
  • Claim: no Changeset, because Lab is private. Verified: the Lab package is private.
  • File packages/lab/src/Comments/CommentActions.tsx: the blocking finding above, plus the non-blocking data-link-copied note and a comment-wording suggestion.
  • File packages/lab/src/Comments/Comments.test.tsx: clear, with the non-blocking coverage note above.

Automated review (maintainer link)

Comments kept its own copy of the failed-write state that Core's
useClipboardCopy owns for CodeBlock and Timestamp. Core now exposes the
hook to Lab as the internal entry @astryxdesign/core/internal/clipboard-copy
(Core and Lab only, by lint), and Comments calls it once. The in-flight
guard moves into the hook: a write that settles after its caller unmounts
sets no state, starts no timer and announces nothing, for every caller.
data-link-copied no longer reads "copied" while a failure shows.
react-component-runtime names the entry.
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 14, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 626b4c2

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 14, 2026

@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: Comments now gets its failed-copy state from Core's shared clipboard hook and the new tests fail on the base and pass on this head, but one thing stands between this head and approval:

  • This head changes what @astryxdesign/core publishes (the ./internal/clipboard-copy export in packages/core/package.json, internal/clipboard-copy.ts and the unmount guard in useClipboard.ts) without a Changeset naming Core, so the required lint check fails on changeset coverage and the description's "Changeset: none" line is not true for this head; add one with pnpm changeset:new --packages @astryxdesign/core --category fix and update that line.

The first-load size report asked for earlier is not needed: the guard is default behavior, which the size rule excludes, and none of the four reference pages reaches useClipboard.ts (a CodeBlock page grows by 19 B gzip). Not blocking: the comment above the useClipboardCopy call restates what the hook decides, and the Comments test could also pin the cross icon and the held-open tooltip; the build, test and docsite-test failures are deferred heavy CI, not this change.

Claims and files checked
  • Claim: a failed link copy used to do nothing. Verified: on the base the button keeps its name and nothing is announced in Chromium, and the new Comments test fails there.
  • Claim: a failed copy now shows a cross for two seconds and the button, its tooltip and screen readers say the failure text, as CodeBlock's copy button does. Verified: CommentActions.tsx:273-288 and :467, and in Chromium at 0.6 s and 2.6 s after a refused copy.
  • Claim: the shared hook is reachable from Lab as an internal entry like the committed-ref one, outside the hooks index and the package entry, and limited by lint to Core and Lab. Verified: internal/clipboard-copy.ts, packages/core/package.json:902-906, hooks/index.ts:22-23, eslint.config.js:330-340.
  • Claim: no public API changes. Verified: the API generator lists no row for Core, build or the seven themes.
  • Claim: a write that settles after unmount sets no state, starts no timer and announces nothing, while onError still runs. Verified: useClipboard.ts:161-164 and :182-184, and the new hook test, which fails on the base.
  • Claim: CodeBlock and Timestamp see no visible change. Verified by reading (the guard acts only after unmount); their suites pass.
  • Claim: Comments calls the hook once and drops its own failed flag, timer, unmount Effect and announcement. Verified: CommentActions.tsx:263-267; none of them remains.
  • Claim: a failure shows the close icon, names the button, opens its tooltip for two seconds and is announced once, assertively. Verified: CommentActions.tsx:273-288, :467, useClipboard.ts:177, useClipboard.test.tsx:169, and in Chromium.
  • Claim: data-link-copied no longer says copied while a failure shows. Verified: CommentActions.tsx:474-476.
  • Claim: success is unchanged. Verified: the mounted success branch is unchanged and the existing copy tests pass.
  • Claim: the runtime record names the internal entry beside the other internal hooks. Verified: react-component-runtime.md:590-596, owner-approved at this head.
  • Claim: two Comments tests and one hook test were added. Verified: Comments.test.tsx:964, :987; useClipboard.test.tsx:212.
  • Claim: the new tests fail without the change and pass with it, the unmount case alone too. Verified: all three fail on the base and pass on this head, in the suite and alone.
  • Claim: the hook, Lab Comments, CodeBlock and Timestamp suites pass. Verified: they pass on this head (503 tests in the files run here; the stated count covers a different file set).
  • Claim: lint, the changeset format check and the knowledge check pass. Verified locally (ESLint reports no error on the changed files, and both checks pass), but the required lint check fails on changeset coverage.
  • Claim: no Changeset is needed because Lab is private and the catalog message has its own. False: Core's source and exports change on this head.
  • Claim: the internal entry is decided by the release record's internal-subpath rule. Partly: that rule allows Core internal subpaths in general; the runtime record's new bullet, owner-approved at this head, names this one.
  • File docs/architecture/react-component-runtime.md: clear.
  • File packages/core/package.json: the missing Changeset above.
  • File packages/core/src/hooks/useClipboard.ts: the missing Changeset above; otherwise clear.
  • File packages/core/src/hooks/useClipboard.test.tsx: clear.
  • File packages/core/src/internal/clipboard-copy.ts: the missing Changeset above; otherwise clear.
  • File packages/lab/src/Comments/CommentActions.tsx: clear, with the non-blocking comment suggestion.
  • File packages/lab/src/Comments/Comments.test.tsx: clear, with the non-blocking coverage note.
  • File scripts/sync-exports.js: clear.

Automated review (maintainer link)

Comment thread packages/core/package.json Resolved
const [isFailed, setIsFailed] = useState(false);
const resetTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const failedTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const isMountedRef = useRef(true);

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.

Evidence gap (component-import-boundaries INV10): this module is shared (CodeBlock, Markdown and Timestamp import it) and grows here, so INV10 asks the pull request to report the first-load gzip delta. None of the four reference pages reaches it; report base against head for a page that renders CodeBlock or Timestamp, for example from pnpm check:component-import-boundaries --base-ref main.

Non-blocking: useIsUnmountedRef in gestures/gestureSync.ts already provides this flag; reusing it, or moving it to hooks/, keeps one unmount flag.

The guard ships in Core, so CodeBlock and Timestamp get a patch [fix]
entry. Drops a comment that restated the hook.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 8bdfe06

@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 full CI run on this head passed, including the heavy build, test and docsite-test jobs.

Nothing blocks this change: Comments gets its failed-copy state from Core's shared clipboard hook, the hook ignores a write that settles after its control unmounts, and the Core Changeset covers that guard.

Not blocking: the Comments test at Comments.test.tsx:964 could also pin the cross icon, the held-open tooltip and the 2 s reset.

Claims and files checked

Review mode: same-head; reason: none

  • Rule change: a re-review whose rule set changed in more than three rules, or by a long rule diff, becomes a full review, and each changed rule is listed with its result. Checked: the two rule sets compared (two changed rules, a short diff), no finding.
  • Rule change: the review mode line gains a reason for many changed rules. Checked: this comment's mode line, no finding.
  • Claim: a failed link copy used to do nothing. Verified: the base component used only the public hook's copy and copied flag (CommentActions.tsx:259 on the base), whose failure resolves false silently, and the new Comments tests fail on the base.
  • Claim: a failure now shows a cross for two seconds and the button, its tooltip and screen readers say the failure text, as CodeBlock's copy button does. Verified: CommentActions.tsx:271-286 and :465, the hook's 2 s default (useClipboard.ts:29), and CodeBlock's same hook call and cross (CodeBlock.tsx:1043, :1172).
  • Claim: the shared hook is reachable from Lab as an internal entry like the committed-ref one, outside the hooks index and the package entry, and limited by lint to Core and Lab. Verified: internal/clipboard-copy.ts, packages/core/package.json:902-906, hooks/index.ts:22-23, eslint.config.js:330-340.
  • Claim: no public API changes. Verified: the API surface comparison lists no row for any published package, and CI's own comparison for this head agrees.
  • Claim: a write that settles after unmount sets no state, starts no timer and announces nothing, while onError still runs. Verified: useClipboard.ts:161-164 and :182-184, and the new hook test, which fails on the base.
  • Claim: CodeBlock and Timestamp see no visible change. Verified by reading: the guard acts only after unmount, and their suites pass.
  • Claim: Comments calls the hook once and drops its own failed flag, timer, unmount Effect and announcement. Verified: CommentActions.tsx:260-265; none of them remains.
  • Claim: a failure shows the close icon, names the button, opens its tooltip for two seconds and is announced once, assertively. Verified: CommentActions.tsx:271-286, :465, useClipboard.ts:177 and the once-per-failure test at useClipboard.test.tsx:169.
  • Claim: data-link-copied no longer says copied while a failure shows. Verified: CommentActions.tsx:472-474.
  • Claim: success is unchanged. Verified: the mounted success branch is unchanged (useClipboard.ts:185-203) and the existing copy tests pass.
  • Claim: the runtime record names the internal entry beside the other internal hooks, in the present tense, with no research, evidence, alternatives, references, open questions or project status. Verified: react-component-runtime.md:590-596, owner-approved at this head.
  • Claim: Core gets a patch fix entry for the guard, and neither Lab (private) nor the internal entry (not public API) needs one. Verified: .changeset/clipboard-copy-unmount-guard.md, packages/lab/package.json:4, and CI's Changeset coverage passes.
  • Claim: two Comments tests and one hook test were added. Verified: Comments.test.tsx:964, :987; useClipboard.test.tsx:212.
  • Claim: the new tests fail without the change and pass with it, the unmount case alone too. Verified: all three fail on the base with this head's tests and pass on this head; the hook case passes alone.
  • Claim: the hook, Lab Comments, CodeBlock and Timestamp suites pass (546). Verified: 16 files, 546 tests pass on this head.
  • Claim: lint, the changeset check and the knowledge check pass. Verified: CI's lint passes on this head, including its Changeset coverage and changeset checks, and the knowledge check passes on this head.
  • Claim: the Comments failure message has its own Changeset in a separate, merged change. Verified: the message is on the base (packages/core/locales/en.json:2422) with its own Changeset.
  • Claim: the internal entry is decided by the release record's internal-subpath rule. Verified in substance: that rule allows Core internal subpaths in general, and the runtime record's new bullet, owner-approved at this head, names this one.
  • Claim: the land path is review of this head, a fresh CI run, then merge. Verified: a fresh CI run on this head passed after the ci:run label.
  • Changeset: CodeBlock's and Timestamp's copy buttons no longer update after they unmount; a late write sets no state, starts no timer and announces nothing. Verified: useClipboard.ts:161-164, :182-184, and both components call the hook (CodeBlock.tsx:1043, TimestampHoverCard.tsx:149); Markdown heading links and RichText's code-block header also get the guard through the public hook, which the entry does not need to name.
  • File .changeset/clipboard-copy-unmount-guard.md: clear.
  • File docs/architecture/react-component-runtime.md: clear.
  • File packages/core/package.json: clear.
  • File packages/core/src/hooks/useClipboard.ts: clear.
  • File packages/core/src/hooks/useClipboard.test.tsx: clear.
  • File packages/core/src/internal/clipboard-copy.ts: clear.
  • File packages/lab/src/Comments/CommentActions.tsx: clear.
  • File packages/lab/src/Comments/Comments.test.tsx: clear, with the non-blocking coverage note.
  • File scripts/sync-exports.js: clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as draft November 15, 2026 07:52
@cixzhang
cixzhang marked this pull request as ready for review November 15, 2026 07:52
@cixzhang
cixzhang merged commit c3d24e1 into main Nov 15, 2026
158 of 161 checks passed
@github-actions
github-actions Bot deleted the fix/comments-copy-link-failure branch November 16, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 8bdfe061 Deployed Nov 14, 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) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant