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
fix: align Native deletion with its running requirement (#10730)
Adam Eivy7b47541780a9
diff --git a/client/src/components/settings/DatabaseTab.jsx b/client/src/components/settings/DatabaseTab.jsxindex 403d47cb83..b1fe84af29 100644--- a/client/src/components/settings/DatabaseTab.jsx+++ b/client/src/components/settings/DatabaseTab.jsx@@ -33,7 +33,9 @@ function BackendCard({ label, icon: Icon, backend, isActive, dbStatus, runActionconst canStart = backend === 'docker'? data?.installed && data?.daemonRunning && !data?.containerRunning: data?.configured && !data?.running;- const canDestroy = !isActive && !isRunning && (backend === 'docker' ? data?.installed : data?.configured);+ const canDestroy = backend === 'docker'+ ? !isActive && !isRunning && data?.installed+ : !isActive && isRunning && data?.configured;const statusLabel = isRunning ? 'Running': (backend === 'docker' ? (data?.installed ? 'Stopped' : 'Not installed'): (data?.configured ? 'Stopped' : data?.installed ? 'Not configured' : 'Not installed'));@@ -152,8 +154,10 @@ function BackendCard({ label, icon: Icon, backend, isActive, dbStatus, runAction<buttononClick={() => setConfirmAction({type: 'destroy',- label: `Destroy ${displayLabel} database and all its data?`,- detail: 'This permanently removes the database files. You can set it up again later.',+ label: backend === 'native' ? 'Delete the inactive Native database?' : 'Destroy Docker database and all its data?',+ detail: backend === 'native'+ ? 'This permanently deletes its tables and records. System PostgreSQL and other databases are kept. The active Docker database is unchanged.'+ : 'This permanently removes the Docker database files. You can set it up again later.',displayLabel,action: () => runAction(`destroy-${backend}`, () => destroyDatabase(backend), `${displayLabel} database destroyed`)})}@@ -161,7 +165,7 @@ function BackendCard({ label, icon: Icon, backend, isActive, dbStatus, runActionclassName={`${btnClass} bg-port-error/20 hover:bg-port-error/30 text-port-error`}><Trash2 size={12} />- Destroy+ {backend === 'native' ? 'Delete Native database…' : 'Destroy'}</button>)}</>diff --git a/client/src/components/settings/DatabaseTab.test.jsx b/client/src/components/settings/DatabaseTab.test.jsxindex fa5688d2e2..6da46ca347 100644--- a/client/src/components/settings/DatabaseTab.test.jsx+++ b/client/src/components/settings/DatabaseTab.test.jsx@@ -44,6 +44,7 @@ vi.mock('../../lib/safeStorage', () => ({import {getDatabaseStatus, getDatabaseMaintenanceStatus, cutoverDatabase, recoverDatabaseCutover,+ destroyDatabase,} from '../../services/api';import toast from '../ui/Toast';import { safeReadJsonSession } from '../../lib/safeStorage';@@ -154,6 +155,48 @@ describe('DatabaseTab sync and replacement', () => {expect(screen.getByRole('button', { name: /Delete Docker database/i })).toBeTruthy();});+ it('offers Native deletion only while configured Native is running and explains its scope', async () => {+ const nativeRunningStatus = {+ ...dbStatus,+ docker: { containerRunning: true, installed: true, daemonRunning: true },+ native: { configured: true, installed: true, running: true },+ mode: 'docker',+ };+ getDatabaseStatus.mockResolvedValue(nativeRunningStatus);+ destroyDatabase.mockResolvedValue({ success: true });+ render(<DatabaseTab />);+ await waitFor(() => expect(getDatabaseStatus).toHaveBeenCalled());++ fireEvent.click(await screen.findByRole('button', { name: 'Delete Native database…' }));+ expect(screen.getByText('Delete the inactive Native database?')).toBeTruthy();+ expect(screen.getByText(/permanently deletes its tables and records/i)).toBeTruthy();+ expect(screen.getByText(/System PostgreSQL and other databases are kept/i)).toBeTruthy();+ expect(screen.getByText(/active Docker database is unchanged/i)).toBeTruthy();++ fireEvent.click(screen.getByRole('button', { name: /Cancel/i }));+ expect(destroyDatabase).not.toHaveBeenCalled();++ fireEvent.click(await screen.findByRole('button', { name: 'Delete Native database…' }));+ fireEvent.click(screen.getByRole('button', { name: 'Delete Native database' }));+ await waitFor(() => expect(destroyDatabase).toHaveBeenCalledWith('native'));+ });++ it('does not offer Native deletion when it is active, stopped, or unconfigured', async () => {+ const statuses = [+ { ...dbStatus, mode: 'native', native: { configured: true, installed: true, running: true } },+ { ...dbStatus, mode: 'docker', native: { configured: true, installed: true, running: false } },+ { ...dbStatus, mode: 'docker', native: { configured: false, installed: false, running: false } },+ ];++ for (const status of statuses) {+ getDatabaseStatus.mockResolvedValueOnce(status);+ const { unmount } = render(<DatabaseTab />);+ await waitFor(() => expect(getDatabaseStatus).toHaveBeenCalled());+ expect(screen.queryByRole('button', { name: /Delete Native database/i })).toBeNull();+ unmount();+ }+ });+it('cancel button does not make any request and closes dialog', async () => {const nativeRunningStatus = {...dbStatus,