Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
confirm before deleting an AI provider or a backend connection
[._.]/ Adam Eivy296d0459410d
diff --git a/client/src/components/providers/ProviderCard.jsx b/client/src/components/providers/ProviderCard.jsxindex 3276319f98..056feda1ae 100644--- a/client/src/components/providers/ProviderCard.jsx+++ b/client/src/components/providers/ProviderCard.jsx@@ -11,6 +11,7 @@* and which section the page filed the card under can never disagree.*/+import { useState } from 'react';import { hardwareUnavailableReason } from '../../utils/systemCapabilities';import { Link } from 'react-router';import { ExternalLink, Network, Terminal } from 'lucide-react';@@ -41,6 +42,7 @@ import { isHttpsUrl } from '../../utils/urlNormalize';import ProviderRuntimeStatus from './ProviderRuntimeStatus';import ProviderReadiness from './ProviderReadiness';import { CodexRoutingNotice, GatewayKeyHint } from './ProviderNotices';+import InlineConfirmRow from '../ui/InlineConfirmRow';// One phrasing for "this command isn't on the CoS Agent Runner's allowlist".// The editor states the same thing in its own inline banner, in prose.@@ -124,8 +126,15 @@ export default function ProviderCard({onCodexCopyCode,onCodexEnable,}) {+ // Deleting a provider is not undoable and the button sits in the same row as+ // Test/Edit, so it arms an inline confirm row rather than firing immediately.+ // (Inline confirm, not a two-click-arm button — see client/src/AGENTS.md.)+ // One card, one record: a plain boolean, not the id-keyed useConfirmDelete+ // that a component owning several rows needs.+ const [confirmingDelete, setConfirmingDelete] = useState(false);const modes = (provider.executionModes || []).map(mode => providersById?.[mode.id]).filter(Boolean);const unified = modes.length > 1;+ const displayName = unified ? provider.name.replace(/\b(CLI|TUI)\b\s*/i, '').trim() : provider.name;const shellProvider = unified ? modes.find(isTuiProvider) : provider;const style = CARD_STATE_STYLES[cardState.state];// Non-blocking: it never touches `cardState`, only what the card SAYS about@@ -168,7 +177,7 @@ export default function ProviderCard({to split, and it is narrower than the viewport by the sidebar. */}<div className="flex flex-col @2xl:flex-row @2xl:items-start justify-between gap-3"><div className="flex flex-wrap items-center gap-2 min-w-0">- <h3 className="text-lg font-semibold text-white">{unified ? provider.name.replace(/\b(CLI|TUI)\b\s*/i, '').trim() : provider.name}</h3>+ <h3 className="text-lg font-semibold text-white">{displayName}</h3><span className={`text-xs px-2 py-0.5 rounded ${providerTypeClass(provider.type)}`}>{unified ? 'CLI / TUI' : provider.type.toUpperCase()}</span>@@ -339,18 +348,37 @@ export default function ProviderCard({Edit</button>}- <button- onClick={() => onDelete(provider.id)}- className="px-3 py-1.5 text-sm bg-port-error/20 text-port-error hover:bg-port-error/30 rounded transition-colors"- >- Delete- </button>+ {!confirmingDelete && (+ <button+ onClick={() => setConfirmingDelete(true)}+ className="px-3 py-1.5 text-sm bg-port-error/20 text-port-error hover:bg-port-error/30 rounded transition-colors"+ >+ Delete+ </button>+ )}</div></div>{/* Card body — full width, below the header row rather than beside theaction buttons. */}<div className="mt-3 space-y-2">+ {/* Full-width and directly under the action row so the question is+ read where the click happened, whatever the buttons wrapped to.+ A unified card owns BOTH modes: the server deletes the whole mode+ group, so the question has to say so. */}+ {confirmingDelete && (+ <InlineConfirmRow+ question={`Delete ${displayName}?${unified ? ' Both its CLI and TUI modes are removed.' : ''} Its saved settings and model defaults are gone for good.`}+ confirmText="Delete provider"+ autoFocus+ aria-label={`Confirm deleting ${displayName}`}+ onConfirm={() => {+ setConfirmingDelete(false);+ onDelete(provider.id);+ }}+ onCancel={() => setConfirmingDelete(false)}+ />+ )}{unified && (<div className="text-xs text-gray-400 space-y-1"><p>CLI and TUI share enablement and the model catalog. Edit a mode to configure its arguments and model defaults.</p>diff --git a/client/src/components/providers/ProviderCard.test.jsx b/client/src/components/providers/ProviderCard.test.jsxindex 10a2d14d11..8e16d0d819 100644--- a/client/src/components/providers/ProviderCard.test.jsx+++ b/client/src/components/providers/ProviderCard.test.jsx@@ -1,5 +1,5 @@-import { describe, it, expect } from 'vitest';-import { render, screen } from '@testing-library/react';+import { describe, it, expect, vi } from 'vitest';+import { fireEvent, render, screen } from '@testing-library/react';import { MemoryRouter } from 'react-router';import ProviderCard from './ProviderCard';import { PROVIDER_CARD_STATE } from '../../utils/providers';@@ -16,7 +16,7 @@ const wrapper = (overrides = {}) => ({...overrides,});-const renderCard = (provider, daemonReadiness = null) => render(+const renderCard = (provider, daemonReadiness = null, props = {}) => render(<MemoryRouter><ProviderCardprovider={provider}@@ -30,6 +30,7 @@ const renderCard = (provider, daemonReadiness = null) => render(providersById={{}}runnerAllowedCommands={[]}testResult={null}+ {...props}/></MemoryRouter>);@@ -273,3 +274,49 @@ describe('ProviderCard codex routing override', () => {expect(screen.queryByText(/may not be counted here/)).toBeNull();});});++describe('ProviderCard delete confirmation', () => {+ const renderDeletable = (provider, props = {}) => {+ const onDelete = vi.fn();+ renderCard(provider, null, { onDelete, ...props });+ return onDelete;+ };++ it('asks before deleting instead of firing on the first click', () => {+ // Delete sits in the same button row as Test and Edit and the record is not+ // recoverable — a misclick there used to destroy the provider outright.+ const onDelete = renderDeletable(wrapper());+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));+ expect(onDelete).not.toHaveBeenCalled();+ expect(screen.getByText(/Delete OpenCode OpenRouter TUI\?/)).toBeTruthy();+ });++ it('deletes once the confirm button is pressed', () => {+ const onDelete = renderDeletable(wrapper());+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));+ fireEvent.click(screen.getByRole('button', { name: 'Delete provider' }));+ expect(onDelete).toHaveBeenCalledWith('opencode-openrouter-tui');+ });++ it('cancels back to the card without deleting', () => {+ const onDelete = renderDeletable(wrapper());+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));+ expect(onDelete).not.toHaveBeenCalled();+ expect(screen.queryByText(/Delete OpenCode OpenRouter TUI\?/)).toBeNull();+ expect(screen.getByRole('button', { name: 'Delete' })).toBeTruthy();+ });++ it('warns that a unified card takes both modes with it', () => {+ // The server deletes the whole mode group, so a question naming only the+ // mode whose button was clicked would understate what is about to happen.+ const cli = wrapper({ id: 'opencode-cli', name: 'OpenCode CLI', type: 'cli' });+ const tui = wrapper({ id: 'opencode-tui', name: 'OpenCode TUI' });+ renderDeletable(+ { ...cli, executionModes: [{ id: 'opencode-cli' }, { id: 'opencode-tui' }] },+ { providersById: { 'opencode-cli': cli, 'opencode-tui': tui } },+ );+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));+ expect(screen.getByText(/Both its CLI and TUI modes are removed/)).toBeTruthy();+ });+});diff --git a/client/src/components/providers/ProviderConnections.jsx b/client/src/components/providers/ProviderConnections.jsxindex 5f45182088..7547386767 100644--- a/client/src/components/providers/ProviderConnections.jsx+++ b/client/src/components/providers/ProviderConnections.jsx@@ -7,6 +7,8 @@ import EmptyState from '../EmptyState';import ProviderConnectionForm from './ProviderConnectionForm';import ProviderHarnessForm from './ProviderHarnessForm';import ProviderRouteRow from './ProviderRouteRow';+import InlineConfirmRow from '../ui/InlineConfirmRow';+import useConfirmDelete from '../../hooks/useConfirmDelete';import * as api from '../../services/api';import { harnessLabel } from '../../utils/providerHarnesses';import {@@ -54,6 +56,9 @@ const EMPTY_BACKEND_DRAFT = Object.freeze({label: '', kind: 'ollama', protocol: 'openai', baseUrl: '', credentialKey: '', credential: '',});+/** What a backend is CALLED on screen — its label, or its id until one is typed. */+const connectionName = (connection) => connection.label || connection.id;+/** How each catalog state reads at a glance — the four are deliberately distinct. */const CATALOG_TONE_CLASS = {error: 'text-port-error',@@ -102,6 +107,10 @@ export default function ProviderConnections({const [addingBackend, setAddingBackend] = useState(false);const [backendDraft, setBackendDraft] = useState(EMPTY_BACKEND_DRAFT);const [harnessDraft, setHarnessDraft] = useState({});+ // Deleting a backend throws away its stored key as well as the row, and the+ // button sits beside Save/Refresh — so it asks first. This component owns N+ // backend rows, so the armed one is id-keyed rather than a boolean.+ const { isConfirming, requestDelete, cancelDelete, confirmDelete } = useConfirmDelete();const loadGraph = useCallback(async () => {setLoading(true);@@ -401,6 +410,7 @@ export default function ProviderConnections({|| group.bindings.some((entry) => entry.binding.harnessId === harnessId)).map((group) => {const isOpen = group.connection.id === connectionId;+ const confirmingDelete = isConfirming(group.connection.id);const summary = catalogSummary(group.connection.catalog);return (<section key={group.connection.id} className="rounded-lg border border-port-border bg-port-card">@@ -411,7 +421,7 @@ export default function ProviderConnections({className="flex w-full flex-col gap-1 p-3 text-left sm:flex-row sm:items-center sm:justify-between"><span className="min-w-0">- <span className="block truncate font-medium">{group.connection.label || group.connection.id}</span>+ <span className="block truncate font-medium">{connectionName(group.connection)}</span><span className="block text-xs text-port-muted">{group.connection.kind}{' · '}@@ -482,14 +492,25 @@ export default function ProviderConnections({Clear key</button>)}- {group.bindings.length === 0 && (- <button type="button" disabled={busy} onClick={() => removeConnection(group.connection)}+ {group.bindings.length === 0 && !confirmingDelete && (+ <button type="button" disabled={busy} onClick={() => requestDelete(group.connection.id)}className="flex items-center gap-1 rounded border border-port-error px-3 py-1 text-sm text-port-error disabled:opacity-50"><Trash2 size={14} aria-hidden="true" /> Delete</button>)}</div>+ {confirmingDelete && (+ <InlineConfirmRow+ question={`Delete the ${connectionName(group.connection)} backend? Its endpoint, catalog and saved key go with it.`}+ confirmText="Delete backend"+ autoFocus+ aria-label={`Confirm deleting the ${connectionName(group.connection)} backend`}+ onConfirm={() => confirmDelete(() => removeConnection(group.connection))}+ onCancel={cancelDelete}+ />+ )}+<ProviderHarnessFormgraph={graph}connection={group.connection}@@ -582,7 +603,7 @@ export default function ProviderConnections({.filter((candidate) => candidate.connection.id !== group.connection.id).map((candidate) => (<option key={candidate.connection.id} value={candidate.connection.id}>- {candidate.connection.label || candidate.connection.id}+ {connectionName(candidate.connection)}</option>))}</select>diff --git a/client/src/components/providers/ProviderConnections.test.jsx b/client/src/components/providers/ProviderConnections.test.jsxindex ec8d3dffc0..46825cf663 100644--- a/client/src/components/providers/ProviderConnections.test.jsx+++ b/client/src/components/providers/ProviderConnections.test.jsx@@ -490,3 +490,21 @@ describe('adding a backend and a harness (#6369)', () => {expect(api.createProviderBinding).not.toHaveBeenCalled();});});++describe('deleting a backend', () => {+ it('asks before it throws the backend and its stored key away', async () => {+ api.deleteProviderConnection.mockResolvedValue({ deleted: true });+ renderPanel({ connectionId: OTHER });++ fireEvent.click(await screen.findByRole('button', { name: /Delete/ }));+ expect(api.deleteProviderConnection).not.toHaveBeenCalled();+ expect(screen.getByText(/Delete the Remote daemon backend\?/)).toBeInTheDocument();++ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));+ expect(api.deleteProviderConnection).not.toHaveBeenCalled();++ fireEvent.click(screen.getByRole('button', { name: /Delete/ }));+ fireEvent.click(screen.getByRole('button', { name: 'Delete backend' }));+ await waitFor(() => expect(api.deleteProviderConnection).toHaveBeenCalledWith(OTHER, { silent: true }));+ });+});