Repository navigation
fix(chat): show a muted cue on a refused link's label - #28418
Conversation
83b80be to
13dd5ef
Compare
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Issue #9945 is linked, and tests added here fail on base. The issue's choice between silent prose and a cue is settled by a maintainer merging or closing this PR. The PR doesn't change any default mode. What this change shipsInventory (10 items) — 9 justifiedIntent: let a chat reader tell that a link was there and why it does nothing when the link policy refuses its destination. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 0bcb998 Description read[DESCRIPTION-READ] 42fa9fd180956c44db46f5fb9e8bc297ee58a6bc2fde7b188120951465372b8a That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The cue is small and reversible. One shared rule covers both chat renderers, and the screenshots match the description. Notes
[DESIGN-REVIEWED] 0bcb998 Description read[DESCRIPTION-READ] d2eceebee8c199c31d65c8b81105a516b5f3eedf9786c48aff3bc41e7c72522f That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The blind reader correctly took every refused label to be "a blocked link" where clicking would do "probably nothing", which is what the diff does. Notes
[UX-REVIEWED] 0bcb998 Description read[DESCRIPTION-READ] 241dd8126d271406f9aad16f75dfc9eaf4cc53ea8d2a8f556743137bc8781098 That sha256 names everything this verdict read: the PR description, plus the 7 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
13dd5ef to
198c7a1
Compare
|
198c7a1 to
4c34bf8
Compare
|
|
HOLD (product decision) at 4c34bf8. The code looks sound. A refused destination still never becomes an anchor. The reason is kept out of the label's text nodes, so sourcePos and copy are unaffected (MarkdownRenderer.tsx#L325-L338). Named, id-only and empty anchors keep the plain span. Both earlier GPT and Opus findings were fixed with regression tests, and CI is green. Blocker: #9945 is labelled needs-human and explicitly leaves "cue or silent prose" to a maintainer. The PR itself calls this the concrete form of the cue option, and Design Review asks for that decision before merge. A maintainer's ruling on #9945, or on this PR, in favour of the cue clears this. AI findings judged non-blocking:
— crew-pr-reviewer (r142) |
4c34bf8 to
8ec5c39
Compare
|
Rebased onto main 35a1f00; resolved conflicts in |
8ec5c39 to
5dd2316
Compare
|
Rebased onto main 39717a0 to pick up #31625 (security package line budget), which fixes the inherited |
A chat link whose destination the link policy refuses rendered as plain prose, indistinguishable from the sentence around it. Both chat renderers (MdAnchor and Mochi's ChatPanelMarkdown) now give the inert label a muted dotted underline from existing tokens, plus a generic translated reason as the hover title and as a visually-hidden suffix. Allowed links are unchanged and the label is still never an anchor. Fixes #9945
5dd2316 to
0bcb998
Compare
|
Rebased onto main 7c364bc to pick up #31803, which fixes the |
bolichen97
left a comment
There was a problem hiding this comment.
Approving head 0bcb998. The gate shows 97 checks passed, none red or pending.
What I checked:
- One decision for both renderers.
wearsRefusedLinkCuereturns false for a raw in-page target (nameoridset) or an anchor with no children, and bothMdAnchorand Mochi'sChatPanelMarkdownbranch on it. The tests cover the''sentinel, sanitizer-deletedjavascript:/data:hrefs,[label]()and a bare<a>, plus the plain-prose cases. - The label text stays the source text. In
MdAnchorthe reason is::aftercontent fed fromdata-refused-reason, not a text node, and the newresolveSourcePostest pins that a selection after a refused link still maps to line 3, column 35. Mochi has no stylesheet for that, so it uses an unselectable visually-hidden span, which keeps copy clean there too. - Nothing leaks. The reason is one generic string, and the tests assert the refused destination never appears in the rendered HTML.
- i18n.
refused_link_destinationis added to every locale file in the diff, en-XA included.
A small visual change that adds no new restriction. The convention note in frontend-conventions.md matches the code.
A chat link whose destination the link policy refuses rendered as plain prose, indistinguishable from the sentence around it. Both chat renderers (MdAnchor and Mochi's ChatPanelMarkdown) now give the inert label a muted dotted underline from existing tokens, plus a generic translated reason as the hover title and as a visually-hidden suffix. Allowed links are unchanged and the label is still never an anchor. Fixes #9945 (cherry picked from commit 0975050)
Problem / Motivation
Goal: When a chat link's destination is refused by the link policy, the reader sees that a link was there and why it does nothing, instead of a label that looks like ordinary prose.
A chat message like
open [my note](obsidian://vault/note)or[click me](javascript:alert(1))renders its label as plain text: the destination is refused (correctly), but nothing on screen says so. The reader cannot tell a refused link from a normal word, so the message reads as if the agent forgot the link.Why it matters
Agents regularly send custom-scheme deep links (obsidian://, other app schemes) and occasionally empty
[x]()links. Today those silently lose their destination, and the user has no clue to ask for the raw URL or to open it another way. A small, muted cue closes that gap without making a refused destination clickable.Not a goal
javascript:/data:vs empty). The reason is one generic sentence.Preview.tsx, which is not a chat renderer and keeps its plain span.docs/decisions/entry. The issue asks a maintainer to choose between keeping silent prose and adding a cue; this draft is the concrete form of the cue option for that choice, and an entry can only record a decision a maintainer made.What changed (motivation → approach → change)
<span>{children}</span>with no styling, title or accessible text.text-muted,decoration-mutedin the dashboard;var(--text-muted)in Mochi, whose windows do not load the dashboard stylesheet), atitlewith the generic reason, and the same reason as visually-hidden text so touch, keyboard and screen-reader users get it too. In the dashboard that text is a::afterpseudo-element fed from adata-refused-reasonattribute (after:sr-only after:content-[attr(data-refused-reason)]), not a text node: inline commenting'sresolveSourcePosaligns the element's text nodes against the source span, so a hidden text node would shift every later selection in the paragraph, and copying a message would paste the reason into the sentence. Mochi has no sourcePos mode and no stylesheet for a pseudo-element, so it keeps a visually-hidden span markeduser-select: none. The reason is a new catalog key,components.markdownRenderer.refused_link_destination("Link not active: its destination can't be opened here."), translated into all 11 shipped catalogs underwebsite/src/i18n/locales/(en.jsonplusde,fr,es,it,pt,ru,ja,ko,zh-CN,hi,bn) and the regenerated pseudolocaleen-XA.json.''sentinel (custom scheme, empty destination) and an href the sanitizer deleted (javascript:,data:), which arrives absent exactly like a raw<a>that never had an href. The deleted-href case cannot be told apart from a raw<a>with no href, so a plain<a>label</a>shares the cue. A raw in-page anchor (nameorid, both kept by the sanitizer) and an anchor with no content are targets, not links, and keep the plain span;website/src/components/markdown/refusedLinkCue.tsholds that one rule for both renderers.website/docs/frontend-conventions.mddocuments the cue next to the existing refused-destination contract.Backwards compatibility
Compatible: only the styling and accessible text of an already-inert span change; no link becomes or stops being an anchor.
Removes nothing: the change adds a class, a title and a hidden suffix to an existing span and removes no path, key or behaviour.
Tests
website/src/test/MarkdownRenderer.test.tsx(rejected link destinations): a refused custom scheme carriesdata-refused-link, the muted dotted classes, the translatedtitleanddata-refused-reason, the::afterclasses, label-onlytextContent, and the output never contains the destination; a sourcePos regression selectstargetafter a refused link intarget\n\nSee [note](obsidian://vault/note) target.and assertsresolveSourcePosreturns line 3, column 35 (it returnsundefinedwhen the reason is a text node);javascript:,data:,[label]()and<a>bare</a>all get the same cue, while<a name="install">,<a id="top">, an empty<a name="top"></a>and an empty<a></a>render with no cue and no title. The existing https / vscode controls still render real anchors.website/src/apps/mochi/test/mochiRefusedLinkAnchor.test.tsx: the same cue in Mochi's ChatPanel for obsidian://,javascript:,data:and empty destinations; the https control asserts no cue, and named / id-only / empty anchors get none.origin/main, the new cue tests fail; with the reason rendered as a hidden text node instead of::after, the sourcePos test fails; withwearsRefusedLinkCueforced totrue, both named-anchor tests fail; with the fix, all pass.Proof: not provable -- frontend test (prove.py runs Python only)
Ran:
npx vitest run src/test/MarkdownRenderer src/apps/mochi/testplussrc/test/MarkdownPanelCoverage.test.tsx(121 files, 1640 tests pass),I18N_BASE_REF=origin/main npx vitest run src/i18n(54 files pass, including catalog parity),tsc --noEmit,eslinton the changed files.Manual verification
Rendered
MarkdownRendererwith the real stylesheet and English catalog in a local loopback Vite harness (not committed) and screenshotted it in dark and light themes with Playwright, plus Mochi'sBubbleunder its own theme. The hovertitleread back as the translated reason in both renderers, and the dashboard label'stextContentread back as the label alone. A third dashboard shot forces the::afterreason visible (outlined) to show what assistive tech reads; a nativetitletooltip does not render in a headless screenshot.Screenshots / video
Dashboard, dark theme: an allowed link (accent) above three refused ones (custom scheme,
javascript:, empty), each muted with a dotted underline.Dashboard, light theme, same content.
Dashboard with the visually-hidden reason forced visible (dashed outline added for the shot only): the text screen readers announce after each refused label, and the same string as the hover title.
Mochi chat bubble, same content: the same muted dotted cue.
Related Issues
Fixes #9945
Sibling sweep
Swept: git grep -nE "children}|href ? <a" -- website/src
Sibling: website/src/components/MarkdownRenderer.tsx -- changed here
Sibling: website/src/apps/mochi/src/renderer/ChatPanelMarkdown.tsx -- changed here
Sibling: website/src/apps/md-notebook/Preview.tsx -- not affected -- notebook preview, not a chat renderer; scoped out in Not a goal
Pattern harvest
Not generalizable: the cue is a per-renderer presentation choice for one inert-label branch, not a recurring code defect.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.