Skip to content

fix(Markdown): a heading copy link shows and announces a failed copy - #10424

Merged
cixzhang merged 13 commits into
mainfrom
fix/heading-links-copy-failure
Nov 20, 2026
Merged

cixzhang merged 13 commits into
mainfrom
fix/heading-links-copy-failure

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #10448 (a failed copy is announced assertively); the base is that branch until it merges.

Who this helps

Readers who copy a Markdown heading's link. When the clipboard write fails (permission denied, an insecure context, no Clipboard API), the # button used to do nothing, so they couldn't tell the link wasn't copied. Now it shows a cross for 1.5 seconds and screen readers hear "Failed to copy value to clipboard.", matching CodeBlock's copy button.

What changed

  • Renderer: HeadingLinksRenderer uses Core's internal useClipboardCopy, the hook CodeBlock's copy button uses. A rejected write:

    • swaps # for the close icon for the same 1.5 s as the success check;
    • names the button "Failed to copy value to clipboard." and announces it once on the assertive live region;
    • exposes no error detail.

    A later successful copy clears the failure. Success behavior is unchanged.

  • Locale: a new key, @astryx.markdownHeadingLinks.copyFailed.

  • Record: docs/specs/components/Markdown/modules/headingLinks.spec.md updates the copy-control concept row, FR10 and the copy contract. They used to say failure stays silent. Owner decision, Nov 6 2026 (Cindy).

  • Tests:

    • The rejection test and the unavailable-Clipboard test now expect the failure name, the cross and the announcement, then the return to rest. The rejection test counts every write to a live region and expects exactly one assertive announcement.
    • The Chromium browser spec's failure case expects the failure name, and still checks that the row doesn't move.

Verification

  • Red first: both failure tests fail on main's renderer and pass here.
  • Suites: Markdown, useClipboard and Outline pass (1101 of 1102). The one failure is parser.perf "streaming full re-parse XL", a known timing-sensitive budget that fails under machine load.
  • Other checks: lint, typecheck, check:changesets and check-knowledge pass.

Changeset: [feat] patch for Core.

Writing rubric results

Covers docs/specs/components/Markdown/modules/headingLinks.spec.md.

R1 narration: none; the failure line states what the button does.
R2 research: none.
R3 evidence: no evidence cell names a pull request.
R4 rejected alternatives: none.
R5 change references: none.
R6 open questions: none.

The heading copy-link button now uses the internal useClipboardCopy, as
CodeBlock does: a rejected write swaps `#` for a cross for 1.5 s, names
the button and announces "Failed to copy value to clipboard." once, and
exposes no error detail. It used to fail silently. The headingLinks
record FR10 and the copy contract say so (owner decision, Nov 6 2026).
@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 20, 2026 3:25am 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
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 7, 2026
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec ce2fd9b

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

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 54ad4f9

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
lab/CommentThread 379.5 kB (+70 B) · 2.4 kB CSS (0) — — · — · —
Markdown · Storybook 208.0 kB (+23 B) · 23.4 kB CSS (0) 8,879 (0) ✓ · ✓ · —
lab/Comments 386.4 kB (+20 B) · 2.5 kB CSS (0) — — · — · —

