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: resolve and open Xcode projects server-side instead of guessing the filename (#3438)
[._.]/ Adam Eivy75ba3c9b1302
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 447ff87e62..2bc6f565c0 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -55,3 +55,4 @@- **Quota-burn agents run as TUI, so a burn can be watched and steered.** A burn runs unattended for minutes on the user's own subscription, and the family's provider was picked with a plain `find` over the enabled CLI/TUI providers — which returns the CLI, because that is what sorts first. Every dispatch therefore went to a headless run that could only be read after it finished. The picker now prefers the TUI (the same preference `pickScrapeProvider` applies when reading `/usage`), so the agent shows up in Active Agents with a live terminal. Two selection bugs came out with it: the whole **`agy` family was unreachable** — its providers ship as `antigravity-cli`/`antigravity-tui`, neither of which contains "agy", so a configured Antigravity plan reported "no enabled CLI/TUI provider" forever while the quota card above it showed a healthy window (the card's matcher checks the *command*; the burn picker only checked the id, and now checks both) — and an **ollama-backed wrapper was eligible**: `claude-ollama-tui` matches the claude family and is a TUI, but it runs a local model, so burning through it spends nothing and lets the window it was meant to drain expire unused. `resolveEnabledFamilies` already excludes those from the quota cards for the same reason; the burn picker now excludes them too, explicit pin included.- **A provider's reset time is an instant, not the wording its CLI happened to use.** Two of the four quota adapters put a raw panel string on the wire — claude's `Aug 4 at 1:59pm` plus a separate `timezone` field, grok's year-less `August 10, 06:07` — so the Usage page printed those two verbatim while codex and agy rendered properly: the same field, formatted two ways on one screen, with no localization and no relative time. The parsing stays in `server/lib/quotaReset.js` but is now exported as `parseHumanReset(str, { now, timezone })` and called from `parseLimitLine` and `parseGrokUsage`, so `resetsAt` is ISO 8601 (or `null` when unreadable) for all four families and a fifth provider's dialect belongs in its own adapter rather than in the shared choke point. Both parsers take `now` explicitly, as `parseAgyUsage` already did. `normalizeResetAt` keeps its wall-clock fallback — a reading off an older federated peer still carries the raw string and must not regress to "no window states a reset time" — but every in-tree adapter now hits its `hasExplicitZone` fast path. The Usage page localizes the instant and adds the countdown (`Aug 4, 1:59 PM (in 3h)`). (#3433)- **Unarchiving your last archived app no longer strands you on a blank Apps page.** The Active/Archived toggle only rendered while at least one archived app existed, and `showArchived` was local state with nothing to reset it — so unarchiving the last one unmounted the only control on screen and left a permanently empty "No archived apps" card, recoverable only by navigating away and back. The filter now lives in the URL (`/apps?view=archived`), so the archived list is linkable and reload-safe; the toggle stays mounted while the archived view is open even once it empties (reading `Active (N)`), and the empty state gained a "Back to active apps" button. (#3434)+- **"Open in Xcode" opens the actual project instead of guessing its filename.** The button built `<display name>.xcodeproj` on the client and navigated to an `xcode://` URL, so any app whose display name wasn't byte-identical to its project on disk ("My Client" → `MyClient.xcodeproj`) got a path that doesn't exist — and a custom-scheme navigation reports nothing either way, so the click was a silent no-op, doubly so from a phone where the scheme isn't registered at all. The new `POST /api/apps/:id/open-xcode` resolves the real target the same way the Xcode script generators do (`deriveProjectInfo`: `project.yml` `name:` → the `*.xcodeproj` on disk → the sanitized app name), prefers a `.xcworkspace` over the `.xcodeproj` it wraps, and opens it on the machine Xcode is installed on. A repo with no Xcode project comes back as a 404 naming what it looked for, so the click always ends in a visible toast. (#3438)diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsxindex 54acd19c08..71d8ea7d5d 100644--- a/client/src/pages/Apps.jsx+++ b/client/src/pages/Apps.jsx@@ -632,10 +632,9 @@ export default function Apps() {{/* Xcode-specific actions */}{isNonPm2 && (<button- onClick={() => {- const xcodeprojName = app.name + '.xcodeproj';- window.open(`xcode://open?url=file://${app.repoPath}/${xcodeprojName}`, '_self');- }}+ onClick={() => api.openAppInXcode(app.id)+ .then(result => { if (result?.success) toast.success(`Opening ${app.name} in Xcode`); })+ .catch(() => null)}className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded-lg text-xs flex items-center gap-1"aria-label={`Open ${app.name} in Xcode`}>diff --git a/client/src/pages/Apps.test.jsx b/client/src/pages/Apps.test.jsxindex fdf37f2835..814622e8cd 100644--- a/client/src/pages/Apps.test.jsx+++ b/client/src/pages/Apps.test.jsx@@ -31,6 +31,7 @@ vi.mock('../services/api', () => ({getMySprintTickets: vi.fn(() => Promise.resolve([])),openAppInEditor: vi.fn(() => Promise.resolve({})),openAppFolder: vi.fn(() => Promise.resolve({})),+ openAppInXcode: vi.fn(() => Promise.resolve({ success: true, path: '/srv/example-ios/ExampleIos.xcodeproj' })),handleSelfRestart: vi.fn(),}));@@ -129,6 +130,28 @@ describe('Apps row action hierarchy', () => {await waitFor(() => expect(api.archiveApp).toHaveBeenCalledWith('app-alpha'));});+ it('asks the server to resolve and open the Xcode project instead of guessing the filename', async () => {+ // Display name deliberately differs from the on-disk project name — the old+ // client-side `<name>.xcodeproj` guess was a silent no-op for exactly this app.+ api.getApps.mockResolvedValue([{+ ...APPS[0],+ id: 'app-ios',+ name: 'Example iOS App',+ type: 'ios-native',+ repoPath: '/srv/example-ios',+ pm2ProcessNames: [],+ processes: [],+ }]);+ const user = userEvent.setup();+ render(<MemoryRouter><Apps /></MemoryRouter>);+ await screen.findByRole('link', { name: 'Example iOS App' });++ await user.click(screen.getByRole('button', { name: 'Expand Example iOS App details' }));+ await user.click(screen.getByRole('button', { name: 'Open Example iOS App in Xcode' }));++ await waitFor(() => expect(api.openAppInXcode).toHaveBeenCalledWith('app-ios'));+ });+it('withholds the overflow menu for the PortOS baseline app', async () => {api.getApps.mockResolvedValue([{ ...APPS[0], id: 'portos-default', name: 'PortOS' }]);render(<MemoryRouter><Apps /></MemoryRouter>);diff --git a/client/src/services/README.md b/client/src/services/README.mdindex 35b0ec132d..ee0c4a0196 100644--- a/client/src/services/README.md+++ b/client/src/services/README.md@@ -36,7 +36,7 @@ toasts on throw). **Custom catch ⇒ `silent: true`** — otherwise toasts fire| File | Purpose ||---|---|-| `apiApps.js` | App CRUD + PM2 ops (start/stop/restart/logs). |+| `apiApps.js` | App CRUD + PM2 ops (start/stop/restart/logs) + local open actions (editor, Claude Code, folder, Xcode). || `apiWorkspaceContexts.js` | Per-project working-context save/restore (branch, shells, tasks). || `apiAccounts.js` | Platform accounts. || `apiAgents.js` | Running-agent process management. |diff --git a/client/src/services/apiApps.js b/client/src/services/apiApps.jsindex 198c0e1051..98e2b0c964 100644--- a/client/src/services/apiApps.js+++ b/client/src/services/apiApps.js@@ -92,6 +92,10 @@ export const unarchiveApp = (id) => request(`/apps/${id}/unarchive`, { method: 'export const openAppInEditor = (id) => request(`/apps/${id}/open-editor`, { method: 'POST' });export const openAppInClaude = (id) => request(`/apps/${id}/open-claude`, { method: 'POST' });export const openAppFolder = (id) => request(`/apps/${id}/open-folder`, { method: 'POST' });+// The server resolves the real .xcworkspace/.xcodeproj name and opens it on the+// machine Xcode runs on — so this works from a phone, and a missing project+// comes back as a real error instead of a silent `xcode://` no-op.+export const openAppInXcode = (id) => request(`/apps/${id}/open-xcode`, { method: 'POST' });export const refreshAppConfig = (id) => request(`/apps/${id}/refresh-config`, { method: 'POST' });export const pullAndUpdateApp = (id) => request(`/apps/${id}/update`, { method: 'POST' });// `options` lets a caller suppress request()'s auto-toast with `{ silent: true }`diff --git a/server/routes/apps/index.js b/server/routes/apps/index.jsindex 0b6f7a8ba0..338caf9a30 100644--- a/server/routes/apps/index.js+++ b/server/routes/apps/index.js@@ -11,7 +11,7 @@* xcode — xcode-scripts/install* icons — icon serving + detection* taskTypes — per-app task-type overrides, work-tracker, layered-intelligence- * launch — open-editor, open-claude, open-folder+ * launch — open-editor, open-claude, open-folder, open-xcode* documents — planning-doc read/list/commit* agents — recent CoS agent history*diff --git a/server/routes/apps/launch.js b/server/routes/apps/launch.jsindex 99c1675336..1a90fd5d22 100644--- a/server/routes/apps/launch.js+++ b/server/routes/apps/launch.js@@ -1,19 +1,40 @@/**- * Local launch helpers: open the app in an editor, in Claude Code, or in the- * OS file manager. Each spawns a detached child process.+ * Local launch helpers: open the app in an editor, in Claude Code, in Xcode, or+ * in the OS file manager. Each spawns a detached child process.** POST /:id/open-editor → { success, command, path }* POST /:id/open-claude → { success, path }* POST /:id/open-folder → { success, path }+ * POST /:id/open-xcode → { success, path }*/import { Router } from 'express';import { spawn } from 'child_process';+import { join } from 'path';import { asyncHandler, ServerError } from '../../lib/errorHandler.js';+import { deriveProjectInfo } from '../../services/xcodeScripts.js';import { loadApp, pathExists } from './shared.js';const router = Router();+/**+ * Hand a path to the OS's default handler, detached. `open`/`explorer`/`xdg-open`+ * all take the path as their only argument, so folder-opening and+ * project-opening share this one launcher.+ */+function openWithSystemHandler(targetPath) {+ const cmd = process.platform === 'darwin'+ ? 'open'+ : process.platform === 'win32' ? 'explorer' : 'xdg-open';++ const child = spawn(cmd, [targetPath], {+ detached: true,+ stdio: 'ignore',+ windowsHide: true+ });+ child.unref();+}+// Allowlist of safe editor commands// Security: Only allow known-safe editor commands to prevent arbitrary code executionconst ALLOWED_EDITORS = new Set([@@ -118,29 +139,48 @@ router.post('/:id/open-folder', loadApp, asyncHandler(async (req, res) => {throw new ServerError('App path does not exist', { status: 400, code: 'PATH_NOT_FOUND' });}- // Cross-platform folder open command- const platform = process.platform;- let cmd, args;-- if (platform === 'darwin') {- cmd = 'open';- args = [app.repoPath];- } else if (platform === 'win32') {- cmd = 'explorer';- args = [app.repoPath];- } else {- cmd = 'xdg-open';- args = [app.repoPath];+ openWithSystemHandler(app.repoPath);++ res.json({ success: true, path: app.repoPath });+}));++// POST /api/apps/:id/open-xcode - Open the app's Xcode workspace/project+//+// The project filename is resolved server-side (project.yml `name:` → the+// `*.xcodeproj` on disk → the sanitized app name) rather than guessed from the+// display name on the client, and the project is opened on the machine Xcode is+// installed on — so this still works when the click comes from a phone.+router.post('/:id/open-xcode', loadApp, asyncHandler(async (req, res) => {+ const app = req.loadedApp;++ if (!await pathExists(app.repoPath)) {+ throw new ServerError('App path does not exist', { status: 400, code: 'PATH_NOT_FOUND' });+ }++ const { targetName } = await deriveProjectInfo(app.repoPath, app.name);++ // A workspace supersedes the project it wraps (CocoaPods/SPM multi-project+ // setups), so prefer it when both are present.+ let projectPath = null;+ for (const ext of ['.xcworkspace', '.xcodeproj']) {+ const candidate = join(app.repoPath, `${targetName}${ext}`);+ if (await pathExists(candidate)) {+ projectPath = candidate;+ break;+ }}- const child = spawn(cmd, args, {- detached: true,- stdio: 'ignore',- windowsHide: true- });- child.unref();+ if (!projectPath) {+ throw new ServerError(+ `No ${targetName}.xcworkspace or ${targetName}.xcodeproj found in ${app.repoPath}`,+ { status: 404, code: 'XCODE_PROJECT_NOT_FOUND', context: { targetName, repoPath: app.repoPath } }+ );+ }- res.json({ success: true, path: app.repoPath });+ openWithSystemHandler(projectPath);++ console.log(`📱 Opened Xcode project for ${app.name}: ${targetName}`);+ res.json({ success: true, path: projectPath });}));export default router;diff --git a/server/routes/apps/launch.test.js b/server/routes/apps/launch.test.jsnew file mode 100644index 0000000000..5587b51523--- /dev/null+++ b/server/routes/apps/launch.test.js@@ -0,0 +1,119 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import express from 'express';+import { join } from 'path';+import { request } from '../../lib/testHelper.js';+import launchRoutes from './launch.js';++vi.mock('../../services/apps.js', () => ({+ getAppById: vi.fn(),+ PORTOS_APP_ID: 'portos-default'+}));++vi.mock('../../services/xcodeScripts.js', () => ({+ deriveProjectInfo: vi.fn()+}));++// `pathExists` (shared.js) is the only fs/promises consumer this router hits —+// stub `access` so the test controls which candidate paths "exist" on disk.+vi.mock('fs/promises', async (importOriginal) => ({+ ...(await importOriginal()),+ access: vi.fn()+}));++vi.mock('child_process', async (importOriginal) => ({+ ...(await importOriginal()),+ spawn: vi.fn(() => ({ unref: vi.fn() }))+}));++import * as appsService from '../../services/apps.js';+import { deriveProjectInfo } from '../../services/xcodeScripts.js';+import { access } from 'fs/promises';+import { spawn } from 'child_process';++const REPO_PATH = '/example/repos/my-client';++/** Make only the listed paths resolve through `pathExists`. */+const existingPaths = (...paths) => {+ const set = new Set(paths);+ access.mockImplementation(async (p) => {+ if (!set.has(p)) throw Object.assign(new Error('ENOENT'), { code: 'ENOENT' });+ });+};++describe('Apps Launch Routes — POST /:id/open-xcode', () => {+ let app;++ beforeEach(() => {+ app = express();+ app.use(express.json());+ app.use('/api/apps', launchRoutes);+ vi.clearAllMocks();+ appsService.getAppById.mockResolvedValue({+ id: 'app-001',+ name: 'My Client',+ type: 'ios-native',+ repoPath: REPO_PATH+ });+ });++ it('opens the resolved project when the display name differs from the project filename', async () => {+ deriveProjectInfo.mockResolvedValue({ targetName: 'MyClient', bundleId: 'com.example.MyClient' });+ existingPaths(REPO_PATH, join(REPO_PATH, 'MyClient.xcodeproj'));++ const response = await request(app).post('/api/apps/app-001/open-xcode');++ expect(response.status).toBe(200);+ expect(response.body).toMatchObject({ success: true, path: join(REPO_PATH, 'MyClient.xcodeproj') });+ expect(deriveProjectInfo).toHaveBeenCalledWith(REPO_PATH, 'My Client');+ expect(spawn).toHaveBeenCalledWith(+ expect.any(String),+ [join(REPO_PATH, 'MyClient.xcodeproj')],+ expect.objectContaining({ detached: true })+ );+ });++ it('prefers an existing .xcworkspace over the .xcodeproj', async () => {+ deriveProjectInfo.mockResolvedValue({ targetName: 'MyClient', bundleId: 'com.example.MyClient' });+ existingPaths(+ REPO_PATH,+ join(REPO_PATH, 'MyClient.xcworkspace'),+ join(REPO_PATH, 'MyClient.xcodeproj')+ );++ const response = await request(app).post('/api/apps/app-001/open-xcode');++ expect(response.status).toBe(200);+ expect(response.body.path).toBe(join(REPO_PATH, 'MyClient.xcworkspace'));+ });++ it('returns 404 with the resolved target name when no project exists', async () => {+ deriveProjectInfo.mockResolvedValue({ targetName: 'MyClient', bundleId: 'com.example.MyClient' });+ existingPaths(REPO_PATH);++ const response = await request(app).post('/api/apps/app-001/open-xcode');++ expect(response.status).toBe(404);+ expect(response.body.code).toBe('XCODE_PROJECT_NOT_FOUND');+ expect(response.body.error).toContain('MyClient.xcodeproj');+ expect(spawn).not.toHaveBeenCalled();+ });++ it('returns 400 when the repo path is missing', async () => {+ existingPaths();++ const response = await request(app).post('/api/apps/app-001/open-xcode');++ expect(response.status).toBe(400);+ expect(response.body.code).toBe('PATH_NOT_FOUND');+ expect(deriveProjectInfo).not.toHaveBeenCalled();+ });++ it('returns 404 when the app does not exist', async () => {+ appsService.getAppById.mockResolvedValue(null);++ const response = await request(app).post('/api/apps/app-999/open-xcode');++ expect(response.status).toBe(404);+ expect(response.body.code).toBe('NOT_FOUND');+ });+});diff --git a/server/services/xcodeScripts.js b/server/services/xcodeScripts.jsindex 9a3d6db742..17a3887fb7 100644--- a/server/services/xcodeScripts.js+++ b/server/services/xcodeScripts.js@@ -1033,8 +1033,12 @@ export function checkScripts(app) {/*** Derive the target name and bundle ID from an Xcode project at repoPath.* Checks project.yml first, then falls back to .xcodeproj name, then app name.+ *+ * Exported so callers that need the *real* on-disk project name (e.g. the+ * `open-xcode` route) resolve it the same way the script generators do, instead+ * of guessing `<display name>.xcodeproj`.*/-async function deriveProjectInfo(repoPath, appName) {+export async function deriveProjectInfo(repoPath, appName) {if (process.platform === 'win32') {return { targetName: toTargetName(appName), bundleId: toBundleId(appName) };}