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
address review (codex): avoid refetching deleted app detail
[._.]/ Adam Eivy8a77b6b64a1f
diff --git a/client/src/components/apps/AppDetailView.jsx b/client/src/components/apps/AppDetailView.jsxindex 25509cd440..f482c4d26c 100644--- a/client/src/components/apps/AppDetailView.jsx+++ b/client/src/components/apps/AppDetailView.jsx@@ -85,10 +85,19 @@ export default function AppDetailView() {// Real-time updatesuseEffect(() => {- const handleAppsChanged = () => fetchApp();+ const handleAppsChanged = (change) => {+ // The delete event reaches this mounted detail view before the DELETE+ // response can navigate it away. Avoid refetching the known-deleted app,+ // which would turn the expected 404 into an error toast beside success.+ if (change?.action === 'delete' && change.appId === appId) {+ navigate('/apps');+ return;+ }+ fetchApp();+ };socket.on('apps:changed', handleAppsChanged);return () => socket.off('apps:changed', handleAppsChanged);- }, [fetchApp]);+ }, [appId, fetchApp, navigate]);const handleStart = async () => {setActionLoading('start');diff --git a/client/src/components/apps/AppDetailView.test.jsx b/client/src/components/apps/AppDetailView.test.jsxnew file mode 100644index 0000000000..996e6cd244--- /dev/null+++ b/client/src/components/apps/AppDetailView.test.jsx@@ -0,0 +1,97 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { act, render, screen } from '@testing-library/react';+import { MemoryRouter, Route, Routes, useLocation } from 'react-router';++const socketHandlers = new Map();++vi.mock('../../services/api', () => ({+ PORTOS_APP_ID: 'portos-default',+ getApp: vi.fn(),+}));++vi.mock('../../services/socket', () => ({+ default: {+ on: vi.fn((event, handler) => socketHandlers.set(event, handler)),+ off: vi.fn((event, handler) => {+ if (socketHandlers.get(event) === handler) socketHandlers.delete(event);+ }),+ },+}));++vi.mock('../../services/appUrls', () => ({+ getLaunchUrls: vi.fn(() => ({ https: null, http: null, dev: null })),+}));++vi.mock('../ui/Toast', () => ({+ default: { error: vi.fn(), success: vi.fn(), loading: vi.fn(), dismiss: vi.fn() },+}));+vi.mock('../BrailleSpinner', () => ({ default: () => null }));+vi.mock('../StatusBadge', () => ({ default: () => null }));+vi.mock('./DeployPanel', () => ({ default: () => null }));+vi.mock('./EditAppDrawer', () => ({ default: () => null }));+vi.mock('./DesktopLaunchProgress', () => ({ default: () => null }));+vi.mock('./tabs/OverviewTab', () => ({ default: () => null }));+vi.mock('./tabs/TasksTab', () => ({ default: () => null }));+vi.mock('./tabs/AutomationTab', () => ({ default: () => null }));+vi.mock('./tabs/DocumentsTab', () => ({ default: () => null }));+vi.mock('./tabs/GitTab', () => ({ default: () => null }));+vi.mock('./tabs/GsdTab', () => ({ default: () => null }));+vi.mock('./tabs/IssuesTab', () => ({ default: () => null }));+vi.mock('./tabs/JiraTab', () => ({ default: () => null }));+vi.mock('./tabs/ProcessesTab', () => ({ default: () => null }));+vi.mock('./tabs/ReferencesTab', () => ({ default: () => null }));+vi.mock('./tabs/SubmodulesTab', () => ({ default: () => null }));+vi.mock('./tabs/DatadogTab', () => ({ default: () => null }));+vi.mock('./tabs/UpdateTab', () => ({ default: () => null }));++import * as api from '../../services/api';+import AppDetailView from './AppDetailView';++const APP = {+ id: 'app-1',+ name: 'Example App',+ type: 'static',+ repoPath: '/mock/example-app',+ pm2ProcessNames: [],+ processes: [],+};++function LocationProbe() {+ const { pathname } = useLocation();+ return <output data-testid="location">{pathname}</output>;+}++function renderDetail() {+ return render(+ <MemoryRouter initialEntries={['/apps/app-1/overview']}>+ <LocationProbe />+ <Routes>+ <Route path="/apps/:appId/:tab" element={<AppDetailView />} />+ <Route path="/apps" element={<div>Apps index</div>} />+ </Routes>+ </MemoryRouter>,+ );+}++describe('AppDetailView app-removal socket handling', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ socketHandlers.clear();+ api.getApp.mockResolvedValue(APP);+ });++ it('navigates away without refetching a detail record known to be deleted', async () => {+ renderDetail();++ await screen.findByRole('heading', { name: 'Example App' });+ const handleAppsChanged = socketHandlers.get('apps:changed');+ expect(handleAppsChanged).toBeTypeOf('function');++ await act(async () => {+ handleAppsChanged({ action: 'delete', appId: 'app-1' });+ });++ expect(screen.getByTestId('location')).toHaveTextContent('/apps');+ expect(api.getApp).toHaveBeenCalledTimes(1);+ });+});diff --git a/server/routes/apps/crud.js b/server/routes/apps/crud.jsindex 15e9dce8f6..3b05684c26 100644--- a/server/routes/apps/crud.js+++ b/server/routes/apps/crud.js@@ -183,7 +183,7 @@ router.delete('/:id', asyncHandler(async (req, res, next) => {// Keep the dashboard, sidebar, OpenWorld, and any open detail view in sync// with the registry removal. This only removes PortOS's association; the// app's repository is not touched by appsService.deleteApp().- notifyAppsChanged('delete');+ notifyAppsChanged('delete', req.params.id);res.status(204).send();}));diff --git a/server/routes/apps/crud.test.js b/server/routes/apps/crud.test.jsindex a0dc063fe2..046840dc8c 100644--- a/server/routes/apps/crud.test.js+++ b/server/routes/apps/crud.test.js@@ -487,7 +487,7 @@ describe('Apps CRUD Routes', () => {expect(response.status).toBe(204);expect(appsService.deleteApp).toHaveBeenCalledWith('app-001');- expect(appsService.notifyAppsChanged).toHaveBeenCalledWith('delete');+ expect(appsService.notifyAppsChanged).toHaveBeenCalledWith('delete', 'app-001');});it('should return 404 if app not found', async () => {diff --git a/server/services/apps.js b/server/services/apps.jsindex 2a31f7e658..aca5c12d7d 100644--- a/server/services/apps.js+++ b/server/services/apps.js@@ -158,8 +158,12 @@ export function invalidateCache() {* Notify clients that apps data has changed* Call this after any operation that modifies app state*/-export function notifyAppsChanged(action = 'update') {- appsEvents.emit('changed', { action, timestamp: Date.now() });+export function notifyAppsChanged(action = 'update', appId) {+ appsEvents.emit('changed', {+ action,+ ...(appId ? { appId } : {}),+ timestamp: Date.now()+ });}/**