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(cos): restore missing spawn import in git.js so agent PRs open
Adam Eivyc8cd0ae958e4
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 236a51e1a9..7e476a1244 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -10,6 +10,8 @@## Fixed+- **CoS agent PRs now actually open.** Every recent CoS-agent automation that finished its work and pushed its branch was failing at the PR-creation step with `Failed to create PR for <branch>: spawn is not defined`, then triggering `[Recovery] Investigate and retry failed PR for branch …` recovery tasks for the orchestrator to clean up. Root cause: a refactor (commit `17311282`) extracted `execGit` to `server/lib/execGit.js` and dropped the `import { spawn } from 'child_process'` line from `server/services/git.js` — but `createPR()` still calls `spawn('gh', …)` directly, so every PR creation hit a `ReferenceError`. The existing `cleanupAgentWorktree` test suite mocked `git.createPR` so the bug never surfaced in CI. Restored the import and added `server/services/git.test.js` with a regression test that calls the real `createPR` against a non-existent path: success path returns `{ success: false, error: '<gh failure>' }` instead of throwing. The recovery flow continues to work as a safety net, but agents will now hit the happy path and open the PR directly. Files: `server/services/git.js`, `server/services/git.test.js` (new).+- **Mobile responsiveness — narrow forms and wide tables no longer break on small screens.** Four spots were squeezing or clipping content under ~640px wide viewports: (1) the Create App form's Port fields used `grid-cols-3` so the three port inputs (UI, Dev UI, API) crammed into ~100px each on a phone — now `grid-cols-1 sm:grid-cols-3` so they stack on mobile and only side-by-side on `sm:` and up; (2) the Body tab's eye-exam history table has eight columns (Date, L SPH/CYL/AXIS, R SPH/CYL/AXIS, actions) and was wrapped in `overflow-hidden` so the rightmost columns were invisible on mobile — now wrapped in `overflow-x-auto` with `min-w-[640px]` on the table so it scrolls horizontally instead of clipping; (3) the Posture session-history table (5 columns) had the same `overflow-hidden` wrapper — now `overflow-x-auto` with `min-w-[520px]`; (4) the Data Manager Backup Archives table (Archive name + Size + Created + delete button) — same fix with `min-w-[480px]`. Files: `client/src/pages/CreateApp.jsx`, `client/src/pages/DataManager.jsx`, `client/src/components/meatspace/tabs/BodyTab.jsx`, `client/src/components/meatspace/post/PostHistory.jsx`.- **Taste summaries render as markdown and appear inline immediately after generation.** The Digital Twin → Taste tab had two regressions in the summary flow: (1) after clicking "Generate Summary" on the section-complete view, the button returned to its enabled state with no visible change — the summary was saved but not rendered until the user navigated away and back into the section's Review view, and (2) every place the summary did show (review-mode AI Summary card, expandable summary on the dashboard grid, "Unified Taste Profile" overall summary) used a `whitespace-pre-wrap` `<div>` so the LLM-generated markdown displayed as raw `### Movies & Film Profile`, `**Core Preferences:**`, `- Item 1` etc. instead of styled headings, bold text, and bullets. Now: the section-complete view shows the freshly-generated summary inline in a violet-bordered card the moment `loadProfile()` returns, and all three summary surfaces use the existing `MarkdownOutput` component (which already powers CoS, autobiography, etc.) so headings/bold/italics/bullets/blockquotes render properly. File: `client/src/components/digital-twin/tabs/TasteTab.jsx`.diff --git a/server/services/git.js b/server/services/git.jsindex 3022fecdb8..4004b4f6e3 100644--- a/server/services/git.js+++ b/server/services/git.js@@ -1,3 +1,4 @@+import { spawn } from 'child_process';import { existsSync } from 'fs';import { join } from 'path';import { safeJSONParse, PATHS } from '../lib/fileUtils.js';diff --git a/server/services/git.test.js b/server/services/git.test.jsnew file mode 100644index 0000000000..aab0178cfd--- /dev/null+++ b/server/services/git.test.js@@ -0,0 +1,58 @@+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';+import { createPR, extractAgentSummary } from './git.js';++describe('createPR', () => {+ beforeEach(() => {+ vi.resetModules();+ });++ afterEach(() => {+ vi.restoreAllMocks();+ });++ // Regression: `spawn` was previously used inside createPR but the+ // `import { spawn } from 'child_process'` line was dropped during a refactor,+ // causing every CoS-agent PR to fail with "spawn is not defined" and falling+ // back to the recovery-task path. The check below ensures a real call into+ // createPR doesn't throw a ReferenceError before completing.+ it('does not throw ReferenceError when spawn is invoked (regression: missing spawn import)', async () => {+ // Use a non-existent cwd; gh will simply fail to launch ("ENOENT") which+ // is the desired failure mode — it must surface as a structured+ // { success: false, error: ... } object, not a thrown ReferenceError.+ const result = await createPR('/nonexistent-path-for-test', {+ title: 'test',+ body: 'test',+ base: 'main',+ head: 'test-branch'+ });++ expect(result).toHaveProperty('success', false);+ expect(typeof result.error).toBe('string');+ // The error must come from gh/spawn behavior, NOT from a missing-import bug.+ expect(result.error).not.toMatch(/spawn is not defined/);+ });+});++describe('extractAgentSummary', () => {+ it('returns null for short output', () => {+ expect(extractAgentSummary(null)).toBeNull();+ expect(extractAgentSummary('')).toBeNull();+ expect(extractAgentSummary('too short')).toBeNull();+ });++ it('extracts trailing summary after last tool-call line', () => {+ const output = [+ 'Investigating the bug.',+ '🔧 Using Read tool',+ ' → /path/to/file.js',+ '',+ 'Implemented the fix by adding the missing null check on line 42.',+ 'All tests pass: 187/187.'+ ].join('\n');++ const summary = extractAgentSummary(output);+ expect(summary).toContain('Implemented the fix');+ expect(summary).toContain('All tests pass');+ expect(summary).not.toContain('🔧');+ });+});