Loading
Expose restartedAs on the DuoWorkflow GraphQL type
What does this MR do and why?
Adds a restartedAs field to DuoWorkflow so the Sessions widget can tell whether a failed or cancelled session has already been retried, and link to the retry.
- Add
restartedAstoDuoWorkflow, returning the newest session restarted from the session, ornull - Batch load it, so a page of sessions costs one indexed lookup of restart links, one lookup of sessions by ID, and batched preloads of their projects and routes
- Mark the field as a GraphQL experiment, since session restarts are still behind the
dap_session_restartsfeature flag
Why a new field
inverseWorkflowLinksalready exposes the sessions restarted from a session, but it hasFieldCallCount limit: 1like the other link connections on this type. It can only be resolved for one session per request, and the widget lists up to 20.- Lifting that limit without adding a query per session would need batch loading the connection with
LazyRelationLoader, which uses aJOIN LATERALquery. The widget only needs the newest restart for each session, which a single-value field returns with indexed lookups. - Turning
restartDuoWorkflowoff once a session is retried would hide Retry, but it would also block retrying again from the session page, it can't tell "already retried" apart from "not allowed", and it gives no session to link to.
Plan
| # | MR | What it adds |
|---|---|---|
| 1 | Add Retry to failed and cancelled sessions in the Sessions widget | Retry button on failed and cancelled sessions, at the end of the row and borderless |
| 2 | Expose restartedAs on the DuoWorkflow GraphQL type | restartedAs field, so the widget can tell a session was retried |
| 3 | Show a View retry link on retried sessions in the Sessions widget | Retried failed and cancelled sessions get a View retry link |
We split it this way so the Retry button (1) can merge without waiting on the backend field (2). Only the design feedback on what happens after a retry needs the new field, so that part (3) is stacked on 2.
See design and UX discussion - !263742 (comment 4059242321)
References
- Related to FE: Add retry button to sessions widgets compon... (#598747 - closed) • Allison Villa • 19.6 • At risk
- Retry button MR: Add Retry to failed and cancelled sessions in t... (!263742 - merged) • Allison Villa • 19.6
- Stacked frontend MR: Show a View retry link on retried sessions in t... (!268887 - merged) • Allison Villa • 19.6
- Epic: Session Resilience & Recovery (gitlab-org#22549) • Unassigned • 19.7 • On track
inverseWorkflowLinkswas added in Add GraphQL endpoint for workflow-workflow links (!258867 - merged) • Roman Eisner • 19.5
Screenshots or screen recordings
No UI changes
How to set up and validate locally
- Prerequisite: Have GitLab Duo set up in your GDK or Caproni
- Have a Duo-enabled group and project created by the Duo setup above
- Prerequisite: Have GitLab Runner working in your GDK or Caproni
- Enable the
dap_session_restartsfeature flag. - Start a session in the Duo-enabled project. For example, select Implement on an issue.
- Open the session at
/<project full path>/-/automate/agent-sessions/<session ID>. - Select Cancel session.
- Select Retry session. A new session starts.
- Go to
/-/graphql-explorerand run:query { duoWorkflowWorkflows(projectPath: "<project full path>") { nodes { id status restartedAs { id webPath } } } } - Check that the cancelled session's
restartedAsis the new session, and the new session'srestartedAsisnull. - Retry the cancelled session again and rerun the query.
restartedAsis now the newest retry.
Edited by Allison Villa