cmux NEXT: bare PR refs in agent replies link to the PR with its hover card

Merged
TE
17d ago
+386-8

In progress: stacked on #22743 (it targets cmux/pr-hover-card until that merges, then feat-cmux-next). Review and merge after #22743 lands.

Stacked on #22743 (cmux/pr-hover-card), which adds the pull request hover card.

Summary

  • A bare pull request reference in an agent reply (#22777, (#22664), owner/repo#123) now links to github.com/{repo}/pull/N, so its chip opens the pull request hover card. If the number is an issue, GitHub redirects to it, and the card shows owner/repo#N.
  • The repository comes from the chat folder's GitHub remote, as before. When the folder has no remote (remote and cloud chats, folders without one), each row uses the repository the transcript mentioned most recently up to that row (an owner/repo#N reference or a github.com URL in a prompt or reply). If there is none, it uses the repository of the header's pull request. Mentions inside code don't count. Each row's text is scanned once per change, not once per render.
  • Matcher fixes: #0, leading zeros (#012) and HTML entities ({) no longer link.
  • Code spans and fenced blocks never link; a test now pins this.
  • The markdown file editor keeps its /issues/N links. The URL kind is a new parameter whose default is issues.

Testing

  • timeout 150 bun test src/githubReferences.test.ts: table-driven matcher cases, mentionedRepository and latestMentionedRepository. Red at 67b8ed7 (11 fail, 17 pass); green at f1480fb (28 pass).
  • timeout 150 bun test test/bare-pr-refs.test.tsx: a rendered bare #634 gets a chip linking to /pull/634 whose hover opens the PR card; a code span or fence produces no chip; the fallback repository from the transcript; and the header fallback plus per-row cache. Red at 67b8ed7 (4 fail); green at f1480fb (4 pass).
  • test/pr-hover-card.test.tsx and chips/githubRef.test.ts still pass. vp check is clean.
  • test/gallery-coverage.test.ts fails on pages/apps/CloudFeature.tsx#CloudFeature. That failure comes from the base branch (#22772), not this PR.
  • I didn't dogfood this in a tagged build.

Changelog

  • Added: Bare pull request references like #123 in agent replies link to the pull request and show its hover card, using the repository the chat last mentioned when the folder has no GitHub remote.

🤖 Generated with Claude Code

Agent session: cosmic-gray


Summary by cubic

Bare pull request references (#123, owner/repo#123) in agent replies now link to github.com/{repo}/pull/N instead of /issues/N, so their chips open the pull request hover card (issue numbers redirect there too).

Repository fallback

  • Without the chat folder's GitHub remote, each row uses the repository the transcript mentioned most recently up to that row, else the header pull request's; each row's text is scanned once per change.
  • Mentions inside code spans and fenced blocks never count; github.com's own pages (login/device, settings/tokens) don't count either.

Matcher fixes

  • #0, leading zeros (#012), HTML entities ({), and numbers longer than ten digits no longer link.
  • The markdown file editor keeps its /issues/N links via a new link-kind parameter.