fix(forgejo): share complete Gitea PR scans across branches#25568

open2
main
maria/takeover-pr-24853
opened1d agobyMmaria
View on GitHubTwo-way sync enabledPR last imported 17h ago

Problem

Gitea ignores the head filter, so background branch PR discovery repeatedly scans the entire repository. Branch and worktree lookups cannot currently share those results.

Change

Reuse successful complete scans for one minute, keyed by resolved server, account, CLI, and repository. Detect ignored head filters before taking this path; Forgejo's filtered queries stay unchanged. Preserve source identity, arbitrary bases, and open/closed/merged selection. Explicit refreshes, identity changes, and creation checks bypass cached scans. Failed and partial scans are never reused.

Retains the original implementation and regression coverage. The pagination fixture uses 75 PRs instead of 3,089 while still checking a match beyond page one. No production behavior was dropped or moved.

Verification

Readiness pass at c02dc64347a0c9a10f054e31936ac4a3ccd57791:

  • Merged github/main (becf853defb6) cleanly with a merge commit. This includes main's removal of the inherited unused mobile import; no task source edits were necessary. The PR remains five files, +482/-11 against main.
  • Blacksmith vp run check:changed becf853defb6127dbe4447860383777d69346b6f: passed formatting, lint, both knip checks, generated GraphQL, 18 affected package typechecks, and all 143 tests in three existing files.
  • Blacksmith vp run lint: passed all 5,815 files, zero errors or warnings.
  • Two independent GPT-6.1-Sol reviews approved this exact merged head with no blocker or should-fix findings.
  • Full CI for the pushed head is pending mirror synchronization.
  • Real Gitea runtime verification below belongs to the original takeover; it was not repeated in this merge-only readiness pass.

Original takeover verification:

  • Both sharing regressions failed on current github/main (210b2e7c6a8b): six page requests instead of four.
  • vp run check:changed through Blacksmith: passed format, lint, both knip checks, generated GraphQL, 17 affected package typechecks, and 143 tests across three existing files.
  • Real Gitea 1.25.2 with 55 API-created PRs, production driver, and installed tea 0.16.0: main made three requests per missing branch; candidate made four cold requests and zero for the next missing branch or an existing PR lookup. Candidate returned PR #55, then explicit refresh observed its closure despite a warm cached open result.
  • Two independent GPT-6.1-Sol reviews approved head 80fc4ce670043ce78ff4cde824c284d78076d422 with no findings.
  • Existing GitManager integration coverage checks latest-open selection across bases and discovery of a newly opened PR after an explicit refresh.
  • Unverified: installed fj, WSL, and production forge credentials. Cold/expired lookups still scan the repository; background reads can add one minute of snapshot staleness to the existing branch cache.

No UI changes or image evidence apply.

Scope and approval

Maria requested this maintainer takeover of #24853 and this readiness pass. It remains a focused fix for repeated Gitea branch-discovery scans, limited to the original five files. No UI or unrelated behavior changes.

Takeover

Replaces #24853, with thanks to @Zheruel for the original implementation.

Built with GPT-6.1-Sol in the Codex harness on T3 Code.

Checks

19 successful · 11 skipped
All checks passed
c02dc64

Added 1 commit

  • fix(forgejo): share complete Gitea PR scans across branches80fc4ce
Synced from GitHub

Approvability

Verdict: Approved at 80fc4ce

Macroscope's review found this PR approvable — This is a contained Forgejo/Gitea PR-discovery fix that shares complete repository scans for background lookups while preserving filtering and explicit refresh semantics. The production logic is narrowly scoped and accompanied by extensive regression coverage for pagination, cache expiry, failures, identity filtering, and concurrency.

No code changes detected at c02dc64. Prior analysis still applies.

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

Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
CodexLive turn messages220 (0.0%)8✅
ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
ClaudeLive turn messages220 (0.0%)8✅

Baseline: becf853 · PR result: c02dc64 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Synced from GitHub

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between 80fc4ce670043ce78ff4cde824c284d78076d422 and c02dc64347a0c9a10f054e31936ac4a3ccd57791.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

External image Recent review info
External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between 210b2e7c6a8be11441b7afc94742ce3c76860111 and 80fc4ce670043ce78ff4cde824c284d78076d422.

External image Files selected for processing: 5
  • apps/server/src/git/GitManager.test.ts
  • apps/server/src/git/GitManager.ts
  • packages/source-control-core/src/server/SourceControlProvider.ts
  • packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts
  • packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.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.

Walkthrough

Forgejo pull-request lookups now cache complete paginated scans by repository identity and filter the results for each lookup. GitManager passes cache preferences to the provider and disables cached results for refresh lookups.

Changes: Pull-request lookup caching

Layer / File(s)Summary
Forgejo scan cache and filtering
packages/source-control-core/src/server/SourceControlProvider.ts, packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.ts, packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts
The provider caches successful complete scans for one minute, keyed by CLI command, server URL, login, and repository. It filters results by branch, optional source repository and owner, and requested state. Tests cover pagination, cache reuse and expiry, identity isolation, uncached reads, scan failures, and in-flight lookups.
GitManager cache controls and lookup tests
apps/server/src/git/GitManager.ts, apps/server/src/git/GitManager.test.ts
GitManager passes cache preferences to provider lookups. Missing-PR and explicit refresh lookups disable provider caching. The Gitea-backed test checks paginated branch lookups and refresh results.

Priority: External image Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

mermaid
1sequenceDiagram
2 participant GitManager
3 participant ForgejoSourceControlProvider
4 participant RepositoryPullsCache
5 participant ForgejoPullListAPI
6 GitManager->>ForgejoSourceControlProvider: listChangeRequests with allowCached
7 ForgejoSourceControlProvider->>RepositoryPullsCache: Look up repository scan
8 RepositoryPullsCache-->>ForgejoSourceControlProvider: Return cached scan when available
9 ForgejoSourceControlProvider->>ForgejoPullListAPI: Fetch pull requests in pages on cache miss
10 ForgejoPullListAPI-->>ForgejoSourceControlProvider: Return paginated pull requests
11 ForgejoSourceControlProvider-->>GitManager: Return filtered pull requests

Possibly related issues

  • pingdotgg/t3code, issue 23551: This change detects ignored head filters by using a complete paginated scan and filtering the results by branch and source.

Suggested reviewers: juliusmarminge

Merge Risk: External image Minimal · previous review 80fc4

No confirmed issue prevents merging after normal checks.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title clearly identifies the Forgejo fix and the main change: sharing complete Gitea pull-request scans across branches.
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Description checkPassedThe pull request description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the issue, implementation, scope, approval context, test results, limitat…
Full details: Description check

Explanation

The pull request description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the issue, implementation, scope, approval context, test results, limitations, and agent usage. The approval reference is described through the linked takeover request and maintainer direction.

Finishing Touches: 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Added 1 commit

  • chore: merge main into takeover-pr-24853c02dc64