Skip to content

feat(site): stop and resume workflow runs from the card and panel - #346

Merged
ibetitsmike merged 14 commits into
mainfrom
mike/issue-323-workflow-stop-resume
Nov 16, 2026
Merged

ibetitsmike merged 14 commits into
mainfrom
mike/issue-323-workflow-stop-resume

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Coder Agents opened this PR on behalf of @ibetitsmike.

Closes #323

What

Stop and Resume controls for fork workflow runs, plus a composer prefill for Resume.

  • Stop on the live tool card. ForkWorkflowStopButton is a pure move of the Workflows panel's stop control (confirm dialog, mutation, cache update, focus fallback), so the card and the panel run detail stop runs through the same component. The live card mounts it while a run is running.
  • Resume in the panel and on the card. ForkWorkflowResumeButton dispatches a fork-workflow-resume request scoped by chat ID. The panel shows it next to the heading of an interrupted run; the live card shows it once its poll reports the run interrupted.
  • Composer prefill. ForkWorkflowResumePrefill (mounted from ForkComposerSlot behind the fork-workflows experiment) listens for the request, appends the resume prompt on a new line without wiping a draft, and focuses the composer. It never sends. Listeners clean up on unmount and drop requests for other chats.
  • Write-access gate. useCanWriteChat runs the canUpdateChat check for the run's chat. Both controls stay hidden while the check is pending or false, because the stop route authorizes as a chat update and a resume sends a chat message. The interrupted detail keeps its "ask the agent" hint only when the viewer cannot write.
  • Scope. Frontend and fork files only. The single upstream-file change is one hook line in AgentChatInput.tsx that passes inputRef to ForkComposerSlot. Polling is unchanged (site, coderd: five fork panels poll; publish one chat watch event and invalidate on it #304 owns it).

Test plan

  • pnpm test on the touched tests: 26 unit tests pass (ForkWorkflowTool.test.tsx 10, ForkWorkflowRunDetail.test.tsx 4, ForkWorkflowsPanel.test.tsx 3, ForkWorkflowResumePrefill.test.tsx 4, ForkWorkflowStopButton.test.tsx 3, ForkWorkflowResumeButton.test.tsx 2), covering stop from the card updating the panel's cached detail, hidden controls while the check is pending or false, the child-chat cross-cache guard, the 409 path, and prefill append/focus/scope/unmount.
  • pnpm test:storybook on the touched stories: 33 story tests pass (17 tool-card, 12 run-detail, 4 run-list), including new stories for the card's Stop, interrupted Resume and no-write-access states.
  • npx tsc --noEmit -p tsconfig.json: exit 0.
  • biome check, pnpm lint:oxlint, biome format: clean on the touched tree.
  • node scripts/check-compiler.mjs: same single pre-existing warning as main (ForkHtmlAttachmentViewer.tsx: onFrameLoad), verified by stashing this branch's changes.
  • Runtime click-through on the dev server: not exercised; the controls' behavior is covered by the unit and story tests above.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T03:22:26.982886Z 00c62e7 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15a7616c45

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15a7616c45

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 6b3e0bcc6a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 4a5449f920

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…sue #323)

Stop and Resume on the run_workflow tool card, next to the heading in the
Workflows panel run detail, and a composer prefill for Resume.

- ForkWorkflowStopButton: pure move of the panel's stop control (confirm
  dialog, mutation, cache updates) so the card and the panel share it.
- ForkWorkflowResumeButton: dispatches a fork-workflow-resume request.
- ForkWorkflowResumePrefill: listens for that request, appends the resume
  prompt to the composer without wiping a draft, and focuses it. Never
  sends.
- useCanWriteChat: shared update check; both controls stay hidden while
  the check is pending or false, since the stop route authorizes as a
  chat update and a resume sends a chat message.
- LiveForkWorkflowTool mounts the controls for running and interrupted
  runs; the static interrupted card stays read-only.

The composer hook line is the single upstream-file change
(AgentChatInput.tsx passes inputRef to ForkComposerSlot).

Closes #323
#323)

P1s:
- Prefill preserves the draft's structured nodes (file references, skill
  chips) by appending through restoreEditorState instead of rewriting the
  editor as plain text.
- The live card passes its Run row as the stop dialog's focus fallback, so
  keyboard focus returns somewhere after a successful stop unmounts the
  button.

P2s fixed:
- ResumeButton test installs the dispatch spy before clicking, so it no
  longer depends on test order.
- The resume event helper narrows with instanceof CustomEvent and validates
  the detail instead of asserting the shape.
- The RunDetail stories' write-access override carries the chat seed, since
  story-level queries replace the meta-level array.
- The NoWriteAccess story's play no longer asserts; the screenshot shows the
  absent controls and the assertions live in the Vitest test.
- The StopButton header no longer narrates where the code moved from.

P2s answered on the review thread, not changed:
- Surfacing authorization-check failures separately from pending: the
  controls hide on any non-true result by design; the failed query stays
  inspectable.
- Gating Resume on composer send eligibility: Resume only prefills and the
  user sends, so a wider permission set is acceptable for now.
- Routing already-interrupted tool results through the live path: that is a
  #324 run-detail gap, not a regression from this PR.
