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: add lean app list projections (#7043)
[._.]/ Adam Eivy55655c89511e
diff --git a/client/src/components/Layout.test.jsx b/client/src/components/Layout.test.jsxindex 5f2f3215eb..3d150a4444 100644--- a/client/src/components/Layout.test.jsx+++ b/client/src/components/Layout.test.jsx@@ -120,6 +120,12 @@ const renderLayout = async (initialPath = '/brain/inbox') => {const pinnedSection = () => screen.queryByTestId('pinned-section');describe('Layout — manifest-derived sidebar structure', () => {+ it('loads sidebar apps through the lean navigation projection', async () => {+ await renderLayout();++ expect(api.getApps).toHaveBeenCalledWith({ silent: true, view: 'nav' });+ });+it('keeps NAV_PRESENTATION presentation-only and keyed to live manifest paths', () => {const manifestPaths = new Set(NAV_COMMANDS.map((command) => command.path));expect(Object.keys(NAV_PRESENTATION).filter((path) => !manifestPaths.has(path))).toEqual([]);diff --git a/client/src/components/sprites/PublishWorkflow.jsx b/client/src/components/sprites/PublishWorkflow.jsxindex 2e87b0ddde..5790e63bca 100644--- a/client/src/components/sprites/PublishWorkflow.jsx+++ b/client/src/components/sprites/PublishWorkflow.jsx@@ -86,7 +86,9 @@ export default function PublishWorkflow({const seedCell = savedContract?.cellSize != null ? String(savedContract.cellSize) : '';const seedCols = savedContract?.columnCount != null ? String(savedContract.columnCount) : '';- const apps = useSidebarApps();+ // This picker shows each app's repository path, so retain the full list+ // contract while the Layout/sidebar callers use the lean nav projection.+ const apps = useSidebarApps({ includeDetails: true });const [appId, setAppId] = useState(saved?.appId || '');const [destPath, setDestPath] = useState(saved?.atlasDestPath || '');const [portraitPath, setPortraitPath] = useState(saved?.portraitDestPath || '');diff --git a/client/src/hooks/useSidebarApps.js b/client/src/hooks/useSidebarApps.jsindex d3c1faf04b..995ac78e89 100644--- a/client/src/hooks/useSidebarApps.js+++ b/client/src/hooks/useSidebarApps.js@@ -6,12 +6,15 @@ import socket from '../services/socket';// `apps:changed`. Archived apps are filtered out and the rest sorted by name.// Unlike the series/universes lists this is socket-driven (not focus-debounced)// because app create/rename/archive events are pushed live.-export function useSidebarApps() {+// The default is the cheap navigation projection. A detail-oriented consumer+// can opt into the frozen full list with includeDetails without changing the+// hook's socket refresh behavior.+export function useSidebarApps({ includeDetails = false } = {}) {const [apps, setApps] = useState([]);useEffect(() => {let cancelled = false;const fetchApps = () => {- api.getApps({ silent: true })+ api.getApps({ silent: true, ...(includeDetails ? {} : { view: 'nav' }) }).then((result) => {if (cancelled) return;setApps((result || [])@@ -28,6 +31,6 @@ export function useSidebarApps() {cancelled = true;socket.off('apps:changed', fetchApps);};- }, []);+ }, [includeDetails]);return apps;}diff --git a/client/src/services/apiApps.js b/client/src/services/apiApps.jsindex fcd6a8acfd..254b948816 100644--- a/client/src/services/apiApps.js+++ b/client/src/services/apiApps.js@@ -1,8 +1,15 @@import toast from '../components/ui/Toast';import { request, API_BASE } from './apiCore.js';-// Apps-export const getApps = ({ includeQuality = false, ...options } = {}) => request(includeQuality ? '/apps?includeQuality=true' : '/apps', options);+// Apps. The default response remains the PM2-enriched list; `view=nav` and+// `view=probe` are explicit projections for hot name-only and peer callers.+export const getApps = ({ includeQuality = false, view, ...options } = {}) => {+ const query = new URLSearchParams();+ if (includeQuality) query.set('includeQuality', 'true');+ if (view) query.set('view', view);+ const suffix = query.toString() ? `?${query}` : '';+ return request(`/apps${suffix}`, options);+};export const getApp = (id, { includeQuality = false, ...options } = {}) => request(includeQuality ? `/apps/${id}?includeQuality=true` : `/apps/${id}`, options);export const getAppQualityHistory = (id, days, options) => request(`/apps/${id}/quality-history?days=${days}`, { silent: true, ...options });// Managed checkout topology: returns sanitized local/fork/upstream revisiondiff --git a/client/src/services/apiApps.test.js b/client/src/services/apiApps.test.jsindex a5e1b71417..a39379dd83 100644--- a/client/src/services/apiApps.test.js+++ b/client/src/services/apiApps.test.js@@ -63,8 +63,9 @@ it('requests quality only for opted-in views and preserves caller request optionawait getApp('portos-default');await getApps({ includeQuality: true, signal });await getApp('portos-default', { includeQuality: true, signal });+ await getApps({ view: 'nav' });expect(fetch.mock.calls.map(([url]) => url)).toEqual([- '/api/apps', '/api/apps/portos-default', '/api/apps?includeQuality=true', '/api/apps/portos-default?includeQuality=true',+ '/api/apps', '/api/apps/portos-default', '/api/apps?includeQuality=true', '/api/apps/portos-default?includeQuality=true', '/api/apps?view=nav',]);expect(fetch.mock.calls[2][1]).toMatchObject({ signal });expect(fetch.mock.calls[2][1]).not.toHaveProperty('includeQuality');diff --git a/server/lib/auditQuality.js b/server/lib/auditQuality.jsindex c796578f58..fb5c3d403f 100644--- a/server/lib/auditQuality.js+++ b/server/lib/auditQuality.js@@ -51,6 +51,14 @@ Allowed coverage: broad, partial, unavailable, not-applicable. Allowed confidencexport const appQualityQuerySchema = z.object({ includeQuality: z.enum(['true', 'false']).optional() });+// The list endpoint has two intentionally narrow projections in addition to+// its frozen default response: the sidebar/navigation shape and the PM2-backed+// peer-probe shape. Keep the detail endpoint on appQualityQuerySchema so a+// view flag cannot silently change its response contract.+export const appListQuerySchema = appQualityQuerySchema.extend({+ view: z.enum(['nav', 'probe']).optional(),+});+export const auditQualityReportSchema = z.object({version: z.literal(1),category: z.string().refine(value => Object.hasOwn(AUDIT_DEFINITIONS, value)),diff --git a/server/routes/apps/crud.js b/server/routes/apps/crud.jsindex aad03ed216..e78c2d211f 100644--- a/server/routes/apps/crud.js+++ b/server/routes/apps/crud.js@@ -1,4 +1,4 @@-import { appQualityQuerySchema, appQualityHistoryQuerySchema, appQualityFederationQuerySchema } from '../../lib/auditQuality.js';+import { appListQuerySchema, appQualityQuerySchema, appQualityHistoryQuerySchema, appQualityFederationQuerySchema } from '../../lib/auditQuality.js';import { exportPortosQuality } from '../../services/appQualityFederation.js';import { enrichAppsWithQuality, getAppQualityHistory } from '../../services/appQuality.js';/**@@ -39,11 +39,25 @@ router.get('/quality-federation', asyncHandler(async (req, res) => {res.json(payload);}));-// GET /api/apps - List all apps. The route fetches the raw records; the-// appListEnrichment service owns the PM2 status/port/process enrichment.+// GET /api/apps - List all apps. The bare response is the frozen PM2-enriched+// peer-probe contract. `view=nav` is the cheap sidebar projection; `view=probe`+// keeps PM2 enrichment but returns only the fields the peer UI consumes.router.get('/', asyncHandler(async (req, res) => {- const { includeQuality } = validateRequest(appQualityQuerySchema, req.query);- const apps = await enrichAppsWithPm2Status(await appsService.getAllApps());+ const { includeQuality, view } = validateRequest(appListQuerySchema, req.query);+ const rawApps = await appsService.getAllApps();+ if (view === 'nav') {+ res.json(rawApps.map(({ id, name, icon, archived, type }) => ({ id, name, icon, archived, type })));+ return;+ }++ const apps = await enrichAppsWithPm2Status(rawApps);+ if (view === 'probe') {+ res.json(apps.map(({ id, name, icon, overallStatus, uiPort, apiPort, type }) => ({+ id, name, icon, overallStatus, uiPort, apiPort, type,+ })));+ return;+ }+// The bare list is the frozen peer-probe contract. Local UI opts into// assessment prose explicitly so it never rides automatic federation probes.res.json(includeQuality === 'true' ? await enrichAppsWithQuality(apps) : apps);diff --git a/server/routes/apps/crud.test.js b/server/routes/apps/crud.test.jsindex 3bbb1b1a41..e2e0036c31 100644--- a/server/routes/apps/crud.test.js+++ b/server/routes/apps/crud.test.js@@ -93,6 +93,40 @@ describe('Apps CRUD Routes', () => {expect(response.body[0].overallStatus).toBe('online');});+ it('returns the nav projection without invoking PM2 enrichment', async () => {+ const mockApps = [{+ id: 'app-001', name: 'Test App', icon: 'package', archived: false, type: 'express',+ repoPath: '/tmp/test', pm2ProcessNames: ['test-app'],+ }];+ appsService.getAllApps.mockResolvedValue(mockApps);++ const response = await request(app).get('/api/apps?view=nav');++ expect(response.status).toBe(200);+ expect(response.body).toEqual([{+ id: 'app-001', name: 'Test App', icon: 'package', archived: false, type: 'express',+ }]);+ expect(pm2Service.listProcessesStrict).not.toHaveBeenCalled();+ });++ it('returns the PM2-backed probe projection without the enriched body', async () => {+ appsService.getAllApps.mockResolvedValue([{+ id: 'app-001', name: 'Test App', icon: 'package', type: 'express',+ uiPort: 5555, apiPort: 5551, pm2ProcessNames: ['test-app'], processes: [],+ }]);+ pm2Service.listProcessesStrict.mockResolvedValue([{ name: 'test-app', status: 'online' }]);++ const response = await request(app).get('/api/apps?view=probe');++ expect(response.status).toBe(200);+ expect(response.body).toEqual([{+ id: 'app-001', name: 'Test App', icon: 'package', overallStatus: 'online',+ uiPort: 5555, apiPort: 5551, type: 'express',+ }]);+ expect(pm2Service.listProcessesStrict).toHaveBeenCalledTimes(1);+ expect(response.body[0].pm2Status).toBeUndefined();+ });+it('keeps quality reports off peer probes and returns them only for explicit local UI reads', async () => {appsService.getAllApps.mockResolvedValue([{ id: 'portos-default', name: 'PortOS', type: 'ios-native', repoPath: '/tmp/test' }]);const peer = await request(app).get('/api/apps');@@ -102,6 +136,8 @@ describe('Apps CRUD Routes', () => {expect(local.body[0].quality).toEqual({ score: 75 });const invalid = await request(app).get('/api/apps?includeQuality=anything');expect(invalid.status).toBe(400);+ const invalidView = await request(app).get('/api/apps?view=anything');+ expect(invalidView.status).toBe(400);appsService.getAppById.mockResolvedValue({ id: 'portos-default', name: 'PortOS', type: 'ios-native' });const detail = await request(app).get('/api/apps/portos-default?includeQuality=true');expect(detail.body.quality).toEqual({ score: 75 });diff --git a/server/services/instances.js b/server/services/instances.jsindex 6dec3f6873..927ba7a1aa 100644--- a/server/services/instances.js+++ b/server/services/instances.js@@ -722,7 +722,7 @@ export async function probePeer(peer) {const forPeerQs = typeof ourInstanceId === 'string' && ourInstanceId && ourInstanceId !== UNKNOWN_INSTANCE_ID? `?forPeer=${encodeURIComponent(ourInstanceId)}`: '';- // Fetch health details, apps, sync status, and opted-in media capacity in+ // Fetch health details, the PM2-backed app probe projection, sync status, and opted-in media capacity in// parallel under the same bounded probe budget. The first three paths are// the frozen peer-probe contract documented in docs/API.md: deployed peers// call them across independently upgraded installs, so remove/rename or@@ -731,7 +731,7 @@ export async function probePeer(peer) {// request.const [healthRes, appsRes, syncRes, mediaProviderStatus] = await Promise.all([peerFetch(`${baseUrl}/api/system/health/details`, { signal }, peer),- peerFetch(`${baseUrl}/api/apps`, { signal }, peer).catch(() => null),+ peerFetch(`${baseUrl}/api/apps?view=probe`, { signal }, peer).catch(() => null),peerFetch(`${baseUrl}/api/instances/sync-status${forPeerQs}`, { signal }, peer).catch(() => null),normalizePeerMediaProviderConfig(peer).enabled? probeFederatedMediaProvider(peer, { signal })diff --git a/server/services/instances.test.js b/server/services/instances.test.jsindex 8763131712..9d38d22a0a 100644--- a/server/services/instances.test.js+++ b/server/services/instances.test.js@@ -1149,7 +1149,10 @@ describe('instances.js', () => {readJSONFile.mockResolvedValue({ self: null, peers });const healthData = { instanceId: 'remote-id', version: '1.0.0', hostname: 'remote-host' };- const appsData = [{ id: 'app1', name: 'MyApp', overallStatus: 'running' }];+ const appsData = [{+ id: 'app1', name: 'MyApp', icon: 'package', overallStatus: 'online',+ uiPort: 3000, apiPort: 3001, type: 'express',+ }];fetch.mockResolvedValueOnce({ ok: true, json: () => Promise.resolve(healthData) }) // health@@ -1162,8 +1165,10 @@ describe('instances.js', () => {expect(result.instanceId).toBe('remote-id');expect(result.version).toBe('1.0.0');expect(result.lastSeen).toBeDefined();+ expect(result.lastApps).toEqual(appsData);expect(connectToPeer).toHaveBeenCalledWith(peer);expect(fetch).toHaveBeenCalledTimes(3);+ expect(fetch.mock.calls[1][0]).toBe('http://10.0.0.1:5555/api/apps?view=probe');});it('discovers and persists capacity only for an opted-in media provider peer', async () => {@@ -1193,7 +1198,7 @@ describe('instances.js', () => {if (String(url).endsWith('/api/system/health/details')) {return { ok: true, json: async () => ({ instanceId: 'remote-id', version: '1.0.0' }) };}- if (String(url).endsWith('/api/apps')) return { ok: true, json: async () => [] };+ if (String(url).includes('/api/apps?view=probe')) return { ok: true, json: async () => [] };if (String(url).includes('/api/instances/sync-status')) return { ok: true, json: async () => ({}) };if (String(url).includes('/api/federation/media/v1/status')) {return { ok: true, status: 200, text: async () => JSON.stringify(providerStatus) };