feat(agents): add Delete Agent button with confirmation - #497
feat(agents): add Delete Agent button with confirmation#497kristopolous wants to merge 1 commit into
Conversation
When editing an existing agent, the composer only offered "Update
Agent" — there was no way to delete it from the chat UI, even though
the registry already supports DELETE /api/v1/agents/{agent_id} and the
AgentBuilderServer port already has an optional deleteAgent hook.
Add a "Delete Agent" button to the left of "Update Agent" in
SaveAgentButton, visible only while editing an existing (named,
mutable) agent. Clicking it opens a confirmation dialog (reusing
CenteredModal + the existing destructive button variant, matching the
rest of the app's UX) before permanently deleting. On success, clears
the current chat and invalidates the agents list so it disappears from
the library. Wires deleteAgent through createHarnessBuilderServer using
the SDK's existing client.agents.delete (no new backend/SDK surface
needed).
Fixes truefoundry#496
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MxyEPwQ73B27NTr83U69Ba
🦋 Changeset detectedLatest commit: 07150de The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 07150de. Configure here.
| } finally { | ||
| setDeleting(false); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Missing delete hook treated as success
Medium Severity
Confirming delete calls builder.deleteAgent with optional chaining, so a missing hook still invalidates the library and switches to a fresh draft. The agent remains on the server, and the Delete Agent control still appears whenever the shell is in update mode.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 07150de. Configure here.


Summary
Fixes #496.
When editing an existing agent, the composer only offered "Update Agent" (top right) — there was no way to delete the agent from the chat UI at all, even though:
DELETE /api/v1/agents/{agent_id}(packages/trueforge/src/routes/agentRoutes.ts/apis/agents.ts), and the SDK already hasclient.agents.delete(...).AgentBuilderServerport (@truefoundry/assistant-ui-runtime) already has an optionaldeleteAgent?(req: { agentName: string })hook — nothing inpackages/trueforge-uicalled it.Changes
SaveAgentButton.tsx: a "Delete Agent" button now renders to the left of "Update Agent", visible only while editing an existing (named, mutable) agent. Clicking it opens a confirmation dialog — reusing the sameCenteredModalprimitive and the existingdestructivebutton variant already used elsewhere in the app, not a nativeconfirm()— before permanently deleting. On success it invalidates the Agents Library list and drops the now-dangling edit binding, landing on a fresh draft (rather thanclearChat(), which deliberately preserves the edit binding for the "still editing the same agent" case — wrong here, since the agent no longer exists).builderServer.ts: implementsdeleteAgentincreateHarnessBuilderServerby looking up the agent's id by name (same patternsaveAgent's update path already uses) and calling the SDK's existingclient.agents.delete(id). No new backend or SDK surface needed — this was already there, just unwired.Test plan
harnessBuilderServer.test.ts:deleteAgentlooks up the id and issuesDELETE; no-op when the name is unknown.SaveAgentButton.test.tsx: hidden for a new/unnamed draft; shown + callsdeleteAgenton confirm for an existing binding; Cancel does not call it; a rejecteddeleteAgentshows an inline error and keeps the dialog open.pnpm vitest runinpackages/trueforge-ui— 871/871 pass.pnpm tsc --noEmit— clean.pnpm eslinton changed files — clean.@truefoundry/trueforge-uipatch).pnpm standalone:dev) — see screenshots below, including a direct SQLite check that theagentrow count actually goes to 0 after confirming delete (not just a UI-only removal).Screenshots (local run against the real app)
1. Editing an existing agent — "Delete Agent" now sits to the left of "Update Agent":

2. Confirmation dialog before the permanent delete:

3. After confirming — Agents Library count drops to 0 and the composer lands on a fresh draft (not still "Editing" a now-deleted agent):

(Screenshots hosted on an orphan
delete-agent-screenshotsbranch on my fork, not merged into this PR's diff.)🤖 Generated with Claude Code
https://claude.ai/code/session_01MxyEPwQ73B27NTr83U69Ba
Note
Medium Risk
Permanent agent deletion is user-facing and irreversible; implementation reuses existing APIs but wrong name/id handling could delete the wrong row or leave inconsistent UI state.
Overview
Adds Delete Agent in the composer when editing an existing mutable agent (beside Update Agent), hidden for new drafts. A confirmation modal runs the optional
deleteAgentbuilder hook; on success the agents list refreshes and the shell moves to a fresh mutable draft instead of keeping a stale edit binding.createHarnessBuilderServernow implementsdeleteAgentby resolving the agent id from the registry name (same as update save) and calling the SDK delete API; unknown names no-op.Component and adapter tests cover visibility, confirm/cancel, errors, and HTTP DELETE behavior. Patch changeset for
@truefoundry/trueforge-ui.Reviewed by Cursor Bugbot for commit 07150de. Bugbot is set up for automated code reviews on this repo. Configure here.