Skip to content

feat(site): create and edit personal agent definitions - #102

Merged
ibetitsmike merged 52 commits into
mainfrom
mike/agent-definitions-ui-4-editor-wiring
Nov 11, 2026
Merged

ibetitsmike merged 52 commits into
mainfrom
mike/agent-definitions-ui-4-editor-wiring

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #75. Stacked on #101; retarget to main once it merges.

Wires the agent definition editor from #101 into the personal agent definitions page:

  • New agent definition in the header, available while the list loads, opens the editor in create mode and sends POST to the user-tier route. A row menu Edit… loads the definition with GET and saves with PATCH {content}.
  • The editor stays open while a request runs and shows a failed request's message and detail inline, so the user keeps their input. A load failure offers a retry.
  • A create or save whose response is lost (no response at all) still closes the editor as done when the refetch shows it: a create when the refetched list has the name, the list did not have it before (or was not loaded), and that definition has the submitted content, a save when the refetched definition has the submitted content. Any HTTP error, such as a 409, stays a failure.
  • Editing seeds from the first current copy of the definition it gets, cached or fetched, so a reopened definition is editable at once, a failed background refetch does not hide it, and a later refetch cannot reset the user's edits. A copy, cached or fetched, is current when it is at least as new as the listed definition (strictly newer if its id differs), so a definition recreated or edited elsewhere waits for its fetch, and a fetch that still returns older content shows an error with a retry. Once the editor has loaded, a loaded list without the definition, or a list or detail copy newer than the loaded one, blocks Save with an inline error and keeps the draft, so a save cannot overwrite the newer version. A definition the loaded list no longer has does not open, and a 404 while loading drops the row it was requested for from the list, unless a refetch has replaced that row since. Timestamps are compared to the microsecond the API returns.
  • Create, update, and delete carry their organization in the mutation variables. A successful create or update is written into the cached list (a create replaces a row a refetch already listed), an update also into the definition's cached detail unless the cached copy is newer, and the list is refetched after every request. A create response does not replace a listed row that is newer or recreated, and its row goes in the list's order by name. An update response replaces the listed row with its name unless that row is newer. A request waits for its list refetch only when its response was lost (or a delete got a 404), so a known outcome is reported at once.
  • The editor and the delete dialog keep the organization they were opened in, and close if the selected organization changes, staying closed when it changes back. A create or save that settles after another editor opened leaves that editor open.
  • After a dialog closes, focus returns to the button that opened it, then to the first row's menu button, then to New agent definition.
  • The editor's state, detail query, and create and save mutations live in useForkAgentDefinitionEditor. Timestamps are compared with compareUpdatedAtInstants from api/queries/chats.ts, now exported, to keep sub-millisecond precision.

Limits:

  • A save that races another session of the same user, which edits, or deletes and recreates, the definition after the editor's last refetch, still overwrites it (last write wins). The update API takes no version, and for a personal definition that is acceptable.

UAT on the fork UI UAT server, as a member user, through this branch's Vite dev server:

Scenario Result
Create from the header button: POST sends name and description, the server accepts it, toast, row appears Pass
Edit from the row menu: values load with the name read-only, save updates the list and GET Pass
Edit a definition with tools and readonly front-matter: both keep their values Pass
Duplicate name: POST 409, the error shows in the dialog, which stays open Pass
Import an agent .md file: fills the fields, create keeps tools and model Pass
Lost create response (server returns 201, the browser sees a network failure): the dialog closes as created and the row appears Pass
Reopen Edit while every detail GET fails: cached values load and the save goes through Pass
Escape and an outside click right after Save, with the PATCH held: the dialog stays open with Cancel disabled, then closes as saved Pass
A definition with an indented front-matter comment after description:: a description edit keeps the comment, which YAML moves to the end of the description line Pass
Save, then fail every detail GET: the reopened editor shows the saved description Pass
A definition deleted elsewhere, then Edit: the 404 shows without Retry and the row leaves the table Pass
Flag off: no sidebar link, direct URL redirects to /agents/settings Pass
Definition edited elsewhere while the editor is open, then the browser reconnects: the editor shows that it changed, keeps the draft, and Save sends no PATCH Pass
List request held: New agent definition is enabled and opens the editor Pass
Duplicate name POST 409 while every list refetch hangs: the error shows at once and Cancel is enabled Pass
Create, edit, and delete through the UI after these changes: each toasts and closes Pass

Checks: tsc, biome, oxlint, knip, lint:compiler, lint:circular-deps, and the folder's Vitest tests pass locally.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 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-10T22:04:35.343686Z 1f65c01 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

Xum posted this 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: 9db598726d

ℹ️ 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 site/src/api/forkAgentDefinitions.ts Resolved
…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.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum acted for Mike on this comment.

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

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

…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.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum acted for Mike on this comment.

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

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

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.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of Mike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: fd68ccb0bf

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

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.
…ionsPage): rename the editor error display helper
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this 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: ddab46964e

ℹ️ 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 site/src/api/queries/chats.ts Resolved
…ionsPage): document the editor hook contract
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review 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: 1f65c01bca

ℹ️ 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 requested this review on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 1f65c01bca

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

Base automatically changed from mike/agent-definitions-ui-3-editor-dialog to main November 10, 2026 22:54
…s-ui-4-editor-wiring

# Conflicts:
#	site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage/ForkAgentDefinitionEditorDialog.stories.tsx
#	site/src/pages/AgentsPage/AgentSettingsPage/ForkAgentDefinitionsPage/ForkAgentDefinitionEditorDialog.tsx
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this on behalf of @ibetitsmike.

Closing and reopening only to make GitHub recompute the merge ref against current main (50e9121c3b) and run fork-ci on it. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) closed and reopened this again on behalf of @ibetitsmike.

The merge ref now points at current main (50e9121c3b), but the run started by the first reopen was queued against the old merge ref. This second reopen starts fork-ci on the recomputed merge. The head is unchanged.

@ibetitsmike ibetitsmike reopened this Nov 10, 2026
@ibetitsmike
ibetitsmike merged commit bbf776d into main Nov 11, 2026
20 of 27 checks passed
@ibetitsmike
ibetitsmike deleted the mike/agent-definitions-ui-4-editor-wiring branch November 11, 2026 00:40
@ibetitsmike

Copy link
Copy Markdown
Owner Author

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

Merge evidence for head 837652e4c8a6c29316b602c9094b09cb48d4e38e:

  • fork-ci pull_request run 42926863914 passed; its build job checked out Merge 837652e4c8 into 50e9121c3b (current main). All checks green.
  • Codex: no major issues on 1f65c01bca (comment 6780514072). This head only merges main after feat(site): add the agent definition editor dialog #101's squash; its own diff has the same patch ID as 1f65c01bca's diff from feat(site): add the agent definition editor dialog #101's head. 0 review threads unresolved. The frontend deep review findings were fixed or declined with reasons.
  • UI UAT round 14 at ddab46964e passed as a member user on the personal agent definitions page: create, edit (name read-only, tools and readonly front matter kept), a duplicate name 409 shown in the dialog, file import, a lost create response, failing detail reads, Escape and outside click while a save is in flight, front-matter comments kept, a definition deleted or edited elsewhere while the editor is open, and flag off (no link, the URL redirects). The later commits rename one local helper and edit comments.
  • No migration.

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