Add agent plan WI widget; expose through GraphQL
What does this MR do and why?
Stacked MR on top of Create WorkItem::AgentPlan and its table, with ... (!232335 - merged).
Adds the agent plan work item widget, and exposes it through GraphQL. This is per https://gitlab.com/gitlab-org/gitlab/-/work_items/596369+, specifically MRs 2 and a bit of 3 of https://gitlab.com/gitlab-org/gitlab/-/work_items/596369#note_3267365555 — it didn't seem to amount to enough to have just the widget without the API bits.
Mostly following the steps at https://docs.gitlab.com/development/work_items_widgets/#create-a-new-backend-widget, with heavy reference to Draft: Add Work Item WorkPlan widget (!230936). Used ai_workflows as the licensed feature for now per !231689 (comment 3260218282).
How to set up and validate locally
Since it's not wired up to the frontend yet, these instructions assume you have the glab command line tool setup and authorised against your gdk.test instance as the user you like to use. You'll need GDK with an EE license.
-
Read a work item's agent plan by setting
WIIDto the global ID of the WI, e.g.gid://gitlab/WorkItem/123. Note the ID is the database ID, not the per-namespace IID, and executing:glab api --hostname gdk.test graphql \ -F query='query { workItem(id: "'"$WIID"'") { features { agentPlan { content contentHtml } } } }'Example output when there's no agent plan for a WI yet:
$ glab api --hostname gdk.test graphql -F query='query { workItem(id: "gid://gitlab/WorkItem/662") { features { agentPlan { content contentHtml } } } }' { "data": { "workItem": { "features": { "agentPlan": { "content": null, "contentHtml": "" } } } } } -
Update the agent plan for an existing work item:
glab api --hostname gdk.test graphql \ -F query='mutation { workItemUpdate(input: { id: "'"$WIID"'", agentPlanWidget: { content: "## My Plan\n\nStep 1: do the thing." } }) { workItem { features { agentPlan { content contentHtml } } } errors } }'Example output:
$ glab api --hostname gdk.test graphql -F query='mutation { workItemUpdate(input: { id: "gid://gitlab/WorkItem/662", agentPlanWidget: { content: "## My Plan\n\nStep 1: do the thing." } }) { workItem { features { agentPlan { content contentHtml } } } errors } }' { "data": { "workItemUpdate": { "workItem": { "features": { "agentPlan": { "content": "## My Plan\n\nStep 1: do the thing.", "contentHtml": "\u003ch2 id=\"user-content-my-plan\" data-sourcepos=\"1:1-1:10\" dir=\"auto\"\u003eMy Plan\u003ca href=\"#my-plan\" aria-label=\"Link to heading 'My Plan'\" data-heading-content=\"My Plan\" class=\"anchor\"\u003e\u003c/a\u003e\u003c/h2\u003e\u0026#x000A;\u003cp data-sourcepos=\"3:1-3:21\" dir=\"auto\"\u003eStep 1: do the thing.\u003c/p\u003e" } } }, "errors": [] } } } -
Create a new work item with an agent plan (set
NSPto a namespace path, likeflightjs/Flight):glab api --hostname gdk.test graphql \ -F query='mutation { workItemCreate(input: { title: "Test agent plan", workItemTypeId: "gid://gitlab/WorkItems::Type/1", namespacePath: "'"$NSP"'", agentPlanWidget: { content: "## Plan\n\nDo the thing." } }) { workItem { id features { agentPlan { content contentHtml } } } errors } }'Example output:
$ glab api --hostname gdk.test graphql -F query='mutation { workItemCreate(input: { title: "Test agent plan", workItemTypeId: "gid://gitlab/WorkItems::Type/1", namespacePath: "root/comrak", agentPlanWidget: { content: "## Plan\n\nDo the thing." } }) { workItem { id features { agentPlan { content contentHtml } } } errors } }' { "data": { "workItemCreate": { "workItem": { "id": "gid://gitlab/WorkItem/673", "features": { "agentPlan": { "content": "## Plan\n\nDo the thing.", "contentHtml": "\u003ch2 id=\"user-content-plan\" data-sourcepos=\"1:1-1:7\" dir=\"auto\"\u003ePlan\u003ca href=\"#plan\" aria-label=\"Link to heading 'Plan'\" data-heading-content=\"Plan\" class=\"anchor\"\u003e\u003c/a\u003e\u003c/h2\u003e\u0026#x000A;\u003cp data-sourcepos=\"3:1-3:13\" dir=\"auto\"\u003eDo the thing.\u003c/p\u003e" } } }, "errors": [] } } }
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.