Repository navigation
feat(coderd): return per-caller actions on saved workflows - #430
Conversation
The saved workflow responses now carry permissions with update, delete and share, computed for the caller with the same RBAC checks the handlers use. The member workflows page shows only those row actions instead of guessing from created_by, so a revoked author loses Edit and Delete and a caller with broader rights keeps them. Closes #423
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cfbdf1714d
ℹ️ 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: 287c035f00
ℹ️ 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 |
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! 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:
What this changes: saved workflow responses carry Not exercised: a live browser session, and Storybook opened by hand (the stories ran as tests). The AI settings workflows page is unchanged. |
Closes #423
What changed
The saved workflows page guessed which row actions a caller could use. It showed Share on every row and inferred edit rights from
created_by. The server now computes the actions per caller and returns them on every saved workflow, and the page shows only those.codersdk:ForkSavedWorkflowMetadatagainspermissionswithupdate,deleteandsharebooleans.coderd/fork_saved_workflows.go:forkSavedWorkflowPermissionsruns the same RBAC checks the update, delete and share handlers run, against the row already loaded. No extra database queries. Organization rows check update, delete and share on the row's RBAC object. Update also requires read, because the patch handler reads the row first. Personal rows require organization read, then update, delete and share on the owner's user skill resource, and share additionally requires the caller to be the author and to hold delete and read, as the share handler does.site:ForkSavedWorkflowsPagebuilds row access fromworkflow.permissionsfor both tables. The table shows Share only whenpermissions.shareis true. Thecreated_byguess is gone.docs/fork/workflows.mdanddocs/fork/workflow-administration.mddescribe the permissions object and the row menu.make genoutput for the new type only:coderd/apidoc,docs/reference/api/schemas.md,site/src/api/typesGenerated.ts.The feature stays behind the
fork-workflowsexperiment. All logic is in fork files.One finding from the tests: a site owner can delete a member's personal workflow but cannot update or share it, because the update and share handlers check ownership. The permissions match the handlers, so the site owner sees only Delete on those rows.
Tests
flock ~/.fork-go.lock go test ./coderd/ -run 'TestForkSavedWorkflowPermissions|TestForkShareUserSavedWorkflow|TestForkOrganizationSavedWorkflows|TestForkUserSavedWorkflows|TestForkSavedWorkflow' -count=1: pass.TestForkSavedWorkflowPermissionscovers the personal owner (all true), a site owner on a member's personal row (delete only, checked against the real handlers), an organization member (none), organization admin and site owner on organization rows (all), an author whose shared workflow is revoked (edit rights, then none), and a scoped key with organization skill create and update but no read (update false, and the patch fails).pnpm test src/pages/AgentsPage/AgentSettingsPage/ForkSavedWorkflowsPage src/pages/AISettingsPage/ForkWorkflowsPage: 3 files, 46 tests pass. Two new cases assert the delete request for an organization workflow another member made and for a delete-only personal workflow. The existing share test asserts the share request.pnpm test:storybookonForkSavedWorkflowsPage.stories.tsx: 9 stories pass. New stories open the row menu for full rights, delete only, and an editable organization row, so the screenshots cover which items show.pnpm lint:typesandbiome check --error-on-warningson the changed directories: clean.Negative controls
Each was applied, run, and reverted.
PersonalOwnerfails, expected all true, got all false.SharedThenRevokedfails, expected edit rights, got none.PersonalSiteOwnerfails, expected Share false, got true.OrganizationUpdateWithoutReadfails, expected update false.ForkSavedWorkflowsPage.tsxandForkSavedWorkflowsTableView.tsxrestored to the base: the organization delete case fails, the other 14 pass. The personal delete-only case passes either way, because the old page also allowed delete on personal rows.Not exercised
ForkWorkflowsPageis unchanged and still uses its own access rules.make lintfails on issues already onmain(golangci-lint, react compiler check, typos), none in the files this PR changes.lint/go/new-codeandlint/markdownpass.