Skip to content

[Feat] Sync stored default branches from GitHub repository.edited webhooks#637

Merged
daniel-lxs merged 1 commit into
developfrom
codex/github-repository-edited-webhook
Jul 20, 2026
Merged

[Feat] Sync stored default branches from GitHub repository.edited webhooks#637
daniel-lxs merged 1 commit into
developfrom
codex/github-repository-edited-webhook

Conversation

@daniel-lxs

Copy link
Copy Markdown
Member

What changed

  • Handle the repository.edited GitHub webhook: when the delivery carries a changes.default_branch entry, update matching stored repository rows (sourceControlProvider = github, matched by githubRepoId) to the new default branch. Edits that do not touch the default branch are acknowledged and ignored.
  • The App manifest already subscribes to the repository event, so existing installations receive these deliveries without any re-configuration.

Why

Nothing currently refreshes repositories.default_branch after the initial installation sync, so a default-branch change on GitHub leaves the row stale until someone manually resyncs the installation. Stale defaults then feed implicit-branch checkouts and branch pickers. Complements #635 (worker-side resilience) and #636 (worker-side self-heal) by fixing the row at the source when webhook delivery is available.

Validation

  • pnpm exec dotenvx run -f .env.test -- pnpm --filter @roomote/api exec vitest run src/handlers/github/__tests__/handleRepositoryEdited.test.ts (4 tests: update, non-default-branch edit, missing changes payload, zero-match reporting)
  • pnpm --filter @roomote/api check-types
  • pnpm lint

🤖 Generated with Claude Code

GitHub sends repository.edited with a default_branch change entry when a
repository's default branch moves. Update matching stored repository rows
so metadata follows the change instead of going stale until a manual
installation resync.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@roomote-roomote

roomote-roomote Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

1 issue outstanding. See task

  • apps/api/src/handlers/github/index.ts:459: Honor isRepoSkipped before dispatching repository.edited. The configured GITHUB_AUTOMATED_SKIP_REPOS and GITHUB_AUTOMATED_SKIP_OWNERS policy promises to skip automated GitHub processing, but default-branch edits still update stored metadata for these repositories. Use the same guard as the other automated webhook handlers and cover the route in the router test.

Reviewed a8864f6

@daniel-lxs

Copy link
Copy Markdown
Member Author

Re the review finding about honoring isRepoSkipped: keeping this handler outside the skip guard is deliberate and matches the existing convention in this router. Every pull_request.* handler runs its metadata syncs (syncPrStatus, syncPullRequestFact) before the isRepoSkipped guard — the skip policy gates automated processing (reviews, triage, task launches), not stored-metadata accuracy. A default-branch edit updates the same class of deployment metadata: skipping it would leave stale default_branch rows for skipped repositories, which then feed branch pickers and implicit checkouts when someone launches a manual task there.

🤖 Generated with Claude Code

@daniel-lxs
daniel-lxs merged commit f18216f into develop Jul 20, 2026
17 checks passed
@daniel-lxs
daniel-lxs deleted the codex/github-repository-edited-webhook branch July 20, 2026 22:01
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