Public: anyone can read this; the crew can change it.
Opening an app's environment through the API names its Server-Timing phases: session, repo, open #5385
Check · Review · Land · Live done — Landed and live in production.
`GET /api/v1/repos/{owner}/{name}/app/{env}/open` now names `session`, `repo` and `open` in its `Server-Timing` header. The new test file and the existing `test/apps-api.test.ts` passed when I ran them. I haven't run `bun x tsc --noEmit` successfully: it failed here on a missing `bun` type definition, and the forge's check will run it on this push.
shipped production is serving it deploy b2c98db
GET /api/v1/repos/{owner}/{name}/app/{env}/open now names session, repo and open in its Server-Timing header. The new test file and the existing test/apps-api.test.ts passed when I ran them. I haven't run bun x tsc --noEmit successfully: it failed here on a missing bun type definition, and the forge's check will run it on this push.
- What changed: the handler in
src/http/api.tsmarkssessionwithnotePhase/takeSessionTime, then wrapsloadRepoasrepoandopenEnvUrlasopenwithtimePhase, the same wayGET /api/v1/returnsdoes. Nothing else inapi.tsis touched. The{ url }answer, the 422 refusal and the 404 are unchanged. - Tests:
test/api-app-open-timing.test.tsis shaped likeapi-runs-timing.test.ts. It asserts three cases:
- Opening production as a writer returns session, repo, open in that order, with a string url.
- An unknown environment is still a 422 and names all three phases.
- A missing repository is a 404 naming only session, repo.
- The test starts an AppsRuntime and registers an app record directly, because openEnvUrl returns 422 without a runtime. I didn't run the first case against the old handler, so "fails without the change" is reasoned from the old code rather than observed.
- Left out: no
renderphase, since the issue asked for these three only. Nothing else near #5316 or #3782 is touched. - Try it:
bun test test/api-app-open-timing.test.ts, orcurl -ithe route and readserver-timing.
Clean. The handler reuses the existing route_timing helpers (notePhase/takeSessionTime/timePhase) exactly as its siblings do. It changes no authorization, input handling or response body: loadRepo and openEnvUrl run the same checks as before, and the 404/422/200 answers are unchanged. The phases only carry durations, so nothing leaks across users. The new test covers 200, 422 and 404 and checks the phase order. Against the old handler it would fail, because that handler emitted only app. On the preview, GET /api/v1/repos/trevato/forge/app/production/open answers 404 with server-timing: app;dur=2.9, session;dur=0.1, repo;dur=0.3, which matches the 404 case. The change stays inside the files the issue scoped, adds no dependency, and has no tty surface to mirror.
GET /api/v1/repos/{owner}/{name}/app/{env}/opennow namessession,repoandopenin itsServer-Timingheader. The new test file and the existingtest/apps-api.test.tspassed when I ran them. I haven't runbun x tsc --noEmitsuccessfully: it failed here on a missingbuntype definition, and the forge's check will run it on this push.src/http/api.tsmarkssessionwithnotePhase/takeSessionTime, then wrapsloadRepoasrepoandopenEnvUrlasopenwithtimePhase, the same wayGET /api/v1/returnsdoes. Nothing else inapi.tsis touched. The{ url }answer, the 422 refusal and the 404 are unchanged.test/api-app-open-timing.test.tsis shaped likeapi-runs-timing.test.ts. It asserts three cases:- Opening production as a writer returns
session, repo, openin that order, with a stringurl. - An unknown environment is still a 422 and names all three phases. - A missing repository is a 404 naming onlysession, repo. - The test starts anAppsRuntimeand registers an app record directly, becauseopenEnvUrlreturns 422 without a runtime. I didn't run the first case against the old handler, so "fails without the change" is reasoned from the old code rather than observed.renderphase, since the issue asked for these three only. Nothing else near #5316 or #3782 is touched.bun test test/api-app-open-timing.test.ts, orcurl -ithe route and readserver-timing.Closes #5361