Skip to content

feat: auto-watch Bitbucket PRs (--mine / --review-requested) - #27

Merged
devblac merged 1 commit into
mainfrom
feat/bitbucket-autowatch
Nov 1, 2026
Merged

devblac merged 1 commit into
mainfrom
feat/bitbucket-autowatch

Conversation

@devblac

@devblac devblac commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Stacked on #26 (release v0.5.0). Retarget to main once #26 is merged.

What

  • prw watch --mine / --review-requested and prw run find Bitbucket Cloud PRs too, when a Bitbucket token or bitbucket_user is set:
    • mine: your open PRs in every workspace (or bitbucket_workspaces), one request per workspace.
    • review-requested: open PRs listing you as a reviewer that you haven't approved or requested changes on yet. Bitbucket only filters reviewers per repository, so prw scans the repositories active in the last 30 days (max 60 per workspace) every 15 minutes.
  • Auto-watch is now a Finder per host; watch-list keys include the host.
  • prw run spaces out Bitbucket checks as the list grows (18s × number of Bitbucket PRs, min 1 minute), so ~30 PRs stay around 600 of the 1,000 requests/hour.
  • Without a GitHub token, auto-watch works on Bitbucket alone.

Test plan

  • go test -race ./..., go vet ./...
  • Unit tests: finder across workspaces, partial results never remove PRs, reviewed PRs skipped, 15-minute rescan, two hosts with the same owner/repo#N, interval scaling
  • Live: prw watch --mine with a public Bitbucket user plus the owner's GitHub account added PRs from both hosts; prw run --once read CI and merge state for both
  • With the owner's Bitbucket token: /user, /user/workspaces, review scan on private repositories

🤖 Generated with Claude Code

Auto-watch now runs on every configured host through a Finder per host.
GitHub keeps its search; the new BitbucketFinder lists your open PRs per
workspace, and scans the repositories active in the last 30 days for open PRs
listing you as a reviewer that you haven't approved or requested changes on
yet, every 15 minutes, since Bitbucket can only filter reviewers per
repository. Watch-list keys include the host, so the same owner/repo#N on both
hosts stays apart.

With dozens of Bitbucket PRs, checking each once a minute would exceed
Bitbucket's 1,000 requests/hour, so `prw run` now spaces them out by the size of
the list (18s per PR, at least a minute), about 600 requests an hour.

Also drops two unused variables left in the dashboard view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T17:42:16.580220Z 6ea69d8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ea69d81fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/prw/clients.go
Comment on lines +45 to 47
if len(cfg.AutoWatch) > 0 && !bitbucketConfigured(cfg) {
return true // auto-watch has nothing else to search
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow Bitbucket-only auto-watch to start with an empty list

When Bitbucket credentials are configured, auto-watch is enabled, and no PRs are currently watched, this condition falls through to return len(cfg.WatchedPRs) == 0, which still returns true. Without a GitHub token, runCmd consequently returns errMissingToken before running Bitbucket discovery. This prevents Bitbucket-only users from starting the watcher while waiting for their first matching PR, or restarting it after all watched PRs have closed. Exempt configured Bitbucket auto-watch from the empty-list GitHub default while retaining the token requirement for explicitly watched GitHub PRs.

Useful? React with 👍 / 👎.

Comment on lines +96 to +98
f.reviewFound, f.lastReviewScan = found, f.now()
}
return f.reviewFound, nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prevent cached review results from resurrecting closed PRs

If a Bitbucket review-request PR closes after a review scan, checkAllPRs sends its final notification and removes it from the watch list. However, the next five-minute auto-watch sync receives this cached result until the fifteen-minute rescan and Sync unconditionally adds the closed PR again. Its next check then sends another final notification and removes it again, potentially repeating at both intervening syncs. Keep the scan throttling, but invalidate or filter cached entries after lifecycle cleanup so completed PRs are not re-added and notified repeatedly.

Useful? React with 👍 / 👎.

@devblac
devblac changed the base branch from chore/release-v0.5.0 to main October 31, 2026 22:36
@devblac devblac closed this Oct 31, 2026
@devblac devblac reopened this Oct 31, 2026
@devblac
devblac merged commit f2b8bfa into main Nov 1, 2026
2 checks passed
@devblac
devblac deleted the feat/bitbucket-autowatch branch November 1, 2026 03:18
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.

1 participant