…ser (issue #323)

A mounted Lexical editor serializes to a non-empty JSON tree even when
it has no text, so the old editor-state branch never took setValue and a
fresh composer ended up with two blank lines before the resume prompt.
Branch on the composer's text content instead, and make the test double
match the real handle so the empty-composer path stays covered.
@ibetitsmike
ibetitsmike force-pushed the mike/issue-323-workflow-stop-resume branch from 4a5449f to 46b9ed7 Compare November 15, 2026 20:57
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Rebased onto main (no code changes; head is now 46b9ed7). @codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46b9ed7cd9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged main in (merge commit 8b97cc4, no code changes to this PR's files). @codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b97cc4ffe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged main in again (merge commit f24e592, no code changes to this PR's files; fork-ci green on this head). @codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: f24e592fac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Address Opus review findings before the next Codex round:

- P1: Resume no longer wipes a chip-only draft. ForkWorkflowResumePrefill
  branches on getContentParts().length === 0 instead of empty text,
  since FileReferenceNode/SkillInvocationNode report empty text.
- restoreEditorState no longer adds a stray space before appends that
  already start with whitespace.
- Double-click Resume no longer prefills the same prompt twice; the
  resume dispatch is guarded per run via skipIfPrompted.
- Stop 409 now shows an info toast ("already ended") instead of an
  error toast.
- Card Stop button gets aria-label "Stop workflow run".
- ForkWorkflowTool stop test asserts the settled mutation data instead
  of a cache entry the running refetch evicts.
- Tests: shared seedChatWriteAccess helper in testHelpers/forkWorkflows,
  mockApiError carries top-level status (matching AxiosError), drop dead
  helpers and toBeInTheDocument per FE1, no as CustomEvent cast (FE2),
  story Date.now spy uses mockName("spy") instead of disabling actions.
- Hide Stop/Resume for archived chats via useCanWriteChat.
…story seeds (#323)

Address the open Codex P2 threads before the next review round:

- Remove the unused optional label prop from ForkWorkflowResumeButton;
  both callers render "Resume run", and the only override consumer was
  the test created for it.
- Narrow dispatched events with instanceof CustomEvent instead of
  casting Event to CustomEvent in the workflow tests, per the
  frontend rule against avoidable casts.
- Inline the chat and update-check query seeds in each live-card story
  instead of a shared pre-wired helper, so each story's cache state is
  visible in the story.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1457f3f6bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

)

The resume dedup marker was never cleared, so after the composer listener
consumed a prompt every later Resume click for that run was a silent no-op
until another run was clicked or the page reloaded. The listener now
clears the marker when it accepts the prompt, so the marker only
deduplicates the immediate double click. Covers the later-click path in
the button and prefill tests.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5582e646bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…arker (#323)

The dedup marker never worked while a composer was mounted: dispatchEvent
runs the listener synchronously, and the listener consumed the marker
before requestForkWorkflowResume returned, so a double click prefilled the
prompt twice. Drop the marker entirely. The listener now only focuses the
composer when its text already ends with the resume prompt, which is the
signature of the first click having landed; it prefills again otherwise,
so a cleared or sent draft can still be prefilled again, and a request
for another chat is dropped without side effects.

Also revert the needsSpace tweak in ChatMessageInput.restoreEditorState
(upstream file) now that the prefill appends "\n\n" plus the prompt: the
leading whitespace already separates it, and the upstream behavior is
unchanged for every other caller.

Tests: a double-click test with the real listener mounted, a test that a
dropped request for another chat does not block the next one, and a test
that an archived chat hides Stop and Resume in the run detail.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5df0ef06c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…323)

Address the Codex review on 5df0ef0:

- Hide Resume on the live card and in the Workflows panel while the chat
  is in plan mode: plan-mode turns omit run_workflow, so a resume
  request could not run the workflow. Stop stays. Both components read
  the chat's cached plan_mode, so no props change hands.
- The run row that receives focus after Stop keeps a visible
  focus-visible ring (outline-hidden plus ring-2) instead of hiding the
  outline, so keyboard users see where focus landed.
- ForkWorkflowsPanel.test replaces its duplicated seed block with
  seedChatWriteAccess.
- Tests: plan mode hides Resume on the panel detail and the live card,
  Stop stays in plan mode on both, and the panel uses the shared seed.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 00c62e7e8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike merged commit c71b3ab into main Nov 16, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-323-workflow-stop-resume branch November 16, 2026 03:45
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged as c71b3ab (squash), parent 29781c8 (#360). The merge ran after 29781c8 had deployed (v2.39.2-devel+29781c8f17 at 03:45:10Z).

Gates on head 00c62e7:

  1. Head matched the verified SHA (--match-head-commit), and main was 29781c8 when checked.
  2. All check runs passed; fork-ci run 43797391816 green on this head.
  3. Codex receipt on 00c62e7: "Didn't find any major issues".
  4. 0 unresolved review threads.
  5. Not behind main.
  6. Test evidence I ran on the exact head: pnpm vitest run --project unit over the ForkWorkflows components, ForkWorkflowTool, the ForkWorkflowsPanel, api/errors.test.ts and ChatMessageInput: 14 files, 197 tests passed.

Independent Opus reviews covered f24e592, the delta to 5582e64, and I reviewed the last delta to 00c62e7 (plan-mode Resume gate, focus ring, test helper). All P1 and P2 findings were fixed.

Not exercised: a live run against a dev server (Stop on a real running workflow, Resume after a real restart), and Storybook visual checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

site: Stop and Resume on the workflow run card, Resume in the Workflows panel

1 participant