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: address PR review feedback (round 5)

Adam Eivya635ac85b7f1
diff --git a/client/src/components/cos/tabs/ProviderStatusCard.jsx b/client/src/components/cos/tabs/ProviderStatusCard.jsx
index d3adc46a70..61fef2dba3 100644
--- a/client/src/components/cos/tabs/ProviderStatusCard.jsx
+++ b/client/src/components/cos/tabs/ProviderStatusCard.jsx
@@ -95,6 +95,29 @@ export default function ProviderStatusCard() {
);
}
+ // Handle case when statuses failed to load
+ if (!statuses) {
+ return (
+ <div className="bg-port-card border border-port-warning/50 rounded-lg p-4">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-2">
+ <AlertTriangle size={16} className="text-port-warning" />
+ <span className="text-sm text-gray-400">AI Providers</span>
+ </div>
+ <div className="flex items-center gap-2">
+ <span className="text-sm text-port-warning">Unable to load status</span>
+ <button
+ onClick={loadData}
+ className="ml-2 text-gray-500 hover:text-white transition-colors"
+ >
+ <RefreshCw size={12} />
+ </button>
+ </div>
+ </div>
+ </div>
+ );
+ }
+
// All providers healthy - show compact success state
if (unavailableCount === 0) {
return (
diff --git a/client/src/components/cos/tabs/ScheduleTab.jsx b/client/src/components/cos/tabs/ScheduleTab.jsx
index 064c76dfdc..c8f0221773 100644
--- a/client/src/components/cos/tabs/ScheduleTab.jsx
+++ b/client/src/components/cos/tabs/ScheduleTab.jsx
@@ -234,7 +234,7 @@ function TaskTypeRow({ taskType, config, onUpdate, onTrigger, onReset, category,
<select
value={selectedModel}
onChange={(e) => handleModelChange(e.target.value)}
- disabled={updating || (!selectedProviderId && !selectedModel)}
+ disabled={updating}
className="w-full bg-port-card border border-port-border rounded px-3 py-2 text-white text-sm"
>
<option value="">Default model</option>
diff --git a/client/src/pages/Brain.jsx b/client/src/pages/Brain.jsx
index 31d9a0671b..941e21ee88 100644
--- a/client/src/pages/Brain.jsx
+++ b/client/src/pages/Brain.jsx
@@ -2,7 +2,6 @@ import { useState, useEffect, useCallback } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import * as api from '../services/api';
import { Brain as BrainIcon, RefreshCw } from 'lucide-react';
-import toast from 'react-hot-toast';
import {
TABS,
diff --git a/docs/features/soul-system.md b/docs/features/soul-system.md
index 5082aad6c8..a409b9fb91 100644
--- a/docs/features/soul-system.md
+++ b/docs/features/soul-system.md
@@ -31,7 +31,7 @@ LLMs can embody specific personas, but creating comprehensive identity documents
## Directory Structure
```
-data/soul/
+data/digital-twin/
├── meta.json # Document metadata, test history, settings
├── SOUL.md # Core identity
├── Expanded.md # High-fidelity spec
diff --git a/server/cos-runner/index.js b/server/cos-runner/index.js
index 6d386c728b..f8e98e1338 100644
--- a/server/cos-runner/index.js
+++ b/server/cos-runner/index.js
@@ -10,7 +10,7 @@
import express from 'express';
import { spawn } from 'child_process';
-import { join, dirname } from 'path';
+import { join, dirname, basename } from 'path';
import { fileURLToPath } from 'url';
import { writeFile, mkdir, readFile } from 'fs/promises';
import { existsSync } from 'fs';
@@ -38,12 +38,13 @@ const ALLOWED_COMMANDS = new Set([
/**
* Validate that a command is in the allowlist.
- * Extracts the base command name from the full path.
+ * Extracts the base command name from the full path using path.basename for cross-platform support.
*/
function isAllowedCommand(command) {
if (!command || typeof command !== 'string') return false;
// Extract base command name from full path (e.g., /usr/bin/claude -> claude)
- const baseName = command.split('/').pop();
+ // Uses path.basename for correct handling on both Unix and Windows
+ const baseName = basename(command);
return ALLOWED_COMMANDS.has(baseName);
}
@@ -238,7 +239,7 @@ app.post('/spawn', async (req, res) => {
// Use new CLI params if provided, otherwise fallback to legacy Claude defaults
let command, spawnArgs;
- if (cliCommand && cliArgs !== undefined) {
+ if (cliCommand) {
// Validate command against allowlist to prevent arbitrary code execution
if (!isAllowedCommand(cliCommand)) {
return res.status(400).json({
@@ -246,11 +247,13 @@ app.post('/spawn', async (req, res) => {
});
}
command = cliCommand;
+ // Default to empty args if cliArgs not provided
+ const args = cliArgs ?? [];
// Normalize cliArgs to an array
- if (Array.isArray(cliArgs)) {
- spawnArgs = cliArgs;
- } else if (typeof cliArgs === 'string') {
- spawnArgs = [cliArgs];
+ if (Array.isArray(args)) {
+ spawnArgs = args;
+ } else if (typeof args === 'string') {
+ spawnArgs = [args];
} else {
return res.status(400).json({
error: 'Invalid cliArgs: expected an array or string'
diff --git a/server/index.js b/server/index.js
index d9101b4368..64de10d3e0 100644
--- a/server/index.js
+++ b/server/index.js
@@ -4,7 +4,7 @@ import cors from 'cors';
import { createServer } from 'http';
import { Server } from 'socket.io';
import { fileURLToPath } from 'url';
-import { dirname } from 'path';
+import { dirname, join } from 'path';
import healthRoutes from './routes/health.js';
import appsRoutes from './routes/apps.js';
@@ -64,8 +64,8 @@ const io = new Server(httpServer, {
initSocket(io);
// Build absolute paths from __dirname to ensure consistency regardless of cwd
-const DATA_DIR = `${__dirname}/../data`;
-const DATA_SAMPLE_DIR = `${__dirname}/../data.sample`;
+const DATA_DIR = join(__dirname, '..', 'data');
+const DATA_SAMPLE_DIR = join(__dirname, '..', 'data.sample');
// Initialize AI Toolkit with PortOS configuration and hooks
const aiToolkit = createAIToolkit({
@@ -73,8 +73,8 @@ const aiToolkit = createAIToolkit({
providersFile: 'providers.json',
runsDir: 'runs',
promptsDir: 'prompts',
- screenshotsDir: `${DATA_DIR}/screenshots`,
- sampleProvidersFile: `${DATA_SAMPLE_DIR}/providers.json`,
+ screenshotsDir: join(DATA_DIR, 'screenshots'),
+ sampleProvidersFile: join(DATA_SAMPLE_DIR, 'providers.json'),
io,
asyncHandler,
hooks: {
diff --git a/server/lib/fileUtils.js b/server/lib/fileUtils.js
index 9f0d87e92b..3b00aba925 100644
--- a/server/lib/fileUtils.js
+++ b/server/lib/fileUtils.js
@@ -203,7 +203,11 @@ export async function readJSONFile(filePath, defaultValue = null, { allowArray =
export function safeJSONLParse(content, { logErrors = false, context = '' } = {}) {
if (!content || !content.trim()) return [];
- const lines = content.split('\n').filter(line => line.trim());
+ // Split on CRLF or LF to handle both Windows and Unix line endings
+ const lines = content
+ .split(/\r?\n/)
+ .map(line => line.trim())
+ .filter(Boolean);
const results = [];
for (const line of lines) {
diff --git a/server/lib/fileUtils.test.js b/server/lib/fileUtils.test.js
index 6cd84c9308..5e737ee764 100644
--- a/server/lib/fileUtils.test.js
+++ b/server/lib/fileUtils.test.js
@@ -192,6 +192,18 @@ describe('fileUtils', () => {
const result = safeJSONLParse(content);
expect(result).toEqual([{ complete: true }]);
});
+
+ it('should handle CRLF line endings (Windows)', () => {
+ const content = '{"a": 1}\r\n{"b": 2}\r\n{"c": 3}';
+ const result = safeJSONLParse(content);
+ expect(result).toEqual([{ a: 1 }, { b: 2 }, { c: 3 }]);
+ });
+
+ it('should handle mixed LF and CRLF line endings', () => {
+ const content = '{"a": 1}\n{"b": 2}\r\n{"c": 3}';
+ const result = safeJSONLParse(content);
+ expect(result).toEqual([{ a: 1 }, { b: 2 }, { c: 3 }]);
+ });
});
describe('readJSONFile', () => {