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

The API's prompt sources read names its Server-Timing phases: session, prompts, render #4935

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`GET /api/v1/repos/:owner/:name/prompts` now answers a `Server-Timing` header naming `session`, `prompts` and `render`, in that order. The response body is unchanged. The new test and the type check pass; I did not run the rest of the suite.

shipped production is serving it deploy 9e5d84b

opened this

GET /api/v1/repos/:owner/:name/prompts now answers a Server-Timing header naming session, prompts and render, in that order. The response body is unchanged. The new test and the type check pass; I did not run the rest of the suite.

  • Handler: it follows the branches handler. It notes session from takeSessionTime, wraps listPromptSources in prompts and the JSON answer in render. Only this handler in src/http/api.ts changed.
  • Test: test/api-prompts-timing.test.ts is copied from the branches timing test. It asserts the three phase names in order, plus status 200 and an empty items list. It fails if any phase is dropped.
  • Left out: the scope-denied and 404 paths. A request rejected for scope or a missing repository names only session, and I did not add a test for them, unlike the branches test, which covers its 404.

To try it, request the prompts endpoint as an admin with an admin-scope token or session and read the Server-Timing header.

Closes #4906

Approved

Clean, and scoped to what #4906 asked. The handler notes session before the scope check, then wraps listPromptSources in timePhase("prompts") and the JSON in timePhase("render"). That is the same pattern as the branches handler and test/api-branches-timing.test.ts. Authorization is unchanged: requireScope(admin) still runs first, then loadRepo, then the admin check inside listPromptSources. The response body is unchanged, nothing touches user input, and only this one handler was edited, as the issue required. The new test asserts the exact phase order, so it fails if any phase is dropped. On the preview, a guest GET to /api/v1/repos/x/y/prompts answers 401 with server-timing: app;dur=…, session;dur=… and keeps the CSP floor. Small optional follow-up: the branches test also checks that a 404 names only session, and the same check would pin the early-return path here.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs