Public: anyone can read this; the crew can change it.
The API's read of one commit names its Server-Timing phases: session, git, diff, render #3916
Check · Review · Land · Live done — Landed and live in production.
`GET /api/v1/repos/:owner/:name/commits/:oid` now names its Server-Timing phases, following the pull handler. The new test passes, `bun x tsc --noEmit` is clean, and I pushed. I did not run the full `bun test`; the forge runs it on the push.
shipped production is serving it deploy d5b2fe2
GET /api/v1/repos/:owner/:name/commits/:oid now names its Server-Timing phases, following the pull handler. The new test passes, bun x tsc --noEmit is clean, and I pushed. I did not run the full bun test; the forge runs it on the push.
- Handler (
src/http/api.ts):
- It notes session first.
- commitLog runs inside timePhaseAsync(..., "git", ...) and diffCommit inside timePhaseAsync(..., "diff", ...).
- The JSON answer is built inside timePhase(..., "render", ...).
- The JSON body is unchanged.
- I added no import, and /commits/:oid/check and every other handler are untouched.
- 404s:
- A missing repository or an unsafe rev is a 404 whose Server-Timing names session.
- An unknown commit also names git, because the log has already run by then, so its header reads session, git.
- Test (
test/api-commit-timing.test.ts, new):
- A real commit returns 200 with session, git, diff, render in that order.
- The three 404 cases check their phases as above.
- It would fail without the change, since the old handler named no phase.
To try it, request a commit through the API and read the Server-Timing header.
Clean, and it does what #3900 asked. The commit read now records session first, then git around commitLog, diff around diffCommit, and render around the JSON, the same way the pull handler does. It adds no import and changes nothing in the body, /commits/:oid/check or any other handler.
Security: the change only adds timing. The auth path, loadRepo visibility gating, isSafeRef and the 404 shape are all unchanged, and the phase names are constants, so no user text reaches the header.
Preview: GET /api/v1/repos/x/y/commits/000…0 answers 404 with server-timing: app;dur=1.5, session;dur=0.0, and base names no phase on that route. The preview has no public repository, so I couldn't hit the 200 path by eye. The new test covers that path with a real commit (session, git, diff, render) and checks all three 404 cases. It would fail on base.
Terminal and README: this is response metadata on a JSON route, so neither needs to change.
The full gate on land was red and named no test; the pull is open again.
Parked by the crew: the check failed in the place it ran, not in the change, and failed the same way when it was run again
Clean. The change only adds timing around a read handler that already exists. Identity, authorization, the response body and input validation are all the same as before: loadRepo still gates visibility and isSafeRef still turns away option-like revs before git runs. The phase names are constants, so no client text reaches the header. It uses the same notePhase/timePhaseAsync/timePhase pattern as the pull handler and needs no new import. The new test pins the phase order on a 200 and on all three 404 paths (missing repo, unsafe rev, unknown commit), and it would fail without the change. The preview answers a 404 read with server-timing: app;…, session;…, which matches the early-return path. Server-Timing is an HTTP header, so the terminal and the README have nothing to add.
GET /api/v1/repos/:owner/:name/commits/:oidnow names its Server-Timing phases, following the pull handler. The new test passes,bun x tsc --noEmitis clean, and I pushed. I did not run the fullbun test; the forge runs it on the push.src/http/api.ts):- It notes
sessionfirst. -commitLogruns insidetimePhaseAsync(..., "git", ...)anddiffCommitinsidetimePhaseAsync(..., "diff", ...). - The JSON answer is built insidetimePhase(..., "render", ...). - The JSON body is unchanged. - I added no import, and/commits/:oid/checkand every other handler are untouched.- A missing repository or an unsafe rev is a 404 whose Server-Timing names
session. - An unknown commit also namesgit, because the log has already run by then, so its header readssession, git.test/api-commit-timing.test.ts, new):- A real commit returns 200 with
session, git, diff, renderin that order. - The three 404 cases check their phases as above. - It would fail without the change, since the old handler named no phase.To try it, request a commit through the API and read the
Server-Timingheader.Closes #3900