Skip to content

Navigation Menu

Sign in
Appearance settings
Sign up
Appearance settings

fix(jetbrains): linkify urls inside inline code - #13551

#13551
Open
kirillk wants to merge 2 commits into
mainKilo-Org/kilocode:mainfrom
happy-ferretKilo-Org/kilocode:happy-ferretCopy head branch name to clipboard
Open

fix(jetbrains): linkify urls inside inline code#13551
kirillk wants to merge 2 commits into
mainKilo-Org/kilocode:mainfrom
happy-ferretKilo-Org/kilocode:happy-ferretCopy head branch name to clipboard

Conversation

@kirillk

@kirillk kirillk commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Issue

No issue filed; reported directly while reviewing a JetBrains release report where every URL was unclickable.

Context

In the JetBrains chat transcript, http/https URLs written inside backticks render as inert text — no hover, no cursor change, no click. Agents routinely emit URLs as inline code (release reports, PR links, run URLs), so a large share of the links a user sees in the JetBrains plugin are dead.

The link plumbing itself was fine. The gap is that CommonMark's AutolinkExtension only visits text nodes, never code spans, so `https://…` never becomes an anchor. Bare URLs already worked end to end.

Implementation

The HTML renderer now overrides CommonMark's core Code node renderer. It runs org.nibor.autolink.LinkExtractor over each raw inline-code literal and emits anchors for http/https spans before HtmlWriter escapes their text and attributes. This is the same URL scanner used by CommonMark's existing autolink extension, so trailing punctuation, balanced brackets, quote boundaries, control characters, and Unicode whitespace follow the library's tested behavior instead of custom URL parsing.

Only http and https matches become links. LinkType.URL can detect any scheme://…, while the session link router sends non-file schemes to the browser; filtering here prevents file, ftp, or other schemes from being routed incorrectly.

org.nibor.autolink:autolink:0.12.0 is declared explicitly as an implementation dependency in the frontend module and pinned in the version catalog. We do not rely on an IntelliJ-bundled classpath or on CommonMark's transitive dependency edge. buildPlugin packages it as kilo.jetbrains/lib/autolink-0.12.0.jar in the distributable ZIP.

MdCommon only retains the CSS rule for the generated kilo-url-ref anchors: standard IDE link color and underline while preserving the inline-code monospace font. Existing click handling remains unchanged (MdView.LinkEventopenSessionLinkBrowserUtil.browse), and fenced code remains on the separate editor/code-block rendering path.

Screenshots / Video

N/A — the visual delta is that an inline-code URL picks up the standard IDE link color and underline; there is no new UI surface. Behavior is asserted in tests against the rendered HTMLDocument.

How to Test

Manual/local verification

  • ./gradlew test from packages/kilo-jetbrains/ — passed (executed by the agent)
  • ./gradlew typecheck from packages/kilo-jetbrains/ — passed (executed by the agent)
  • ./gradlew buildPlugin from packages/kilo-jetbrains/ — passed (executed by the agent)
  • Inspected build/distributions/kilo.jetbrains-7.1.0.zip; it contains kilo.jetbrains/lib/autolink-0.12.0.jar (executed by the agent)
  • New tests in MdViewTest (executed by the agent): a code-span URL produces <a class="kilo-url-ref"> plus the matching CSS rule; query separators survive in the href; trailing punctuation and unbalanced brackets stay outside the link; balanced brackets stay inside; URL scanning stops at characters that cannot appear in a URL; autolinked and markdown-link URLs are not wrapped a second time; fenced-code URLs are not linkified; a URL followed by a file reference produces both link kinds.
  • New test in MdViewHybridTest (executed by the agent): the rendered HTMLDocument contains a live A element with the expected href, and activating it dispatches an MdView.LinkEvent.

Reviewer test steps

  1. Run the plugin: ./gradlew runIde from packages/kilo-jetbrains/
  2. In a Kilo chat, send a message that renders a URL in backticks, for example: Release PR: `https://github.com/Kilo-Org/kilocode/pull/13524`
  3. Confirm the URL is underlined in the IDE link color, shows a hand cursor on hover, and opens in the browser on click
  4. Confirm a URL inside a fenced code block is still plain text, and that an ordinary bare URL and [text](url) link still behave as before

Blocked checks and substitute verification

  • None; all relevant checks ran.

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

Get in Touch

N/A

CommonMark's autolink extension skips code spans, so a URL written in
backticks rendered as inert text in chat messages while bare URLs became
links. Extend the post-render pass in MdCommon that already linkifies
file references so it also wraps http(s) URLs, giving them link color,
underline, hover, and click handling inside inline code.
@kilo-code-bot

kilo-code-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • packages/kilo-jetbrains/frontend/build.gradle.kts
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/MdCommon.kt
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/hybrid/MdProjector.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/md/MdViewTest.kt
  • packages/kilo-jetbrains/gradle/libs.versions.toml
Previous Review Summary (commit 1d6744e)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 1d6744e)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • .changeset/jetbrains-inline-code-urls.md
  • packages/kilo-jetbrains/frontend/src/main/kotlin/ai/kilocode/client/ui/md/MdCommon.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/md/MdViewHybridTest.kt
  • packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/md/MdViewTest.kt

Reviewed by grok-4.6 · Input: 144.5K · Output: 12.9K · Cached: 311.4K

Review guidance: REVIEW.md from base branch main

}

/** Trims a raw URL match down to the part that belongs to the link. */
private fun cut(value: String): String {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a standard lib for that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — org.nibor.autolink is already the scanner behind CommonMark’s AutolinkExtension. I replaced the custom regex/cut() boundary logic with LinkExtractor over raw Code AST literals, so punctuation, bracket balancing, quote/control-character boundaries, Unicode whitespace, and escaping all come from the library/CommonMark renderer. Updated in 46a885c.

I also made org.nibor.autolink:autolink:0.12.0 an explicit pinned implementation dependency rather than relying on the transitive edge or the IDE classpath. ./gradlew buildPlugin succeeds, and the resulting ZIP contains kilo.jetbrains/lib/autolink-0.12.0.jar.

Replace the custom URL boundary and bracket trimming logic with the same
org.nibor.autolink scanner used by CommonMark's autolink extension. Run
it against raw inline-code AST literals so HtmlWriter owns escaping, and
declare the dependency explicitly so Gradle bundles it with the plugin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.