Skip to content

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

feat([confirm-ux-button-pair-popover-audit]): extract ConfirmButtonPair primitive

[._.]/ Adam Eivy38186c73dc05
diff --git a/client/src/components/digital-twin/tabs/TimeCapsuleTab.jsx b/client/src/components/digital-twin/tabs/TimeCapsuleTab.jsx
index 8adda479eb..06405aec75 100644
--- a/client/src/components/digital-twin/tabs/TimeCapsuleTab.jsx
+++ b/client/src/components/digital-twin/tabs/TimeCapsuleTab.jsx
@@ -15,6 +15,7 @@ import {Archive,
import BrailleSpinner from '../../BrailleSpinner';
import * as api from '../../../services/api';
import toast from '../../ui/Toast';
+import ConfirmButtonPair from '../../ui/ConfirmButtonPair';
import { formatBytes, formatDateTime, timeAgo } from '../../../utils/formatters';
export default function TimeCapsuleTab({ onRefresh: _onRefresh }) {
@@ -352,20 +353,11 @@ export default function TimeCapsuleTab({ onRefresh: _onRefresh }) {
)}
</button>
{confirmDelete === snap.id ? (
- <div className="flex items-center gap-1">
- <button
- onClick={() => handleDelete(snap.id)}
- className="px-2 py-1 min-h-[40px] text-xs text-red-400 hover:text-red-300 font-medium"
- >
- Confirm
- </button>
- <button
- onClick={() => setConfirmDelete(null)}
- className="px-2 py-1 min-h-[40px] text-xs text-gray-500 hover:text-white"
- >
- Cancel
- </button>
- </div>
+ <ConfirmButtonPair
+ confirmText="Confirm"
+ onConfirm={() => handleDelete(snap.id)}
+ onCancel={() => setConfirmDelete(null)}
+ />
) : (
<button
onClick={() => setConfirmDelete(snap.id)}
diff --git a/client/src/components/feature-agents/FeatureAgentCard.jsx b/client/src/components/feature-agents/FeatureAgentCard.jsx
index 65a19ee541..2c01822c0a 100644
--- a/client/src/components/feature-agents/FeatureAgentCard.jsx
+++ b/client/src/components/feature-agents/FeatureAgentCard.jsx
@@ -2,6 +2,7 @@ import { useState } from 'react';
import { Link } from 'react-router-dom';
import { Play, Pause, Square, Zap, Trash2 } from 'lucide-react';
import { STATUS_COLORS, STATUS_BG, PRIORITY_COLORS, SCHEDULE_LABELS, timeAgo } from './constants';
+import ConfirmButtonPair from '../ui/ConfirmButtonPair';
export default function FeatureAgentCard({ agent, onStart, onPause, onResume, onStop, onTrigger, onDelete }) {
const [confirmingDelete, setConfirmingDelete] = useState(false);
@@ -76,23 +77,13 @@ export default function FeatureAgentCard({ agent, onStart, onPause, onResume, on
)}
<div className="flex-1" />
{confirmingDelete ? (
- <div className="flex items-center gap-2">
- <span className="text-xs text-gray-400">Delete?</span>
- <div className="inline-flex rounded-lg overflow-hidden border border-port-border">
- <button
- onClick={() => { onDelete(agent.id); setConfirmingDelete(false); }}
- className="px-2 py-1 bg-port-error/20 text-port-error hover:bg-port-error/30 text-xs"
- >
- Yes
- </button>
- <button
- onClick={() => setConfirmingDelete(false)}
- className="px-2 py-1 bg-port-card text-gray-400 hover:bg-port-border/50 text-xs border-l border-port-border"
- >
- No
- </button>
- </div>
- </div>
+ <ConfirmButtonPair
+ prompt="Delete?"
+ confirmText="Yes"
+ cancelText="No"
+ onConfirm={() => { onDelete(agent.id); setConfirmingDelete(false); }}
+ onCancel={() => setConfirmingDelete(false)}
+ />
) : (
<button onClick={() => setConfirmingDelete(true)} className="flex items-center gap-1 px-2 py-1 text-xs text-port-error hover:bg-port-error/10 rounded transition-colors">
<Trash2 size={12} />
diff --git a/client/src/components/settings/LocalLlmTab.jsx b/client/src/components/settings/LocalLlmTab.jsx
index f0ca01202b..e2b06989f0 100644
--- a/client/src/components/settings/LocalLlmTab.jsx
+++ b/client/src/components/settings/LocalLlmTab.jsx
@@ -2,6 +2,7 @@ import { useState, useEffect, useRef, useCallback, useMemo } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { Cpu, Box, ArrowRightLeft, Download, Trash2, RefreshCw, Search, Plus, ExternalLink, Star, Link2, Copy, Play, Square, Power, PowerOff, Eye, Wrench, Brain, Code2, MessageSquare, Boxes, AlertTriangle, FlaskConical } from 'lucide-react';
import toast from '../ui/Toast';
+import ConfirmButtonPair from '../ui/ConfirmButtonPair';
import BrailleSpinner from '../BrailleSpinner';
import { formatBytes, timeAgo } from '../../utils/formatters';
import {
@@ -803,23 +804,14 @@ export function LocalLlmTab() {
Chat
</Link>
{confirmDeleteId === m.id ? (
- <div className="flex items-center gap-1.5 shrink-0">
- <span className="text-xs text-port-error">Delete?</span>
- <button
- onClick={() => { setConfirmDeleteId(null); remove(m.id); }}
- disabled={busy}
- className="px-2 py-1 text-xs bg-port-error/30 hover:bg-port-error/50 text-port-error rounded disabled:opacity-50 flex items-center gap-1"
- >
- <Trash2 size={12} />
- Delete
- </button>
- <button
- onClick={() => setConfirmDeleteId(null)}
- className="px-2 py-1 text-xs text-gray-400 hover:text-white transition-colors"
- >
- Cancel
- </button>
- </div>
+ <ConfirmButtonPair
+ prompt="Delete?"
+ confirmIcon={Trash2}
+ busy={busy}
+ className="shrink-0"
+ onConfirm={() => { setConfirmDeleteId(null); remove(m.id); }}
+ onCancel={() => setConfirmDeleteId(null)}
+ />
) : (
<button
onClick={() => setConfirmDeleteId(m.id)}
diff --git a/client/src/components/ui/ConfirmButtonPair.jsx b/client/src/components/ui/ConfirmButtonPair.jsx
new file mode 100644
index 0000000000..6c84bc48a7
--- /dev/null
+++ b/client/src/components/ui/ConfirmButtonPair.jsx
@@ -0,0 +1,65 @@
+import { Loader2 } from 'lucide-react';
+
+// Compact inline "confirm / cancel" button pair for destructive actions that
+// live in a dense action area (a card's button row, a list-row's trailing
+// controls) — the sibling of <InlineConfirmRow> for when there's no room for a
+// full question row. The question, if any, is a short inline word ("Delete?").
+//
+// Tones pre-compose full Tailwind class names — the JIT scans for complete
+// tokens, so `bg-port-${tone}/20` would NOT generate the utility. Spell it out.
+// Only `error` ships today (every confirm pair is destructive); add a map entry
+// when a non-destructive tone is actually needed.
+const TONES = {
+ error: 'bg-port-error/20 text-port-error hover:bg-port-error/30',
+};
+
+export default function ConfirmButtonPair({
+ prompt,
+ confirmText = 'Delete',
+ cancelText = 'Cancel',
+ confirmIcon: ConfirmIcon,
+ onConfirm,
+ onCancel,
+ busy = false,
+ busyText,
+ tone = 'error',
+ ariaLabel,
+ className = '',
+}) {
+ const confirmTone = TONES[tone] || TONES.error;
+ // While busy with a busyText, swap the confirm icon for a spinner and the
+ // label for the in-flight word ("Deleting"); otherwise keep the resting
+ // icon/label and just disable both buttons.
+ const showSpinner = busy && busyText;
+
+ return (
+ <div
+ role="group"
+ aria-label={ariaLabel}
+ className={`flex items-center gap-2 ${className}`.trim()}
+ >
+ {prompt ? <span className="text-xs text-gray-400">{prompt}</span> : null}
+ <button
+ type="button"
+ onClick={onConfirm}
+ disabled={busy}
+ className={`inline-flex items-center gap-1 px-2 py-1 text-xs rounded transition-colors disabled:opacity-50 ${confirmTone}`}
+ >
+ {showSpinner ? (
+ <Loader2 size={12} className="animate-spin" />
+ ) : ConfirmIcon ? (
+ <ConfirmIcon size={12} />
+ ) : null}
+ {showSpinner ? busyText : confirmText}
+ </button>
+ <button
+ type="button"
+ onClick={onCancel}
+ disabled={busy}
+ className="px-2 py-1 text-xs text-gray-400 hover:text-white transition-colors disabled:opacity-50"
+ >
+ {cancelText}
+ </button>
+ </div>
+ );
+}
diff --git a/client/src/components/ui/ConfirmButtonPair.test.jsx b/client/src/components/ui/ConfirmButtonPair.test.jsx
new file mode 100644
index 0000000000..13b3bf3e18
--- /dev/null
+++ b/client/src/components/ui/ConfirmButtonPair.test.jsx
@@ -0,0 +1,70 @@
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen, fireEvent } from '@testing-library/react';
+import { Trash2 } from 'lucide-react';
+
+import ConfirmButtonPair from './ConfirmButtonPair';
+
+describe('ConfirmButtonPair', () => {
+ it('renders default Delete/Cancel buttons with the error tone and no prompt', () => {
+ render(<ConfirmButtonPair />);
+ const confirm = screen.getByRole('button', { name: 'Delete' });
+ expect(confirm.className).toContain('bg-port-error/20');
+ expect(screen.getByRole('button', { name: 'Cancel' })).toBeTruthy();
+ // No prompt span when prompt is omitted.
+ expect(screen.queryByText('Delete?')).toBeNull();
+ });
+
+ it('renders a short inline prompt when supplied', () => {
+ render(<ConfirmButtonPair prompt="Delete?" />);
+ expect(screen.getByText('Delete?')).toBeTruthy();
+ });
+
+ it('fires onConfirm and onCancel for the respective buttons', () => {
+ const onConfirm = vi.fn();
+ const onCancel = vi.fn();
+ render(<ConfirmButtonPair onConfirm={onConfirm} onCancel={onCancel} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
+ expect(onConfirm).toHaveBeenCalledTimes(1);
+ expect(onCancel).toHaveBeenCalledTimes(1);
+ });
+
+ it('honors custom labels', () => {
+ render(<ConfirmButtonPair confirmText="Yes" cancelText="No" />);
+ expect(screen.getByRole('button', { name: 'Yes' })).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'No' })).toBeTruthy();
+ });
+
+ it('renders the confirm icon alongside the label', () => {
+ const { container } = render(<ConfirmButtonPair confirmIcon={Trash2} />);
+ // lucide renders an <svg>; it sits inside the confirm button.
+ const confirm = screen.getByRole('button', { name: 'Delete' });
+ expect(confirm.querySelector('svg')).not.toBeNull();
+ });
+
+ it('disables both buttons while busy', () => {
+ render(<ConfirmButtonPair busy />);
+ expect(screen.getByRole('button', { name: 'Delete' }).disabled).toBe(true);
+ expect(screen.getByRole('button', { name: 'Cancel' }).disabled).toBe(true);
+ });
+
+ it('swaps the confirm label to busyText and shows a spinner when busy with busyText', () => {
+ const { container } = render(
+ <ConfirmButtonPair confirmText="Delete" busy busyText="Deleting" confirmIcon={Trash2} />,
+ );
+ expect(screen.getByRole('button', { name: 'Deleting' })).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Delete' })).toBeNull();
+ // The spinner svg renders (animate-spin) and the resting Trash2 is hidden.
+ expect(container.querySelector('.animate-spin')).not.toBeNull();
+ });
+
+ it('exposes the group ariaLabel for assistive tech', () => {
+ render(<ConfirmButtonPair ariaLabel="Confirm deletion of My App" />);
+ expect(screen.getByRole('group', { name: 'Confirm deletion of My App' })).toBeTruthy();
+ });
+
+ it('merges passthrough className onto the container', () => {
+ render(<ConfirmButtonPair ariaLabel="x" className="shrink-0" />);
+ expect(screen.getByRole('group', { name: 'x' }).className).toContain('shrink-0');
+ });
+});
diff --git a/client/src/components/universe/CharacterReferenceSheetPanel.jsx b/client/src/components/universe/CharacterReferenceSheetPanel.jsx
index 653aefe159..6c0921779e 100644
--- a/client/src/components/universe/CharacterReferenceSheetPanel.jsx
+++ b/client/src/components/universe/CharacterReferenceSheetPanel.jsx
@@ -24,6 +24,7 @@ import useMediaJobProgress from '../../hooks/useMediaJobProgress';
import useMounted from '../../hooks/useMounted';
import { readSheetPointer, LEGACY_SHEET_VARIANT_ID } from '../../lib/sheetPointers';
import toast from '../ui/Toast';
+import ConfirmButtonPair from '../ui/ConfirmButtonPair';
import MediaImage from '../MediaImage';
// HEAD-poll for the rendered sheet at its destination URL, with backoff. The
@@ -153,25 +154,13 @@ function VariantRow({
</div>
<div className="flex items-center gap-1">
{confirmingDelete ? (
- <>
- <button
- type="button"
- onClick={() => setConfirmingDelete(false)}
- disabled={deleting}
- className="inline-flex items-center gap-1 px-2 py-1 text-[10px] rounded border border-port-border text-gray-300 hover:bg-port-border/40 hover:text-white disabled:opacity-40"
- >
- Cancel
- </button>
- <button
- type="button"
- onClick={handleDelete}
- disabled={deleting}
- className="inline-flex items-center gap-1 px-2 py-1 text-[10px] rounded border border-port-error/60 text-port-error hover:bg-port-error/15 disabled:opacity-40"
- >
- {deleting ? <Loader2 size={10} className="animate-spin" /> : <Trash2 size={10} />}
- {deleting ? 'Deleting' : 'Delete'}
- </button>
- </>
+ <ConfirmButtonPair
+ confirmIcon={Trash2}
+ busy={deleting}
+ busyText="Deleting"
+ onConfirm={handleDelete}
+ onCancel={() => setConfirmingDelete(false)}
+ />
) : (
<>
{existing && !inFlight ? (
diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsx
index 145d8dac07..c9c187232f 100644
--- a/client/src/pages/Apps.jsx
+++ b/client/src/pages/Apps.jsx
@@ -2,6 +2,7 @@ import { useState, useEffect, useCallback } from 'react';
import { Link } from 'react-router-dom';
import { ExternalLink, Play, Square, RotateCcw, FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Ticket, Download, Hammer, Smartphone } from 'lucide-react';
import toast from '../components/ui/Toast';
+import ConfirmButtonPair from '../components/ui/ConfirmButtonPair';
import AppIcon from '../components/AppIcon';
import BrailleSpinner from '../components/BrailleSpinner';
import KanbanBoard from '../components/KanbanBoard';
@@ -331,25 +332,14 @@ export default function Apps() {
{/* Edit/Delete Actions */}
{confirmingDelete === app.id ? (
- <div className="flex items-center gap-2" role="alertdialog" aria-label={`Confirm deletion of ${app.name}`}>
- <span className="text-xs text-gray-400">Remove?</span>
- <div className="inline-flex rounded-lg overflow-hidden border border-port-border">
- <button
- onClick={() => handleDelete(app)}
- className="px-2 py-1 bg-port-error/20 text-port-error hover:bg-port-error/30 text-xs focus:outline-hidden focus:ring-2 focus:ring-port-error"
- aria-label={`Confirm delete ${app.name}`}
- >
- Yes
- </button>
- <button
- onClick={() => setConfirmingDelete(null)}
- className="px-2 py-1 bg-port-border/50 text-gray-400 hover:text-white text-xs border-l border-port-border focus:outline-hidden focus:ring-2 focus:ring-port-accent"
- aria-label="Cancel deletion"
- >
- No
- </button>
- </div>
- </div>
+ <ConfirmButtonPair
+ prompt="Remove?"
+ confirmText="Yes"
+ cancelText="No"
+ ariaLabel={`Confirm deletion of ${app.name}`}
+ onConfirm={() => handleDelete(app)}
+ onCancel={() => setConfirmingDelete(null)}
+ />
) : (
<div className="flex items-center gap-2">
{/* Archive/Unarchive button (hidden for PortOS baseline) */}