Skip to content

site: Save workflow action on the run card - #411

Merged
ibetitsmike merged 17 commits into
mainfrom
mike/issue-326-save-workflow-from-run-card
Nov 21, 2026
Merged

ibetitsmike merged 17 commits into
mainfrom
mike/issue-326-save-workflow-from-run-card

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Coder Agents opened this PR on behalf of @ibetitsmike.

Closes #326

What

Adds a Save workflow action to completed workflow runs, behind the existing fork-workflows experiment, in two places:

  • The run card in the chat (ForkWorkflowTool), rendered by ForkWorkflowRunControls when run.status === "completed".
  • The right panel run detail (ForkWorkflowRunDetail summary), under the same condition.

The action opens a save dialog that:

  • Prefills the name from the run title with the same slug rule the composer menu uses (lowercase, non alphanumerics to hyphens, trimmed, 128 chars).
  • Reuses the name and description fields plus the shared form validation from the saved workflow editor on the AI Settings page.
  • Offers a Personal or Organization tier. The tier choice appears only when checkAuthorization grants canCreateOrganizationSkill for the chat's organization.
  • Saves through the existing createSavedWorkflow mutation and shows API errors in the dialog via SkillErrorDisplay.

After a successful save the action becomes a read-only link ("Saved <name>") to the matching settings page: personal workflows on /agents/settings/workflows, organization ones on /ai/settings/workflows?org=\<name>.

New files under site/src/pages/AgentsPage/components/ForkWorkflows/:

  • ForkWorkflowSaveAction.tsx: gating (experiment, non-empty script, organization id, dashboard context) and button/link rendering.
  • useForkWorkflowSave.tsx: dialog state, org permission query, create mutation.
  • ForkWorkflowSaveDialog.tsx: the dialog itself.
  • ForkWorkflowSaveControls.tsx: ForkWorkflowSaveButton and ForkWorkflowSavedLink.

Also exports SavedWorkflowNameField from ForkSavedWorkflowEditorDialog so the dialog can reuse it, and threads organization_id from the chat query into the action.

Test evidence

All commands run in site/ on the branch head before push.

  • pnpm exec vitest run --project unit on the four changed test files: 103 passed.
    • ForkWorkflowTool.test.tsx: 12 upstream tests restored plus 8 new save tests (saves personal from card with organization id, name and script asserted on the createUserSavedWorkflow call, then the Saved link href; server error shown in dialog; hidden without script; hidden when the chat is unknown; Organization tier hidden without permission; not shown for running runs; polling keeps working; failed run error shown).
    • ForkWorkflowRunDetail.test.tsx: 7 upstream plus 2 new (saves from the panel with the prefilled name; save hidden without create permission).
  • pnpm test:storybook on both changed story files: 43 passed (24 tool stories including 3 new save stories, 19 run detail stories including the save dialog and saved states).
  • pnpm test:ci src/pages/AgentsPage: 185 files, 3174 passed, 2 skipped.
  • pnpm run lint:types: passed.
  • pnpm exec biome check on all 16 changed files: passed (import order and formatting fixed with biome check --write, a11y radio labels fixed to the id/htmlFor pattern).
  • Sentence case check on the changed files: no findings. Note test and story files are excluded from that check by the script's own rules; the full repo check reports the same 24 pre-existing findings as main, none in this diff.

Pre-commit hook

