Repository navigation
feat(bitbucket): connect Bitbucket from Settings and create pull requests - #5832
Conversation
|
Ready to review this PR? Stage has broken it down into 6 individual chapters for you: Chapters generated by Stage for commit a769ab7 on Jun 19, 2026 7:55pm UTC. |
No keychain prompt when opening SettingsConfirmed + regression-tested that opening the Settings page never decrypts the stored secret (which would trigger the OS "unlock keychain" prompt):
Tradeoff (intentional): a stored connection isn't live-revalidated on each Settings open — the card trusts the account resolved at connect time. That's the price of not prompting; a revoked token surfaces when a PR fetch fails rather than on the card. Flag if you'd prefer the opposite. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds end-to-end Bitbucket credential integration. The change defines shared authentication contracts, environment-based authentication, encrypted credential storage, user verification, and connection status handling. It refactors Bitbucket API requests to resolve environment or stored credentials. It adds IPC and preload APIs, pull-request creation, provider wiring, settings components, search metadata, tests, and English localization. It also prevents draft review creation for Bitbucket. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/renderer/src/components/settings/bitbucket-credentials-dialog.tsx (1)
265-265: ⚡ Quick winReplace arbitrary
text-[11px]with a style token class.
Line 265introduces an ad-hoc font size in renderer UI. Use a documented typography token/class from the style system instead.As per coding guidelines, “Never invent new color values, font sizes, or shadow tiers when a documented one in STYLEGUIDE.md already covers the role.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ef54c8d6-8f5d-43d8-b2ce-7313b316bd72
📒 Files selected for processing (24)
src/main/bitbucket/bitbucket-auth-config.tssrc/main/bitbucket/client.tssrc/main/bitbucket/credential-connection.test.tssrc/main/bitbucket/credential-connection.tssrc/main/bitbucket/credential-store.test.tssrc/main/bitbucket/credential-store.tssrc/main/bitbucket/status-no-decrypt.test.tssrc/main/bitbucket/user-request.tssrc/main/integration-credential-file.tssrc/main/ipc/bitbucket.tssrc/main/ipc/register-core-handlers.test.tssrc/main/ipc/register-core-handlers.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/settings/bitbucket-credentials-dialog.tsxsrc/renderer/src/components/settings/bitbucket-integration-card.tsxsrc/renderer/src/components/settings/source-control-integration-cards.tsxsrc/renderer/src/components/settings/token-source-control-integration-cards.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/integration-credential-errors.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/components/settings/token-source-control-integration-cards.tsx
|
this is a needed feature |
Sorry just got buried If I cut an adhoc release, can you give it a spin? I'm not much of a bitbucket person 🥹 |
|
Yes, I can check, We use bitbucket everything unfortunately. On latest stable release even when via launchctl the vars are added and it marks it correctly, on a bitbucket repo it says "Pull request not supported here Will check it along with your adhoc release. |
…ntial storage Bitbucket Cloud was the only review provider with no in-app auth: GitHub and GitLab delegate to the gh/glab CLIs, but Bitbucket has no comparable first-party CLI, so the only option was ORCA_BITBUCKET_* env vars plus a restart (discussion #5364). Adds a Connect/Edit/Disconnect flow on the Bitbucket integration card, modeled on Linear and Jira: - Credentials are verified against /user before they are persisted, so a dead token is rejected inline instead of silently stored. - The secret is encrypted with safeStorage (0600 plaintext fallback when no OS keyring); non-secret metadata lives in a separate plaintext file so status reads render the connected account without decrypting. Opening Settings therefore never triggers a keychain prompt. - Env vars keep precedence over stored credentials, so existing headless and SSH setups are unaffected. Env-managed connections hide Disconnect. - connect/disconnect reset the preflight cache, so no relaunch is needed. The Bitbucket card moves to its own file to stay under the tsx max-lines cap.
a769ab7 to
1b7e15f
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
@devatnull thanks for the nudge — I rebuilt this on current Since you offered to try it: still very keen. I don't have a Bitbucket account, so the one thing I can't verify is a successful connection end to end. The parts I could prove are in the PR body — the dialog, the inline rejection of a bad token against the real API, and env-var precedence. What would help most:
Also worth knowing: Bitbucket Server / Data Center is not covered — repo detection still hardcodes the Happy to cut an adhoc build if that's easier than running from source — just say the word. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/renderer/src/components/settings/integrations-search.ts (1)
59-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGenerate locale keys for the new strings.
Replace
bitbucketDescriptionandbitbucketAccessTokenwith IDs generated from<filePath>:<text>. This catalog uses generated hash IDs for new renderer strings.Based on learnings, generate locale keys as the first 10 characters of the SHA-1 hash of
<filePath>:<text>, then validate the localization catalogs.Also applies to: 92-93
Source: Learnings
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 48f4d6f4-b02a-4eb6-83bd-2ec33820af84
📒 Files selected for processing (23)
src/main/bitbucket/bitbucket-auth-config.tssrc/main/bitbucket/client.tssrc/main/bitbucket/credential-connection.test.tssrc/main/bitbucket/credential-connection.tssrc/main/bitbucket/credential-store.test.tssrc/main/bitbucket/credential-store.tssrc/main/bitbucket/status-no-decrypt.test.tssrc/main/bitbucket/user-request.tssrc/main/global-fetch-call-site-audit.test.tssrc/main/integration-credential-file.tssrc/main/ipc/bitbucket.tssrc/main/ipc/register-core-handlers.test.tssrc/main/ipc/register-core-handlers.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/settings/bitbucket-credentials-dialog.tsxsrc/renderer/src/components/settings/bitbucket-integration-card.tsxsrc/renderer/src/components/settings/integrations-search.tssrc/renderer/src/components/settings/source-control-integration-cards.tsxsrc/renderer/src/components/settings/token-source-control-integration-cards.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/shared/bitbucket-credentials.tssrc/shared/integration-credential-errors.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/components/settings/token-source-control-integration-cards.tsx
🚧 Files skipped from review as they are similar to previous changes (9)
- src/main/ipc/register-core-handlers.ts
- src/renderer/src/components/settings/source-control-integration-cards.tsx
- src/shared/integration-credential-errors.ts
- src/preload/index.ts
- src/main/bitbucket/bitbucket-auth-config.ts
- src/main/ipc/bitbucket.ts
- src/main/integration-credential-file.ts
- src/main/ipc/register-core-handlers.test.ts
- src/main/bitbucket/credential-connection.test.ts
Yes please, an ad-hoc macOS arm64 build would be easiest. Send the artifact and I will test it against my Bitbucket cloud. |
Bitbucket was the only configured provider whose Create button reported
"This repository provider does not support creating a pull request from
Orca" — supportsReviewCreation was false and the forge provider had no
createReview, so even a correctly authenticated setup was blocked.
Adds createBitbucketPullRequest against POST /repositories/{ws}/{repo}/
pullrequests, using the same env-first / stored-credential resolution as PR
lookups (extracted into resolve-auth.ts so both share one path).
Bitbucket Cloud has no draft pull requests, so a draft request is rejected
with a clear message rather than silently publishing a live PR.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/source-control/forge-provider.test.ts (1)
167-202: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a Bitbucket delegate test.
This assertion only verifies
supportsReviewCreation. It does not verify thatcreateReviewcallscreateBitbucketPullRequest. Add a mocked Bitbucket creation handler and assert its arguments and result, as this file already does for the other providers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e9989262-4f2e-462d-abd2-b7c588a6aafe
📒 Files selected for processing (6)
src/main/bitbucket/client.tssrc/main/bitbucket/pull-request-creation.test.tssrc/main/bitbucket/pull-request-creation.tssrc/main/bitbucket/resolve-auth.tssrc/main/source-control/forge-provider.test.tssrc/main/source-control/forge-provider.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/bitbucket/client.ts
|
Also hold up, my AI was dumb. It didn't build the adhoc release... |
|
@devatnull found your actual problem, and it wasn't your env vars — those were working fine. Bitbucket was the only provider Orca could read PRs from but never create them. The code literally had creation turned off for Bitbucket while GitHub, GitLab, Azure DevOps and Gitea all had it. That's why you got "This repository provider does not support creating a pull request from Orca" even with everything configured correctly. So this PR now does two things:
Adhoc build, if you want to try it: Grab What I'd love you to check:
Two things I already know:
I don't have a Bitbucket account, so you'd be the first person to run this against a real one. Any failure, paste what you see and I'll fix it. |
… review fixes Bitbucket Cloud has no draft pull requests, so the composer no longer offers the toggle for it and forces the flag off at submit — better than failing after the user has filled the form in. Review fixes: - writeFileSync's `mode` only applies when it creates the file, so rewriting a credential kept whatever permissions it already had. chmod after every write, for the secret and the metadata. - An explicit ORCA_BITBUCKET_API_BASE_URL now wins over a stored base URL. Env precedence is per-setting, not all-or-nothing. - Enter in the credentials dialog only submits from a text field, so it no longer hijacks Cancel and the docs link. - Replace the chmod-based delete-failure test with a mocked unlinkSync: file modes are not portable to Windows and elevated runners unlink anyway.
|
I will add issues as I encounter: 1st: even when a PR status is merged it blocks from creating new PRs. "Pull request already exists |
|
@devatnull use this build instead — I fixed a few things since the last one:
Changed since the last build: the Draft checkbox is now hidden for Bitbucket instead of erroring when you tick it, credential file permissions get re-tightened on reconnect, and The main thing to try: create a PR from a Bitbucket worktree. That was impossible before regardless of your env vars — Bitbucket was the only provider with PR creation switched off in the code, which is what produced that "does not support creating a pull request" message you saw. Your launchctl vars still take priority over anything saved in the app, so nothing should regress there. Optionally you can drop them entirely now: Settings → Integrations → Bitbucket → Connect, with your Atlassian email + an API token. Still Cloud only — no Bitbucket Server / Data Center. Tell me if that's what you're on. Anything breaks, paste the error and I'll fix it. |
… next one Reported on #5832: with a merged PR on a branch, Create reported "Pull request already exists" and offered no way forward. The branch lookup queries every PR state and returns the most recently updated one, so a merged PR came back as the branch's current review and eligibility blocked on it. Bitbucket only discarded such a match on the repo default branch (#9171), while GitHub already drops any merged PR it matched by branch alone — "a merged PR without an explicit link is just a historical branch match, not implicit review context". Applies that rule to Bitbucket. An explicitly linked review still resolves through the linked-number fallback, so merging a PR Orca knows about keeps showing it.
|
Same issue, sees an already merged PR and says:
On a repo with no existing PRs(so the above issue isnt triggered) says:
git remote -v git remote get-url origin:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/bitbucket/client.test.ts (1)
147-163: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExercise the explicit linked-number fallback.
The mock returns pull request 7 for every non-status request. Therefore, this test passes from the branch-list response and does not verify the fallback request for the explicitly linked pull request.
Return an empty or different branch-list result, return pull request 7 only for
/pullrequests/7, and assert that the fallback request was made.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4e619151-29a1-4c6e-a2fc-71f830d6bf28
📒 Files selected for processing (2)
src/main/bitbucket/client.test.tssrc/main/bitbucket/client.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/bitbucket/client.ts
|
I use SSH for bitbucket, not http, could be related to SSH, but should work with both. if it reads the provider for http format and not ssh may cause the PR not supported for this provdier issue. |
|
@devatnull good catch, that's a real bug and it wasn't fixed in the build you had. New one: What was happening: the branch lookup asks Bitbucket for pull requests in any state and takes the most recently updated one. So once your PR merged, that merged PR came back as the branch's current review, and Create refused to run because it thought one already existed. GitHub already handles this — it drops a merged PR it matched only by branch name, on the grounds that it's history rather than an active review. Bitbucket only did that on the repo's default branch, never on feature branches. Now it does. A PR that Orca created or that you opened from Orca stays linked, so it'll still show as merged on the card. It's only the "found it purely by branch name" case that gets dropped. Keep them coming. |
…list Reported on #5832: on a Bitbucket repo with no existing PR, Create still said "This repository provider does not support creating a pull request from Orca", even after the forge provider gained createReview. There are two capability lists. Enabling supportsReviewCreation on the forge provider was necessary but not sufficient — the blocker and the whole renderer read the separate shared list, which never included bitbucket. Adds it, gives Bitbucket its own provider name so review copy stops saying "GitHub", and asserts the two lists agree so they cannot drift apart again.
|
@devatnull the second one was a separate bug and you were right to call it out. Fixed:
There were two lists of "providers Orca can create a review on". I'd only updated the backend one, so PR creation worked while the UI still refused to offer it. The blocker and the whole right sidebar read a different shared list that never had Bitbucket in it. Added, plus a test that the two lists match so this can't drift again.
Good instinct, but SSH is fine here — remote parsing has passing coverage for One more thing I fixed while in there: Bitbucket was falling through to GitHub's copy, so some strings would have said "GitHub" on a Bitbucket repo. This build should get you a working Create PR on both repos. If it fails, the error text is mapped per Bitbucket status code now, so whatever it says should point at the real cause — paste it and I'll take a look. |
|
The one above is indeed the latest. Sorry for the rounds of iteration 😅 |
|
Thanks for building this. I tested the Bitbucket flow and found that PR creation still was not working end to end. I fixed the remaining issues, and it is now working in my local build: PR creation succeeds, the new PR appears immediately, and it stays linked after it is closed or merged. I opened a follow-up PR against your branch with the fixes and regression tests: #13795 I also addressed the outstanding localization and forge-provider review comments. The commits are separated so you can merge or cherry-pick them individually. |
|
@devatnull merged your #13795 and cut a build off it: That's your fixes plus everything earlier in one app. Should be the first build where the whole flow works end to end rather than just further along than the last one. Worth a sanity pass on your side since you know what broke before: create a PR, confirm it shows up right away, then merge or decline it and confirm the card still points at it. Thanks for doing the legwork on this — you found four separate bugs the tests didn't, and the linking one was mine. |
|
Looks good, no issues, can be merged to stable or based on the official schedule, thanks for the help |
Appreciate you sticking with it through five builds. You found four bugs the test suite didn't, and one of them was mine — that's the only reason this is actually working rather than just looking like it does. I've updated the PR description to cover the full scope, since it grew from "store credentials" into "Bitbucket PR creation works at all", and credited your #13795. Green on CI and mergeable; I'll let it go through normal review. |
… comment notFoundIsNull arrived without the rationale its sibling flag carries, and reads as a bare `true` at the only call site that opts in.
Two of these made the feature unusable in real setups: - Create PR checked GitHub authentication for Bitbucket. isProviderAuthenticated fell through to isGitHubAuthenticated, which was unreachable while Bitbucket could not create reviews at all. Anyone with Bitbucket connected but no `gh auth login` got auth_required with no way forward. - The draft flag was only gated in ChecksPanel, not the two SourceControl call sites. With "create as draft" saved as a default, the composer hides the toggle for Bitbucket, so the flag could not be cleared and creation failed every time. Bitbucket now ignores draft instead of rejecting it. Also: - Blocked-create copy said "GitHub is not authenticated. Run gh auth login" on Bitbucket repos, in both the main-process and renderer paths. - A decryption failure resolved to an anonymous config and queried anyway; a private repo answers 404, which reads as "no pull request" and offers Create for a branch that already has one. Requests now fail closed. - Hiding non-open implicit branch matches was too broad: a declined PR became permanently invisible off the default branch. Scoped to merged, restoring the default-branch rule (#9171) for the rest. - A failed disconnect rejected unhandled and the card silently re-rendered as connected; a partial delete left the secret live in memory for the session. - The credentials dialog refused to open on a remote runtime, so a local repo could never store a credential. Now only the storage note changes, matching the Jira dialog.
|
Merged as 63271a5. @devatnull thanks again — this landed because you tested it properly. A final review pass before merge caught two more things that would have bitten you specifically:
Both fixed, along with a few smaller ones: a decryption failure could query anonymously and report "no pull request" for a branch that has one, declined PRs were being hidden, and the credentials dialog wouldn't open at all on a remote runtime. It'll be in the next build off main rather than an adhoc one. Open a fresh issue for anything else and tag me — Bitbucket Server / Data Center is still the obvious gap. |
…ests (stablyai#5832) * feat(bitbucket): connect Bitbucket from Settings with encrypted credential storage Bitbucket Cloud was the only review provider with no in-app auth: GitHub and GitLab delegate to the gh/glab CLIs, but Bitbucket has no comparable first-party CLI, so the only option was ORCA_BITBUCKET_* env vars plus a restart (discussion stablyai#5364). Adds a Connect/Edit/Disconnect flow on the Bitbucket integration card, modeled on Linear and Jira: - Credentials are verified against /user before they are persisted, so a dead token is rejected inline instead of silently stored. - The secret is encrypted with safeStorage (0600 plaintext fallback when no OS keyring); non-secret metadata lives in a separate plaintext file so status reads render the connected account without decrypting. Opening Settings therefore never triggers a keychain prompt. - Env vars keep precedence over stored credentials, so existing headless and SSH setups are unaffected. Env-managed connections hide Disconnect. - connect/disconnect reset the preflight cache, so no relaunch is needed. The Bitbucket card moves to its own file to stay under the tsx max-lines cap. * feat(bitbucket): support creating pull requests from Orca Bitbucket was the only configured provider whose Create button reported "This repository provider does not support creating a pull request from Orca" — supportsReviewCreation was false and the forge provider had no createReview, so even a correctly authenticated setup was blocked. Adds createBitbucketPullRequest against POST /repositories/{ws}/{repo}/ pullrequests, using the same env-first / stored-credential resolution as PR lookups (extracted into resolve-auth.ts so both share one path). Bitbucket Cloud has no draft pull requests, so a draft request is rejected with a clear message rather than silently publishing a live PR. * fix(bitbucket): hide the draft toggle where drafts do not exist, plus review fixes Bitbucket Cloud has no draft pull requests, so the composer no longer offers the toggle for it and forces the flag off at submit — better than failing after the user has filled the form in. Review fixes: - writeFileSync's `mode` only applies when it creates the file, so rewriting a credential kept whatever permissions it already had. chmod after every write, for the secret and the metadata. - An explicit ORCA_BITBUCKET_API_BASE_URL now wins over a stored base URL. Env precedence is per-setting, not all-or-nothing. - Enter in the credentials dialog only submits from a text field, so it no longer hijacks Cancel and the docs link. - Replace the chmod-based delete-failure test with a mocked unlinkSync: file modes are not portable to Windows and elevated runners unlink anyway. * fix(bitbucket): stop a merged pull request from blocking the branch's next one Reported on stablyai#5832: with a merged PR on a branch, Create reported "Pull request already exists" and offered no way forward. The branch lookup queries every PR state and returns the most recently updated one, so a merged PR came back as the branch's current review and eligibility blocked on it. Bitbucket only discarded such a match on the repo default branch (stablyai#9171), while GitHub already drops any merged PR it matched by branch alone — "a merged PR without an explicit link is just a historical branch match, not implicit review context". Applies that rule to Bitbucket. An explicitly linked review still resolves through the linked-number fallback, so merging a PR Orca knows about keeps showing it. * fix(bitbucket): add bitbucket to the shared review-creation provider list Reported on stablyai#5832: on a Bitbucket repo with no existing PR, Create still said "This repository provider does not support creating a pull request from Orca", even after the forge provider gained createReview. There are two capability lists. Enabling supportsReviewCreation on the forge provider was necessary but not sufficient — the blocker and the whole renderer read the separate shared list, which never included bitbucket. Adds it, gives Bitbucket its own provider name so review copy stops saying "GitHub", and asserts the two lists agree so they cannot drift apart again. * fix(bitbucket): persist pull request links after creation * fix(bitbucket): fetch linked pull requests by number first * fix(i18n): use generated Bitbucket integration keys * test(bitbucket): cover forge creation delegation * fix(bitbucket): fall back when linked pull request is stale * docs(bitbucket): explain notFoundIsNull and fix a garbled permissions comment notFoundIsNull arrived without the rationale its sibling flag carries, and reads as a bare `true` at the only call site that opts in. * fix(bitbucket): address review findings before merge Two of these made the feature unusable in real setups: - Create PR checked GitHub authentication for Bitbucket. isProviderAuthenticated fell through to isGitHubAuthenticated, which was unreachable while Bitbucket could not create reviews at all. Anyone with Bitbucket connected but no `gh auth login` got auth_required with no way forward. - The draft flag was only gated in ChecksPanel, not the two SourceControl call sites. With "create as draft" saved as a default, the composer hides the toggle for Bitbucket, so the flag could not be cleared and creation failed every time. Bitbucket now ignores draft instead of rejecting it. Also: - Blocked-create copy said "GitHub is not authenticated. Run gh auth login" on Bitbucket repos, in both the main-process and renderer paths. - A decryption failure resolved to an anonymous config and queried anyway; a private repo answers 404, which reads as "no pull request" and offers Create for a branch that already has one. Requests now fail closed. - Hiding non-open implicit branch matches was too broad: a declined PR became permanently invisible off the default branch. Scoped to merged, restoring the default-branch rule (stablyai#9171) for the rest. - A failed disconnect rejected unhandled and the card silently re-rendered as connected; a partial delete left the secret live in memory for the session. - The credentials dialog refused to open on a remote runtime, so a local repo could never store a credential. Now only the storage note changes, matching the Jira dialog. --------- Co-authored-by: devatnull <[email protected]>
Connect Bitbucket from Settings — no env vars, no restart
Bitbucket Cloud is the only review provider Orca can't connect to from inside the app. GitHub and GitLab delegate auth to the
gh/glabCLIs, which own keychain storage and OAuth. Bitbucket has no comparable first-party CLI, so today the only way to authenticate is to setORCA_BITBUCKET_*environment variables and restart — which is what discussion #5364 ran into.This adds an in-app credential flow that mirrors what Linear and Jira already do: type the token into Orca, it's verified before saving, encrypted with Electron
safeStorage, and the connection renders from plaintext metadata so opening Settings never triggers a keychain prompt.Environment variables still win, so existing headless / SSH / CI setups are untouched.
While testing this with a real Bitbucket user, it turned out credentials were only half the problem — Orca could never create a Bitbucket pull request at all, however it was authenticated. That's fixed here too; see Creating pull requests below.
Visual proof
Captured against this branch in a dev build (
Settings → Integrations).Before — env-var instructions only, no way to connect from the app:
After — a Connect button:
The dialog, in both auth modes:
Verify-before-save — a junk token hitting the real Bitbucket API. Rejected inline, dialog stays open, and
~/.orca/bitbucket-credential.*is not created:Env precedence — same build relaunched with
ORCA_BITBUCKET_ACCESS_TOKENset. The card switches to env-managed messaging and drops the Connect/Disconnect affordances entirely. ("Auth failed" because the demo token is deliberately fake — env credentials are checked live, unlike stored ones.)What you get
Settings → Integrations → Bitbucket now has Connect / Edit credentials / Disconnect:
/userwith what you typed; a dead token is rejected inline and nothing is written to disk.Creating pull requests
bitbucketForgeProviderhadsupportsReviewCreation: falseand nocreateReview, so Create reported "This repository provider does not support creating a pull request from Orca" on every Bitbucket repo — the complaint that started this thread. AddscreateBitbucketPullRequestagainstPOST /repositories/{workspace}/{repo}/pullrequests, resolving auth through the same env-first / stored-credential path as lookups.Four follow-on bugs surfaced during real-account testing:
supportsReviewCreationon the forge provider is not what the blocker reads —src/shared/hosted-review-creation-providers.tsis, and it never listed bitbucket. Both lists now agree, with a test asserting they stay in sync.updateWorktreeMetacall sites had a per-providerifchain with no bitbucket branch, so a created PR succeeded and then wasn't linked to the worktree. Now an exhaustiveresolveCreatedHostedReviewLinkswitch, so a new provider fails to compile rather than silently going unlinked.No draft pull requests. Bitbucket Cloud's API has no such concept, so the composer hides the Draft toggle for Bitbucket and forces the flag off at submit rather than quietly publishing a live PR.
Bitbucket also fell through to GitHub's review copy, so some strings read "GitHub" on a Bitbucket repo.
How it's stored
~/.orca/bitbucket-credential.enc{ accessToken, apiToken }safeStorage, 0600 plaintext fallback when no OS keyring~/.orca/bitbucket-credential.json{ version, authMode, email, baseUrl, account, updatedAt }Both files are written
0600. The secret is never logged and never crosses IPC back to the renderer —bitbucket:statusreturns only non-secret fields.The no-keychain-prompt guarantee
This is the part worth reviewing closely. Three layers, mirroring Linear:
loadStoredBitbucketSecret({ force })returns the in-memory cache if warm; withoutforceit returnsnullwithout touching disk. Only a real API call forces a decrypt, once, then caches.getBitbucketAuthStatus()refines this: if the secret happens to be warm in memory from an earlier PR fetch, it does revalidate against/user(free — no decrypt), so a revoked token surfaces on the next "Re-check". If the cache is cold it trusts the metadata rather than prompting.status-no-decrypt.test.tssimulates a cold session and assertssafeStorage.decryptStringis never called by either status path, and exactly once when a PR is actually fetched.Auth resolution
Every Bitbucket API path already funnels through
src/main/bitbucket/client.ts, so wiring the fallback there covers PR fetching, build statuses, and hosted-review creation in one place.Files
bitbucket-auth-config.ts(new)hasAuth,authHeaders, shared config type — extracted fromclient.tsuser-request.ts(new)fetchBitbucketUser()— shared by status checks and connect-time verificationcredential-store.ts(new)credential-connection.ts(new)connectBitbucket(verify → save),disconnectBitbucket,getBitbucketConnectionStatusclient.tssrc/main/ipc/bitbucket.ts(new)bitbucket:connect/:disconnect/:status, resets preflight cachesrc/shared/bitbucket-credentials.ts(new)integration-credential-file.tswriteEncryptedCredential()(Linear/Jira duplicated this)bitbucket-credentials-dialog.tsx(new)bitbucket-integration-card.tsx(new)token-source-control-integration-cards.tsx(max-lines)Testing
Automated:
credential-store.test.ts— persist/read-back, 0600 perms, the lazy-decrypt invariant, malformed-JSON field narrowing, and that a failed delete surfaces instead of silently leaving files on disk.credential-connection.test.ts— verify-before-save, reject on 401 without persisting, reject incomplete Basic creds with no network call, Basic header shape, env precedence, disconnect.status-no-decrypt.test.ts— cold-session no-decrypt invariant, decrypt-exactly-once on a real fetch, revalidation when the cache is warm.client.test.tsunchanged and passing — the env path keeps its exact return shape.Verified against a real Bitbucket Cloud account by @devatnull, who doesn't have my problem of not owning one. They ran the flow end to end across five adhoc builds and confirmed: connect works, PR creation succeeds, the new PR appears immediately, and it stays linked after it's closed or merged. Four of the bugs above came out of that testing, and they contributed the fixes for two of them in #13795 (merged into this branch).
Still unverified: the keyring-unavailable fallback, and any non-macOS platform.
Deliberately out of scope
bitbucket.orghost inrepository-ref.ts. The store already carries a custombaseUrl, so this is mostly relaxing that host check.saveBitbucketCredentialwithauthMode: 'token'.ORCA_BITBUCKET_*on the remote instead. Needs abitbucket.*RPC to lift.writeEncryptedCredentialand theIntegrationCredentialServiceunion are already shared.Credits
@devatnull did the real-account testing this needed and contributed #13795. The linking bug in particular was mine and their fix is better than what I'd have written.
Rollback
Self-contained and additive. Reverting removes the feature with no migration; older builds simply ignore
~/.orca/bitbucket-credential.*and the env-var path is unchanged.Made with Orca 🐋