Skip to content

fix(ui): show link chips for URLs written in inline code - #141429

Closed
steipete wants to merge 2 commits into
mainfrom
ui/code-span-url-chips
Closed

steipete wants to merge 2 commits into
mainfrom
ui/code-span-url-chips

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a URL written in backticks in a chat message, such as `https://github.com/openclaw/openclaw/pull/141131`, rendered as a plain monospace code span with the full URL. The same URL written bare shows the compact GitHub chip with an icon, a shortened label, and the hover card. Models frequently wrap URLs in backticks, so the chips were missing exactly where they were most useful.

Why This Change Was Made

markdown-it never linkifies inside code_inline, and the Control UI's link classifier only walks link_open tokens, so a backtick-wrapped URL never reached the chip logic. A code span whose entire content is a single absolute HTTP(S) URL is now wrapped in a link inside that same classifier and revisited by it, so GitHub issue and pull-request links get the #number chip and hover card, other GitHub links get the shortened label, and non-GitHub links get their favicon. Session URLs written in backticks are left for the session-link rule that already owns them, and fenced or indented code blocks are untouched. Classification wins over authoring syntax: the inner <code> drops its box and inherits the link typography so the result is indistinguishable from a bare URL.

User Impact

Backtick-wrapped GitHub issue and PR URLs in chat now show the same compact chip, icon, tooltip, and hover card as bare URLs. Other backtick URLs become normal links with a favicon. Code spans containing anything besides a single URL, and all code blocks, render exactly as before.

Evidence

Before and after, light theme (synthetic fixtures):

Before: backtick URLs render as plain code spans
After: backtick URLs render as GitHub chips and favicon links

  • node scripts/run-vitest.mjs ui/src/components/markdown-links.test.ts ui/src/components/markdown.test.ts ui/src/components/github-link-hovercard.test.ts: 3 files, 278 tests passed. The five new inline-code cases failed before the parser change (expected anchor absent) and pass after.
  • ui/src/styles/chat-github-link-presentation.browser.test.ts (Chromium): 5 tests passed, including inherited typography, no inner code box, and identical geometry to the bare-URL chip in light and dark.
  • pnpm check:changed: passed.
  • Independent code review: clean at P2, including the CI repair.
  • CI exposed a selector-dependent contrast check in two jobs. Restoring the ordinary-code selector keeps that coverage intact while the more specific link rule owns the code-URL styling. The contrast and Chromium presentation suites then passed together: 2 files, 10 tests.

Known Gaps

Hover-card fetches were verified against the rendered anchors, not a live Gateway round trip; the hover card keys on href, which is unchanged in shape.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 7, 2026 18:09
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Sep 7, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 7, 2026, 3:11 PM ET / 19:11 UTC.

ClawSweeper review

What this changes

The Control UI gives standalone HTTP(S) URLs written in backticks the existing link presentation, with matching styles, documentation, and regression coverage.

Merge readiness

⛔ Blocked before merge - 3 items remain

The PR remains useful: current main still excludes standalone code spans from link classification. No actionable correctness defect was found, and the maintainer-authored work is protected from cleanup closure.

Priority: P3
Reviewed head: 48089b9d4400a7df67b2544bf364cb4784a39019

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with useful boundary coverage and no identified correctness defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary external-contributor proof gate does not apply to this maintainer-authored PR. Its body supplies visual fixtures and reports parser/browser checks for the changed classifier and CSS; attachment retrieval failed here, and no live hover-card round trip is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary external-contributor proof gate does not apply to this maintainer-authored PR. Its body supplies visual fixtures and reports parser/browser checks for the changed classifier and CSS; attachment retrieval failed here, and no live hover-card round trip is claimed.
Evidence reviewed 6 items Introduced behavior: The pinned introduced patch wraps eligible code spans in anchors, avoids nested authored links, and defers recognized session URLs to their existing owner.
Still necessary on current main: Inspection of the fetched main parser confirms that web-link classification only enters through link_open tokens; standalone code_inline URLs remain excluded. No merged replacement was established. The supplied related profiler PR is an example link, not a fix for this behavior. The latest-release parser blob was unavailable, so release inclusion is not claimed.
Safety and navigation boundaries: The existing sanitizer restricts anchor protocols and applies noreferrer/noopener; session-link handling retains origin checks. Hover-card activation continues to parse the anchor href. No dependency, permission, credential, or persistent-state change is introduced.
Findings None None.
Security None None.

How this fits together

The Control UI turns chat Markdown into sanitized HTML. Its link classifier adds compact GitHub labels and favicon placeholders, while existing navigation and hover-card handlers consume the resulting anchors.

flowchart LR
  A[Chat Markdown] --> B[Markdown tokens]
  B --> C{Standalone web URL in code?}
  C -->|Yes| D[Existing link classification]
  C -->|No| E[Preserve ordinary code and session handling]
  D --> F[Sanitized HTML]
  E --> F
  F --> G[Styled links and hover cards]
