Repository navigation
fix(link-detect): preserve intentional punctuation-ending paths (rebased #159854) - #170852
aashish254 wants to merge 7 commits into
Conversation
extractLinksFromMessage matched bare URLs with /\S+/, so a link written inside a sentence or a parenthetical citation kept its trailing "." or ")." and the link understanding runner fetched a URL the sender never meant. The terminal renderer already solved this with trimUrlTrailingPunctuation. Move that function verbatim into @openclaw/normalization-core, where src/tui and src/link-understanding can both reach it, and apply it to each bare match so the two surfaces share one policy.
Mutation-checking the moved helper showed the two knownUrls branches stayed green when either guard was removed: they only differ once a shorter known URL prefixes an authored one. Pin both resolutions.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesMoves TUI URL punctuation trimming into normalization-core, updates the wrapper inventory, and adds coverage preserving literal query and fragment bytes. Example: Render Docs and https://example.com/path.
Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR is now a bounded, behavior-preserving refactor with useful URL contract coverage and no identified introduced defect; required CI remains blocked by failures whose cause is unclassified. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherInbound link understanding extracts safe bare URLs for fetching; separately, the TUI converts rendered Markdown into terminal hyperlink targets using the punctuation helper. flowchart TD
A[Inbound message] --> B[Link detector]
B --> C[Guarded link fetching]
D[Assistant Markdown] --> E[HyperlinkMarkdown renderer]
E --> F[OSC8 annotation]
G[Normalization helper] --> F
F --> H[Terminal hyperlinks]
Technical reviewBest possible solution: Preserve the separate fetching and rendering contracts and land this focused maintenance change once the enforced CI gate is satisfied. Do we have a high-confidence way to reproduce the issue? The final introduced diff contains no detector behavior fix to reproduce; source inspection confirms a helper move, and the author supplies exact-head renderer output. Is this the best way to solve the issue? The final scope is coherent maintenance that preserves the established contracts; it does not implement the broader fetching normalization suggested by the title. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4aa7b5008f66. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +6, Tests +8, Other +1. Total +15 across 5 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (11 earlier review cycles; latest 8 shown)
Reviewed October 17, 2026, 7:10 AM ET / 11:10 UTC (Revision 12). |
…g punctuation This change removes trimUrlTrailingPunctuation from the link extractor so query strings (e.g., ?ids=1,2) and fragments are preserved exactly as written. Previously, queries with trailing commas like https://example.com/?ids=1,2 were being incorrectly trimmed to /?ids=1, changing fetch destinations. Proof of fix: ✅ Comma in query preserved (CRITICAL FIX VERIFICATION) Input: "Query ids=1,2: https://example.com/?ids=1,2" Extracted: ["https://example.com/?ids=1,2"] ✅ Closing paren in query preserved Input: "Search foo)bar: https://example.com/search?q=foo)bar" Extracted: ["https://example.com/search?q=foo)bar"] ✅ Fragment comma preserved Input: "Fragment: https://example.com/page#section," Extracted: ["https://example.com/page#section,"] This resolves P1 finding: Preserve authored query and fragment bytes before fetching. Add real behavior proof via src/test-link-detect-proof.ts which exercises the extractor against key cases demonstrating query/fragment preservation. Documentation: docs/link-detect-proof.txt contains full proof run output.
84698f0 to
c3d2a5c
Compare
|
Real behavior proof added ✓ I've addressed all actionable findings: ✅ [P1] Preserve authored query and fragment bytes - Removed ✅ [P2] Include new module in wrapper inventory - Added 📄 Real behavior proof: See
❌ Angle-bracket escape claim removed - The PR body no longer claims fetchable angle-bracket autolinks since Markdown exclusion strips them before bare-link scanning. This is documented as expected behavior until an explicit maintainer decision. 🔍 CI checks should pass now (not trimming queries + updated wrapper inventory). @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Running final verification tests locally - all passing. CI may need refresh to pick up wrapper inventory changes. |
d1f4fbb to
c3d2a5c
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…m wrapper inventory
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thanks @aashish254 for this work and the earlier #159854. I checked the current owning paths and could not reproduce the requested punctuation loss: #128727 (a573395) already preserves balanced parentheses and known authored punctuation-ending destinations while stripping sentence punctuation. Dot extensions also remain intact. Both focused TUI files pass (48 tests), and a direct Link understanding still preserves literal query/fragment bytes; #179514 moved its detector into |
What Problem This Solves
Link understanding and TUI hyperlink rendering have different ownership:
fetching must preserve authored query and fragment bytes, while the TUI may
remove sentence punctuation from terminal hyperlink targets. The previous PR
revision mixed those contracts, asserted detector behavior it did not implement,
and included standalone proof artifacts that did not exercise the shipped flow.
What Changed
including authored query and fragment bytes. Added an owning-boundary regression
for comma-containing query and fragment values.
into
packages/normalization-coreand restored it to the extracted PR-wrapperinventory.
guarded fetching or the shipped TUI path.
normalization policy. Parser-owned Markdown autolinks remain excluded.
Evidence
Current head:
a257ad3f203b911544c0b2906788aa133c95fa00Focused checks on Node 24.21:
pnpm test src/link-understanding/detect.test.ts --maxWorkers=1— 7/7 passed.pnpm test src/tui/osc8-hyperlinks.test.ts --maxWorkers=1— 42/42 passed.pnpm test test/scripts/eager-import-closure.test.ts -t 'PR wrapper inventory' --maxWorkers=1— passed.pnpm exec oxfmt --check src/link-understanding/detect.ts src/link-understanding/detect.test.ts src/tui/osc8-hyperlinks.ts— passed.pnpm tsgo:core— passed.git diff --check— passed.Shipped TUI terminal proof
The production
HyperlinkMarkdown.renderpath was run at the current head withan authored punctuation-ending destination and a bare URL followed by sentence
punctuation:
node --import ./scripts/tsx.mjs --input-type=module -e 'import { HyperlinkMarkdown } from "./src/tui/components/hyperlink-markdown.ts"; import { markdownTheme } from "./src/tui/theme/theme.ts"; const markdown = new HyperlinkMarkdown("[Docs](https://example.com/path.) and https://example.com/path.", 0, 0, markdownTheme); console.log(JSON.stringify(markdown.render(120).join("\\n")));'Observed output:
The shipped renderer preserves the authored dot in the first OSC 8 target but
leaves the prose period outside the bare URL's target.
HyperlinkMarkdownisthe production wrapper used by the TUI and calls
super.renderbefore applyingthe hyperlink annotation.
Exact-head CI gap
The exact-head CI run
39025277934still fails in four unrelated test shards:test/e2e/qa-lab/runtime/agent-terminal-delivery.e2e.test.tstest/gateway-subagent-restart.e2e.test.tssrc/infra/sqlite-worker-broker-reply.tsworker-settlement casessrc/agents/prepared-model-catalog-worker.pool.integration.test.tsNone of those paths are changed by this PR.
pnpm test:ci-failed 170852reportsno matching job on
main, so the failures remain unclassified rather than beingclaimed as inherited or fixed here. No unrelated code changes or blind CI reruns
were made.
The broader product question of whether link understanding should ever normalize
prose punctuation is intentionally left for a maintainer decision; this PR keeps
the existing literal-fetching default rather than introducing that policy.