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
feat: disable worktree/PR toggles for non-git apps in the task form (#11981)
Adam Eivy6677419b3441
diff --git a/client/src/components/cos/TaskAddForm.test.jsx b/client/src/components/cos/TaskAddForm.test.jsxindex 4403da126e..660f7a9bab 100644--- a/client/src/components/cos/TaskAddForm.test.jsx+++ b/client/src/components/cos/TaskAddForm.test.jsx@@ -256,6 +256,24 @@ describe('TaskAddForm responsive layout', () => {expect(options).not.toHaveClass('grid-cols-2');});+ it('disables worktree and PR with an explanation only for a non-git app', async () => {+ const apps = [+ { id: 'git-app', name: 'Git App', repoPath: 'example.com/git', isGitRepo: true },+ { id: 'plain-app', name: 'Plain App', repoPath: 'example.com/plain', isGitRepo: false },+ ];+ render(<TaskAddForm providers={[]} apps={apps} defaultApp="git-app" onTaskAdded={vi.fn()} />);+ await waitFor(() => expect(worktreeToggle()).toBeChecked());+ expect(worktreeToggle()).toBeEnabled();+ expect(screen.queryByText(/is not a git repository/)).toBeNull();++ fireEvent.change(screen.getByLabelText('Target application'), { target: { value: 'plain-app' } });+ await waitFor(() => expect(worktreeToggle()).toBeDisabled());+ expect(worktreeToggle()).not.toBeChecked();+ expect(openPrToggle()).toBeDisabled();+ expect(openPrToggle()).not.toBeChecked();+ expect(screen.getByText(/Plain App is not a git repository/)).toBeInTheDocument();+ });+it('restores the description draft and clears it after a successful submit', async () => {const user = userEvent.setup();const description = 'Keep this task after an accidental navigation';diff --git a/client/src/components/cos/TaskAddFormView.jsx b/client/src/components/cos/TaskAddFormView.jsxindex 1375f16d8c..77858aca44 100644--- a/client/src/components/cos/TaskAddFormView.jsx+++ b/client/src/components/cos/TaskAddFormView.jsx@@ -408,6 +408,7 @@ function TaskCompletionFields({ form }) {reviewerModelOptions,handlePlanOnlyChange,} = form;+ const notGitRepo = selectedApp?.isGitRepo === false;const reviewDefaults = state.reviewDefaults;const reviewOverrides = state.reviewOverrides;const reviewerCliInstalled = state.reviewerCliInstalled;@@ -472,17 +473,21 @@ function TaskCompletionFields({ form }) {<inputtype="checkbox"checked={state.useWorktree}+ disabled={notGitRepo}onChange={(event) => {setField('useWorktree', event.target.checked);setField('openPR', event.target.checked);}}- className="w-4 h-4 rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent focus:ring-offset-0"+ className="w-4 h-4 rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent focus:ring-offset-0 disabled:opacity-40"/><span className="flex items-center gap-1.5 text-sm text-gray-400" title="Work in an isolated git worktree on a feature branch. If unchecked, commits directly to the default branch."><GitBranch size={14} className="text-emerald-400" />Worktree</span></label>+ {notGitRepo && (+ <p className="basis-full text-xs text-gray-500">{selectedApp.name} is not a git repository — worktree and PR are unavailable. Run <code>git init</code> in its directory (and add a remote if PRs are needed) to enable them.</p>+ )}{!state.useWorktree && (<label htmlFor="task-when-done" className="flex flex-wrap items-center gap-2 py-1 basis-full @sm:basis-auto"><span className="text-sm text-gray-400">When done</span>@@ -496,7 +501,7 @@ function TaskCompletionFields({ form }) {<inputtype="checkbox"checked={state.openPR}- disabled={!state.useWorktree}+ disabled={!state.useWorktree || notGitRepo}onChange={(event) => setField('openPR', event.target.checked)}className="w-4 h-4 rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent focus:ring-offset-0 disabled:opacity-40"/>diff --git a/client/src/hooks/useTaskAddForm.js b/client/src/hooks/useTaskAddForm.jsindex 45a296db6c..fe3ee1c8f9 100644--- a/client/src/hooks/useTaskAddForm.js+++ b/client/src/hooks/useTaskAddForm.js@@ -95,6 +95,7 @@ const soleSelectableModel = (provider, selectedModel = '') => {};const runShapeDefaultsPatch = (selectedApp) => {+ if (selectedApp?.isGitRepo === false) return { useWorktree: false, openPR: false, prCompletion: DEFAULT_PR_COMPLETION };const worktreeOptOut = selectedApp?.defaultUseWorktree === false;const defaultOpenPR = selectedApp?.defaultOpenPR ?? !worktreeOptOut;return {@@ -394,7 +395,7 @@ export default function useTaskAddForm({const appDefaultsSig = useMemo(() => selectedApp- ? `${selectedApp.id}|${String(selectedApp.defaultOpenPR)}|${selectedApp.defaultPrCompletion || DEFAULT_PR_COMPLETION}|${String(selectedApp.defaultUseWorktree)}|${!!selectedApp.jira?.enabled}`+ ? `${selectedApp.id}|${String(selectedApp.defaultOpenPR)}|${selectedApp.defaultPrCompletion || DEFAULT_PR_COMPLETION}|${String(selectedApp.defaultUseWorktree)}|${String(selectedApp.isGitRepo)}|${!!selectedApp.jira?.enabled}`: `none:${state.newTask.app || ''}`,[selectedApp, state.newTask.app],);diff --git a/server/routes/apps/crud.js b/server/routes/apps/crud.jsindex 199a42fff5..0eec6c416f 100644--- a/server/routes/apps/crud.js+++ b/server/routes/apps/crud.js@@ -16,6 +16,7 @@ import { publishAppQualitySnapshot } from '../../services/appQualitySnapshotFile*/import { Router } from 'express';+import { existsSync } from 'fs';import { join } from 'path';import { readJSONFile } from '../../lib/fileUtils.js';import * as appsService from '../../services/apps.js';@@ -28,11 +29,20 @@ import { detectAppIcon } from '../../services/appIconDetect.js';import { hasDeployScript } from '../../services/appDeployer.js';import { checkScripts } from '../../services/xcodeScripts.js';import { applyEcosystemPortEdits } from '../../services/appPortConfig.js';+import { isRepo } from '../../services/git.js';import { enrichAppsWithPm2Status } from '../../services/appListEnrichment.js';import { loadApp, pathExists, deriveAppPorts, computeOverallStatus } from './shared.js';const router = Router();+// Lets the task form disable worktree/PR for a non-git app before submit (the+// create route refuses it with NOT_A_GIT_REPO). Left undefined — i.e. unknown,+// not "not a repo" — when the directory is missing, mirroring that route.+async function withGitRepoFlag(app) {+ if (!app.repoPath || !existsSync(app.repoPath)) return app;+ return { ...app, isGitRepo: await isRepo(app.repoPath) };+}+// Numeric local evidence only. This endpoint never invokes aggregate reads or forwards peer data.router.get('/quality-federation', asyncHandler(async (req, res) => {const { days, repository, categories } = validateRequest(appQualityFederationQuerySchema, req.query);@@ -56,7 +66,7 @@ router.get('/', asyncHandler(async (req, res) => {return;}- const apps = await enrichAppsWithPm2Status(rawApps);+ const apps = await Promise.all((await enrichAppsWithPm2Status(rawApps)).map(withGitRepoFlag));if (view === 'probe') {res.json(apps.map(({ id, name, icon, overallStatus, uiPort, apiPort, type }) => ({id, name, icon, overallStatus, uiPort, apiPort, type,diff --git a/server/routes/apps/crud.test.js b/server/routes/apps/crud.test.jsindex cd36ad2b7a..cd9214222e 100644--- a/server/routes/apps/crud.test.js+++ b/server/routes/apps/crud.test.js@@ -4,6 +4,10 @@ vi.mock('../../services/appQuality.js', () => ({ getAppQualityHistory: vi.fn(asyvi.mock('../../services/appQualitySnapshotFile.js', () => ({ publishAppQualitySnapshot: vi.fn(async () => ({ published: true, hash: 'abc1234', path: '.quality.json' })) }));import { describe, it, expect, vi, beforeEach } from 'vitest';import express from 'express';+import { execFileSync } from 'child_process';+import { mkdtempSync, rmSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';import { request } from '../../lib/testHelper.js';import { errorEvents } from '../../lib/errorHandler.js';import crudRoutes from './crud.js';@@ -142,6 +146,29 @@ describe('Apps CRUD Routes', () => {expect(response.body[0].overallStatus).toBe('online');});+ it('flags non-git directories with isGitRepo and leaves a missing directory unknown', async () => {+ const plainDir = mkdtempSync(join(tmpdir(), 'portos-plain-'));+ const gitDir = mkdtempSync(join(tmpdir(), 'portos-git-'));+ try {+ execFileSync('git', ['init', '-q'], { cwd: gitDir });+ appsService.getAllApps.mockResolvedValue([+ { id: 'plain', name: 'Plain', repoPath: plainDir, pm2ProcessNames: [] },+ { id: 'repo', name: 'Repo', repoPath: gitDir, pm2ProcessNames: [] },+ { id: 'gone', name: 'Gone', repoPath: join(plainDir, 'missing'), pm2ProcessNames: [] },+ ]);+ pm2Service.listProcessesStrict.mockResolvedValue([]);+ streamingDetect.parseEcosystemFromPath.mockResolvedValue([]);++ const response = await request(app).get('/api/apps');++ const flags = Object.fromEntries(response.body.map(a => [a.id, a.isGitRepo]));+ expect(flags).toEqual({ plain: false, repo: true, gone: undefined });+ } finally {+ rmSync(plainDir, { recursive: true, force: true });+ rmSync(gitDir, { recursive: true, force: true });+ }+ });+it('returns the nav projection without invoking PM2 enrichment', async () => {const mockApps = [{id: 'app-001', name: 'Test App', icon: 'package', archived: false, type: 'express',