Skip to content

fix(terminal): end a url at CJK punctuation instead of swallowing it - #15240

Merged
nwparker merged 1 commit into
mainfrom
nwparker/terminal-cjk-url-terminator
Aug 18, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/terminal-cjk-url-terminator

Conversation

@nwparker

@nwparker nwparker commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​44 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​44
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9

Closes #10571.

Terminal URL detection treated every non-ASCII character as part of the url, so Japanese or Chinese text written straight after one was absorbed into the link:

- PR: https://github.com/org/repo/pull/12345(作成済み・マージ待ち)

underlined the whole run, and ⌘-click opened the annotation percent-encoded onto the end of the url, which 404s.

Root cause

isHttpUrlBodyTerminator (terminal-http-url-extraction.ts) listed only ASCII code points, so nothing at or above 0x80 could ever end a url — not full-width brackets, not an ideographic space, not 、, 。 or ・.

The obvious fix is wrong, and I shipped it first

RFC 3986 says URIs are ASCII, so "terminate on any non-ASCII" looks correct. It made all three reported cases pass — and broke four existing tests:

× opens a URL when a wide glyph starts the continuation row
× opens a URL when a multi-code-point wide cell starts the continuation row
× reconstructs a wide-glyph URL whose row span exceeds the single-width column bound
× joins a real multi-line URL whose continuation is a Chinese path segment

Those tests are right. A url path may legitimately carry unencoded CJK, and edge-wrapped-terminal-http-links.test.ts:352 deliberately covers https://example.com/…文档/路径 wrapped across rows. Terminating on non-ASCII would have fixed one CJK bug by creating another.

The distinction is punctuation, not ASCII. Non-ASCII punctuation, symbols and separators end a url; letters do not. Full-width brackets, an ideographic space, a full-width comma and the katakana middle dot are prose. 文档 in a path is not.

Behaviour

input result
…/12345(作成済み・マージ待ち) stops at (
詳細は「https://example.com/docs」を参照 stops at 」
…/a (全角スペース区切り) stops at U+3000
…/a、次へ stops at 、
https://example.com/文档/路径 stays one url
https://example.com/a_b-c?d=1&e=2#f unchanged
https://example.com/a. trailing . still trimmed

ASCII handling is untouched — the existing explicit ASCII lists still run, so this cannot change behaviour for a url with no non-ASCII near it.

Tests

terminal-http-url-extraction.ts had no test file of its own; this adds one, covering the reporter's three cases, the CJK-path case that must keep working, and ASCII behaviour as a regression guard.

terminal-http-url-extraction        7 passed
edge-wrapped-terminal-http-links   ) all previously
hard-wrapped-terminal-http-links   ) failing cases
terminal-handle-links              ) now pass
                                    50 passed (50)

Note

This is the mirror image of #13396, where file link detection truncated at the first non-Latin character so CJK paths never opened. Different module, opposite failure, same underlying gap: neither had a considered rule for where non-ASCII belongs in a path.

Terminal URL detection treated every non-ASCII character as part of the
url, so Japanese or Chinese text written straight after one was absorbed
into the link. A line like

  PR: https://github.com/org/repo/pull/12345(作成済み・マージ待ち)

underlined the whole run and opened the annotation percent-encoded onto
the end of the url, which 404s.

The body terminator listed only ASCII codes, so nothing at or above 0x80
could end a url.

Terminating on all non-ASCII is the obvious repair and is wrong: a url
path may legitimately carry unencoded CJK, and the wrapped-url tests
cover exactly that - a real multi-line url whose continuation row is a
Chinese path segment. That repair was written first and broke four of
them.

The distinction is punctuation, not ASCII. Non-ASCII punctuation,
symbols and separators end a url; letters do not. Full-width brackets,
an ideographic space, a full-width comma and the katakana middle dot are
prose; 文档 in a path is not.

Adds the extraction test file the module never had, covering the
reporter's three cases, the CJK-path case that must keep working, and
ASCII behaviour as a regression guard.