Loading

Before merge

  • Resolve merge risk (P1) - The submitted before/after attachments could not be fetched in this review environment, leaving visual verification incomplete.
  • Resolve merge risk (P1) - The PR explicitly leaves live Gateway hover-card fetching unverified; source inspection confirms reuse of the existing href-based handler.
  • Complete next step (P2) - Inspect the supplied before/after screenshots to complete visual verification; they were inaccessible in this review environment.
Agent review details

Security

None.

PR surface

Source +38, Tests +87, Docs 0. Total +125 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 41 3 +38
Tests 2 95 8 +87
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 137 12 +125

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one link-classification flow for standalone URLs while preserving authored destinations, session navigation, and ordinary code content.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one link-classification flow for standalone URLs while preserving authored destinations, session navigation, and ordinary code content.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a broken-contract bug: existing documentation explicitly excluded code spans; this PR extends their presentation. The old rendering path is clear from current-main source.

Is this the best way to solve the issue?

Yes. Reusing the classifier and retaining the session-link exception is a narrow approach that avoids a competing renderer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 749ea74bbbe6.

Labels

Label justifications:

  • P3: This is bounded chat presentation polish with no established loss of messages, state, or availability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The ordinary external-contributor proof gate does not apply to this maintainer-authored PR. Its body supplies visual fixtures and reports parser/browser checks for the changed classifier and CSS; attachment retrieval failed here, and no live hover-card round trip is claimed.

Evidence

What I checked:

  • Introduced behavior: The pinned introduced patch wraps eligible code spans in anchors, avoids nested authored links, and defers recognized session URLs to their existing owner. (ui/src/components/markdown-parser.ts:515, 48089b9d4400)
  • Still necessary on current main: Inspection of the fetched main parser confirms that web-link classification only enters through link_open tokens; standalone code_inline URLs remain excluded. No merged replacement was established. The supplied related profiler PR is an example link, not a fix for this behavior. The latest-release parser blob was unavailable, so release inclusion is not claimed. (ui/src/components/markdown-parser.ts:505, 749ea74bbbe6)
  • Safety and navigation boundaries: The existing sanitizer restricts anchor protocols and applies noreferrer/noopener; session-link handling retains origin checks. Hover-card activation continues to parse the anchor href. No dependency, permission, credential, or persistent-state change is introduced. (ui/src/components/markdown.ts:444, 48089b9d4400)
  • Focused regression coverage: Parser cases cover standalone and padded URLs, authored-link destinations, non-URL code, favicon metadata, and fenced blocks; existing session cases cover local and external inline URLs. Browser cases compare typography, geometry, wrapping, hover, and keyboard focus in both themes. Tests were inspected, not executed. (ui/src/components/markdown-links.test.ts:843, 48089b9d4400)
  • Submitted proof and review continuity: The captured body at sourceRevision 7f91a7607e49ab85700b608a46f0fe72017fd18947aab33209a37b2dfe9658c0 supplies before/after synthetic-fixture screenshots and reports parser, Chromium, and contrast checks. Both attachment fetches failed, preventing visual inspection. The previous review projection contains no findings; its earlier SHA was unavailable for comparison. Current source preserves the ordinary-code selector described by the follow-up commit. (ui/src/styles/chat/text.css:808, 48089b9d4400)
  • Area history: Main history identifies Peter Steinberger in recent GitHub-reference, reference-chip, session-link, and file-link work. This supports routing relevance; exact source-line introduction was not established. (ui/src/components/markdown-parser.ts, 127ecdd810b5)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Inspect the existing before/after screenshots to complete the visual review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-07T18:16:56.738Z sha 3366ca1 :: blocked before merge. :: none
  • reviewed 2026-09-07T18:28:44.500Z sha 07f99cf :: needs maintainer review before merge. :: none

Chat URLs written in backticks rendered as plain code spans because inline code never reached the web-link classifier. Route code spans containing one absolute HTTP(S) URL through the existing link presentation, preserving session-link ownership and ordinary code content. Match the surrounding chip typography and document the behavior with focused parser and browser coverage.
The inline URL chip change unnecessarily changed the ordinary-code selector, breaking the contrast check that reads its tokens. Keep that selector intact and let the more specific link rule remove the inner code box. Contrast and Chromium presentation tests verify both behaviors together.
@steipete
steipete force-pushed the ui/code-span-url-chips branch from 07f99cf to 48089b9 Compare September 7, 2026 19:05
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #141446, which landed the same backtick-URL promotion for github.com links (chip, tooltip, hover card) with a simpler text-token approach that needs no CSS change. Closing this PR rather than rebasing it.

The one behavior this branch had beyond #141446 was promoting non-GitHub backtick URLs to favicon links while deferring session URLs to the session-link rule. #141446 deliberately keeps non-GitHub code spans as code, so that stays a separate product decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant