Repository navigation
feat: members share personal saved workflows with the organization (fork-workflows) - #404
Conversation
…ork-workflows)
Adds POST .../members/{user}/workflows/{workflow}/share, which moves a
personal workflow to the organization tier in one statement. The owner
keeps read, update and delete through user_acl, and the Everyone group
gets read. The member Workflows page gains a Share action and lets the
owner edit and delete the organization workflows they shared.
Closes #395
Closes #327
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eaa53a13ed
ℹ️ 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 review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78bf53c20c
ℹ️ 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 review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b6c9e8c9e8
ℹ️ 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 review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b08c86dc3b
ℹ️ 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 review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b369a78398
ℹ️ 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".
…ontract (fork-workflows)
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Merged at head Gates on this exact head:
Tests I ran on
Review notes:
Not exercised: the share flow in a dev build, and a second member running the shared workflow by name from a chat. Coverage is coderd integration tests and mocked site tests. |
Closes #395
Closes #327
What
Members can share a personal saved workflow with their organization.
POST /api/v2/chats/fork/organizations/{organization}/members/{user}/workflows/{workflow}/share, with an optionalexpect_idquery parameter. It answers 201 with the new organization workflow. Behindfork-workflows.ForkSavedWorkflowShareDialog) that shows the server error and stays open on failure. A 404 drops the row from the personal list, then closes the dialog with an info toast, because the workflow was shared or deleted elsewhere or the member left the organization. Dropping the row first sends focus to the table's fallback button. The request sendsexpect_idthroughsavedWorkflowWriteSearchParamsfrom feat(site): send expect_id with saved workflow saves and deletes #400, which rejects an empty id. In the organization table, the member can now edit and delete the rows they shared (created_byis them). Other organization rows stay read-only.Design: move, not copy
Share moves the row from the personal tier to the organization tier in one SQL statement (
ShareUserSavedWorkflowByName, a CTE that deletes the personal row and inserts the organization row with the same name, description, script, args schema and phases). The new row has:created_by= the owner,user_acl= owner: read, update, delete,group_acl= Everyone group: read.Why:
run_workflowresolves first, so the member's chats would keep running the personal copy while others run the shared one. The move avoids that shadowing.Caveats:
created_byis the member. If an admin revoked the grant, the server answers 403 and the dialog shows it. Deriving row actions from effective permissions needs a per-row permission field in the API, which is a follow-up.Alertblock as the delete confirmation in the same view, notErrorAlert, so the two stay alike.coderd/x/chatd/ARCHITECTURE.mddirectly, as feat(site): send expect_id with saved workflow saves and deletes #400 did, instead of leaving TODOs.Tests
flock ~/.fork-go.lock go test ./coderd -run 'TestForkShareUserSavedWorkflow|TestForkUserSavedWorkflows|TestForkOrganizationSavedWorkflows|TestForkSavedWorkflowConditionalWrites' -count=1: pass.TestForkShareUserSavedWorkflowcovers:flock ~/.fork-go.lock go test ./coderd/database/dbauthz -run Fork -count=1: pass, with the newShareUserSavedWorkflowByNamemethod entry.pnpm exec vitest run --project unit src/api/forkSavedWorkflows.test.ts src/api/queries/forkSavedWorkflows.test.ts src/pages/AgentsPage/AgentSettingsPage/ForkSavedWorkflowsPage src/pages/AISettingsPage/ForkWorkflowsPage: 5 files, 64 passed. New page tests assert requests and callbacks: share success (the share request, the success toast, both lists refetch), retry after a 409 (the same dialog sends a second request that succeeds), and share after the workflow is gone (404 shows an info toast, refetches the personal list, and focus lands on the New workflow button while the refetch is still pending). Mutation tests cover the cache: a share moves the row from the personal list into the organization list and detail cache from the response, so it stays listed if the refetch fails, a 409 keeps the personal row, and a 404 drops only the picked row. An API test checks that share sendsexpect_idand rejects an empty one. Visual states (confirm, pending, error, row access, shared-by-me) are stories:ShareMenuOpen,RowAccess,ShareConfirm,SharePending,ShareError,SharedByMe.tsc --noEmit,biome check,oxlinton the changed files: clean.golangci-linton the changed Go packages: no findings in changed files.Negative controls:
user_aclchanged to read only in the generated query: OwnerEditsOthersRead fails at the owner's PATCH (403).canShare={false}on the page: all three share vitest tests fail.savedWorkflowWriteSearchParams: the share URL test fails.onErrorin the share mutation removed: the 404 mutation test fails, and the page test fails because focus does not reach the New workflow button.Not verified: the #327 end-to-end flow on a dev build (share in the UI, then
run_workflowfrom a second member's chat) was not exercised. The run path is unchanged and reads organization workflows the same way as before. The new stories were type checked but not rendered locally; Pixel renders them in CI.mainwas merged in after #400; that merge changed no Go code, so the Go tests were not rerun after it.