Skip to content

feat: share organization agent definitions with members and groups - #175

Merged
ibetitsmike merged 6 commits into
mainfrom
mike/agent-definitions-ui-9-sharing
Nov 11, 2026
Merged

ibetitsmike merged 6 commits into
mainfrom
mike/agent-definitions-ui-9-sharing

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #75.

Lets organization admins choose which organization members and groups can use an organization agent definition, from the AI settings Agent definitions page, behind the fork-agent-definitions experiment. It mirrors the organization Skills sharing flow.

  • New public endpoint: GET /api/v2/chats/fork/organizations/{organization}/agent-definitions/{agentDefinition}/acl/available returns the organization's users and groups that can be granted access (codersdk.ACLAvailable), using the same writeOrganizationACLAvailable helper as skills, MCP servers and models. It authorizes like the existing ACL GET and PATCH from feat: share organization agent definitions behind fork-agent-definitions #71 (share permission on the definition), so a member without that permission and an unknown name get 404. It is registered on the existing inline orgAgentDefinitions router, carries a full Swagger block (skipped from the markdown docs like its neighbors), and gets a codersdk client method.
  • Dialog: ForkOrganizationAgentDefinitionSharingDialog is built on the shared ResourceSharingDialog, ACLPrincipalAutocomplete and aclSharing, like OrganizationSkillSharingDialog. Saving marks the ACL, the list and the definition's detail stale.
  • Manage permissions action: the organization page passes a Manage permissions row action (the label the Skills, MCP server and model sharing flows use) to the table only when the viewer has the organization skill share permission. The personal page never shows it.
  • Docs: the pstack adapter doc says how to reach the dialog, and its line range for the ACL handlers is updated.

Tests: a coderd subtest checks that an org admin gets a known user and group from /acl/available, that a member without share permission and an unknown name get 404, and that after a group gets read and Everyone is dropped, a group member can read the definition and a non-member cannot. Vitest covers the dialog (it saves only changed entries, shows save errors, and edits the refetched ACL rather than a cached one), the mutation's cache effects, an admin opening Manage permissions with focus returning to the row menu on cancel, and the dialog closing without a save when Back or Forward changes the organization. Stories show the dialog with a group row and a user row, with no permissions, and with a load error and a save error, plus the page's row menu with and without share permission.

Checks: Go TestForkOrganizationAgentDefinitions, TestForkChatRoutes, TestEndpointsDocumented and TestSwagger; site pnpm lint (biome, oxlint, tsc, knip, circular deps, compiler), unit tests (92) and story tests (35) pass locally.

UAT on a branch server built from 6d0ebe28fb (Fork ops), with local Vite at the same head proxying to it. The row action was still labeled Share then; only the label has changed since.

  • A new organization definition is shared with the Everyone group by default.
  • The admin opens the dialog from the row menu, removes the Everyone group row, searches and adds a member through /acl/available, and saves. The ACL then holds that user and no groups.
  • The shared member can read the definition. An unshared member gets 404 and no list entry.
  • An auditor sees the row with no row menu or New button, and the API refuses the auditor's ACL PATCH and /acl/available with 404. A plain member is denied the page and gets 404 from /acl/available.
  • Removing the member's row and saving takes their access away again (404).

Custom groups weren't live-tested because no licensed UAT server is available, so the server's only group was Everyone. The coderd test and the GroupAndUser story cover sharing with a custom group.

Add GET /api/v2/chats/fork/organizations/{organization}/agent-definitions/{agentDefinition}/acl/available,
which lists the organization members and groups an organization agent
definition can be shared with. It authorizes share on the definition like
the existing ACL routes, so other callers and unknown names get 404.

Add a Share row action to the organization agent definitions page for
viewers who can share organization skills. It opens an "Agent definition
permissions" dialog built on ResourceSharingDialog and returns focus to the
row menu on close. Personal definitions do not offer Share.
…anage permissions like the other sharing flows
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 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-11T05:57:26.763246Z 95ecd91 Draft marked ready
ℹ️ 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

@codex review

Xum commented on behalf of @ibetitsmike.

@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: da3392ab1f

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

Comment thread docs/fork/pstack-adapter.md Resolved
… refetched ACL and close the sharing dialog when the organization changes
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

@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: d17564cbe1

ℹ️ 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 sharing dialog stops reading the old organization's ACL and refresh the adapter's source references
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum commented on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 95ecd91dac

ℹ️ 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 marked this pull request as ready for review November 11, 2026 05:54
@ibetitsmike
ibetitsmike merged commit 7accbb4 into main Nov 11, 2026
10 checks passed
@ibetitsmike
ibetitsmike deleted the mike/agent-definitions-ui-9-sharing branch November 11, 2026 06:26
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merge evidence for head 95ecd91dacb1ba7234e2c147b5762179ae948735:

  • The head contains current main 9b0cc8c045 (feat(site/src): add the organization agent definitions page to AI settings #160).
  • fork-ci pull_request run 42964793180 passed on this exact head. All 9 checks green.
  • Codex: receipt on this exact head, no major issues (feat: share organization agent definitions with members and groups #175 (comment)); the review after ready also completed on 95ecd91dac with no findings. 0 of 6 review threads unresolved.
  • New route GET .../agent-definitions/{agentDefinition}/acl/available uses the same share check as the ACL routes (readForkOrganizationAgentDefinitionForShare) and has full swagger annotations with regenerated apidoc.
  • UAT: round 1 on a branch server at 6d0ebe28fb, 5 of 5: direct user share, unshared member cannot see it, removing the share hides it, a non-admin sees no write controls, and principal search. Groups were not live-tested because no licensed server is available; a coderd test and a story cover group principals. Since UAT there are no Go changes, only narrow frontend fixes with tests (the dialog waits for the ACL refetch before seeding, resets when the organization changes, and the action is relabeled Manage permissions), plus stories and docs.
  • No migration.

ibetitsmike added a commit that referenced this pull request Nov 11, 2026
)

* feat: share organization agent definitions with members and groups

Add GET /api/v2/chats/fork/organizations/{organization}/agent-definitions/{agentDefinition}/acl/available,
which lists the organization members and groups an organization agent
definition can be shared with. It authorizes share on the definition like
the existing ACL routes, so other callers and unknown names get 404.

Add a Share row action to the organization agent definitions page for
viewers who can share organization skills. It opens an "Agent definition
permissions" dialog built on ResourceSharingDialog and returns focus to the
row menu on close. Personal definitions do not offer Share.

* docs: describe sharing organization agent definitions from AI settings in the pstack adapter

* refactor(site/src/pages): label the agent definition sharing action Manage permissions like the other sharing flows

* test(site/src): cover the agent definition sharing dialog's empty and load error states and trim restating JSDoc

* fix(site/src/pages/AISettingsPage/ForkAgentDefinitionsPage): edit the refetched ACL and close the sharing dialog when the organization changes

* test(site/src/pages/AISettingsPage/ForkAgentDefinitionsPage): assert the sharing dialog stops reading the old organization's ACL and refresh the adapter's source references
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.

1 participant