From f408608db0971e7ffc7d735fc161ddbed6f1ee6a Mon Sep 17 00:00:00 2001 From: Haoqing Wang <78337154+hqhq1025@users.noreply.github.com> Date: Fri, 17 Apr 2026 11:37:06 +0800 Subject: [PATCH] fix(web): exclude brackets from CJK autolink punctuation stripping (#486) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(web): exclude brackets from CJK autolink punctuation stripping Fullwidth brackets and parentheses (()【】「」etc.) can appear in valid URL paths, so they should not be stripped. Narrow the regex to only sentence-ending punctuation: comma, period, semicolon, colon, exclamation, question mark. via [HAPI](https://hapi.run) Co-Authored-By: HAPI * fix(web): always show 'Agent launched' for internal metadata results The tool state is set to 'completed' immediately when the result arrives, so the state-based label was always showing 'Done' for internal launch metadata. Remove the state check and always show 'Agent launched'. via [HAPI](https://hapi.run) Co-Authored-By: HAPI * fix(web): handle sentence-ending punctuation followed by closing brackets The regex was missing cases like 。) where a sentence-ender is followed by a closing bracket. Use a pattern that matches sentence-ending punctuation optionally followed by trailing closing brackets/parens. A bare closing bracket without a preceding sentence-ender is still preserved as a valid URL character. via [HAPI](https://hapi.run) Co-Authored-By: HAPI --------- Co-authored-by: HAPI --- .../components/ToolCard/views/_results.tsx | 3 +-- web/src/lib/remark-strip-cjk-autolink.test.ts | 19 +++++++++++++++++++ web/src/lib/remark-strip-cjk-autolink.ts | 8 ++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/web/src/components/ToolCard/views/_results.tsx b/web/src/components/ToolCard/views/_results.tsx index 0f4630c4..26d7b15a 100644 --- a/web/src/components/ToolCard/views/_results.tsx +++ b/web/src/components/ToolCard/views/_results.tsx @@ -536,8 +536,7 @@ const AgentResultView: ToolViewComponent = (props: ToolViewProps) => { || (text.startsWith('Async agent launched successfully.') && text.includes('agentId:')) if (isInternalMeta) { - const label = state === 'completed' ? 'Done' : 'Agent launched' - return
{label}
+ return
Agent launched
} return ( diff --git a/web/src/lib/remark-strip-cjk-autolink.test.ts b/web/src/lib/remark-strip-cjk-autolink.test.ts index f6bf9ba1..7db656bb 100644 --- a/web/src/lib/remark-strip-cjk-autolink.test.ts +++ b/web/src/lib/remark-strip-cjk-autolink.test.ts @@ -83,6 +83,25 @@ describe('remarkStripCjkAutolink', () => { expect(tree.children[0].children.length).toBe(2) }) + it('does not strip fullwidth brackets/parens that may be part of the URL', () => { + const tree = makeAutolink('https://example.com/路径)') + transform(tree) + + const link = tree.children[0].children[1] + expect(link.url).toBe('https://example.com/路径)') + expect(tree.children[0].children.length).toBe(2) + }) + + it('strips sentence-ending punctuation followed by closing bracket', () => { + const tree = makeAutolink('https://example.com/path。)') + transform(tree) + + const paragraph = tree.children[0] + const link = paragraph.children[1] + expect(link.url).toBe('https://example.com/path') + expect(paragraph.children[2].value).toBe('。)') + }) + it('does not modify explicit markdown links', () => { // Explicit markdown link: [click here](https://example.com/path)) // The link text differs from the URL, so it's not an autolink diff --git a/web/src/lib/remark-strip-cjk-autolink.ts b/web/src/lib/remark-strip-cjk-autolink.ts index ab4fff26..93a521dd 100644 --- a/web/src/lib/remark-strip-cjk-autolink.ts +++ b/web/src/lib/remark-strip-cjk-autolink.ts @@ -10,10 +10,10 @@ * node. */ -// Common CJK / fullwidth punctuation that should never be part of a URL. -// Includes: fullwidth comma/period/semicolon/colon/exclamation/question/parens, -// ideographic comma/period, CJK brackets, ideographic space, fullwidth full stop. -const TRAILING_CJK_PUNCT = /[,。、;:!?()【】「」『』《》〈〉\u3000\uFF0E]+$/ +// CJK / fullwidth sentence-ending punctuation that should never be part of a +// URL, optionally followed by closing brackets/parens (which on their own are +// valid URL characters but should be stripped when they trail sentence-enders). +const TRAILING_CJK_PUNCT = /(?:[,。、;:!?\u3000\uFF0E]+[)】」』》〉]*)$/ interface MdastNode { type: string