Skip to content

feat(v2-chat): GitHub PR preview cards + auto-linkify bare URLs#301

Closed
samxu01 wants to merge 1 commit intomainfrom
sam/v2-github-pr-card
Closed

feat(v2-chat): GitHub PR preview cards + auto-linkify bare URLs#301
samxu01 wants to merge 1 commit intomainfrom
sam/v2-github-pr-card

Conversation

@samxu01
Copy link
Copy Markdown
Contributor

@samxu01 samxu01 commented May 4, 2026

Summary

Two related fixes for messages that reference work artifacts.

Bare URLs are clickable now

Previously, raw URLs in messages rendered as plain text. ReactMarkdown's default mode doesn't autolink bare URLs and remark-gfm isn't installed. Pre-process with a regex to wrap bare http(s) URLs in markdown link syntax. Existing messageMarkdownComponents.a handles target=_blank.

GitHub PR URLs render as preview cards

New <V2GithubPrCard> fetches from the public GitHub REST API on mount and renders title, state pill, commit/file counts, line stats, contributor avatars. Click → github.com PR (new tab). Cache memoized at module scope.

Visual

┌───────────────────────────────────────────────────────┐
│ Team-Commonly/commonly                          [Open]│
│ #297 Add sign-up flow per spec                        │
│ 3 commits · 3 files · +48 · −0          [N][C][P] +0  │
└───────────────────────────────────────────────────────┘

Borders, not shadows. One accent. Matches the v2 design system.

Failure modes

  • Private repo / rate-limit / network error → card silently doesn't render; clickable URL stays
  • Bare URL detection skips already-linked URLs (negative lookbehind on (, <, [)
  • 60/hr unauth GitHub rate limit is fine for chat surface; same PR memoized within session

Test plan

  • tsc --noEmit clean
  • Smoke after deploy: post a message with https://github.com/Team-Commonly/commonly/pull/297 — card renders below the bubble with title + state + contributors
  • Bare URL https://example.com renders as clickable link
  • URL inside [text](url) doesn't double-wrap

🤖 Generated with Claude Code

Two related fixes for messages that reference work artifacts.

1. Bare URLs are now clickable
-------------------------------
Previously, agents/users posting raw URLs (e.g.
"#297") rendered as
plain text — no anchor, no click. ReactMarkdown's default mode
doesn't autolink bare URLs and remark-gfm isn't installed.

Quick fix: pre-process message content to wrap bare http(s) URLs
in markdown link syntax `[url](url)` before passing to
ReactMarkdown. Skips URLs already inside markdown link / autolink
syntax via negative lookbehind on `(`, `<`, `[`. Existing
messageMarkdownComponents.a sets target="_blank" + rel.

2. GitHub PR URLs render as inline preview cards
-------------------------------------------------
New V2GithubPrCard component fetches PR meta from the public
GitHub REST API on mount and renders:

- Repo (owner/name)
- State pill (Open / Merged / Closed) with color
- PR number + title
- Commit count, file count, +/- line stats
- Contributor avatars (up to 4, with overflow chip)

Click target is the github.com PR URL (target=_blank).

Detection regex matches `pull/<number>` URLs anywhere in the
message body. Detected URLs are stripped from the rendered text
so we don't double-show "URL as text + URL as card".

Fetch is memoized at module scope — one fetch per (owner, repo,
number) per session. Failure mode (private repo, rate limited,
network error) renders nothing; the parent's clickable URL is the
fallback.

Why this exists
---------------
Agent collaboration in Commonly centers on shared artifacts.
Pull requests are the canonical "this is what the agents shipped"
moment, and showing them as plain text URLs sells the workflow
short. The card visualization makes the multi-vendor contributor
list visible at a glance — exactly the moat moment for any
multi-agent demo.

Net diff:
- New: V2GithubPrCard.tsx (~190 lines incl. fetch + memo + types)
- V2MessageBubble.tsx: +21 lines (parse, strip, linkify, render)
- v2.css: +110 lines (.v2-prcard chrome — borders not shadows,
  one accent, no gradients per the v2 design system)

No new dependencies. No backend changes. Public GitHub API only;
private-repo PRs render the URL only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@samxu01 samxu01 closed this May 4, 2026
@samxu01 samxu01 deleted the sam/v2-github-pr-card branch May 4, 2026 16:30
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