Repository navigation
fix(markdown): keep a link's parenthesised URL whole outside chat - #15714
iamwhatever merged 1 commit into
Conversation
Opus 5 Review (fork) — ✅ no blocking findingsReviewed Review detailsAdvisory only: an unbalanced FINDING — src/kiro_crew/dashboard/handlers/artifacts.py:582 — a truncated link such as [OPUS-REVIEWED] 2065bdf |
bd80a8f to
47e5871
Compare
|
Rebased: main moved in files beside this PR's ( The re-run also repeats the lanes a GitHub installation rate limit stopped on the previous head: Security Scope Review wrote no candidates, Design and First Principles reported incomplete, and the GPT lane passed without posting its comment. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 2065bdf Description read[DESCRIPTION-READ] 11f1ead195123843d0a8776054133d1025cf94a0040d37138c5f0a7b0c28012a 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 |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the one deliberate divergence: these four labels keep What this change shipsInventory (8 items) — 8 justifiedIntent: FIX — links whose URLs hold a balanced parenthesis pair render whole in session previews, artifact snippets, voice replies and deploy pages, without quadratic rescans.
[FIRST-PRINCIPLES-REVIEWED] 2065bdf Description read[DESCRIPTION-READ] 6d2dbc32bd03b42a05666746024146b89a98895ee777ccbcb3d2c534884ec666 That sha256 names the PR description this verdict read. Recompute it with |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
47e5871 to
f8587f9
Compare
|
Rebased: main moved since this head's CI ran (7038f5f -> 20a9365, 18 commits). The overlap is same-directory and importing files only; none of this PR's files changed, and the patch is identical. The Opus 5 Review lane on 47e5871 ended "review incomplete" because the fork lane hit "API rate limit exceeded for installation" at 05:31 UTC, before the review ran. CI re-running. |
|
self-added: no
|
|
self-added: no
|
f8587f9 to
54c298e
Compare
|
Re-pushed the same commit (identical tree, same base 20a9365) to rerun CI. Backend Tests (Windows) (2) failed on f8587f9 on one timing-dependent test outside this PR: |
|
self-added: no
|
|
self-added: no
|
The session preview, voice reply, artifact snippet and artifact-deploy page each read a Markdown link with their own pattern, which ended the URL at its first ")". A link such as [Python](https://en.wikipedia.org/wiki/Python_(programming_language)) left a stray ")" after the label in the preview, the snippet and the spoken reply, and the deploy page linked a URL with its ")" cut off. All four build the destination from constants.md_link_destination(), the unit every channel renderer and the display-safety screen use, so a balanced "(...)" pair stays inside the URL. A destination that unit does not read as a link (an unbalanced "(", nesting two deep, an escaped ")" or a nested "[label](") is left as written, as the channel renderers leave it. Each label stops at the next "[", so a long run of "[" is read in linear time. A label that ran on to the next "]" made every opener rescan the rest of the text, which stalled the dashboard's slot preview on a bracket-heavy reply.
54c298e to
2065bdf
Compare
|
Rebased onto d8fa6a5, where main's own CI passes again: every Backend Tests shard and Backend Lint & Type Check are green in run 36832900240. Every red on 54c298e came from main ( |
|
self-added: no
|
|
self-added: no
|
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed. All five link patterns build the URL from md_link_destination and stop the label at the next '['; deploy/render.py still html.escape()s before the regex and re-escapes the href, the scheme stays a literal https?://, and the stricter URL class leaves a non-matching link as escaped text. artifacts.py only produces a snippet through _STRIP_TAGS_RE. Tests pin each behaviour plus the linear-time bound.
Non-blocking: voice_reply.py:420 now reads an unbalanced-paren URL aloud where main read only the label (no test); no test proves the href stays escaped with a quote inside a parenthesised URL.
|
Both notes measured on 2065bdf against main 996b450. voice_reply.py:420: an deploy href: |
Two outputs of the parenthesised-URL sweep (kirodotdev#15714) had no test. A link whose destination holds an unbalanced "(" is not a link, so the voice reply leaves its text as written. A web address in it is still replaced by "(link)", but a relative destination is spoken as written. The artifact-deploy page keeps a quote inside a parenthesised URL escaped as " in the link's href, so it cannot end the attribute. Both outputs are pinned now, so a later change to either fails a test.
Two outputs of the parenthesised-URL sweep (kirodotdev#15714) had no test. A link whose destination holds an unbalanced "(" is not a link, so the voice reply leaves its text as written. A web address in it is still replaced by "(link)", but a relative destination is spoken as written. The artifact-deploy page keeps a quote inside a parenthesised URL escaped as " in the link's href, so it cannot end the attribute. Both outputs are pinned now, so a later change to either fails a test.
Two outputs of the parenthesised-URL sweep (kirodotdev#15714) had no test. A link whose destination holds an unbalanced "(" is not a link, so the voice reply leaves its text as written. A web address in it is still replaced by "(link)", but a relative destination is spoken as written. The artifact-deploy page keeps a quote inside a parenthesised URL escaped as " in the link's href, so it cannot end the attribute. Both outputs are pinned now, so a later change to either fails a test.
…15951) Two outputs of the parenthesised-URL sweep (#15714) had no test. A link whose destination holds an unbalanced "(" is not a link, so the voice reply leaves its text as written. A web address in it is still replaced by "(link)", but a relative destination is spoken as written. The artifact-deploy page keeps a quote inside a parenthesised URL escaped as " in the link's href, so it cannot end the attribute. Both outputs are pinned now, so a later change to either fails a test.
Problem / Motivation
Goal: A Markdown link whose URL holds a balanced pair of parentheses shows only its label in session previews, artifact snippets and spoken replies and links its whole URL on artifact-deploy pages, and a long run of
[no longer stalls any of the four.A link such as
[Python](https://en.wikipedia.org/wiki/Python_(programming_language))still comes out broken in four places outside chat. Each reads links with its own pattern, and each pattern ends the URL at its first).see Python) nowSee Python) docs[docs](https://example.com/a_(b)_c)reads asdocsc)<a href=".../Python_(programming_language">Python</a>), a link to a page that does not existThe same patterns let a label run on to the next
], so in a long run of[every opener rescans the rest of the text. 20,000 of them take 2.4 s in the session preview, which strips the last message of every session the list shows.Why it matters
Agents cite Wikipedia and vendor docs often. Every such message leaves a stray
)in the sidebar preview and the artifact list, a spoken reply reads part of the URL aloud, and a published deploy page sends its readers to a missing page. A reply holding a long run of[holds up the session list.Not a goal
local_review.pymedia filter. It mirrors the review workflow's own perl filter, so it must match that filter rather than CommonMark.What changed (motivation → approach → change)
Session previews, artifact snippets, spoken replies and artifact-deploy pages read a link with a parenthesised URL whole: the first three show only its label, and the deploy page links the full URL. Each of the four patterns ended the URL at its first
)([^)]*). Each now builds it fromconstants.md_link_destination(), the unit every chat channel and the display-safety screen use, which takes one URL character or one balanced(...)group.preview_text.py_IMAGE_RE,_LINK_RE[^()])voice_reply.py_MARKDOWN_LINK_RE[^()]dashboard/handlers/artifacts.py_MD_LINK_RE[^()]deploy/render.py_LINK_RE[^()\s])Each keeps its own character class apart from the parentheses, so a title, a space or a line break in a destination is handled as before. A destination the shared unit does not read as a link is left as written, which is what the chat channels show for it: an unbalanced
(, two levels of nesting, an escaped\), or a[label](inside the URL. On the deploy page that means plain text rather than a link to a cut URL.Each label stops at the next
[([^\[\]]), so a run of[is read in one pass. A label can still span a line break, as CommonMark link text can, so a hard-wrapped label is stripped as before.Backwards compatibility
Compatible: no input is refused. A link is stripped or linked as before unless its destination holds a parenthesis or its label holds a
[. A balanced pair stays inside the URL, and an unbalanced(, deeper nesting, an escaped\)or a nested[label](leaves the link as written instead of cutting it at its first). A label holding a[, as in[a [b](u), starts at its last[and gives[a b, as on every chat channel and in CommonMark.Tests
test/test_preview_text.py: a Wikipedia link previews as its label alone, an image with a parenthesised URL previews as its alt text or(image), and an unbalanced URL is left as written.test/test_voice_reply.py: a parenthesised URL is not spoken, with and without text after the pair.test/test_artifacts_handlers.py: the?snippet=1list snippet of a markdown artifact drops a parenthesised URL whole.test/test_deploy_web_render_scan.py: the deploy page'shrefcarries the whole Wikipedia URL, and an unbalanced URL renders as text with no link.test/test_markdown_link_parentheses.py: the five patterns are timed on 5,000 and 20,000 repeats of[b,]*fails the[b](xcase of the preview, voice and snippet link patterns, and excluding the line break from a label fails that pattern's hard-wrap case.Manual verification
Ran the four call sites on main and on this branch over twelve link shapes: Wikipedia and MSDN URLs, a pair followed by text, a plain URL, unbalanced, two-deep and escaped destinations, a nested link, a titled link, two images and a link in an aside. Only the parenthesised and unlinkable shapes changed, as described above. A label holding
[and a hard-wrapped label were checked separately, with the results stated above.Timed the four sites at 10,000 and 20,000 characters on both. On a run of
[, unclosed[a](openers,(runs after openers and[b](runs inside a URL, main's time grows with the square of the length (up to 2.4 s at 20,000) and this branch's grows linearly (at most 5 ms). One opener followed by 20,000 URL characters takes up to 7 ms here against up to 5 ms on main.Related Issues
no linked issue: #14314 recorded this follow-up in its Pattern harvest; no issue tracks it.
Pattern harvest
Rule candidate: semgrep
Pattern: a Markdown-link regex whose destination is spelled
[^)]…instead of built fromconstants.md_link_destination. After this change the only such regex undersrc/is the prepare-pr filter listed under Not a goal.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)