cmux next: a quoted or out-of-range bare #N stays text

Merged
TE
7d ago
+120-19

Leo: "these auto render to the pr instead of just #1 #2...".

An agent reply that quoted his "what is #1 / #2" turned each bare number into a chip for cmux's real (and unrelated) pull requests #1 and #2. The cause is rule d in conversation/bareReferences.ts: a bare #N with no other evidence links to the chat folder's repository, whatever N is.

Two changes:

  • Quotes link no bare #N. A blockquote renders with linkBareReferences: false (new InlineOptions field, Markdown.tsx). The quote's options object is memoized per opts, so memoized blocks don't redraw. owner/repo#N, GitHub addresses and commits still link inside a quote. Inline code and code blocks already never linked, and bare-pr-refs.test.tsx covers that.
  • Rule 4: a bare #N must fit the chat's number range. Rules c and d now only consider a candidate repository when N has at least as many digits as the smallest number the chat named in that repository. A cmux chat that named #27262 therefore doesn't read "#1" as a cmux pull request. If the folder's repository is out of range, rule d doesn't apply: the App's pull request cache has to confirm one of the chat's other linked repositories, or N stays text. A repository the chat never named a number in has no range, so Leo's 2026-10-20 behaviour (a bare #634 in a fresh chat links to the folder's repository) still holds. The smallest number per repository is tracked as each row is read (O(1) per named reference), so streaming adds no per-row work.

Rules a and b don't change. A number the turn or an earlier turn named as owner/repo#N or as an address is still a chip, whatever its size.

Risk: a chat that named only large numbers in a repository and then means one of its small, old PRs by bare number will show it as text. An explicit owner/repo#N still links it.

Gallery: transcript → github-references-quoted-numbers.

Changelog

  • Fixed: In the agent transcript, a quoted "#1" or "#2", or a small number in a chat about a repository's recent PRs, now stays plain text instead of linking to an unrelated pull request.

Tests

Red at base (test commit 808d374bd68 on 621568b30ff), cmux-ci test --setup webviews -- bash -c 'cd webviews && bun test test/bare-ref-repo.test.tsx test/bare-pr-refs.test.tsx': 16 pass, 2 fail. Both new tests got extra #1/#2 chips pointing at manaflow-ai/cmux/pull/1 and /pull/2 (run 40835284976).

Green at head c2605c9c2f7, same command: 19 pass, 0 fail (run 40835736342). The added rule-4 test checks that, with the folder's repository out of range, only the cache's answer links a number.

scripts/web-lint.sh and python3 scripts/cmux-next/prepush-gate.py pass.

Observed / Not run

  • Observed: the bun suites above on Linux CI via cmux-ci.
  • Not run: the gallery state hasn't been captured yet, and the app hasn't been launched. This is a webview-only change.
  • Overlap: #27167 (lucasr1b) touches bare-ref-repo.test.tsx and transcript.gallery.ts, so a prompt's pasted PR addresses can become chips. The new tests count only bare # chips where that matters, so they hold whichever PR lands first.

šŸ¤– Generated with Claude Code

Agent session: agent session


Summary by cubic

Stops bare #N references in agent transcript replies from auto-linking to unrelated pull requests. A quoted "#1" or "#2" and numbers smaller than any the chat named in a repository now render as plain text.

  • Blockquotes link no bare #N; owner/repo#N, addresses, and commits still link inside quotes.
  • A bare #N links to the folder's repository only when N is as long as the smallest number the chat named in that repository; otherwise the app's pull request cache must confirm another linked repository.
  • A chat that named only large numbers in a repository will show its small old PRs as text; owner/repo#N still links them.

Changelog

  • Fixed: a quoted "#1" or "#2", or a small number in a chat about a repository's recent PRs, now stays plain text instead of linking to an unrelated pull request.

Tests

  • Red at base (2 fails, extra #1/#2 chips pointing at cmux PRs); green at head (19 pass), with web lint and the prepush gate passing.
  • The rule-4 test checks that, with the folder's repository out of range, only the cache's answer links a number; the github-references-quoted-numbers gallery state covers the quote and prose cases.
  • The new tests count only bare # chips, so the overlapping PR #27167, which chips pasted PR addresses, doesn't break them.