Repository navigation
feat(api): a deployment's timeline, its steps and agent actions (part of #265) - #418
Conversation
Signed-off-by: samuel mbabhazi <[email protected]>
… of #265) Signed-off-by: samuel mbabhazi <[email protected]>
Signed-off-by: samuel mbabhazi <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…ndings Signed-off-by: samuel mbabhazi <[email protected]>
) (#419) Closes #265 (step 2 of #413). The API it reads was merged in #418. ## What changed Screen 15 of the design, built on real data. It replaces the preview at `/deployments/sample`; the preview screen and its sample data are removed. **`…/applications/:applicationId/deployments/:deploymentId` (`delivery/deployment-page.ts`)** - **Header:** - the deployment's release number ("Deployment #3"), as the agent actions already name it, or the start of the release id when that release is not among the 50 most recent; - the status and the elapsed time; - the application, environment, image, trigger and who started it; - a link back to the application's Deployments tab. - **Step durations:** queued, build, release command, placement, starting, health check, switchover, draining, each with the time it began. The step a deployment failed in reads red, the running one blue. - **Timeline:** the audited steps and the agent actions merged by time, with the server, the result and the failure cause (the cause in red). - **While it runs:** the page reads the deployment again every 3 seconds, as the application page does, and stops once it has finished. - **Said plainly:** build output and the release command's output arrive with builds and log collection (M3.3, M6.1). It never shows sample lines. - **Not found:** an unknown deployment, or one read under another application, shows "Deployment not found". **`delivery/deployment-view.ts`** - A pure function from the deployment and its timeline to what the page shows. - Durations come in whole units ("< 1 s", "14 s", "2 min"), so there is no decimal mark to translate. **Application page** - In the Deployments tab, each deployment's version opens its page, and the current deployment's card has a "Details" button. - Deployments are named by their release number everywhere on that page (the list, the current deployment's card, "Roll back to #2", "Start #3"), as the agent actions and the new page already were. It falls back to the start of the release id for a release older than the 50 listed. The maintainer asked for it while validating. **French** - The new texts are translated. - Step labels are nouns ("Démarrage", "Drainage") rather than the existing verb keys. ## Size About 900 added lines, over the 500 we aim for. About 400 of them are tests, and the rest is one screen. It stays together because the page, its view model and the links into it make sense only as a whole. ## How it was tested - **Unit:** - `deployment-view.spec.ts`: durations, the failed and running step colours, steps and actions merged with steps first at the same instant, a stop, whole-unit durations. - `deployment-page.spec.ts`, through the real router: - the content and the back link; - a running deployment followed until it finishes, read twice, then no more; - French; - "Deployment not found"; - the link from the application page; - the trail naming the project once the shell loads it after the title. This test fails without the fix. - Web suite: green. Lint and typecheck green. - **Browser** (`tenant.browser.spec.ts`, production build and CSP): the page opens from its application's Deployments tab, shows its timeline, passes axe and has no CSP problem. 12 tests passed. - **Lab** (a real agent): captures on desktop in English and mobile in French, next to the mockup, of a succeeded deployment and of one made to fail its health check. No horizontal overflow, and no failed API call after sign-in. ## Security considerations - Read-only: it uses the routes of #418 (`environment.read`) and the existing deployment, release and application reads. - No new write and no new audit event. - No inline style, so the strict CSP is unchanged; the browser test runs under it. - Names typed by people (application, project, environment) are never translated. - Failure reasons come from the API and are already capped at 512 characters. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added deployment detail pages with status, elapsed time, release information, statistics, and a chronological activity timeline. * Added links from deployment listings to their detail pages, with clearer release-number labels. * Deployment details update while a deployment is in progress and show loading, unavailable, or error states. * Added French translations for deployment details, statuses, timeline entries, and related messages. * **Tests** * Added browser and component coverage for deployment navigation, status updates, timelines, and error states. * **Removed** * Removed the sample deployment preview screen and route. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: samuel mbabhazi <[email protected]>
Part of #265 (step 2 of #413). This is the API half; the deployment page follows in its own pull request.
What changed
GET …/applications/{applicationId}/deployments/{deploymentId}/timelineRequires
environment.read, with a session or a scoped token, like the other deployment reads. It answers:steps: the deployment's state changes, oldest first. Each hasfrom(null for the first),to,at, andreasonwhen it failed. They are read back from the audit log, where every change is already recorded (deployment.queued,.advanced,.failed,.cancelled,.rolled_back). Only the action, its metadata and its time are selected, never the actor or the address.actions: the agent actions the deployment requested, oldest first, at most 200. They use the same safe summaries as…/agent-actions(Show the agent actions run for an application #263), without payload or raw error.truncated: true when the deployment requested more actions than listed.Build and release command output is not part of it: that needs builds (M3.3) and log collection (M6.1). SPEC says so.
Code:
deployments/domain/timeline.ts: puredeploymentSteps(). Unknown actions and states that are not deployment states are left out rather than guessed. A failure reason is capped at 512 characters.DeploymentStepStore, implemented byPrismaDeploymentSteps, reads the audit rows in the tenant transaction.AgentActions.forDeployment()andAgentActionStore.forDeployment(). The history select and mapping are shared withforApplication(), and the encrypted payload is never selected.DeploymentCommands.timeline(): the same read check asget(), and the deployment is found under its own application before anything is read.The generated
openapi.json, API client and route and role matrix are updated, and SPEC describes the route.Why
#265 is the deployment page of the design: per-step timings and a log of what happened. The audit log already records every state change with its time, and the agent actions already carry their deployment (#263). Nothing exposed them per deployment.
How it was tested
timeline.spec.ts: pipeline order withfrom, a failure with its reason, a cancel and a rollback, unreadable events left out, the reason capped.deployment-timeline-http.integration.spec.ts, restricted runtime role):ensureNetworkaction on the enrolled server, read as an environment viewer;cancelledwith no action;outsiderandmemberget 404, as do a deployment read under another application and an unknown one;Security considerations
environment.read, then the application inside its environment, then the deployment inside its application. Anything else answers 404, without an existence leak.Summary by CodeRabbit