From 4e781c93234f6c9a553ac7baaecee6af64361a06 Mon Sep 17 00:00:00 2001 From: Sas Swart Date: Fri, 6 Mar 2026 14:20:00 +0200 Subject: [PATCH] feat: allow sending follow-up prompts to a task when resuming (#22302) ## Summary This PR adds a follow-up flow for paused Tasks so users can submit another prompt as part of resuming the same task/session. https://github.com/user-attachments/assets/eabe5e91-704c-44ad-9e28-39f55e6c5923 ## What changed - **Task page UX** - Added a new **Follow-up** action in paused task state. - Added `FollowUpDialog` to collect and submit follow-up input. - **Follow-up flow behavior** - If task is paused/stopped: call resume first, then wait for polling to observe task `active`, then send input. - Dialog closes itself after successful send. - Added clear error handling for: - resume failure - build failure/canceled while resuming - send failure - **Stable API route parity** - Added `POST /tasks/{user}/{task}/pause` and `POST /tasks/{user}/{task}/resume` to the stable `/api/v2/tasks` router block. - **SDK alignment** - Updated `codersdk` pause/resume methods to use stable `/api/v2/tasks/...` endpoints instead of `/api/experimental/...`. - **Frontend API/query alignment** - `site` task pause/resume/send paths are on stable `/api/v2/tasks/...`. - Updated task query helpers accordingly. - **Storybook coverage** - Added follow-up dialog stories for key states: - open dialog - active direct send - auto-resume then send - resuming progress visible - resume build failure - send failure - empty message disabled - Added/updated mocks for task logs and new follow-up flows. Closes https://github.com/coder/internal/issues/1269 --- site/src/pages/TaskPage/FollowUpDialog.tsx | 95 ++++++ site/src/pages/TaskPage/TaskPage.stories.tsx | 321 +++++++++++++++++++ site/src/pages/TaskPage/TaskPage.tsx | 240 +++++++++++++- 3 files changed, 641 insertions(+), 15 deletions(-) create mode 100644 site/src/pages/TaskPage/FollowUpDialog.tsx diff --git a/site/src/pages/TaskPage/FollowUpDialog.tsx b/site/src/pages/TaskPage/FollowUpDialog.tsx new file mode 100644 index 0000000000..b09fc51459 --- /dev/null +++ b/site/src/pages/TaskPage/FollowUpDialog.tsx @@ -0,0 +1,95 @@ +import type { Task } from "api/typesGenerated"; +import { Button } from "components/Button/Button"; +import { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "components/Dialog/Dialog"; +import { Textarea } from "components/Textarea/Textarea"; +import { useFormik } from "formik"; +import type { FC } from "react"; +import { useId } from "react"; + +type FollowUpDialogProps = { + task: Task; + initialMessage: string; + open: boolean; + onOpenChange: (open: boolean) => void; + onSubmit: (message: string) => void; +}; + +export const FollowUpDialog: FC = ({ + task, + initialMessage, + open, + onOpenChange, + onSubmit, +}) => { + const formId = useId(); + + const formik = useFormik({ + initialValues: { + message: initialMessage, + }, + enableReinitialize: true, + onSubmit: (values) => { + const message = values.message.trim(); + if (message.length === 0) { + return; + } + onSubmit(message); + onOpenChange(false); + }, + }); + + return ( + + + + Send Follow-up Message + + Add another message to this task. The task will resume and send this + follow-up automatically. + + + +
+
+ +