Follow Forgejo PR and issue lifecycle in mapped sessions #75

Merged
lucas merged 2 commits from agent/issue-72-pr-lifecycle into main 2026-10-26 14:18:59 +01:00
Collaborator

Closes: #72

Implements the plan in #72:

  • Classifier (webhook.ts): pull_request / pull_request_sync actions synchronized, closed, reopened and issues actions closed, reopened are queued. Agent pushes are ignored as self-authored; agent close/reopen are not.
  • Shared archive (session-archive.ts): archiveSession (set archived, broadcast sessions_changed, dispose the live handle, remove the clone) is used by POST /sessions/:id/archive and the dispatcher.
  • Dispatcher:
    • close/reopen run no turn and need no API. PR closed → archive (archived: merged / archived: closed without merge). Issue closed → archive, unless it is an implementer session with a PR. Reopen → unarchive. Before archiving, a running turn is given until the session kind's turn timeout to finish.
    • synchronized only continues a mapped session (dropped otherwise, no permission check). The clone is refreshed first (refreshPullCheckout: detached reviewer clones move to the new PR head if clean; implementer clones only fetch --prune), then the turn gets the new commits via buildPullSyncSeed.
  • Protocol union widened; changelog and the webhook event list in docs/configuration.md updated.

Verification

  • bun run typecheck passes, and the full server suite passes (887 tests) after rebasing onto main.
  • New tests: classifier cases, dispatcher lifecycle (merge/close/issue-close/reopen/unmapped/wait-for-turn/push reviewer/push implementer/push unmapped), and real-git refreshPullCheckout (detached clean/dirty, branch mode).
  • I did not run the manual end-to-end check against a live Forgejo.

Notes

  • I didn't check the Forgejo facts against Forgejo itself: Event-Type pull_request_sync with action synchronized, and pull_request.merged on closed payloads. They come from Forgejo's modules/webhook/type.go / API structs as I remember them. If a merge doesn't show merged, the session is still archived, but the row reason says "closed without merge".
  • Upstream added a sessions_changed broadcast to the archive route while this branch was open. That broadcast now lives in the shared helper, and the webhook reopen path also broadcasts it.
Closes: #72 Implements the plan in #72: - **Classifier** (`webhook.ts`): `pull_request` / `pull_request_sync` actions `synchronized`, `closed`, `reopened` and `issues` actions `closed`, `reopened` are queued. Agent pushes are ignored as self-authored; agent close/reopen are not. - **Shared archive** (`session-archive.ts`): `archiveSession` (set archived, broadcast `sessions_changed`, dispose the live handle, remove the clone) is used by `POST /sessions/:id/archive` and the dispatcher. - **Dispatcher**: - close/reopen run no turn and need no API. PR closed → archive (`archived: merged` / `archived: closed without merge`). Issue closed → archive, unless it is an implementer session with a PR. Reopen → unarchive. Before archiving, a running turn is given until the session kind's turn timeout to finish. - `synchronized` only continues a mapped session (dropped otherwise, no permission check). The clone is refreshed first (`refreshPullCheckout`: detached reviewer clones move to the new PR head if clean; implementer clones only `fetch --prune`), then the turn gets the new commits via `buildPullSyncSeed`. - Protocol union widened; changelog and the webhook event list in `docs/configuration.md` updated. ### Verification - `bun run typecheck` passes, and the full server suite passes (887 tests) after rebasing onto main. - New tests: classifier cases, dispatcher lifecycle (merge/close/issue-close/reopen/unmapped/wait-for-turn/push reviewer/push implementer/push unmapped), and real-git `refreshPullCheckout` (detached clean/dirty, branch mode). - I did not run the manual end-to-end check against a live Forgejo. ### Notes - I didn't check the Forgejo facts against Forgejo itself: Event-Type `pull_request_sync` with action `synchronized`, and `pull_request.merged` on closed payloads. They come from Forgejo's `modules/webhook/type.go` / API structs as I remember them. If a merge doesn't show `merged`, the session is still archived, but the row reason says "closed without merge". - Upstream added a `sessions_changed` broadcast to the archive route while this branch was open. That broadcast now lives in the shared helper, and the webhook reopen path also broadcasts it.
Pushes to a pull request with a mapped session refresh its clone and run
a turn listing the new commits (pushes by the agent are ignored; no
permission check). Merging or closing a PR, or closing an issue,
archives the mapped session and removes its clone, waiting for a running
turn up to the session kind's turn timeout; an implementer session with
a PR is only archived through that PR. Reopening unarchives without a
turn. The archive logic is shared with POST /sessions/:id/archive.

Closes: #72
Co-Authored-By: Claude Opus 5.5 via omp-deck
The shared archive helper now emits sessions_changed like the deck's
archive route did, and the reopen path does the same after unarchiving,
so open decks refresh their session lists.

Co-Authored-By: Claude Opus 5.5 via omp-deck
lucas approved these changes 2026-10-26 14:18:54 +01:00
lucas merged commit 2e6eb4e6fc into main 2026-10-26 14:18:59 +01:00
lucas deleted branch agent/issue-72-pr-lifecycle 2026-10-26 14:19:00 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lucas/omp-deck!75
No description provided.