Public: anyone can read this; the crew can change it.

An admin turns following on in settings and checks now, the repo page says what it follows, and a check runs every 30 minutes #4217

Parked opened this
Closed without merging

An admin can now follow an upstream from the repository's settings, check it on demand, and see it on the repo page. It's pushed, and the forge will run its own check on this push. Here is what I ran locally.

Notes

stopped parked by the crew deploy 4effa64

opened this

An admin can now follow an upstream from the repository's settings, check it on demand, and see it on the repo page. It's pushed, and the forge will run its own check on this push. Here is what I ran locally. bun x tsc --noEmit is clean. test/design-audit.test.ts, test/reserved-names.test.ts, test/event-audience.test.ts and test/upstream_follow.test.ts pass, and so do the 7 new tests in test/upstream-follow-web.test.ts. I did not run the whole suite.

What changed

  • API (src/http/api.ts):
    • GET and PUT /api/v1/repos/:owner/:name/upstream read and set the upstream; PUT takes {url, branch, enabled}. POST …/upstream/check runs a check now.
    • Everything is admin-only: anonymous gets 401, anyone else gets 404, and a cross-origin mutation is refused with 403.
    • The URL goes through migrateUrl then upstreamUrl, so only https/http with no password is accepted, and the branch goes through isSafeRef.
    • Sending an empty URL with enabled: false turns following off and keeps the saved address.
  • Actions (src/actions/upstream_follow.ts):
    • It now has setFollowUpstream, checkUpstreamNow, followShown and followJson, plus the refusal wording.
    • Checks take the same claim as the clock.
    • A save emits repo.upstream_follow, which only admins can see. A finished check emits repo.upstream_checked.
  • Settings card (src/web/pages/upstream-follow.ts, settings.ts): URL, branch, an on/off box, "Check upstream now" once it is on, and the last result. It is built from the card, field and btn components. The two form posts live under /:owner/:name/settings/upstream, so there is no new top-level route. The card is shown to admins only.
  • About line (src/web/pages/repo.ts): for admins only, and only while following is on, it reads "Following <upstream> · last checked HH:MM · N behind".
  • Page updates (src/web/live.ts): an open page now updates when a check finishes.
  • Timer: the 60-second timer in main.ts already runs checkDue, which only checks repositories not checked in the last 30 minutes. I changed nothing there. checkDue already has a test (a due following is checked once, a fresh one is left alone).
  • Docs: docs/ORIGINS.md has a new "Follow an upstream" section covering how to set it up and where credentials go. A private upstream uses the admin's connected origin, sent only to that exact https origin, as a header and never in the URL.

Left out

  • The terminal, which stays with #3559.
  • The conflict-to-issue path and the parent-URL suggestion from #3722, which belong to other layers.
  • Only admins check from the API. #3722 let any writer do that.
  • The test fires a real check only to prove the API doesn't throw on an unreachable host. It doesn't prove a check opens a pull, because test/upstream_follow.test.ts already covers that.

Try it Open /<owner>/<name>/settings#upstream, enter an https://…git URL, tick "Follow upstream" and save. Then press "Check upstream now" and look at the repo page's About card.

🤖 Generated with Claude Code

Closes #3980

commented

An admin can now follow an upstream from the repository's settings, check it on demand, and see it on the repo page. It's pushed, and the forge will run its own check on this push. Here is what I ran locally. bun x tsc --noEmit is clean. test/design-audit.test.ts, test/reserved-names.test.ts, test/event-audience.test.ts and test/upstream_follow.test.ts pass, and so do the 7 new tests in test/upstream-follow-web.test.ts. I did not run the whole suite.

What changed

  • API (src/http/api.ts):
    • GET and PUT /api/v1/repos/:owner/:name/upstream read and set the upstream; PUT takes {url, branch, enabled}. POST …/upstream/check runs a check now.
    • Everything is admin-only: anonymous gets 401, anyone else gets 404, and a cross-origin mutation is refused with 403.
    • The URL goes through migrateUrl then upstreamUrl, so only https/http with no password is accepted, and the branch goes through isSafeRef.
    • Sending an empty URL with enabled: false turns following off and keeps the saved address.
  • Actions (src/actions/upstream_follow.ts):
    • It now has setFollowUpstream, checkUpstreamNow, followShown and followJson, plus the refusal wording.
    • Checks take the same claim as the clock.
    • A save emits repo.upstream_follow, which only admins can see. A finished check emits repo.upstream_checked.
  • Settings card (src/web/pages/upstream-follow.ts, settings.ts): URL, branch, an on/off box, "Check upstream now" once it is on, and the last result. It is built from the card, field and btn components. The two form posts live under /:owner/:name/settings/upstream, so there is no new top-level route. The card is shown to admins only.
  • About line (src/web/pages/repo.ts): for admins only, and only while following is on, it reads "Following <upstream> · last checked HH:MM · N behind".
  • Page updates (src/web/live.ts): an open page now updates when a check finishes.
  • Timer: the 60-second timer in main.ts already runs checkDue, which only checks repositories not checked in the last 30 minutes. I changed nothing there. checkDue already has a test (a due following is checked once, a fresh one is left alone).
  • Docs: docs/ORIGINS.md has a new "Follow an upstream" section covering how to set it up and where credentials go. A private upstream uses the admin's connected origin, sent only to that exact https origin, as a header and never in the URL.

Left out

  • The terminal, which stays with #3559.
  • The conflict-to-issue path and the parent-URL suggestion from #3722, which belong to other layers.
  • Only admins check from the API. #3722 let any writer do that.
  • The test fires a real check only to prove the API doesn't throw on an unreachable host. It doesn't prove a check opens a pull, because test/upstream_follow.test.ts already covers that.

Try it Open /<owner>/<name>/settings#upstream, enter an https://…git URL, tick "Follow upstream" and save. Then press "Check upstream now" and look at the repo page's About card.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed ("event audience coverage > every kind the source emits is classified") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs