refactor(server): migrate webhook-handlers to ForgePort — final Forgejo consumer #281
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!281
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refactor/migrate-webhook-handlers-to-forgeport"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Final pass at the Forgejo consumer migration kicked off by #274. After this lands, the only non-adapter importers of
forgejo-api.tsleft in the server are (a)deps.ts' acknowledgedgetIssueBlockshold-out for the cross-repo filter (#196) and (b)webhook.test.tsfor test-only coverage.Port extensions
ForgePort.listPullRequests(repo, state, opts?: { baseRef?: string })— matches Forgejo's server-sidebase=<ref>filter. Adapter routes tolistOpenPullRequestsForBasewhen set,listOpenPullRequestsotherwise.ForgePort.repoHasWorkflows(repo): Promise<boolean>— no-CI fallback path needs this check; delegates to the existingapi.repoHasWorkflows.webhook-handlers.ts
8 call sites migrated (
getIssue,listOpenPullRequests,listPullReviews,getPullRequest×3,repoHasWorkflows,listOpenPullRequestsForBase).findLinkedPrForIssuereturn shape flipped from raw{number, head: {sha,ref}, user: {login}}to domain{number, headSha, headRef, author}— internal helper onlylatestVerdictsignature migrated toForgeReview[]+ lowercase enum +commitSha; only consumer is same-filedetectOutstandingChangeRequestfetchLinkedIssueLabelsreadsissue?.labelsdirectly (string[] now)fetchPrDispatchLabelsbroadened to acceptlabels: ({name}|string)[]to bridge raw-payload and port-shaped inputshandlePostMergeRebasereuses oneForgejoAdapteracross the loop; readspr.author/pr.headSha/detail.headSha|body|mergeabledirectlyAdditional clean-up caught in review
Subagent review caught three sites missed in earlier PRs; migrated here for completeness:
pipeline.tsbounce-review handler —getPullRequest,deleteReviewRequest,requestReviewers→forge.getPullRequest,forge.removeReviewRequest,forge.requestReview. Readspr.requestedReviewers(string[]) directly instead of(pr.requested_reviewers ?? []).map(r => r.login).board.tsdrag-to-assign —updateIssueAssignees→forge.updateAssigneesboard.tsreroute handler —updateIssueAssignees+createIssueComment→forge.updateAssignees+forge.createComment(reused adapter)board.tstop-of-file docstring — updated the dispatch-path note to referenceForgejoAdapter.updateAssigneesWhat stays raw (intentional)
issues.*,pull_request.*,issue_comment,pull_request_review) — the port is for outbound API calls, not for bodies Forgejo sends us.pr.user.login,comment.user.login,pr.head?.ref, etc. continue to read from raw payloads.labelNames()helper — still needed for raw-payload call sites (webhook-handlers.ts:135, 389, 435).deps.ts::getIssueBlocks— the documented cross-repo filter hold-out from #277. Future work: addsourceRepo?: stringtoForgeIssueRefand migrate.Checks
bunx tsc --noEmit -p apps/server/tsconfig.json— EXIT=0bun --cwd apps/server test— 1006 pass / 4 pre-existing failsgrep -rn "infrastructure/forge/forgejo-api" apps/server/src --include="*.ts"post-merge:deps.ts— 1 documented hold-outwebhook.test.ts— 1 test-onlyforgejo-adapter.ts— the implementationforgejo-api.ts— the module itselfFollow-ups (not in this PR)
forgejo-api.tsexports — most are now only reachable via the adapter; unused exports can be prunedforeman.ts(prerequisite for agent-runner SDK migration)agent-runner.tstoSdkClaudeAgent— biggest SDK-decoupling winb77d93bdad56e4b6b678