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

fix: confirm before deleting a prompt variable from the row trash button (#3935)

[._.]/ Adam Eivy67388827b691
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index a8e8e06f2a..90e7373392 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -69,3 +69,4 @@
- The Digital Twin confidence gauge is now announced to screen readers. The circular SVG ring and the per-dimension bars beneath it were plain `<div>`s with a decorative SVG inside, so assistive tech either skipped them or read the loose "72%" text node with nothing to say what it measured. The overall gauge now carries `role="meter"` with `aria-label="Digital Twin overall confidence"`, the min/max/now values, and an `aria-valuetext` pairing the percentage with its Strong/Moderate/Needs Work band; each dimension bar carries the same meter semantics under its own dimension label, and the ring SVG is marked `aria-hidden` so its geometry isn't read twice.
- Pushing a series or music video project to a peer running an older PortOS no longer fires the same rejected request every sync cycle forever. When the older peer's strict schema rejects a newer bundled key (`manuscriptReview`, `reverseOutline`, `linkedTrack`), the sender strips it and retries — and deliberately withholds `lastPushedHash` so the stripped doc is re-sent once that peer upgrades. With nothing else recorded, the next cycle had no way to tell a settled record from a new edit, so every 60-second tick re-ran the same 400-plus-retry pair for content that had not moved. A second water-mark (`lastPushedLegacyHash`) now records what was actually delivered in stripped form, so an unchanged record short-circuits; any real edit still moves the hash and re-attempts the full push, and the `peer:online` re-probe still pushes unconditionally, which is where the stripped key finally lands after an upgrade. A pending doc the *receiver* reported (its bundled merge threw) is left un-water-marked, since that one is transient and must genuinely retry.
- A failed first read on the Quota Burn page no longer strands you on a dead end. `load()` swallowed the error and left `config` null, and the unavailable branch returns before the header — so the only control that could re-read, "Refresh quota", was never rendered, and the one line on screen named neither the cause nor a way out short of reloading the browser tab. The read's failure is now kept in its own state (`null` = never failed, distinct from "the server answered and has no plan"), and the unavailable branch renders an error banner carrying that message with a Retry button that re-reads and clears it on success.
+- Deleting a prompt variable now asks first. The 14px trash icon on each row in the Prompt Manager's Variables list fired `DELETE /api/prompts/variables/:key` on the first click, so a mis-click — easy on a touch screen or with tight cursor tracking — destroyed the variable and its template content with no warning and no undo. The trash button now arms an inline confirm row in place of that row ("Delete "Tone Guide"?" with Delete / Cancel), using the shared `useConfirmDelete` + `InlineConfirmRow` pattern, so only one row is armed at a time and cancelling leaves the variable untouched. The trash button's accessible name now also names the variable it deletes instead of the generic "Delete variable".
diff --git a/client/src/pages/PromptManager.jsx b/client/src/pages/PromptManager.jsx
index b35ddd9dd0..97b7fa5cc4 100644
--- a/client/src/pages/PromptManager.jsx
+++ b/client/src/pages/PromptManager.jsx
@@ -16,6 +16,8 @@ import useFieldDraft from '../hooks/useFieldDraft';
import SettingsTabsHeader from '../components/settings/SettingsTabsHeader';
import { FormField } from '../components/ui/FormField';
import Modal from '../components/ui/Modal';
+import InlineConfirmRow from '../components/ui/InlineConfirmRow';
+import { useConfirmDelete } from '../hooks/useConfirmDelete';
import {
getPrompts, getPrompt, createPrompt, savePrompt, deletePrompt, previewPrompt, getPromptUsage,
getPromptVariables, createPromptVariable, savePromptVariable, deletePromptVariable,
@@ -105,6 +107,14 @@ export default function PromptManager() {
const [activeProviderId, setActiveProviderId] = useState(null);
const [saving, setSaving] = useState(false);
const [deleteConfirm, setDeleteConfirm] = useState(null);
+ // Variables delete inline-confirms in the row itself (#3935) — the trash icon
+ // arms the row instead of firing DELETE on the first click.
+ const {
+ isConfirming: isConfirmingVar,
+ requestDelete: requestVarDelete,
+ cancelDelete: cancelVarDelete,
+ confirmDelete: confirmVarDelete,
+ } = useConfirmDelete();
useEffect(() => {
loadData();
@@ -682,29 +692,42 @@ export default function PromptManager() {
</div>
<div className="space-y-1">
{Object.entries(variables).sort(([a], [b]) => a.localeCompare(b)).map(([key, v]) => (
- <div
- key={key}
- className={`flex items-center justify-between px-3 py-2 rounded-lg text-sm ${
- selectedVar === key
- ? 'bg-port-accent/20 text-port-accent'
- : 'text-gray-300 hover:bg-port-border'
- }`}
- >
- <button
- onClick={() => setSelectedVar(key)}
- className="flex-1 text-left"
- >
- <div className="font-medium">{v.name || key}</div>
- <div className="text-xs text-gray-500">{v.category || 'uncategorized'}</div>
- </button>
- <button
- onClick={() => deleteVariable(key)}
- aria-label="Delete variable"
- className="p-1 text-gray-500 hover:text-port-error"
+ isConfirmingVar(key) ? (
+ <InlineConfirmRow
+ key={key}
+ className="rounded-lg"
+ question={`Delete "${v.name || key}"?`}
+ confirmText="Delete"
+ aria-label={`Confirm delete variable ${v.name || key}`}
+ autoFocus
+ onConfirm={() => confirmVarDelete(() => deleteVariable(key))}
+ onCancel={cancelVarDelete}
+ />
+ ) : (
+ <div
+ key={key}
+ className={`flex items-center justify-between px-3 py-2 rounded-lg text-sm ${
+ selectedVar === key
+ ? 'bg-port-accent/20 text-port-accent'
+ : 'text-gray-300 hover:bg-port-border'
+ }`}
>
- <Trash2 size={14} />
- </button>
- </div>
+ <button
+ onClick={() => setSelectedVar(key)}
+ className="flex-1 text-left"
+ >
+ <div className="font-medium">{v.name || key}</div>
+ <div className="text-xs text-gray-500">{v.category || 'uncategorized'}</div>
+ </button>
+ <button
+ onClick={() => requestVarDelete(key)}
+ aria-label={`Delete variable ${v.name || key}`}
+ className="p-1 text-gray-500 hover:text-port-error"
+ >
+ <Trash2 size={14} />
+ </button>
+ </div>
+ )
))}
</div>
</div>
diff --git a/client/src/pages/PromptManager.test.jsx b/client/src/pages/PromptManager.test.jsx
index 66647e1500..462ac1842c 100644
--- a/client/src/pages/PromptManager.test.jsx
+++ b/client/src/pages/PromptManager.test.jsx
@@ -10,6 +10,8 @@ const getPrompts = vi.fn();
const getPrompt = vi.fn();
const getPromptUsage = vi.fn();
const deletePrompt = vi.fn();
+const getPromptVariables = vi.fn();
+const deletePromptVariable = vi.fn();
vi.mock('../services/apiPrompts', () => ({
getPrompts: (...a) => getPrompts(...a),
@@ -19,10 +21,10 @@ vi.mock('../services/apiPrompts', () => ({
deletePrompt: (...a) => deletePrompt(...a),
previewPrompt: vi.fn(),
getPromptUsage: (...a) => getPromptUsage(...a),
- getPromptVariables: vi.fn(() => Promise.resolve({ variables: {} })),
+ getPromptVariables: (...a) => getPromptVariables(...a),
createPromptVariable: vi.fn(),
savePromptVariable: vi.fn(),
- deletePromptVariable: vi.fn(),
+ deletePromptVariable: (...a) => deletePromptVariable(...a),
getJobSkills: vi.fn(() => Promise.resolve({ skills: [] })),
getJobSkill: vi.fn(),
saveJobSkill: vi.fn(),
@@ -54,6 +56,13 @@ const renderPage = (entry = '/prompts') => render(
</MemoryRouter>,
);
+// File-level defaults so every describe mounts against the same empty-ish page;
+// individual suites override only what they assert on.
+beforeEach(() => {
+ getPromptVariables.mockReset().mockResolvedValue({ variables: {} });
+ deletePromptVariable.mockReset().mockResolvedValue({ success: true });
+});
+
const searchBox = () => screen.getByLabelText('Search prompt stages');
const groupHeader = (label) => screen.getByRole('button', { name: new RegExp(`^${label}, \\d+ stages?$`, 'i') });
@@ -355,3 +364,64 @@ describe('PromptManager delete demotion', () => {
));
});
});
+
+// #3935: the row trash icon used to fire DELETE on the first click, so a
+// mis-click on a 14px target destroyed the variable with no undo.
+describe('PromptManager variable deletion', () => {
+ const VARIABLES = {
+ 'tone-guide': { name: 'Tone Guide', category: 'style', content: 'stay wry' },
+ 'house-style': { name: 'House Style', category: 'style', content: 'oxford comma' },
+ };
+
+ beforeEach(() => {
+ getPrompts.mockReset().mockResolvedValue({ stages: STAGES, systemStages: SYSTEM_STAGES });
+ getPromptVariables.mockResolvedValue({ variables: VARIABLES });
+ });
+
+ const openVariables = async () => {
+ renderPage('/prompts?tab=variables');
+ return screen.findByText('Tone Guide');
+ };
+
+ it('arms an inline confirm instead of deleting on the trash click', async () => {
+ await openVariables();
+
+ fireEvent.click(screen.getByLabelText('Delete variable Tone Guide'));
+
+ expect(deletePromptVariable).not.toHaveBeenCalled();
+ expect(screen.getByText('Delete "Tone Guide"?')).toBeTruthy();
+ // Only the armed row confirms; its sibling stays a normal row.
+ expect(screen.getByLabelText('Delete variable House Style')).toBeTruthy();
+ });
+
+ it('deletes only after the inline confirm', async () => {
+ await openVariables();
+
+ fireEvent.click(screen.getByLabelText('Delete variable Tone Guide'));
+ fireEvent.click(within(screen.getByLabelText('Confirm delete variable Tone Guide'))
+ .getByRole('button', { name: /^delete$/i }));
+
+ await waitFor(() => expect(deletePromptVariable).toHaveBeenCalledWith('tone-guide', { silent: true }));
+ });
+
+ it('leaves the variable intact when the confirm is cancelled', async () => {
+ await openVariables();
+
+ fireEvent.click(screen.getByLabelText('Delete variable Tone Guide'));
+ fireEvent.click(screen.getByRole('button', { name: /^cancel$/i }));
+
+ expect(deletePromptVariable).not.toHaveBeenCalled();
+ expect(screen.queryByText('Delete "Tone Guide"?')).toBeNull();
+ expect(screen.getByLabelText('Delete variable Tone Guide')).toBeTruthy();
+ });
+
+ it('arms one row at a time', async () => {
+ await openVariables();
+
+ fireEvent.click(screen.getByLabelText('Delete variable Tone Guide'));
+ fireEvent.click(screen.getByLabelText('Delete variable House Style'));
+
+ expect(screen.queryByText('Delete "Tone Guide"?')).toBeNull();
+ expect(screen.getByText('Delete "House Style"?')).toBeTruthy();
+ });
+});