Package size: @astryxdesign/core 7.85 MB packed (+341 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

@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 20, 2026, 6:45 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.

Requesting changes for two small items; the fix itself is sound.

  • packages/core/src/Markdown/Markdown.doc.mjs:979 still says "failures stay silent", and astryx component Markdown --dense prints it, so builders and coding agents are told the opposite of what now ships; reword it to say a failed write shows a cross and announces the localized failure for the same 1.5 seconds.
  • The record now says the failure is announced once, but headingLinks.test.tsx only checks the polite region's text, so please assert that one failed activation produces exactly one announcement, which is the announcement evidence spec:AST-009 FR4 asks for.

The rest checks out: the renderer reuses the shared clipboard hook as CodeBlock does, the string is catalog-backed, the record rewrite carries an engineering owner's approval for this head, and both failure tests fail on main and pass here. CI has not run yet because the pull request is still a draft. Optional: the record's reveal sentence and design row still mention only the #/check swap.

[Automated review]

… announcement

The Markdown doc guidance no longer says failures stay silent, and the
rejection test checks the failure is announced exactly once.
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 59b5d91

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

Requesting changes for one remaining test fix; the builder guidance now matches the new failure behavior.

  • The counter added to the rejection test in headingLinks.test.tsx reads the polite region's text once per observer callback and stops at 1500 ms, so the test still passes if "Failed to copy value to clipboard." is announced a second time while the cross shows or on reset; please push one entry per mutation record that adds text to the polite region, as EmptyState.announce.test.tsx does, and advance one more frame after the reset before asserting, so the test proves the "announces that text once" count that spec:AST-009 FR4 asks for.

Optional: the record's reveal sentence and design row (headingLinks.spec.md lines 138 and 162) still name only the #/check pair.

[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 rejection test records one entry per write that adds text to a live
region and runs one more frame after the reset, so a repeat while the
cross shows or on reset fails it. With the shared hook announcing
failures assertively, it expects one assertive announcement. The record's
reveal sentence and design row name the cross.
@cixzhang
cixzhang changed the base branch from main to fix/copy-failure-assertive November 7, 2026 04:11
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 7, 2026
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 8b68389

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 7, 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.

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, and land it after #10448, whose assertive routing the rejection test needs.

The rejection test now records every live-region write and expects exactly one assertive announcement, which closes the earlier request. The failed Flag review signals job stopped on a changed-file count (7 of 12) taken while the base branch changed; a re-run should clear it.

  • Regression: (optional) the @astryx.markdownHeadingLinks.copyFailed description in packages/core/locales/en.json still says the text is announced to a polite live region; since the base branch it goes once to the assertive one.

[Automated review]

Comment thread packages/core/locales/en.json Resolved
@github-actions
github-actions Bot deleted the branch fix/copy-failure-assertive November 10, 2026 06:04
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 00:37
@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 draft November 12, 2026 22:16
@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 22:18
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec ff17664

@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: when the clipboard refuses the write, a heading's copy button now shows the cross, takes the failure name for 1.5 seconds and announces it once, as the heading-links record states for this head.

The record change carries an engineering owner's approval for this exact head, the four failure tests fail against the base renderer and pass here, and CI is green. The earlier requests on this pull request all stay fixed.

Claims and files checked
  • Changeset: a failed write on a heading's copy-link button now shows, as CodeBlock's copy button does: verified (HeadingLinksRenderer.tsx:193-205; CodeBlock.tsx:1042-1047, :1172).
  • Changeset: the # becomes a cross for 1.5 seconds: verified (HeadingLinksRenderer.tsx:30, :198-199; headingLinks.test.tsx:725-750).
  • Changeset: the button is named and announces the failure text: verified (HeadingLinksRenderer.tsx:193-195; useClipboard.ts:167-170; headingLinks.test.tsx:433-445).
  • Changeset: it used to fail silently and leave # unchanged: verified (the base renderer reads no failure state; the failure tests fail against it).
  • Changeset and description: the error itself is not shown: verified (no error callback is passed; the text is a fixed catalog string).
  • Changeset: a new capability with a patch bump for Core: verified (.changeset/heading-links-copy-failure.md:2, :5; the changeset check passes).
  • Description: the branch sat on the assertive-announcement change until it merged: verified (it merged, and the base is now main).
  • Description: a refused, insecure or missing clipboard used to leave the # button doing nothing: verified (base renderer; the missing-API case reaches the same catch, useClipboard.ts:154-156).
  • Description: it now shows a cross for 1.5 seconds and screen readers hear the failure text, matching CodeBlock: verified (same hook, close icon and English string, en.json:1526-1527).
  • Description: the renderer uses the internal clipboard hook CodeBlock uses: verified (HeadingLinksRenderer.tsx:18, :150-154; CodeBlock.tsx:38, :1043).
  • Description: the cross lasts the same 1.5 s as the success check: verified (one resetAfterMs drives both timers, useClipboard.ts:163-166, :188-191).
  • Description: the failure name is announced once on the assertive live region: verified (useClipboard.ts:169; headingLinks.test.tsx:458-462).
  • Description: no error detail is exposed: verified.
  • Description: a later successful copy clears the failure: verified (useClipboard.ts:174-178).
  • Description: success behavior is unchanged: verified (the success branch and the public hook are unchanged; the success test passes before and after).
  • Description: one new locale key: verified (en.json:834-837).
  • Description: the record's concept row, FR10 and copy contract no longer say failure stays silent, by owner decision: verified (headingLinks.spec.md:94, :110, :150-152), approved by an engineering owner for this exact head.
  • Description: both failure tests expect the failure name, the cross, the announcement and the return to rest: verified (headingLinks.test.tsx:432-452, :482-502, with the cross named at :725-750).
  • Description: the rejection test counts every live-region write and expects one assertive announcement: verified (headingLinks.test.tsx:406-425, :458-462).
  • Description: the Chromium failure case expects the failure name and an unmoved row: verified (headingLinks.a11y.chromium.spec.ts:848-857; it passed in CI on this head).
  • Description: both failure tests fail on main's renderer and pass here: verified (rerun against the base renderer: both fail, as do the two glyph cases; all pass on the head).
  • Description: the Markdown, useClipboard and Outline suites pass apart from one timing-sensitive perf test: consistent (those suites pass here, 1,542 tests, and CI's unit-test shards pass).
  • Description: lint, typecheck, changeset and knowledge checks pass: verified (CI's lint runs the changeset and knowledge checks and passed; typecheck passed; both checks also pass locally).
  • Description: the changeset is a feature with a patch bump for Core: verified.
  • Description: the writing rubric finds no narration, research, pull request references, rejected alternatives, change references or open questions in the record: verified.
  • .changeset/heading-links-copy-failure.md: clear.
  • docs/specs/components/Markdown/modules/headingLinks.spec.md: clear.
  • packages/core/locales/en.json: clear.
  • packages/core/src/Markdown/Markdown.doc.mjs: clear.
  • packages/core/src/Markdown/plugins/HeadingLinksRenderer.tsx: clear.
  • packages/core/src/Markdown/plugins/headingLinks.a11y.chromium.spec.ts: clear.
  • packages/core/src/Markdown/plugins/headingLinks.test.tsx: clear.

Automated review (maintainer link)

cixzhang added a commit that referenced this pull request Nov 13, 2026
* ci: every checkout step in ci.yml stops after 5 minutes

Three jobs today used their whole 15-minute time inside actions/checkout,
before any code ran (#9810 typecheck, #8690 test-node 2/5, #10424 test-build).
Each checkout step now has its own 5-minute bound, so a hung checkout fails
by name in minutes. The bound is for the tool alone and lowers no test
budget. A workflow test keeps every checkout step bounded.

* ci: full-history checkouts get a measured 10-minute bound; release-authority keeps none

release-bump and release-merge-back fetch the whole history (release-bump
took up to 143 s), so their checkouts stop after 10 minutes. The release
lanes read a failed release-authority as a refused authority, so its
checkout keeps only its job's time. The docsite-browser test reads the
bounded checkout step.

* ci: checkout steps stop after 8 minutes, above the slowest checkout that still succeeded

A green run tonight had a checkout take 445 s and still pass, so 5 minutes
would have failed it. Hangs still fail by name, about 7 minutes before the
job's cap.

* ci: checkout steps in jobs capped at 5 minutes stop after 3

Seven jobs have their own 5-minute time, so an 8-minute checkout bound there
never fired: a hang still ended as an unnamed job timeout. Their 10 checkout
steps stop after 3 minutes, about five times their slowest normal checkout
(33 s). The guard checks every checkout bound is below its job's time.

* test: the interaction counter's checkout matches each lane's, apart from its own bound
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 3aa66d3

@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: when the clipboard refuses a heading link, the # button now shows the cross, takes the failure name for 1.5 seconds and announces it once, as the heading-links record describes it for this head. The full CI run on this head passed.

One optional tidy-up: the description's writing-rubric results stop at R6; adding "R7 project status: none" completes them.

Claims and files checked
  • Verified: a refused copy used to leave # and its name unchanged and silent (the new failure tests fail against the previous renderer).
  • Verified: a refused copy shows the cross for 1.5 seconds and names the button "Failed to copy value to clipboard.", on both the rejected-write and missing-API paths.
  • Verified: the failure is announced exactly once, on the assertive live region (the rejection test counts every live-region write).
  • Verified: the error itself is never shown, a later successful copy clears the failure, and the success path is unchanged.
  • Verified: the renderer uses the same internal clipboard hook as CodeBlock's copy button.
  • Verified: a new locale key carries the wording.
  • Verified: the record's concept row, FR10 and copy contract, the builder guidance and the changeset ([feat], patch for Core) describe the new behavior, and an engineering owner approved the record change for this head.
  • Verified: the browser spec's failure case checks the failure name and an unmoved heading row, and it passes.
  • Verified: the Markdown, clipboard-hook and Outline suites pass at this head (with a larger test count than the description's tally), as do lint, typecheck and the changeset and knowledge checks.
  • Verified: the base pull request this was stacked on has merged, so the base is main.
  • Verified: the R1 to R6 rubric answers are accurate for the changed record lines.
  • Files clear: .changeset/heading-links-copy-failure.md, docs/specs/components/Markdown/modules/headingLinks.spec.md, packages/core/locales/en.json, packages/core/src/Markdown/Markdown.doc.mjs, packages/core/src/Markdown/plugins/HeadingLinksRenderer.tsx, packages/core/src/Markdown/plugins/headingLinks.a11y.chromium.spec.ts, packages/core/src/Markdown/plugins/headingLinks.test.tsx.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as draft November 13, 2026 09:48
@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 09:48
@cixzhang
cixzhang marked this pull request as draft November 16, 2026 17:13
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 31fbe39

@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: when the clipboard refuses a heading link, the # button now shows the cross, takes the failure name for 1.5 seconds and announces it once on the assertive channel, as the updated heading-links record describes. CI has run on this head and passed.

Three optional description tidy-ups:

  • "Who this helps" lists "permission denied", but since the copy-command retry (#12035) a refused write is retried with the browser copy command, so the cross appears only when that retry also fails.
  • The import-boundaries record asks a pull request that grows an optional feature to report its first-load size: a page that renders Markdown without heading links grows by 41 B gzip (the limit is 307 B).
  • The writing-rubric results stop at R6; adding "R7 project status: none" completes them.
Claims and files checked

Review mode: same-head; reason: none

  • Verified: a failed copy used to leave # and its name unchanged and silent (the new failure tests fail against the previous renderer, and a browser check on the previous code shows no change and no announcement).
  • Verified: a failed copy shows the cross for 1.5 seconds and names the button "Failed to copy value to clipboard.", on both the rejected-write and missing-API paths, then returns to #.
  • Verified: the failure is announced exactly once, on the assertive live region (the rejection test counts every live-region write; a browser check sees one write).
  • Verified: the error itself is never shown, a later successful copy clears the failure, and the success path is unchanged.
  • Verified: the renderer uses the same internal clipboard hook as CodeBlock's copy button (CodeBlock keeps its cross for its own copied duration; the heading link uses its 1.5 seconds).
  • Verified: a new locale key carries the wording.
  • Verified: the record's concept row, FR10 and copy contract, the builder guidance and the changeset ([feat], patch for Core) describe the new behavior, and the spec-owner approval covers this head.
  • Verified: the test changes are as described; the browser spec's failure case checks the failure name and an unmoved heading row, and it passes on this head.
  • Verified: red first, the four failure tests fail on the previous renderer and pass here.
  • Verified with a different count: the Markdown, clipboard-hook and Outline suites pass at this head, as do CodeBlock and Timestamp, and CI's unit and browser suites pass.
  • Verified: lint, typecheck, and the changeset and knowledge checks pass.
  • Verified: the pull request this was stacked on has merged, so the base is main.
  • Verified with a nuance: a refused write now first retries with the browser copy command, so "permission denied" shows the cross only when that retry fails too.
  • Verified: the R1 to R6 rubric answers are accurate for the changed record lines; R7 is not listed.
  • Files clear: .changeset/heading-links-copy-failure.md, docs/specs/components/Markdown/modules/headingLinks.spec.md, packages/core/locales/en.json, packages/core/src/Markdown/Markdown.doc.mjs, packages/core/src/Markdown/plugins/HeadingLinksRenderer.tsx, packages/core/src/Markdown/plugins/headingLinks.a11y.chromium.spec.ts, packages/core/src/Markdown/plugins/headingLinks.test.tsx.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 19, 2026 06:32
@cixzhang
cixzhang marked this pull request as draft November 20, 2026 02:59
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 54ad4f9

@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: when the clipboard write fails, a Markdown heading's # copy button now shows a cross, takes the name "Failed to copy value to clipboard." for 1.5 seconds and announces it once on the assertive channel, as the updated heading-links record describes. CI passed on this head.

Three optional description tidy-ups:

  • "Who this helps" lists "permission denied", but a refused write is first retried with the browser copy command, so the cross appears only when that retry also fails.
  • The import-boundaries record asks a pull request that grows an optional feature to report its first-load size: a page that renders Markdown without heading links grows by 42 B gzip (the limit is 307 B).
  • The writing-rubric results stop at R6; adding "R7 project status: none" completes them.
Claims and files checked

Review mode: same-head; reason: none

  • Changed rules (0): none.
  • Verified: the pull request this was stacked on has merged, so the base is main.
  • Verified: a failed copy used to leave # and its name unchanged and silent (the new failure tests fail against the previous renderer).
  • Verified: a failed copy shows the cross for 1.5 seconds and names the button "Failed to copy value to clipboard.", on both the rejected-write and missing-API paths, then returns to #, matching CodeBlock's copy button.
  • Verified: the renderer uses the same internal clipboard hook as CodeBlock's copy button.
  • Verified: the failure is announced exactly once, on the assertive live region (the rejection test counts every live-region write).
  • Verified: the error itself is never shown, a later successful copy clears the failure, and the success path is unchanged.
  • Verified: a new locale key carries the wording.
  • Verified: the record's concept row, FR10 and copy contract, the builder guidance and the changeset ([feat], patch for Core) describe the new behavior, and the spec-owner approval covers this head.
  • Verified: the test changes are as described; the browser spec's failure case checks the failure name and an unmoved heading row.
  • Verified: red first, the four failure tests fail on the previous renderer and pass here.
  • Verified with a different count: the Markdown, clipboard-hook, Outline, CodeBlock and Timestamp suites pass at this head.
  • Verified: lint, typecheck, and the changeset and knowledge checks pass at this head, and CI's run on this head passed every check.
  • Verified with a nuance: a refused write first retries with the browser copy command, so "permission denied" shows the cross only when that retry fails too.
  • Verified: the R1 to R6 rubric answers are accurate for the changed record lines; R7 is not listed.
  • Files clear: .changeset/heading-links-copy-failure.md, docs/specs/components/Markdown/modules/headingLinks.spec.md, packages/core/locales/en.json, packages/core/src/Markdown/Markdown.doc.mjs, packages/core/src/Markdown/plugins/HeadingLinksRenderer.tsx, packages/core/src/Markdown/plugins/headingLinks.a11y.chromium.spec.ts, packages/core/src/Markdown/plugins/headingLinks.test.tsx.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 20, 2026 06:20
@cixzhang
cixzhang merged commit 66b2932 into main Nov 20, 2026
153 checks passed
@github-actions
github-actions Bot deleted the fix/heading-links-copy-failure branch November 21, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 54ad4f96 Deployed Nov 20, 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) 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