Skip to content

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

Open
maria-rcks wants to merge 2 commits into
mainfrom
maria/takeover-pr-24853
Open

maria-rcks wants to merge 2 commits into
mainfrom
maria/takeover-pr-24853

Conversation

@maria-rcks

@maria-rcks maria-rcks commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

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 https://git.cafe/pingdotgg/t3code/pulls/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 https://git.cafe/pingdotgg/t3code/pulls/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 https://git.cafe/pingdotgg/t3code/pulls/24853, with thanks to @Zheruel for the original implementation.

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

Co-authored-by: Tin Zeljar <35663757+Zheruel@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 26, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 2 2 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (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.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

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

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 80fc4ce and c02dc64.

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.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 210b2e7 and 80fc4ce.

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: Low

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant GitManager
  participant ForgejoSourceControlProvider
  participant RepositoryPullsCache
  participant ForgejoPullListAPI
  GitManager->>ForgejoSourceControlProvider: listChangeRequests with allowCached
  ForgejoSourceControlProvider->>RepositoryPullsCache: Look up repository scan
  RepositoryPullsCache-->>ForgejoSourceControlProvider: Return cached scan when available
  ForgejoSourceControlProvider->>ForgejoPullListAPI: Fetch pull requests in pages on cache miss
  ForgejoPullListAPI-->>ForgejoSourceControlProvider: Return paginated pull requests
  ForgejoSourceControlProvider-->>GitManager: Return filtered pull requests
Loading

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: Minimal · previous review 80fc4

No confirmed issue prevents merging after normal checks.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly identifies the Forgejo fix and the main change: sharing complete Gitea pull-request scans across branches.
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.
Description check Passed 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, 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.

maria-rcks commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Note

Written by gpt-6.1-sol on behalf of Maria

Verified in a real dev environment

verified unchanged head c02dc64347a0c9a10f054e31936ac4a3ccd57791 against github/main at c3858bf1f7. read the description, diff, discussion, and authors. the pr is open and has no commits by julius or theo.

ran vp i in both checkouts and one background vp run dev at a time, stopping main by its captured process group first. drove the actual web app with repository playwright and /usr/bin/google-chrome. added real git projects through the app, created threads, selected codex gpt-6.1-sol, and completed real provider turns through the local proxy. no replay provider, mocks, seeded database, or demo data.

used real gitea 1.25.2, tea 0.16.0, and a disposable repository with 55 actual prs. gitea ignored the head filter. pr #1 for feature was beyond the first 50 results and targeted release/arbitrary.

  • main reproduced repeated full scans: missing-a and missing-b each fetched pages 1, 2, and 3.
  • this head made four cold requests, then reused the complete scan for a second worktree and the feature lookup without another list request. the app discovered pr #1 and preserved its arbitrary base.
  • after remote closure, the action menu refresh showed closed. after remote reopening, refresh restored the open/merge state. no merge was invoked.
  • a second real codex turn completed and triggered fresh filtered branch scans after another remote closure. the disposable pr was restored to open afterward.

short transcript summarized from the real gitea access log, inspected with docker logs --since ... t3-pr25569-gitea:

main, 11:12:50: head=missing-b pages=1,2,3 -> 200
main, 11:12:50-51: head=missing-a pages=1,2,3 -> 200
pr, 11:16:27: head=missing-b page=1 -> 200
pr, 11:16:27: complete scan pages=1,2,3 -> 200
pr, 11:16:31: second worktree missing-a -> no additional list requests
pr, 11:16:52: feature discovered -> GET /pulls/1, no additional list requests
pr, 11:19:32-33: post-turn refresh -> fresh head=feature pages=1,2,3

remote closure observed by explicit refresh, with real codex response and arbitrary base

explicit refresh observes closure and reopening

inspected captures and verified uploaded video playback and seeking in t3 preview. this changes server behavior, so no visual before/after comparison applies.

blacksmith: vp i && vp test run packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts apps/server/src/git/GitManager.test.ts passed all 142 tests in both existing files. current head has 30 successful ci checks, zero failing or pending. no source changes were needed.

Not verified

native ios/android and electron clients, macos/windows/wsl, installed fj, other forge accounts or fork identities, and real-time cache expiry/failure/concurrency scenarios. the runtime pass used linux, chrome, tea, and real local gitea; focused existing tests cover broader cache boundaries.

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:M 30-99 changed lines (additions + deletions). vouch:trusted PR 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