Skip to content

feat(agents): add Delete Agent button with confirmation - #497

Open
kristopolous wants to merge 1 commit into
truefoundry:mainfrom
kristopolous:feat/delete-agent-button
Open

feat(agents): add Delete Agent button with confirmation#497
kristopolous wants to merge 1 commit into
truefoundry:mainfrom
kristopolous:feat/delete-agent-button

Conversation

@kristopolous

@kristopolous kristopolous commented Aug 29, 2026

Copy link
Copy Markdown

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:

  • The registry already supports DELETE /api/v1/agents/{agent_id} (packages/trueforge/src/routes/agentRoutes.ts / apis/agents.ts), and the SDK already has client.agents.delete(...).
  • The AgentBuilderServer port (@truefoundry/assistant-ui-runtime) already has an optional deleteAgent?(req: { agentName: string }) hook — nothing in packages/trueforge-ui called 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 same CenteredModal primitive and the existing destructive button variant already used elsewhere in the app, not a native confirm() — before permanently deleting. On success it invalidates the Agents Library list and drops the now-dangling edit binding, landing on a fresh draft (rather than clearChat(), which deliberately preserves the edit binding for the "still editing the same agent" case — wrong here, since the agent no longer exists).
  • builderServer.ts: implements deleteAgent in createHarnessBuilderServer by looking up the agent's id by name (same pattern saveAgent's update path already uses) and calling the SDK's existing client.agents.delete(id). No new backend or SDK surface needed — this was already there, just unwired.

Test plan

  • New tests in harnessBuilderServer.test.ts: deleteAgent looks up the id and issues DELETE; no-op when the name is unknown.
  • New tests in SaveAgentButton.test.tsx: hidden for a new/unnamed draft; shown + calls deleteAgent on confirm for an existing binding; Cancel does not call it; a rejected deleteAgent shows an inline error and keeps the dialog open.
  • pnpm vitest run in packages/trueforge-ui — 871/871 pass.
  • pnpm tsc --noEmit — clean.
  • pnpm eslint on changed files — clean.
  • Added a changeset (@truefoundry/trueforge-ui patch).
  • Verified end-to-end against the real running app (pnpm standalone:dev) — see screenshots below, including a direct SQLite check that the agent row 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":
Update and Delete buttons

2. Confirmation dialog before the permanent delete:
Delete confirmation dialog

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

(Screenshots hosted on an orphan delete-agent-screenshots branch 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 deleteAgent builder hook; on success the agents list refreshes and the shell moves to a fresh mutable draft instead of keeping a stale edit binding.

createHarnessBuilderServer now implements deleteAgent by 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.

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-bot

changeset-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 07150de

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@truefoundry/trueforge-ui Patch
frontend Patch

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

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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);
}
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 07150de. Configure here.

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.

No Delete Agent action when editing an agent

1 participant