Skip to content

fix(clients): find linked pull requests by their target branch - #46711

Open
saphid wants to merge 1 commit into
pingdotgg:mainfrom
saphid:hunter/c-3a4e7eac48
Open

saphid wants to merge 1 commit into
pingdotgg:mainfrom
saphid:hunter/c-3a4e7eac48

Conversation

@saphid

@saphid saphid commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Problem

A pull request linked to the thread disappears from a # search for its base (target) branch whenever the project's own results don't include it, e.g. a linked PR from another repository. composerPullRequestsFromLinks already carries baseBranch, but withLinkedComposerPullRequestsFirst leaves it out of the text it matches against. Mobile already matches ordinary project results on baseBranch, so the two disagree there. Web and desktop use the same linked fallback.

Deterministic repro on origin/main (eca5cb0c0f51c33faeb75d7fc7115729a7f20e28):

  1. In a thread whose project is owner/repo, link a readable cross-repository PR by URL with link_pull_request (e.g. owner/other#42: title Fix parser, head feature, base release-2026) and wait for its snapshot to sync.
  2. Type #release-2026 in the composer.

The project listing is filtered to owner/repo, so #42 can only come from the linked fallback. Direct repro: pass composerPullRequestsFromLinks([link], "p1") and matches: [] with query: "release-2026" to withLinkedComposerPullRequestsFirst.

  • Observed: no row (the matcher returns []). Typing #feature instead shows #42.
  • Expected: a #42 row described as owner/other · Fix parser, ranked first like other matching linked PRs.

Change

Add baseBranch to the linked-entry type and to the folded search text in withLinkedComposerPullRequestsFirst. All linked entries come from composerPullRequestsFromLinks, which already sets it, so the fix covers web, desktop and mobile.

The matcher output is what the menus render, with no later filter or dedupe. On web and desktop, apps/web/src/components/chat/useComposerMenuItems.ts maps matches one-to-one into items labelled #${number} and described as ${repository} · ${title} for another repository. On mobile, useComposerPullRequestSearch (apps/mobile/src/state/queries.ts) returns the matcher result as entries, and apps/mobile/src/features/threads/use-composer-command-menu.ts maps each entry to an item labelled #${number}, with the repository and title in its description.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • New case matches a linked pull request by its base branch in packages/shared/src/composerPullRequestMatches.test.ts: on base it fails with expected [] to deeply equal [ { projectId: 'p1', …(10) } ]. With the patch, all 11 tests in the file pass.
  • vp run check:changed exited 0 on HEAD db7b041a0dd4f24ebb045ed25199b6847a92c5f5 (format, lint, knip, typecheck, 2 test files). The summary is in the gist below.
  • Node transcript running the real mapper and matcher, before and after: https://gist.github.com/saphid/884d703c0dc54b77a746d611d557e8f1 (#release-2026 -> [] before, ["owner/other#42"] after).

Not shown: no integrated composer run (web, desktop or mobile), no scenarios:prove run and no screenshots. The proof runs the shared mapper and matcher directly. The rendered row is traced through the source above, not captured.

Authored by Claude Opus 5.5 (Model Hub); reviewed by GPT-6.2 Sol (Codex).

Not shown

  • .github/pull_request_template.md:26 — No integrated before/after composer capture on web, desktop, or mobile; capture the same target-branch query on base and head in a real client and name the surfaces not exercised.
  • .github/pull_request_template.md:26 — No scenarios:prove run; bind the example to a seeded cross-repository PR and assert that the Improve terminal navigation shortcuts and streamline git action PR flow #42 row appears after snapshot sync.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Dec 1, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 4c2f44b

Macroscope's review found this PR approvable — Linked pull requests can now appear in composer search results when their target branch matches the query. The change is limited to suggestion matching in web and mobile, retaining existing ordering and result limits.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Linked pull request matching now searches the base branch as well as the existing fields. A test checks that a base-branch query returns a linked pull request when regular matches are empty.

Changes: Linked pull request search

Layer / File(s) Summary
Base-branch search and test
packages/shared/src/composerPullRequestMatches.ts, packages/shared/src/composerPullRequestMatches.test.ts
The linked-entry type now requires baseBranch. Linked search includes that field, and a test checks that a query matching it returns the linked pull request.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: stienswout

Merge Risk: Minimal · up to 4c2f4

Searching linked pull requests by their target branch now works as described. No merge-blocking issues were found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: linked pull requests are now found by their target (base) branch in the composer search. It matches the summary, the objectives, and the single code change that adds b…
Description check Passed The description covers the problem, the change, the scope, and the verification. It gives a deterministic reproduction, names the affected surfaces, and explains why no issue is needed. It also lists …
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.
Full details: Title check

Explanation

The title names the main change: linked pull requests are now found by their target (base) branch in the composer search. It matches the summary, the objectives, and the single code change that adds baseBranch to the matcher. The title uses the conventional commit form and is concise.

Full details: Description check

Explanation

The description covers the problem, the change, the scope, and the verification. It gives a deterministic reproduction, names the affected surfaces, and explains why no issue is needed. It also lists the surfaces and checks it did not run, so the reader can see the gaps. The template's optional 'agent' line is present, and the scope section states that no issue is needed for a small obvious fix, as the template asks. The description contains an in-body 'Not shown' section and a bot-generated note about a candidate ID, which are noise, but the required sections are complete. The Verification section gives observed results, not just 'tests pass'.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8eac85d and 4c2f44b.

Files selected for processing: 2

  • packages/shared/src/composerPullRequestMatches.test.ts
  • packages/shared/src/composerPullRequestMatches.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant