Skip to content

feat(site/src): add the organization agent definitions page to AI settings - #160

Merged
ibetitsmike merged 79 commits into
mainfrom
mike/agent-definitions-ui-8-org-page
Nov 11, 2026
Merged

ibetitsmike merged 79 commits into
mainfrom
mike/agent-definitions-ui-8-org-page

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #75.

Adds an Agent definitions page to AI settings at /ai/settings/agent-definitions, behind the fork-agent-definitions experiment, for the organization tier:

  • The page follows the organization Skills page: an organization picker over the organizations whose skills the user can read (organization agent definitions use the organization skill RBAC object on the server), the org search parameter, and a denial instead of a fallback when the URL names an organization the user cannot read. Create, update and delete access come from the same organization skill permission checks.
  • The table is ForkAgentDefinitionsTable with the organization scope from refactor(site/src): scope agent definition queries to a user or organization tier #158 and the access from feat(site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage): hide agent definition actions the user cannot take #159.
  • The AI settings sidebar links the page under Skills for the same users, and carries over the selected organization unless the user is known not to read it, keeping it while organization access loads. The link and route are hidden or redirect to /ai/settings while the experiment is off. Upstream files get small hooks only: one route line in router.tsx (the route lives in forkRoutes.tsx), and a hook call plus two links in AISettingsSidebarView.tsx (the logic lives in forkAISettingsNav.ts).

Tests: the page toggles a definition in the organization the URL names, through the organization route; switches organizations through the picker (URL and request); and redirects with no request while the experiment is off. A sidebar test follows the link, with the organization carried over, for a deployment admin, an organization auditor, while organization access loads, and without the organization for a user who cannot read it; stories show both sidebars, and page stories cover the admin, empty, read-only, permission loading, load error, refetch error, multiple organization and denied organization states.

Checks: tsc, biome, oxlint, knip, lint:check, lint:compiler, lint:circular-deps, the page and sidebar unit tests (7) the sidebar story tests (2) and the page story tests (8) pass locally.

