Skip to content

fix(platform): chat markdown link routing + PII precheck send wedge#1647

Merged
larryro merged 3 commits into
mainfrom
fix/chat-link-routing-and-send-wedge
Apr 29, 2026
Merged

fix(platform): chat markdown link routing + PII precheck send wedge#1647
larryro merged 3 commits into
mainfrom
fix/chat-link-routing-and-send-wedge

Conversation

@larryro

@larryro larryro commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Route same-origin markdown anchors through TanStack router instead of always opening in a new tab; external links keep target=_blank + rel=noopener noreferrer. Adds lib/utils/link-classifier.ts to classify internal/external/hash/special hrefs.
  • Reset sendingRef when the PII precheck blocks a message so subsequent sends aren't silently no-oped (toast now fires every time).

Test plan

  • Send a message with a markdown link to an in-app path — verify it navigates client-side without a full reload.
  • Send a message with an external link — verify it opens in a new tab.
  • Send a message with mailto: / hash anchors — verify default browser behavior.
  • Trigger PII detection twice in a row — toast should appear both times and chat input should remain usable.
  • bun run check passes.

Summary by CodeRabbit

  • New Features

    • Improved link handling in chat messages: internal links now navigate within the app, while external links open in new tabs.
  • Bug Fixes

    • Fixed message sending becoming stuck after guardrails-blocked messages are encountered.

larryro added 3 commits April 29, 2026 11:56
Markdown anchors previously always opened in a new tab. Same-origin
links now navigate via TanStack router; external links keep the
target=_blank + noopener treatment.
Without resetting sendingRef on the blocked path, a user who triggers
PII detection once couldn't send any subsequent message — the toast
fired only on the first attempt and later sends were silently no-ops.
LinkKind is only used as classifyLink's return type; exporting it
trips knip's unused-exports check.
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR introduces link classification and conditional markdown anchor rendering, alongside a state management bugfix in message sending. A new link-classifier.ts utility categorizes URLs as internal (same-origin relative paths), external (cross-origin), hash fragments, or special protocols. The markdown renderer uses this classification to render anchors differently: internal links navigate via router without opening new tabs, external links preserve new-tab behavior, and hash/special links render as-is. Additionally, use-send-message.ts now clears the sendingRef flag when guardrails block a message, preventing the hook from remaining in a "sending" state that would block subsequent sendMessage calls. A test validates this blocking behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the summary of changes and includes a test plan, but the pre-merge checklist is not completed or marked as N/A. Complete the pre-merge checklist by ticking boxes or marking items as N/A with brief reasons, including the required checks for format/lint/typecheck and documentation updates.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the two main changes: markdown link routing improvements and fixing the PII precheck send wedge, which aligns with the changesets.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/chat-link-routing-and-send-wedge

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@services/platform/lib/utils/link-classifier.ts`:
- Around line 1-5: The exported type LinkKind is currently unused and causing CI
failures; make it module-private by removing the export modifier (i.e., change
"export type LinkKind" to "type LinkKind") in link-classifier.ts so the type
remains available internally but is not exported, or alternatively, if another
module genuinely needs it, add an explicit import/usage in that module instead
of leaving an unused export.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 867011db-dab3-4152-a8f1-c1e608eecab0

📥 Commits

Reviewing files that changed from the base of the PR and between ac707a1 and 9a35a77.

📒 Files selected for processing (4)
  • services/platform/app/features/chat/components/message-bubble/markdown-renderer.tsx
  • services/platform/app/features/chat/hooks/__tests__/use-send-message.test.ts
  • services/platform/app/features/chat/hooks/use-send-message.ts
  • services/platform/lib/utils/link-classifier.ts

Comment on lines +1 to +5
export type LinkKind =
| { kind: 'internal'; to: string }
| { kind: 'external'; href: string }
| { kind: 'hash'; href: string }
| { kind: 'special'; href: string };

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.

⚠️ Potential issue | 🟠 Major

Fix CI blocker: LinkKind should not be exported if unused.

knip is failing because LinkKind is an unused exported type. Make it module-private unless another file imports it.

Proposed fix
-export type LinkKind =
+type LinkKind =
   | { kind: 'internal'; to: string }
   | { kind: 'external'; href: string }
   | { kind: 'hash'; href: string }
   | { kind: 'special'; href: string };
🧰 Tools
🪛 GitHub Actions: Lint

[error] 1-1: knip reported 'Unused exported types (1)'. LinkKind type is an unused exported type (reported at 1:13).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@services/platform/lib/utils/link-classifier.ts` around lines 1 - 5, The
exported type LinkKind is currently unused and causing CI failures; make it
module-private by removing the export modifier (i.e., change "export type
LinkKind" to "type LinkKind") in link-classifier.ts so the type remains
available internally but is not exported, or alternatively, if another module
genuinely needs it, add an explicit import/usage in that module instead of
leaving an unused export.

@larryro larryro merged commit 46ae8e9 into main Apr 29, 2026
17 checks passed
@larryro larryro deleted the fix/chat-link-routing-and-send-wedge branch April 29, 2026 05:58
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.

1 participant