Skip to content

fix(bitbucket): persist and prioritize created pull requests - #13795

Merged
nwparker merged 5 commits into
stablyai:nwparker/bitbucket-discfrom
devatnull:bitbucket-pr-5832-followups
Aug 11, 2026
Merged

nwparker merged 5 commits into
stablyai:nwparker/bitbucket-discfrom
devatnull:bitbucket-pr-5832-followups

Conversation

@devatnull

Copy link
Copy Markdown
Contributor

Summary

  • persist a newly created Bitbucket PR number in worktree metadata on both creation surfaces
  • use that linked PR number for the immediate hosted-review refresh
  • fetch an explicitly linked Bitbucket PR by number before the branch index, so transient index failures and terminal states do not hide it
  • replace temporary Bitbucket localization keys with generated IDs
  • add direct forge-creation delegation coverage requested in review

Regression covered

Immediately after creation, Bitbucket's branch-index endpoint can fail or lag while GET /pullrequests/{id} already succeeds. The new client test makes the branch index return HTTP 503 and verifies the explicitly linked PR is returned without consulting the index. The shared link-mapping test covers Bitbucket persistence in both renderer callbacks.

Verification

  • 137 focused Bitbucket/provider/renderer tests passed
  • full TypeScript typecheck passed
  • localization catalog and extraction checks passed

Commits are intentionally separated by concern so they can be reviewed or cherry-picked independently.

Copilot AI lite review requested due to automatic review settings August 11, 2026 10:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Bitbucket hosted-review behavior by persisting newly created PR numbers into worktree metadata, using them for immediate refresh, and prioritizing explicit PR-by-number fetches to avoid transient branch-index failures hiding the created review.

Changes:

  • Persist and re-use created hosted-review numbers (including Bitbucket) across both creation surfaces (SourceControl + ChecksPanel) via a shared link resolver.
  • Update Bitbucket client lookup to fetch explicitly linked PRs by number before consulting the branch index; add regression coverage for branch-index 503.
  • Replace temporary Bitbucket localization keys with generated IDs and add forge-provider delegation coverage for Bitbucket creation.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/renderer/src/i18n/locales/en.json Replaces temporary Bitbucket integration strings with generated localization IDs.
src/renderer/src/components/settings/integrations-search.ts Updates integration-search entries to reference the new generated localization IDs.
src/renderer/src/components/right-sidebar/SourceControl.tsx Persists created hosted-review link metadata via shared resolver and uses it for refresh lookup.
src/renderer/src/components/right-sidebar/source-control-created-review-link.ts Adds shared mapping from provider+number to worktree metadata + lookup overrides.
src/renderer/src/components/right-sidebar/source-control-created-review-link.test.ts Adds unit tests covering provider-to-link mapping behavior.
src/renderer/src/components/right-sidebar/ChecksPanel.tsx Mirrors SourceControl behavior for persisting/using created hosted-review links.
src/main/source-control/forge-provider.test.ts Adds test ensuring Bitbucket review creation routes through the shared provider contract.
src/main/bitbucket/client.ts Fetches explicitly linked Bitbucket PR by number before branch index (to avoid transient index failures).
src/main/bitbucket/client.test.ts Adds regression test for explicit PR fetch succeeding when branch index returns 503.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +208 to +217
if (typeof linkedPRNumber === 'number') {
const raw = await requestJson<RawBitbucketPullRequest>(
`/repositories/${encodedRepoPath(repo)}/pullrequests/${encodeURIComponent(String(linkedPRNumber))}`,
{},
throwOnFailure
)
if (raw) {
return normalizePullRequest(repo, raw)
}
}
@nwparker
nwparker merged commit b0fb02f into stablyai:nwparker/bitbucket-disc Aug 11, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Merged — thanks, this is good work and it caught a real bug I'd left behind.

"PR creation still was not working end to end"

You're right, and the linking gap was mine: I wired up creation but never added the bitbucket branch to the two updateWorktreeMeta call sites, so a created Bitbucket PR was never linked to the worktree. Pulling that into an exhaustive resolveCreatedHostedReviewLink switch is a better fix than adding a fifth if — now a new provider fails to compile instead of silently going unlinked.

Fetching the linked PR by number before the branch index is also the right call. The index is eventually consistent, so a freshly created PR could take a moment to show up there, and notFoundIsNull keeps a stale linked number from swallowing the branch lookup. Nice touch testing the exact call order.

Verified on my side before merging: lint, both typechecks, and 7444 tests pass.

@devatnull
devatnull deleted the bitbucket-pr-5832-followups branch August 11, 2026 11:17
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.

3 participants