Closes #10571
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

HTTP URL extraction now treats qualifying non-ASCII punctuation, symbols, and separators as URL terminators. Non-ASCII path characters, including CJK characters, remain valid URL content. Tests cover full-width punctuation, spaces, ASCII URL punctuation, CJK paths, and trailing ASCII punctuation.

Merge Risk: 🟡 Moderate · up to 6e887

The URL extraction change still absorbs some Unicode characters into links, which can make affected URLs open incorrectly. Merge should wait for this bounded correctness issue to be fixed.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the terminal URL parsing fix for CJK punctuation.
Description check ✅ Passed The description explains the problem, solution, linked issue, behavior, and tests, but it omits the required Visual Proof and checklist sections.
Linked Issues check ✅ Passed The implementation meets issue #10571 by terminating URLs at CJK punctuation while preserving valid CJK path characters.
Out of Scope Changes check ✅ Passed The production and test changes are limited to Unicode-aware terminal URL extraction and its regression coverage.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 43f840eb-55e7-4fd3-8efd-fbe0380d8f09

📥 Commits

Reviewing files that changed from the base of the PR and between d143922 and 6e8875d.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/terminal-http-url-extraction.test.ts
  • src/renderer/src/components/terminal-pane/terminal-http-url-extraction.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 2 remain after this review.

Comment on lines +150 to +151
function isNonAsciiUrlTerminator(code: number): boolean {
return code > 0x7e && NON_ASCII_URL_TERMINATOR.test(String.fromCharCode(code))

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

file='src/renderer/src/components/terminal-pane/terminal-http-url-extraction.ts'
test_file='src/renderer/src/components/terminal-pane/terminal-http-url-extraction.test.ts'

printf '%s\n' '--- target implementation ---'
cat -n "$file" | sed -n '1,230p'

printf '%s\n' '--- focused tests ---'
cat -n "$test_file" | sed -n '1,180p'

printf '%s\n' '--- related symbols and call sites ---'
rg -n -C 3 'isNonAsciiUrlTerminator|isHttpUrlBodyTerminator|NON_ASCII_URL_TERMINATOR|scanEnd|codePointAt|charCodeAt' \
  "$file" "$test_file"

Repository: stablyai/orca

Length of output: 12590


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
import re
from pathlib import Path

source = Path("src/renderer/src/components/terminal-pane/terminal-http-url-extraction.ts").read_text()
test_source = Path("src/renderer/src/components/terminal-pane/terminal-http-url-extraction.test.ts").read_text()

# Model the exact code path without importing or executing repository code.
terminator = re.compile(r"[\W]", re.UNICODE)  # placeholder for reporting only
print("Target contains charCodeAt:", "charCodeAt" in source)
print("Target contains codePointAt:", "codePointAt" in source)
print("Target contains fromCharCode:", "fromCharCode" in source)
print("Target contains fromCodePoint:", "fromCodePoint" in source)
print("Target contains White_Space:", "White_Space" in source)
print("Target contains property Z:", r"\p{Z}" in source)
print("Tests contain supplementary-plane case:", "💥" in test_source)
print("Tests contain U+0085 case:", r"\u0085" in test_source)
PY

node - <<'JS'
const re = /[\p{P}\p{S}\p{Z}]/u;
const cases = [
  ["💥", [..."💥"][0].codePointAt(0)],
  ["U+0085", "\u0085", "\u0085".codePointAt(0)],
  ["U+00A0", "\u00a0", "\u00a0".codePointAt(0)],
  ["U+2028", "\u2028", "\u2028".codePointAt(0)],
];
for (const entry of cases) {
  const label = entry[0];
  const value = entry.length === 2 ? entry[1] : entry[1];
  const codePoint = value.codePointAt(0);
  const oldInput = String.fromCharCode(codePoint);
  const newInput = String.fromCodePoint(codePoint);
  console.log(JSON.stringify({
    label,
    codePoint: `U+${codePoint.toString(16).toUpperCase()}`,
    oldCodeUnitInput: JSON.stringify(oldInput),
    oldMatches: re.test(oldInput),
    fullCodePointInput: JSON.stringify(newInput),
    fullCodePointMatches: re.test(newInput),
    whiteSpaceMatches: /[\p{P}\p{S}\p{White_Space}]/u.test(newInput),
  }));
}
JS

Repository: stablyai/orca

Length of output: 1074


🏁 Script executed:

#!/bin/bash
set -eu

node - <<'JS'
const oldRe = /[\p{P}\p{S}\p{Z}]/u;
const newRe = /[\p{P}\p{S}\p{White_Space}]/u;
for (const [label, value] of [
  ["💥", "💥"],
  ["U+0085", "\u0085"],
  ["U+00A0", "\u00a0"],
  ["U+2028", "\u2028"],
]) {
  const codePoint = value.codePointAt(0);
  const oldCodeUnitInput = String.fromCharCode(codePoint);
  const fullCodePointInput = String.fromCodePoint(codePoint);
  console.log(JSON.stringify({
    label,
    codePoint: `U+${codePoint.toString(16).toUpperCase()}`,
    oldCodeUnitInput: JSON.stringify(oldCodeUnitInput),
    oldMatchesOldInput: oldRe.test(oldCodeUnitInput),
    fullCodePointInput: JSON.stringify(fullCodePointInput),
    oldMatchesFullCodePoint: oldRe.test(fullCodePointInput),
    whiteSpaceMatchesFullCodePoint: newRe.test(fullCodePointInput),
  }));
}
JS

Repository: stablyai/orca

Length of output: 912


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path

for name in (
    "src/renderer/src/components/terminal-pane/terminal-http-url-extraction.ts",
    "src/renderer/src/components/terminal-pane/terminal-http-url-extraction.test.ts",
):
    lines = Path(name).read_text().splitlines()
    print(f"--- {name} ({len(lines)} lines) ---")
    for number, line in enumerate(lines, 1):
        if name.endswith(".ts") and not name.endswith(".test.ts") and 120 <= number <= 180:
            print(f"{number}: {line}")
        if name.endswith(".test.ts") and number <= 100:
            print(f"{number}: {line}")
PY

node - <<'JS'
const oldTerminator = (code) =>
  code <= 0x7e ? false : /[\p{P}\p{S}\p{Z}]/u.test(String.fromCharCode(code));
const newTerminator = (code) =>
  code <= 0x7e ? false : /[\p{P}\p{S}\p{White_Space}]/u.test(String.fromCodePoint(code));

function scan(text, useNew) {
  const terminator = useNew ? newTerminator : oldTerminator;
  let index = 0;
  while (index < text.length) {
    const code = useNew ? text.codePointAt(index) : text.charCodeAt(index);
    if (terminator(code)) return index;
    index += useNew && code > 0xffff ? 2 : 1;
  }
  return text.length;
}

for (const suffix of ["💥text", "\u0085text", "\u00a0text", "\u2028text"]) {
  const input = "https://example.com/a" + suffix;
  console.log(JSON.stringify({
    suffix: JSON.stringify(suffix),
    oldStop: scan(input.slice("https://example.com/a".length), false),
    newStop: scan(input.slice("https://example.com/a".length), true),
  }));
}
JS

Repository: stablyai/orca

Length of output: 3921


Scan URL terminators by Unicode code point.

The current scan includes 💥text and \u0085text in the extracted URL. Use codePointAt/fromCodePoint, advance by the code-point width, and replace \p{Z} with \p{White_Space}. Add regressions for both inputs.

📍 Affects 2 files
  • src/renderer/src/components/terminal-pane/terminal-http-url-extraction.ts#L150-L151 (this comment)
  • src/renderer/src/components/terminal-pane/terminal-http-url-extraction.test.ts#L30-L33

@nwparker
nwparker merged commit 2b057eb into main Aug 18, 2026
47 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…tablyai#15240)

Terminal URL detection treated every non-ASCII character as part of the
url, so Japanese or Chinese text written straight after one was absorbed
into the link. A line like

  PR: https://github.com/org/repo/pull/12345(作成済み・マージ待ち)

underlined the whole run and opened the annotation percent-encoded onto
the end of the url, which 404s.

The body terminator listed only ASCII codes, so nothing at or above 0x80
could end a url.

Terminating on all non-ASCII is the obvious repair and is wrong: a url
path may legitimately carry unencoded CJK, and the wrapped-url tests
cover exactly that - a real multi-line url whose continuation row is a
Chinese path segment. That repair was written first and broke four of
them.

The distinction is punctuation, not ASCII. Non-ASCII punctuation,
symbols and separators end a url; letters do not. Full-width brackets,
an ideographic space, a full-width comma and the katakana middle dot are
prose; 文档 in a path is not.

Adds the extraction test file the module never had, covering the
reporter's three cases, the CJK-path case that must keep working, and
ASCII behaviour as a regression guard.

Closes stablyai#10571
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…tablyai#15240)

Terminal URL detection treated every non-ASCII character as part of the
url, so Japanese or Chinese text written straight after one was absorbed
into the link. A line like

  PR: https://github.com/org/repo/pull/12345(作成済み・マージ待ち)

underlined the whole run and opened the annotation percent-encoded onto
the end of the url, which 404s.

The body terminator listed only ASCII codes, so nothing at or above 0x80
could end a url.

Terminating on all non-ASCII is the obvious repair and is wrong: a url
path may legitimately carry unencoded CJK, and the wrapped-url tests
cover exactly that - a real multi-line url whose continuation row is a
Chinese path segment. That repair was written first and broke four of
them.

The distinction is punctuation, not ASCII. Non-ASCII punctuation,
symbols and separators end a url; letters do not. Full-width brackets,
an ideographic space, a full-width comma and the katakana middle dot are
prose; 文档 in a path is not.

Adds the extraction test file the module never had, covering the
reporter's three cases, the CJK-path case that must keep working, and
ASCII behaviour as a regression guard.

Closes stablyai#10571
lazybuttrying pushed a commit to lazybuttrying/orca that referenced this pull request Aug 31, 2026
Space-less languages glue particles onto paths (README.mdへ). Widen
path classes with \p{L} for mid-path CJK (stablyai#13396) and trim non-ASCII
letters after an ASCII extension so the particle is not part of the
link (stablyai#15240 symmetry).
lazybuttrying pushed a commit to lazybuttrying/orca that referenced this pull request Aug 31, 2026
…ary module

Move non-ASCII prose boundary from terminal-http-url-extraction into
src/shared/non-ascii-terminal-text-boundary.ts and wire file-link trim
through the same module (stablyai#15240 mirror).
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#15240)

Terminal URL detection treated every non-ASCII character as part of the
url, so Japanese or Chinese text written straight after one was absorbed
into the link. A line like

  PR: https://github.com/org/repo/pull/12345(作成済み・マージ待ち)

underlined the whole run and opened the annotation percent-encoded onto
the end of the url, which 404s.

The body terminator listed only ASCII codes, so nothing at or above 0x80
could end a url.

Terminating on all non-ASCII is the obvious repair and is wrong: a url
path may legitimately carry unencoded CJK, and the wrapped-url tests
cover exactly that - a real multi-line url whose continuation row is a
Chinese path segment. That repair was written first and broke four of
them.

The distinction is punctuation, not ASCII. Non-ASCII punctuation,
symbols and separators end a url; letters do not. Full-width brackets,
an ideographic space, a full-width comma and the katakana middle dot are
prose; 文档 in a path is not.

Adds the extraction test file the module never had, covering the
reporter's three cases, the CJK-path case that must keep working, and
ASCII behaviour as a regression guard.

Closes stablyai#10571
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.

[Bug]: Terminal URL detection swallows CJK text — non-ASCII characters are never treated as URL terminators

1 participant