The pre-commit hook was disabled for the commits in this PR through the documented worktree opt-out (git config --worktree coder.pre-commit false, per issue #407). Clean main at 5c8c0e2 fails make pre-commit in this workspace: fmt rewrites unrelated files, make gen leaves swagger output dirty, golangci reports pre-existing issues and the sentence case check reports the 24 pre-existing findings listed above. The checks the hook would have run were executed manually against the changed files with the results above.

Adds a Save workflow action (fork-workflows experiment) to completed
workflow runs in the chat tool card and the right panel run detail.
A dialog prefills the name from the run title, collects a description
and a Personal or Organization tier, and creates the saved workflow
through the existing forkSavedWorkflows API. After a successful save
the action becomes a link to the matching settings page.

Closes #326
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 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-21T19:29:21.697151Z 26bcef4 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.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged origin/main (58f9009, #409 fmt sweep) into the branch as 70d147b. The merge kept the export of SavedWorkflowNameField and the sentence-case-expect comment, which the fmt sweep had removed from main but this PR still needs; verified with the sentence case check (0 issues) and the full vitest and biome reruns. New head: 70d147b.

@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: 70d147b032

ℹ️ 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".

Codex reviewed 70d147b and flagged two P1 and five P2 findings.
This commit fixes all seven:

- P1: the saved link hard-coded the user tier, so an organization save
  pointed at the personal workflows page. The hook now records the tier
  the save used and the link targets the matching settings page.
- P1: a pending organization permission check fell through to Personal.
  The dialog now holds the submit while the check is pending, shows a
  loader in place of the tier choice and surfaces the check's error.
- P2: the request now goes through buildCreateSavedWorkflowRequest, so
  the saved name and description are trimmed the same way the editor
  trims them.
- P2: the story plays no longer assert the link href; the vitest tests
  keep that assertion.
- P2: the dialog builds its form values on each render instead of
  memoizing them.
- P2: focus returns to the saved link after the dialog closes instead
  of being lost with the unmounted Save button.
- P2: the tests and stories reuse the MockForkSavedWorkflow fixture
  instead of restating its fields.

The panel test file also restores the checkAuthorization spy it
installs, which the shared afterEach does not undo and which leaked a
never-resolving mock into the next test.
@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: 114e380bd8

ℹ️ 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".

Codex reviewed 114e380 and flagged one P1 and five P2 findings.

P1: the personal link dropped the organization. Personal workflows are
organization scoped, so the link now carries the chat's organization for
both tiers and the member workflows page reads the org search parameter
before its default, which a new page test covers.

P2: a failed authorization check left the dialog stuck on Checking
organization permission with Save disabled. The hook now distinguishes
pending from failed, only a pending answer holds the submit, and a
failed check shows its error while Personal stays usable, which a new
test covers.

P2: closing the dialog without a save lost focus because the dialog
prevented the close autofocus before learning the saved link did not
exist. The dialog now delegates the event and the hook prevents the
default only when the link exists.

P2: the denial test seeded a client renderDetail never rendered with.
renderDetail now accepts a query client override and the test drives
the dialog to prove the seeded denial reached it.

P2: the save stories shared a pre-wired query factory. Each story now
inlines its own cache entries per FE9.

P2: Save sat behind the chat-update gate. Saving creates a new workflow
and does not update the chat, so the run detail and the live card render
it from the completed run alone, including on archived chats and when
the update check is pending or failed.

The dashboards in the touched tests and stories now include a
MockChatOrganization fixture matching MockChat.organization_id, which
the saved link's org lookup needs.
@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: e8973406a6

ℹ️ 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".

Treat a failed organization permission check like a denied one in the
save dialog and prove it in the failed check test. Add pending and
failed permission stories to the card and panel story files. Document
the shared saved workflow name field. Inline the single-use organization
name helper. Correct the dialog comment that claimed only the panel
prefills the name. Drop the two card tests that only repeated what the
stories and sibling tests already cover.
The save action of issue 326 is built, so the workflows page describes
the Save workflow button on a completed run card and run detail, the
save dialog, the Personal and Organization choice with its permission
check, and the Saved link afterward. The Not built yet section goes
away.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@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: 620a311749

ℹ️ 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.

All 8 round-4 findings on 620a311 are answered and resolved. No P1s; the follow-ups are tracked in #413. Requesting a fresh review of the same head.

@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: 620a311749

ℹ️ 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".

…mment

The saved link now shrinks with the run controls and truncates a long
name visually while its accessible name keeps the whole name, with a
128-character name story on the card and the panel and a unit
assertion on the accessible name. The dialog comment no longer claims
the submit waits for typing, because a valid run title slug already
enables it. The exported save controls got their API comments.
@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: 207e0924fb

ℹ️ 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: 7131b2b9f2

ℹ️ 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".

…lection

A saved workflows URL whose org param names an organization the member
does not belong to, or an unknown one, now renders an unavailable state
with no tables and no create control instead of falling back to the
default organization. An absent org param keeps the default behavior.
The page now derives the selection from the URL alone, so back and
forward follow it. The saved link's button overrides the Button
shrink-0 with shrink so long names still fit the narrow panel.
@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: ff35bd2dfe

ℹ️ 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 unavailable state told the user to pick one of their organizations
but rendered no control to do it. It now renders the organization
picker whenever the member has any organization, and the text matches
what is on screen.
@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: ccf1245e84

ℹ️ 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".

- Offer Save on an await_workflow or run_workflow card whose result is
  already completed when the chat loads: the ended card fetches the
  run's detail once instead of polling and retries transient failures.
- The saved-workflows page picker writes push history entries, so back
  and forward move between the organizations the member viewed.
- Recovering from an invalid org keeps focus: both states render the
  same picker element chain, and the unavailable state takes focus on
  mount.
- Submitting the Organization tier sends the organization scope, and a
  stale tier selection cannot send an organization write after the
  permission answer denies or fails.
- The saved link renders only when the organization's name is known.
@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: ba5fe29e7f

ℹ️ 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: 7e20b1979e

ℹ️ 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: 646334bfe6

ℹ️ 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. Another round soon, please!

Reviewed commit: 26bcef4cac

ℹ️ 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 d42304f into main Nov 21, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-326-save-workflow-from-run-card branch November 21, 2026 20:12
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged at head 26bcef4cacd7b9cca6713f6e1e9553c086c11b72 as d42304f, on main e24f7e7db455bad5fce02ec8bfdb1747470aeaae, with the server running that main.

Gates on this exact head:

  1. The head matched the SHA I verified (--match-head-commit).

  2. Every check run passed. fork-ci run 44940823274 passed on this head.

  3. Codex receipt for this head: site: Save workflow action on the run card #411 (comment) ("Didn't find any major issues", Reviewed commit 26bcef4cac).

  4. No unresolved review thread. Over 11 review rounds, every P1 was fixed. Cheap, real P2s were fixed, and the rest were declined with a reason in each thread. The deferred items are tracked in Workflows save action: cleanups from #411 review #413.

  5. 0 commits behind main.

  6. Test evidence I ran in the PR worktree:

    • At this head: pnpm exec vitest run --project unit on ForkWorkflowTool.test, ForkWorkflowRunDetail.test, AISettingsPage/ForkWorkflowsPage/ and AgentSettingsPage/ForkSavedWorkflowsPage/: 4 files, 68 of 68 passed.
    • Negative control at this head: without the guard against reselecting the same organization, "does not push a duplicate entry when the shown organization is reselected" fails.
    • Negative control at 7e20b19: with the branch for already-completed cards disabled, "offers Save on a card whose completed result loaded from history" fails. That code is unchanged at this head.
    • Negative control at 620a311: swapping the tier mapping in savedWorkflowSettingsPath fails ForkWorkflowTool.test. Each negative control was reverted, and the worktree was clean afterwards.

    The workstream also ran lint:types, biome, the story tests, make lint/markdown and fmt/markdown on the docs. I did not rerun those.

What this adds: a Save workflow action on the workflow run card and run detail, for both Personal and Organization tiers. It handles the organization permission, links to the saved workflow, works on cards that were already complete when the chat loaded, and handles an unknown ?org= on the saved-workflows page. The feature sits behind the fork-workflows experiment. It also updates docs/fork/workflows.md.

Not exercised: a live server and browser session. Everything above is unit and story tests. #413 tracks the deferred cleanups:

  • the saved state lost when a card collapses;
  • the empty name prefill, because runs have no title yet;
  • the retry for a failed detail load;
  • the stale permission hold during a refetch;
  • small type and comment fixes.

Pre-commit hook: the workstream used the worktree-only opt-out from #407 and ran the targeted checks above.

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: Save workflow action on the run card

1 participant