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: ensure PortOS baseline app is always present and undeletable

Adam Eivyd5c84181e913
diff --git a/.changelog/v1.1.x.md b/.changelog/v1.1.x.md
index 843e8b57a0..914d276afb 100644
--- a/.changelog/v1.1.x.md
+++ b/.changelog/v1.1.x.md
@@ -8,6 +8,11 @@ Configurable embedding provider for the memory system, plus HealthTab layout imp
## Features
+### PortOS baseline app always present
+- On fresh installs (or empty `data/apps.json`), PortOS is auto-seeded as a managed app with stable ID `portos-default`
+- PortOS cannot be deleted or archived — server returns 403, UI hides delete/archive buttons
+- Ensures dashboard and app list always show at least PortOS
+
### Configurable embedding provider/model
- Memory embedding system now reads provider from CoS config instead of hardcoding `lmstudio`
- When embedding service is unavailable, MemoryTab shows inline provider/model selector with "Save & Retry"
diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsx
index 96267c3f58..d1687637e2 100644
--- a/client/src/pages/Apps.jsx
+++ b/client/src/pages/Apps.jsx
@@ -399,20 +399,22 @@ export default function Apps() {
</div>
) : (
<div className="flex items-center gap-2">
- {/* Archive/Unarchive button */}
- <button
- onClick={() => app.archived ? handleUnarchive(app) : handleArchive(app)}
- disabled={archiving[app.id]}
- className={`px-3 py-1.5 rounded-lg text-xs flex items-center gap-1 transition-colors disabled:opacity-50 border ${
- app.archived
- ? 'bg-port-success/20 text-port-success border-port-success/30 hover:bg-port-success/30'
- : 'bg-port-border text-gray-400 border-port-border hover:text-white hover:bg-port-border/80'
- }`}
- aria-label={app.archived ? `Unarchive ${app.name}` : `Archive ${app.name}`}
- >
- {app.archived ? <ArchiveRestore size={14} /> : <Archive size={14} />}
- {archiving[app.id] ? '...' : app.archived ? 'Unarchive' : 'Archive'}
- </button>
+ {/* Archive/Unarchive button (hidden for PortOS baseline) */}
+ {app.id !== 'portos-default' && (
+ <button
+ onClick={() => app.archived ? handleUnarchive(app) : handleArchive(app)}
+ disabled={archiving[app.id]}
+ className={`px-3 py-1.5 rounded-lg text-xs flex items-center gap-1 transition-colors disabled:opacity-50 border ${
+ app.archived
+ ? 'bg-port-success/20 text-port-success border-port-success/30 hover:bg-port-success/30'
+ : 'bg-port-border text-gray-400 border-port-border hover:text-white hover:bg-port-border/80'
+ }`}
+ aria-label={app.archived ? `Unarchive ${app.name}` : `Archive ${app.name}`}
+ >
+ {app.archived ? <ArchiveRestore size={14} /> : <Archive size={14} />}
+ {archiving[app.id] ? '...' : app.archived ? 'Unarchive' : 'Archive'}
+ </button>
+ )}
<div className="inline-flex rounded-lg overflow-hidden border border-port-border">
<button
onClick={() => setEditingApp(app)}
@@ -421,13 +423,15 @@ export default function Apps() {
>
Edit
</button>
- <button
- onClick={() => setConfirmingDelete(app.id)}
- className="px-3 py-1.5 bg-port-error/10 text-port-error hover:bg-port-error/20 transition-colors text-xs border-l border-port-border focus:outline-none focus:ring-2 focus:ring-port-error"
- aria-label={`Delete ${app.name}`}
- >
- Delete
- </button>
+ {app.id !== 'portos-default' && (
+ <button
+ onClick={() => setConfirmingDelete(app.id)}
+ className="px-3 py-1.5 bg-port-error/10 text-port-error hover:bg-port-error/20 transition-colors text-xs border-l border-port-border focus:outline-none focus:ring-2 focus:ring-port-error"
+ aria-label={`Delete ${app.name}`}
+ >
+ Delete
+ </button>
+ )}
</div>
</div>
)}
diff --git a/package-lock.json b/package-lock.json
index 300b44b9bd..d0c11c549a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "1.1.1",
+ "version": "1.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "1.1.1",
+ "version": "1.2.0",
"license": "MIT",
"workspaces": [
"packages/*",
diff --git a/package.json b/package.json
index b4252ec03b..24c066d6ce 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "1.1.1",
+ "version": "1.2.0",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
diff --git a/server/routes/apps.js b/server/routes/apps.js
index c85395ed0b..b84b6d96a9 100644
--- a/server/routes/apps.js
+++ b/server/routes/apps.js
@@ -2,7 +2,7 @@ import { Router } from 'express';
import { spawn } from 'child_process';
import { existsSync } from 'fs';
import * as appsService from '../services/apps.js';
-import { notifyAppsChanged } from '../services/apps.js';
+import { notifyAppsChanged, PORTOS_APP_ID } from '../services/apps.js';
import * as pm2Service from '../services/pm2.js';
import { logAction } from '../services/history.js';
import { validateRequest, appSchema, appUpdateSchema } from '../lib/validation.js';
@@ -118,8 +118,12 @@ router.put('/:id', asyncHandler(async (req, res, next) => {
res.json(app);
}));
-// DELETE /api/apps/:id - Delete app
+// DELETE /api/apps/:id - Delete app (PortOS baseline cannot be deleted)
router.delete('/:id', asyncHandler(async (req, res, next) => {
+ if (req.params.id === PORTOS_APP_ID) {
+ throw new ServerError('PortOS baseline app cannot be deleted', { status: 403, code: 'PROTECTED' });
+ }
+
const deleted = await appsService.deleteApp(req.params.id);
if (!deleted) {
@@ -131,6 +135,10 @@ router.delete('/:id', asyncHandler(async (req, res, next) => {
// POST /api/apps/:id/archive - Archive app (exclude from COS tasks)
router.post('/:id/archive', asyncHandler(async (req, res) => {
+ if (req.params.id === PORTOS_APP_ID) {
+ throw new ServerError('PortOS baseline app cannot be archived', { status: 403, code: 'PROTECTED' });
+ }
+
const app = await appsService.archiveApp(req.params.id);
if (!app) {
diff --git a/server/routes/apps.test.js b/server/routes/apps.test.js
index ae600b0855..2268e5efed 100644
--- a/server/routes/apps.test.js
+++ b/server/routes/apps.test.js
@@ -10,7 +10,9 @@ vi.mock('../services/apps.js', () => ({
createApp: vi.fn(),
updateApp: vi.fn(),
deleteApp: vi.fn(),
- notifyAppsChanged: vi.fn()
+ archiveApp: vi.fn(),
+ notifyAppsChanged: vi.fn(),
+ PORTOS_APP_ID: 'portos-default'
}));
vi.mock('../services/pm2.js', () => ({
@@ -188,6 +190,22 @@ describe('Apps Routes', () => {
expect(response.status).toBe(404);
});
+
+ it('should return 403 when deleting PortOS baseline app', async () => {
+ const response = await request(app).delete('/api/apps/portos-default');
+
+ expect(response.status).toBe(403);
+ expect(appsService.deleteApp).not.toHaveBeenCalled();
+ });
+ });
+
+ describe('POST /api/apps/:id/archive', () => {
+ it('should return 403 when archiving PortOS baseline app', async () => {
+ const response = await request(app).post('/api/apps/portos-default/archive');
+
+ expect(response.status).toBe(403);
+ expect(appsService.archiveApp).not.toHaveBeenCalled();
+ });
});
describe('POST /api/apps/:id/start', () => {
diff --git a/server/services/apps.js b/server/services/apps.js
index 49981a5698..18a795092a 100644
--- a/server/services/apps.js
+++ b/server/services/apps.js
@@ -7,6 +7,46 @@ import { ensureDir, readJSONFile, PATHS } from '../lib/fileUtils.js';
const DATA_DIR = PATHS.data;
const APPS_FILE = join(DATA_DIR, 'apps.json');
+// Stable ID for the PortOS app — always present, never deletable
+export const PORTOS_APP_ID = 'portos-default';
+
+/**
+ * Build the baseline PortOS app entry with repoPath resolved to the actual project root.
+ */
+function buildPortosApp() {
+ return {
+ name: 'PortOS',
+ description: 'Local App OS portal for dev machines',
+ repoPath: PATHS.root,
+ type: 'express',
+ uiPort: 5555,
+ apiPort: 5554,
+ startCommands: ['npm run dev'],
+ pm2ProcessNames: [
+ 'portos-server',
+ 'portos-cos',
+ 'portos-ui',
+ 'portos-autofixer',
+ 'portos-autofixer-ui',
+ 'portos-browser'
+ ],
+ processes: [
+ { name: 'portos-server', port: 5554, ports: { api: 5554 } },
+ { name: 'portos-cos', port: 5558, ports: { api: 5558 } },
+ { name: 'portos-ui', port: 5555, ports: { ui: 5555 } },
+ { name: 'portos-autofixer', port: 5559, ports: { api: 5559 } },
+ { name: 'portos-autofixer-ui', port: 5560, ports: { ui: 5560 } },
+ { name: 'portos-browser', port: 5556, ports: { cdp: 5556, health: 5557 } }
+ ],
+ envFile: '.env',
+ icon: 'portos',
+ editorCommand: 'code .',
+ archived: false,
+ createdAt: '2024-01-01T00:00:00.000Z',
+ updatedAt: '2024-01-01T00:00:00.000Z'
+ };
+}
+
// Event emitter for apps changes
export const appsEvents = new EventEmitter();
@@ -23,7 +63,8 @@ async function ensureDataDir() {
}
/**
- * Load apps registry from disk (with caching)
+ * Load apps registry from disk (with caching).
+ * Ensures the PortOS baseline app always exists.
*/
async function loadApps() {
const now = Date.now();
@@ -35,7 +76,16 @@ async function loadApps() {
await ensureDataDir();
- appsCache = await readJSONFile(APPS_FILE, { apps: {} });
+ const data = await readJSONFile(APPS_FILE, { apps: {} });
+
+ // Ensure PortOS baseline app is always present
+ if (!data.apps[PORTOS_APP_ID]) {
+ data.apps[PORTOS_APP_ID] = buildPortosApp();
+ await writeFile(APPS_FILE, JSON.stringify(data, null, 2));
+ console.log('📦 Seeded baseline PortOS app into apps registry');
+ }
+
+ appsCache = data;
cacheTimestamp = now;
return appsCache;
}
@@ -161,9 +211,11 @@ export async function updateApp(id, updates) {
}
/**
- * Delete an app
+ * Delete an app (PortOS baseline app cannot be deleted)
*/
export async function deleteApp(id) {
+ if (id === PORTOS_APP_ID) return false;
+
const data = await loadApps();
if (!data.apps[id]) {
@@ -177,9 +229,11 @@ export async function deleteApp(id) {
}
/**
- * Archive an app (soft-delete that excludes from COS tasks)
+ * Archive an app (soft-delete that excludes from COS tasks).
+ * PortOS baseline app cannot be archived.
*/
export async function archiveApp(id) {
+ if (id === PORTOS_APP_ID) return null;
return updateApp(id, { archived: true });
}