UAT on the fork UI UAT server (head 99bc93f40b), local Vite proxying to it: an admin reaches the page from the sidebar and creates, toggles and deletes an organization definition through the UI, with the server reflecting each step; an auditor sees the definition read-only (no New button, no row actions, a status icon instead of the switch, and the API refuses the auditor's delete with 403); a plain member gets no link and a denial, as on AI settings Skills; an unknown org in the URL is denied without showing another organization's rows.

Carry the organization in toggle and delete variables so a request that
settles after an organization switch releases and invalidates its own
list, reconcile the list after a failed delete, fall back to the table
when the last row's menu button is gone, and describe deletion as
removing only the personal definition.
A toggle or delete the server accepted stays visible even if the
reconciling refetch fails.
…ion is gone

A delete whose response was lost can still have committed, so the
refetched list decides whether the dialog closes.
Keep the model and the other front-matter in the dialog and give the
skill form a content builder, so the size limit, the meter, and the
submitted markdown all use the agent definition file. Block Escape while
a save runs, keep standalone front-matter comments, describe the field
for agents, document the exported context hook, and test import and
submit.
…ly bodies

The size limit counts the model, which lives outside the skill form, so
a model change validates again. The server strips HTML comments before it
requires a body, so the form does too. The dialog now submits the name
with the content.
…itions

A create whose response was lost closes the editor when the refetched
list shows the new name and the name was not listed before. Reopening a
definition seeds the editor from cached data instead of waiting for the
refetch. Tighten the API and query JSDoc.
…ssals, and indented comments

The editor keeps the values it opened with as every field's baseline, so
refreshed initial values cannot reset some fields and leave others stale.
Escape and outside clicks act as Cancel, which the form disables from the
moment Save is clicked. Indented front-matter comments after owned keys
are kept unless they sit inside that key's block or quoted text. Add
stories for the submitting and import error states.
…or-dialog' into mike/agent-definitions-ui-4-editor-wiring
A save writes its response to the definition's cached detail, so a
reopened editor shows the saved content even if the refetch fails.
Cached content seeds the editor only when it matches the listed
definition's id and is at least as new, or a fetch just returned it, so
a definition recreated or edited elsewhere waits for its fetch.
Hand-classifying front-matter lines lost inline comments on owned keys and
produced invalid YAML for indented root keys. Parse the front-matter as a
yaml Document and set the owned keys in place, which keeps comments and
other keys.
…m:ibetitsmike/coder into mike/agent-definitions-ui-4-editor-wiring
…m:ibetitsmike/coder into mike/agent-definitions-ui-4-editor-wiring
…m:ibetitsmike/coder into mike/agent-definitions-ui-4-editor-wiring
@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: dd2335778d

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

@codex review

Xum commented on behalf of @ibetitsmike.

…s-ui-4-editor-wiring

# Conflicts:
#	site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage/ForkAgentDefinitionEditorDialog.stories.tsx
#	site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage/ForkAgentDefinitionEditorDialog.tsx
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: cca7806bba

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

…s-ui-6-tier-scope

# Conflicts:
#	site/src/api/forkAgentDefinitions.ts
#	site/src/api/queries/forkAgentDefinitions.test.ts
#	site/src/api/queries/forkAgentDefinitions.ts
#	site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage/ForkAgentDefinitionsPage.test.tsx
#	site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage/ForkAgentDefinitionsTable.tsx
#	site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage/useForkAgentDefinitionEditor.ts
…-scope' into mike/agent-definitions-ui-7-access
…ss' into mike/agent-definitions-ui-8-org-page
…-scope' into mike/agent-definitions-ui-7-access
…ss' into mike/agent-definitions-ui-8-org-page
…s-ui-7-access

# Conflicts:
#	site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage/ForkAgentDefinitionsTable.tsx
…ss' into mike/agent-definitions-ui-8-org-page
@ibetitsmike
ibetitsmike marked this pull request as ready for review November 11, 2026 01:58
@ibetitsmike
ibetitsmike merged commit 9b0cc8c into main Nov 11, 2026
11 checks passed
@ibetitsmike
ibetitsmike deleted the mike/agent-definitions-ui-8-org-page branch November 11, 2026 03:20
@ibetitsmike

Copy link
Copy Markdown
Owner Author

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

Merge evidence for head a773b2c39e4c86521a1cf91accc0db8b8e3277a5:

ibetitsmike added a commit that referenced this pull request Nov 11, 2026
…tings (#160)

* feat(site): toggle and delete personal agent definitions

* fix(site): track each agent definition toggle and restore focus after a delete

* fix(site): let the React Compiler compile the agent definitions table

* fix(site): scope pending agent definition toggles to their organization

* fix(site): settle agent definition mutations in their own organization

Carry the organization in toggle and delete variables so a request that
settles after an organization switch releases and invalidates its own
list, reconcile the list after a failed delete, fall back to the table
when the last row's menu button is gone, and describe deletion as
removing only the personal definition.

* fix(site): write accepted agent definition changes into the list cache

A toggle or delete the server accepted stays visible even if the
reconciling refetch fails.

* fix(site): close the delete dialog when the refetch shows the definition is gone

A delete whose response was lost can still have committed, so the
refetched list decides whether the dialog closes.

* feat(site): add the agent definition editor dialog

* docs(site): document the agent definition editor exports

* fix(site): type the agent definition editor without a cast

Keep the model and the other front-matter in the dialog and give the
skill form a content builder, so the size limit, the meter, and the
submitted markdown all use the agent definition file. Block Escape while
a save runs, keep standalone front-matter comments, describe the field
for agents, document the exported context hook, and test import and
submit.

* feat(site): create and edit personal agent definitions

* docs(site): document the agent definition editor state

* fix(site): revalidate the agent definition size and reject comment-only bodies

The size limit counts the model, which lives outside the skill form, so
a model change validates again. The server strips HTML comments before it
requires a body, so the form does too. The dialog now submits the name
with the content.

* fix(site): reconcile lost create responses and edit from cached definitions

A create whose response was lost closes the editor when the refetched
list shows the new name and the name was not listed before. Reopening a
definition seeds the editor from cached data instead of waiting for the
refetch. Tighten the API and query JSDoc.

* test(site): cover lost create responses and cached editor seeding

* fix(site): keep agent definition edits through refreshes, early dismissals, and indented comments

The editor keeps the values it opened with as every field's baseline, so
refreshed initial values cannot reset some fields and leave others stale.
Escape and outside clicks act as Cancel, which the form disables from the
moment Save is clicked. Indented front-matter comments after owned keys
are kept unless they sit inside that key's block or quoted text. Add
stories for the submitting and import error states.

* fix(site): open agent definitions from current cached content only

A save writes its response to the definition's cached detail, so a
reopened editor shows the saved content even if the refetch fails.
Cached content seeds the editor only when it matches the listed
definition's id and is at least as new, or a fetch just returned it, so
a definition recreated or edited elsewhere waits for its fetch.

* fix(site): rewrite agent definition front-matter with a YAML document

Hand-classifying front-matter lines lost inline comments on owned keys and
produced invalid YAML for indented root keys. Parse the front-matter as a
yaml Document and set the owned keys in place, which keeps comments and
other keys.

* fix(site): put owned front-matter keys a file lacks first

* test(site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage): expect YAML document output

* fix(site): keep aliases of owned front-matter values and quote YAML 1.1 dates

* fix(site/src): replace a listed row when a create response arrives late

* fix(site/src): reconcile only lost create and save responses and keep newer cached definitions

* test(site/src): cover an older toggle response leaving a newer listed row

* fix(site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage): read aliased owned fields, keep unchanged fields as written, and show size errors from model edits

* fix(site/src): reconcile agent definition caches by full timestamp, drop missing definitions, and keep the editor in its organization

* fix(site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage): read merged front-matter fields and keep alias tags and comments

* fix(site/src): keep a newer editor open when an earlier request settles, and drop only the listed row a 404 was fetched for

* fix(site/src/pages/AgentsPage): tighten agent definition editor docs, types, and stories from frontend review

* fix(site/src/pages/AgentsPage): keep aliases of unchanged agent definition fields

* fix(site/src/pages/AgentsPage): block stale agent definition saves and clear editors on organization change

* fix(site): settle agent definition mutations without waiting on known outcomes

* fix(site): match agent definition rows by name and keep created rows in order

* fix(site/src/pages/AgentsPage): block saves of deleted agent definitions and reconcile creates from an unknown list

* fix(site/src/api/queries): replace older listed rows with a created agent definition

* refactor(site/src): move agent definition editor state into a hook

Applies frontend review findings: the editor's state, detail query and
create/save mutations move to useForkAgentDefinitionEditor, the stale
load error is a flat condition, docs move to the fields they describe,
page tests share helpers, and the table view has an editor story.

* refactor(site/src/api/queries): compare agent definition timestamps with the chats helper

* refactor(site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage): rename the editor error display helper

* refactor(site/src): scope agent definition queries to a user or organization tier

The personal page's queries, editor hook and table take an
AgentDefinitionScope instead of an organization ID, and the API module
gains the organization tier's routes, so the organization page can reuse
them.

* feat(site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage): hide agent definition actions the user cannot take

The table takes the SkillAccess the skills pages use, hiding New,
Edit and Delete and disabling the enabled switch without the matching
permission, and picks its copy by tier, so the organization page can
show the organization's definitions read-only to members.

* refactor(site/src): key agent definition dialogs and pending toggles by scope

* refactor(site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage): document the editor hook contract

* fix(site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage): show tier delete copy and a static read-only status

* feat(site/src): add the organization agent definitions page to AI settings

* refactor(site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage): extract the enabled cell

* test(site/src): cover the agent definitions sidebar link in Vitest

* refactor(site/src/pages/AgentsPage): share the read-only skill enabled status

* test(site/src/pages/AISettingsPage): add organization agent definitions page stories

* fix(site/src): keep the organization while AI settings access loads and cover the org page

* test(site/src): cover the agent definitions link for an unreadable organization

* test(site/src/api/queries): cover organization scope list, detail, update and delete

* fix(site/src/pages/AgentsPage): drop the empty actions column for read-only agent definitions
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