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(apps): add per-app detail dashboard pages with tabbed navigation

Adam Eivy4180b3587882
diff --git a/.changelog/v1.18.x.md b/.changelog/v1.18.x.md
index 9d2030fcb2..1d4867af15 100644
--- a/.changelog/v1.18.x.md
+++ b/.changelog/v1.18.x.md
@@ -11,3 +11,4 @@ UX and autonomy improvements for CoS dashboard and autonomous jobs.
- **GSD tab info section** — added explanatory note to the GSD dashboard describing what it monitors and how to use GSD commands
- **Moltworld script-based execution** — converted moltworld exploration job from AI agent to standalone script handler, reducing resource usage and removing unnecessary agent spawning
- **Pre-task git pull** — agents now automatically pull the latest code from origin before starting work on any project, ensuring they always work on the most recent version. If a merge conflict is detected, a high-priority conflict resolution task is created for an agent to handle before the original task retries
+- **App detail dashboard pages** — each app now has a dedicated routable dashboard at `/apps/:appId/:tab` with five tabs: Overview (status, PM2 processes, JIRA, quick actions, edit), Tasks (recent agent history), Automation (per-app task type overrides), Documents (PLAN.md/CLAUDE.md/GOALS.md viewer), and GSD (project phases and concerns). Sidebar nav dynamically lists all apps as sub-links for deep navigation
diff --git a/client/src/App.jsx b/client/src/App.jsx
index f7aa4ed22c..692339c07c 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -31,6 +31,7 @@ const UsagePage = lazy(() => import('./pages/DevTools').then(m => ({ default: m.
const ProcessesPage = lazy(() => import('./pages/DevTools').then(m => ({ default: m.ProcessesPage })));
const AgentsPage = lazy(() => import('./pages/DevTools').then(m => ({ default: m.AgentsPage })));
const CyberCity = lazy(() => import('./pages/CyberCity'));
+const AppDetail = lazy(() => import('./pages/AppDetail'));
// Loading fallback for lazy-loaded pages
const PageLoader = () => (
@@ -63,6 +64,8 @@ export default function App() {
<Route path="digital-twin" element={<Navigate to="/digital-twin/overview" replace />} />
<Route path="digital-twin/:tab" element={<DigitalTwin />} />
<Route path="apps/create" element={<CreateApp />} />
+ <Route path="apps/:appId" element={<AppDetail />} />
+ <Route path="apps/:appId/:tab" element={<AppDetail />} />
<Route path="templates" element={<Templates />} />
<Route path="security" element={<Security />} />
<Route path="uploads" element={<Uploads />} />
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index 08e754c836..6849284c2f 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -1,4 +1,4 @@
-import { useState, useEffect } from 'react';
+import { useState, useEffect, useMemo } from 'react';
import { Outlet, NavLink, useLocation } from 'react-router-dom';
import {
Home,
@@ -61,6 +61,8 @@ import { useAgentFeedbackToast } from '../hooks/useAgentFeedbackToast';
import NotificationDropdown from './NotificationDropdown';
import ThemeSwitcher from './ThemeSwitcher';
import CmdKSearch from './CmdKSearch';
+import * as api from '../services/api';
+import socket from '../services/socket';
const navItems = [
{ to: '/', label: 'Dashboard', icon: Home, single: true },
@@ -74,7 +76,7 @@ const navItems = [
{ to: '/ai', label: 'Providers', icon: Bot }
]
},
- { to: '/apps', label: 'Apps', icon: Package, single: true },
+ { label: 'Apps', icon: Package, dynamic: 'apps', children: [] },
{ to: '/brain', label: 'Brain', icon: Brain, single: true },
{
label: 'Chief of Staff',
@@ -181,13 +183,39 @@ export default function Layout() {
clearAll
} = useNotifications();
+ // Fetch apps for sidebar navigation
+ const [sidebarApps, setSidebarApps] = useState([]);
+ useEffect(() => {
+ const fetchApps = () => {
+ api.getApps().then(apps => {
+ setSidebarApps((apps || []).filter(a => !a.archived).sort((a, b) => a.name.localeCompare(b.name)));
+ }).catch(() => {});
+ };
+ fetchApps();
+ socket.on('apps:changed', fetchApps);
+ return () => socket.off('apps:changed', fetchApps);
+ }, []);
+
useEffect(() => {
localStorage.setItem(SIDEBAR_KEY, String(collapsed));
}, [collapsed]);
+ // Build dynamic nav items with app children
+ const resolvedNavItems = useMemo(() => navItems.map(item => {
+ if (item.dynamic !== 'apps') return item;
+ return {
+ ...item,
+ children: sidebarApps.map(app => ({
+ to: `/apps/${app.id}`,
+ label: app.name,
+ icon: Package
+ }))
+ };
+ }), [sidebarApps]);
+
// Auto-expand sections when on a child page
useEffect(() => {
- navItems.forEach(item => {
+ resolvedNavItems.forEach(item => {
if (item.children) {
const isChildActive = item.children.some(child =>
child.to && (location.pathname === child.to || location.pathname.startsWith(child.to + '/'))
@@ -197,7 +225,7 @@ export default function Layout() {
}
}
});
- }, [location.pathname]);
+ }, [location.pathname, resolvedNavItems]);
// Close mobile menu on route change
useEffect(() => {
@@ -478,7 +506,7 @@ export default function Layout() {
{/* Nav items */}
<nav className="flex-1 py-4 overflow-y-auto">
- {navItems.map(renderNavItem)}
+ {resolvedNavItems.map(renderNavItem)}
</nav>
{/* Footer with version and notifications */}
@@ -541,7 +569,8 @@ export default function Layout() {
location.pathname.startsWith('/meatspace') ||
location.pathname.startsWith('/agents') ||
location.pathname === '/shell' ||
- location.pathname.startsWith('/city');
+ location.pathname.startsWith('/city') ||
+ /^\/apps\/[^/]+/.test(location.pathname);
return (
<main id="main-content" className={`flex-1 ${isFullWidth ? 'overflow-hidden' : 'overflow-auto p-4 md:p-6'}`}>
{isFullWidth ? <Outlet /> : <div className="max-w-7xl mx-auto"><Outlet /></div>}
diff --git a/client/src/components/apps/AppDetailView.jsx b/client/src/components/apps/AppDetailView.jsx
new file mode 100644
index 0000000000..01f1e2de6f
--- /dev/null
+++ b/client/src/components/apps/AppDetailView.jsx
@@ -0,0 +1,202 @@
+import { useState, useEffect, useCallback } from 'react';
+import { Link, useParams, useNavigate } from 'react-router-dom';
+import { ArrowLeft, Play, Square, RotateCcw, ExternalLink } from 'lucide-react';
+import toast from 'react-hot-toast';
+import BrailleSpinner from '../BrailleSpinner';
+import StatusBadge from '../StatusBadge';
+import * as api from '../../services/api';
+import socket from '../../services/socket';
+import { APP_DETAIL_TABS } from './constants';
+import OverviewTab from './tabs/OverviewTab';
+import TasksTab from './tabs/TasksTab';
+import AutomationTab from './tabs/AutomationTab';
+import DocumentsTab from './tabs/DocumentsTab';
+import GsdTab from './tabs/GsdTab';
+
+export default function AppDetailView() {
+ const { appId, tab } = useParams();
+ const navigate = useNavigate();
+ const activeTab = tab || 'overview';
+
+ const [app, setApp] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [notFound, setNotFound] = useState(false);
+ const [actionLoading, setActionLoading] = useState(null);
+ const [hasGsd, setHasGsd] = useState(false);
+
+ const fetchApp = useCallback(async () => {
+ const data = await api.getApp(appId).catch(() => null);
+ if (!data) {
+ setNotFound(true);
+ setLoading(false);
+ return;
+ }
+ setApp(data);
+ setLoading(false);
+ }, [appId]);
+
+ useEffect(() => {
+ fetchApp();
+ }, [fetchApp]);
+
+ // Check if app has a GSD project (silent - no toast on 404)
+ useEffect(() => {
+ if (!appId) return;
+ fetch(`/api/cos/gsd/projects/${appId}`).then(r => {
+ setHasGsd(r.ok);
+ }).catch(() => setHasGsd(false));
+ }, [appId]);
+
+ // Real-time updates
+ useEffect(() => {
+ const handleAppsChanged = () => fetchApp();
+ socket.on('apps:changed', handleAppsChanged);
+ return () => socket.off('apps:changed', handleAppsChanged);
+ }, [fetchApp]);
+
+ const handleStart = async () => {
+ setActionLoading('start');
+ await api.startApp(appId).catch(() => null);
+ setActionLoading(null);
+ };
+
+ const handleStop = async () => {
+ setActionLoading('stop');
+ await api.stopApp(appId).catch(() => null);
+ setActionLoading(null);
+ };
+
+ const handleRestart = async () => {
+ setActionLoading('restart');
+ await api.restartApp(appId).catch(() => null);
+ setActionLoading(null);
+ };
+
+ const visibleTabs = hasGsd
+ ? APP_DETAIL_TABS
+ : APP_DETAIL_TABS.filter(t => t.id !== 'gsd');
+
+ if (loading) {
+ return (
+ <div className="flex items-center justify-center h-64">
+ <BrailleSpinner text="Loading app" />
+ </div>
+ );
+ }
+
+ if (notFound) {
+ return (
+ <div className="p-6 text-center">
+ <p className="text-lg text-gray-400 mb-4">App not found</p>
+ <Link to="/apps" className="text-port-accent hover:underline">Back to Apps</Link>
+ </div>
+ );
+ }
+
+ const renderTab = () => {
+ switch (activeTab) {
+ case 'overview':
+ return <OverviewTab app={app} onRefresh={fetchApp} />;
+ case 'tasks':
+ return <TasksTab appId={appId} />;
+ case 'automation':
+ return <AutomationTab appId={appId} appName={app.name} />;
+ case 'documents':
+ return <DocumentsTab appId={appId} repoPath={app.repoPath} />;
+ case 'gsd':
+ return <GsdTab appId={appId} />;
+ default:
+ return <OverviewTab app={app} onRefresh={fetchApp} />;
+ }
+ };
+
+ return (
+ <div className="flex flex-col h-full">
+ {/* Header */}
+ <div className="px-4 sm:px-6 py-4 border-b border-port-border bg-port-card">
+ <div className="flex flex-col sm:flex-row sm:items-center gap-3">
+ <Link to="/apps" className="text-gray-400 hover:text-white transition-colors self-start">
+ <ArrowLeft size={20} />
+ </Link>
+ <div className="flex-1 min-w-0">
+ <div className="flex flex-wrap items-center gap-3">
+ <h1 className="text-xl font-bold text-white truncate">{app.name}</h1>
+ <StatusBadge status={app.overallStatus || 'unknown'} size="sm" />
+ </div>
+ {app.pm2ProcessNames?.length > 0 && (
+ <div className="text-xs text-gray-500 mt-1">
+ {app.pm2ProcessNames.join(', ')}
+ </div>
+ )}
+ </div>
+ <div className="flex items-center gap-2">
+ {/* Start/Stop/Restart */}
+ <div className="inline-flex rounded-lg overflow-hidden border border-port-border">
+ {app.overallStatus === 'online' ? (
+ <>
+ <button
+ onClick={handleStop}
+ disabled={actionLoading}
+ className="px-3 py-1.5 bg-port-error/20 text-port-error hover:bg-port-error/30 transition-colors disabled:opacity-50 flex items-center gap-1"
+ >
+ <Square size={14} />
+ <span className="text-xs">Stop</span>
+ </button>
+ <button
+ onClick={handleRestart}
+ disabled={actionLoading}
+ className="px-3 py-1.5 bg-port-warning/20 text-port-warning hover:bg-port-warning/30 transition-colors disabled:opacity-50 border-l border-port-border flex items-center gap-1"
+ >
+ <RotateCcw size={14} className={actionLoading === 'restart' ? 'animate-spin' : ''} />
+ <span className="text-xs">Restart</span>
+ </button>
+ </>
+ ) : (
+ <button
+ onClick={handleStart}
+ disabled={actionLoading}
+ className="px-3 py-1.5 bg-port-success/20 text-port-success hover:bg-port-success/30 transition-colors disabled:opacity-50 flex items-center gap-1"
+ >
+ <Play size={14} />
+ <span className="text-xs">{actionLoading === 'start' ? 'Starting...' : 'Start'}</span>
+ </button>
+ )}
+ </div>
+ {/* Launch UI */}
+ {app.uiPort && app.overallStatus === 'online' && (
+ <button
+ onClick={() => window.open(`${window.location.protocol}//${window.location.hostname}:${app.uiPort}`, '_blank')}
+ className="px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 transition-colors rounded-lg border border-port-border flex items-center gap-1"
+ >
+ <ExternalLink size={14} />
+ <span className="text-xs">Launch</span>
+ </button>
+ )}
+ </div>
+ </div>
+
+ {/* Tab Bar */}
+ <div className="flex gap-1 mt-4 -mb-4 overflow-x-auto">
+ {visibleTabs.map(t => (
+ <button
+ key={t.id}
+ onClick={() => navigate(`/apps/${appId}/${t.id}`)}
+ className={`px-4 py-2 text-sm font-medium whitespace-nowrap border-b-2 transition-colors ${
+ activeTab === t.id
+ ? 'border-port-accent text-port-accent'
+ : 'border-transparent text-gray-400 hover:text-white hover:border-gray-600'
+ }`}
+ >
+ {t.label}
+ </button>
+ ))}
+ </div>
+ </div>
+
+ {/* Tab Content */}
+ <div className="flex-1 overflow-auto p-4 sm:p-6">
+ {renderTab()}
+ </div>
+ </div>
+ );
+}
diff --git a/client/src/components/apps/EditAppModal.jsx b/client/src/components/apps/EditAppModal.jsx
new file mode 100644
index 0000000000..7ca4ebb184
--- /dev/null
+++ b/client/src/components/apps/EditAppModal.jsx
@@ -0,0 +1,438 @@
+import { useState, useEffect } from 'react';
+import { Link } from 'react-router-dom';
+import { ChevronDown, ChevronUp, GitBranch } from 'lucide-react';
+import IconPicker from '../IconPicker';
+import * as api from '../../services/api';
+
+export default function EditAppModal({ app, onClose, onSave }) {
+ const [formData, setFormData] = useState({
+ name: app.name,
+ icon: app.icon || 'package',
+ repoPath: app.repoPath,
+ uiPort: app.uiPort || '',
+ apiPort: app.apiPort || '',
+ startCommands: (app.startCommands || []).join('\n'),
+ pm2ProcessNames: (app.pm2ProcessNames || []).join(', '),
+ editorCommand: app.editorCommand || 'code .',
+ defaultUseWorktree: app.defaultUseWorktree || false,
+ jiraEnabled: app.jira?.enabled || false,
+ jiraInstanceId: app.jira?.instanceId || '',
+ jiraProjectKey: app.jira?.projectKey || '',
+ jiraBoardId: app.jira?.boardId || '',
+ jiraIssueType: app.jira?.issueType || 'Task',
+ jiraLabels: (app.jira?.labels || []).join(', '),
+ jiraAssignee: app.jira?.assignee || '',
+ jiraEpicKey: app.jira?.epicKey || '',
+ jiraCreatePR: app.jira?.createPR !== false
+ });
+ const [saving, setSaving] = useState(false);
+ const [error, setError] = useState(null);
+ const [jiraExpanded, setJiraExpanded] = useState(app.jira?.enabled || false);
+ const [jiraInstances, setJiraInstances] = useState([]);
+ const [jiraProjects, setJiraProjects] = useState([]);
+ const [loadingProjects, setLoadingProjects] = useState(false);
+ const [projectSearch, setProjectSearch] = useState('');
+ const [projectDropdownOpen, setProjectDropdownOpen] = useState(false);
+
+ useEffect(() => {
+ api.getJiraInstances().then(data => {
+ const instances = data?.instances ? Object.values(data.instances) : [];
+ setJiraInstances(instances);
+ }).catch(() => setJiraInstances([]));
+ }, []);
+
+ useEffect(() => {
+ if (!formData.jiraInstanceId) {
+ setJiraProjects([]);
+ return;
+ }
+ setLoadingProjects(true);
+ api.getJiraProjects(formData.jiraInstanceId).then(projects => {
+ setJiraProjects(projects || []);
+ }).catch(() => setJiraProjects([])).finally(() => setLoadingProjects(false));
+ }, [formData.jiraInstanceId]);
+
+ useEffect(() => {
+ if (!formData.jiraInstanceId || formData.jiraAssignee) return;
+ const inst = jiraInstances.find(i => i.id === formData.jiraInstanceId);
+ if (inst?.email) {
+ setFormData(prev => ({ ...prev, jiraAssignee: inst.email }));
+ }
+ }, [formData.jiraInstanceId, jiraInstances, formData.jiraAssignee]);
+
+ const handleSubmit = async (e) => {
+ e.preventDefault();
+ setError(null);
+ setSaving(true);
+
+ const data = {
+ name: formData.name,
+ icon: formData.icon,
+ repoPath: formData.repoPath,
+ uiPort: formData.uiPort ? parseInt(formData.uiPort, 10) : null,
+ apiPort: formData.apiPort ? parseInt(formData.apiPort, 10) : null,
+ startCommands: formData.startCommands.split('\n').filter(Boolean),
+ pm2ProcessNames: formData.pm2ProcessNames
+ ? formData.pm2ProcessNames.split(',').map(s => s.trim()).filter(Boolean)
+ : undefined,
+ editorCommand: formData.editorCommand || undefined,
+ defaultUseWorktree: formData.defaultUseWorktree,
+ jira: formData.jiraEnabled ? {
+ enabled: true,
+ instanceId: formData.jiraInstanceId || undefined,
+ projectKey: formData.jiraProjectKey || undefined,
+ boardId: formData.jiraBoardId || undefined,
+ issueType: formData.jiraIssueType || 'Task',
+ labels: formData.jiraLabels ? formData.jiraLabels.split(',').map(s => s.trim()).filter(Boolean) : [],
+ assignee: formData.jiraAssignee || undefined,
+ epicKey: formData.jiraEpicKey || undefined,
+ createPR: formData.jiraCreatePR
+ } : { enabled: false }
+ };
+
+ await api.updateApp(app.id, data).catch(err => {
+ setError(err.message);
+ setSaving(false);
+ throw err;
+ });
+
+ setSaving(false);
+ onSave();
+ };
+
+ return (
+ <div
+ className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4"
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="edit-app-title"
+ >
+ <div className="bg-port-card border border-port-border rounded-xl p-4 sm:p-6 w-full max-w-lg max-h-[90vh] overflow-auto">
+ <h2 id="edit-app-title" className="text-xl font-bold text-white mb-4">Edit App</h2>
+
+ {error && (
+ <div className="mb-4 p-3 bg-port-error/20 border border-port-error rounded-lg text-port-error text-sm">
+ {error}
+ </div>
+ )}
+
+ <form onSubmit={handleSubmit} className="space-y-4">
+ <div className="grid grid-cols-1 sm:grid-cols-[1fr_auto] gap-4">
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">Name</label>
+ <input
+ type="text"
+ value={formData.name}
+ onChange={e => setFormData({ ...formData, name: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ required
+ />
+ </div>
+ <div className="w-full sm:w-32">
+ <IconPicker value={formData.icon} onChange={icon => setFormData({ ...formData, icon })} />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">Repository Path</label>
+ <input
+ type="text"
+ value={formData.repoPath}
+ onChange={e => setFormData({ ...formData, repoPath: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ required
+ />
+ </div>
+
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">UI Port</label>
+ <input
+ type="number"
+ value={formData.uiPort}
+ onChange={e => setFormData({ ...formData, uiPort: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ placeholder="3000"
+ />
+ </div>
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">API Port</label>
+ <input
+ type="number"
+ value={formData.apiPort}
+ onChange={e => setFormData({ ...formData, apiPort: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ placeholder="3001"
+ />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">Start Commands (one per line)</label>
+ <textarea
+ value={formData.startCommands}
+ onChange={e => setFormData({ ...formData, startCommands: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none font-mono text-sm"
+ rows={2}
+ />
+ </div>
+
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">PM2 Process Names (comma-separated)</label>
+ <input
+ type="text"
+ value={formData.pm2ProcessNames}
+ onChange={e => setFormData({ ...formData, pm2ProcessNames: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ />
+ </div>
+
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">Editor Command</label>
+ <input
+ type="text"
+ value={formData.editorCommand}
+ onChange={e => setFormData({ ...formData, editorCommand: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ />
+ </div>
+
+ <label className="flex items-center gap-2 cursor-pointer">
+ <input
+ type="checkbox"
+ checked={formData.defaultUseWorktree}
+ onChange={e => setFormData({ ...formData, defaultUseWorktree: e.target.checked })}
+ className="rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent"
+ />
+ <GitBranch size={14} className="text-emerald-400" />
+ <span className="text-sm text-white">Default to Branch + PR for new tasks</span>
+ </label>
+
+ {/* JIRA Integration Section */}
+ <div className="border border-port-border rounded-lg overflow-hidden">
+ <button
+ type="button"
+ onClick={() => setJiraExpanded(prev => !prev)}
+ className="w-full flex items-center justify-between px-4 py-3 bg-port-bg hover:bg-port-border/50 transition-colors"
+ >
+ <span className="text-sm font-medium text-gray-300">JIRA Integration</span>
+ <div className="flex items-center gap-2">
+ {formData.jiraEnabled && (
+ <span className="text-xs px-2 py-0.5 bg-port-accent/20 text-port-accent rounded">Enabled</span>
+ )}
+ {jiraExpanded ? <ChevronUp size={16} className="text-gray-400" /> : <ChevronDown size={16} className="text-gray-400" />}
+ </div>
+ </button>
+
+ {jiraExpanded && (
+ <div className="p-4 space-y-3 border-t border-port-border">
+ <label className="flex items-center gap-2 cursor-pointer">
+ <input
+ type="checkbox"
+ checked={formData.jiraEnabled}
+ onChange={e => setFormData({ ...formData, jiraEnabled: e.target.checked })}
+ className="rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent"
+ />
+ <span className="text-sm text-white">Enable JIRA Integration</span>
+ </label>
+
+ {formData.jiraEnabled && (
+ <>
+ {jiraInstances.length === 0 ? (
+ <div className="p-3 bg-port-warning/10 border border-port-warning/30 rounded-lg text-sm text-port-warning">
+ No JIRA instances configured. <Link to="/devtools/jira" className="underline hover:text-white">Configure JIRA</Link> first.
+ </div>
+ ) : (
+ <>
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">JIRA Instance</label>
+ <select
+ value={formData.jiraInstanceId}
+ onChange={e => setFormData({ ...formData, jiraInstanceId: e.target.value, jiraProjectKey: '' })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ >
+ <option value="">Select instance...</option>
+ {jiraInstances.map(inst => (
+ <option key={inst.id} value={inst.id}>{inst.name} ({inst.baseUrl})</option>
+ ))}
+ </select>
+ </div>
+
+ <div className="relative">
+ <label className="block text-sm text-gray-400 mb-1">Project Key</label>
+ {loadingProjects ? (
+ <div className="text-xs text-gray-500">Loading projects...</div>
+ ) : jiraProjects.length > 0 ? (
+ <div>
+ <input
+ type="text"
+ value={projectDropdownOpen ? projectSearch : (
+ formData.jiraProjectKey
+ ? `${formData.jiraProjectKey} - ${jiraProjects.find(p => p.key === formData.jiraProjectKey)?.name || ''}`
+ : ''
+ )}
+ onChange={e => {
+ setProjectSearch(e.target.value);
+ if (!projectDropdownOpen) setProjectDropdownOpen(true);
+ }}
+ onFocus={() => {
+ setProjectDropdownOpen(true);
+ setProjectSearch('');
+ }}
+ onBlur={() => setTimeout(() => setProjectDropdownOpen(false), 150)}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ placeholder="Search projects..."
+ />
+ {formData.jiraProjectKey && !projectDropdownOpen && (
+ <button
+ type="button"
+ onClick={() => setFormData({ ...formData, jiraProjectKey: '' })}
+ className="absolute right-2 top-8 text-gray-500 hover:text-white text-sm"
+ >
+ x
+ </button>
+ )}
+ {projectDropdownOpen && (
+ <div className="absolute z-50 w-full mt-1 bg-port-bg border border-port-border rounded-lg max-h-48 overflow-auto shadow-lg">
+ {jiraProjects
+ .filter(proj => {
+ if (!projectSearch) return true;
+ const q = projectSearch.toLowerCase();
+ return proj.key.toLowerCase().includes(q) || proj.name.toLowerCase().includes(q);
+ })
+ .sort((a, b) => a.key.localeCompare(b.key))
+ .slice(0, 100)
+ .map(proj => (
+ <button
+ key={proj.key}
+ type="button"
+ onMouseDown={e => {
+ e.preventDefault();
+ setFormData({ ...formData, jiraProjectKey: proj.key });
+ setProjectDropdownOpen(false);
+ setProjectSearch('');
+ }}
+ className={`w-full text-left px-3 py-2 text-sm hover:bg-port-accent/20 ${
+ formData.jiraProjectKey === proj.key ? 'bg-port-accent/10 text-port-accent' : 'text-white'
+ }`}
+ >
+ <span className="font-mono">{proj.key}</span>
+ <span className="text-gray-400 ml-2">{proj.name}</span>
+ </button>
+ ))
+ }
+ {jiraProjects.filter(proj => {
+ if (!projectSearch) return true;
+ const q = projectSearch.toLowerCase();
+ return proj.key.toLowerCase().includes(q) || proj.name.toLowerCase().includes(q);
+ }).length === 0 && (
+ <div className="px-3 py-2 text-sm text-gray-500">No matching projects</div>
+ )}
+ </div>
+ )}
+ </div>
+ ) : (
+ <input
+ type="text"
+ value={formData.jiraProjectKey}
+ onChange={e => setFormData({ ...formData, jiraProjectKey: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ placeholder="e.g. CONTECH"
+ />
+ )}
+ </div>
+
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">Board ID</label>
+ <input
+ type="text"
+ value={formData.jiraBoardId}
+ onChange={e => setFormData({ ...formData, jiraBoardId: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ placeholder="e.g. 11810 (from JIRA board URL rapidView param)"
+ />
+ </div>
+
+ <div className="grid grid-cols-2 gap-3">
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">Issue Type</label>
+ <input
+ type="text"
+ value={formData.jiraIssueType}
+ onChange={e => setFormData({ ...formData, jiraIssueType: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ placeholder="Task"
+ />
+ </div>
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">Assignee</label>
+ <input
+ type="text"
+ value={formData.jiraAssignee}
+ onChange={e => setFormData({ ...formData, jiraAssignee: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ placeholder="Optional"
+ />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">Labels (comma-separated)</label>
+ <input
+ type="text"
+ value={formData.jiraLabels}
+ onChange={e => setFormData({ ...formData, jiraLabels: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ placeholder="e.g. cos-auto, feature"
+ />
+ </div>
+
+ <div>
+ <label className="block text-sm text-gray-400 mb-1">Epic Key</label>
+ <input
+ type="text"
+ value={formData.jiraEpicKey}
+ onChange={e => setFormData({ ...formData, jiraEpicKey: e.target.value })}
+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
+ placeholder="e.g. CONTECH-100"
+ />
+ </div>
+
+ <label className="flex items-center gap-2 cursor-pointer">
+ <input
+ type="checkbox"
+ checked={formData.jiraCreatePR}
+ onChange={e => setFormData({ ...formData, jiraCreatePR: e.target.checked })}
+ className="rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent"
+ />
+ <span className="text-sm text-white">Create Pull Request on completion</span>
+ </label>
+ </>
+ )}
+ </>
+ )}
+ </div>
+ )}
+ </div>
+
+ <div className="flex justify-end gap-3 pt-4">
+ <button
+ type="button"
+ onClick={onClose}
+ className="px-4 py-2 text-gray-400 hover:text-white"
+ >
+ Cancel
+ </button>
+ <button
+ type="submit"
+ disabled={saving}
+ className="px-6 py-2 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors disabled:opacity-50"
+ >
+ {saving ? 'Saving...' : 'Save Changes'}
+ </button>
+ </div>
+ </form>
+ </div>
+ </div>
+ );
+}
diff --git a/client/src/components/apps/constants.js b/client/src/components/apps/constants.js
new file mode 100644
index 0000000000..808f3b7f2a
--- /dev/null
+++ b/client/src/components/apps/constants.js
@@ -0,0 +1,7 @@
+export const APP_DETAIL_TABS = [
+ { id: 'overview', label: 'Overview' },
+ { id: 'tasks', label: 'Tasks' },
+ { id: 'automation', label: 'Automation' },
+ { id: 'documents', label: 'Documents' },
+ { id: 'gsd', label: 'GSD' }
+];
diff --git a/client/src/components/apps/tabs/AutomationTab.jsx b/client/src/components/apps/tabs/AutomationTab.jsx
new file mode 100644
index 0000000000..c2f11567ad
--- /dev/null
+++ b/client/src/components/apps/tabs/AutomationTab.jsx
@@ -0,0 +1,171 @@
+import { useState, useEffect } from 'react';
+import { RefreshCw, Play } from 'lucide-react';
+import toast from 'react-hot-toast';
+import BrailleSpinner from '../../BrailleSpinner';
+import * as api from '../../../services/api';
+
+const INTERVAL_OPTIONS = [
+ { value: null, label: 'Inherit Global' },
+ { value: 'rotation', label: 'Rotation' },
+ { value: 'daily', label: 'Daily' },
+ { value: 'weekly', label: 'Weekly' },
+ { value: 'once', label: 'Once' },
+ { value: 'on-demand', label: 'On-demand' }
+];
+
+export default function AutomationTab({ appId, appName }) {
+ const [overrides, setOverrides] = useState({});
+ const [schedule, setSchedule] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [triggering, setTriggering] = useState(null);
+
+ const fetchData = async () => {
+ const [taskTypesData, scheduleData] = await Promise.all([
+ api.getAppTaskTypes(appId).catch(() => ({ taskTypeOverrides: {} })),
+ api.getCosSchedule().catch(() => null)
+ ]);
+ setOverrides(taskTypesData.taskTypeOverrides || {});
+ setSchedule(scheduleData);
+ setLoading(false);
+ };
+
+ useEffect(() => {
+ fetchData();
+ }, [appId]);
+
+ const handleToggle = async (taskType, currentEnabled) => {
+ const newEnabled = currentEnabled === false;
+ await api.updateAppTaskTypeOverride(appId, taskType, { enabled: newEnabled }).catch(err => {
+ toast.error(err.message);
+ return null;
+ });
+ setOverrides(prev => ({
+ ...prev,
+ [taskType]: { ...prev[taskType], enabled: newEnabled }
+ }));
+ };
+
+ const handleIntervalChange = async (taskType, interval) => {
+ const value = interval === 'null' ? null : interval;
+ await api.updateAppTaskTypeOverride(appId, taskType, { interval: value }).catch(err => {
+ toast.error(err.message);
+ return null;
+ });
+ setOverrides(prev => ({
+ ...prev,
+ [taskType]: { ...prev[taskType], interval: value }
+ }));
+ };
+
+ const handleTrigger = async (taskType) => {
+ setTriggering(taskType);
+ const result = await api.triggerCosOnDemandTask(taskType, appId).catch(err => {
+ toast.error(err.message);
+ return null;
+ });
+ setTriggering(null);
+ if (result?.success) {
+ toast.success(`Triggered ${taskType} for ${appName}`);
+ }
+ };
+
+ if (loading) {
+ return <BrailleSpinner text="Loading automation settings" />;
+ }
+
+ const taskTypes = schedule?.tasks ? Object.keys(schedule.tasks).sort() : [];
+
+ return (
+ <div className="max-w-5xl space-y-4">
+ <div className="flex items-center justify-between">
+ <div>
+ <h3 className="text-lg font-semibold text-white">Task Type Overrides</h3>
+ <p className="text-sm text-gray-500">Per-app automation preferences for CoS task scheduling</p>
+ </div>
+ <button
+ onClick={fetchData}
+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"
+ >
+ <RefreshCw size={14} /> Refresh
+ </button>
+ </div>
+
+ {taskTypes.length === 0 ? (
+ <div className="bg-port-card border border-port-border rounded-lg p-6 text-center text-gray-500">
+ No task types configured in the schedule
+ </div>
+ ) : (
+ <div className="bg-port-card border border-port-border rounded-lg overflow-hidden">
+ <div className="overflow-x-auto">
+ <table className="w-full text-sm">
+ <thead>
+ <tr className="border-b border-port-border">
+ <th className="text-left px-4 py-3 text-xs text-gray-500 uppercase tracking-wide font-medium">Task Type</th>
+ <th className="text-center px-4 py-3 text-xs text-gray-500 uppercase tracking-wide font-medium">Enabled</th>
+ <th className="text-left px-4 py-3 text-xs text-gray-500 uppercase tracking-wide font-medium">Interval</th>
+ <th className="text-left px-4 py-3 text-xs text-gray-500 uppercase tracking-wide font-medium">Global Interval</th>
+ <th className="text-right px-4 py-3 text-xs text-gray-500 uppercase tracking-wide font-medium">Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ {taskTypes.map(taskType => {
+ const override = overrides[taskType] || {};
+ const globalConfig = schedule.tasks[taskType] || {};
+ const isEnabled = override.enabled !== false;
+ const overrideInterval = override.interval || null;
+
+ return (
+ <tr key={taskType} className="border-b border-port-border/50 hover:bg-white/5">
+ <td className="px-4 py-3">
+ <span className="text-white font-mono text-xs">{taskType}</span>
+ </td>
+ <td className="px-4 py-3 text-center">
+ <button
+ onClick={() => handleToggle(taskType, override.enabled)}
+ className={`w-10 h-5 rounded-full transition-colors relative ${
+ isEnabled ? 'bg-port-success' : 'bg-gray-600'
+ }`}
+ >
+ <span className={`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${
+ isEnabled ? 'left-5' : 'left-0.5'
+ }`} />
+ </button>
+ </td>
+ <td className="px-4 py-3">
+ <select
+ value={overrideInterval ?? 'null'}
+ onChange={e => handleIntervalChange(taskType, e.target.value)}
+ className="px-2 py-1 bg-port-bg border border-port-border rounded text-xs text-white focus:border-port-accent focus:outline-none"
+ >
+ {INTERVAL_OPTIONS.map(opt => (
+ <option key={String(opt.value)} value={String(opt.value)}>{opt.label}</option>
+ ))}
+ </select>
+ </td>
+ <td className="px-4 py-3">
+ <span className="text-xs text-gray-400">
+ {globalConfig.type || 'rotation'}
+ {globalConfig.intervalMs && ` (${Math.round(globalConfig.intervalMs / 3600000)}h)`}
+ </span>
+ </td>
+ <td className="px-4 py-3 text-right">
+ <button
+ onClick={() => handleTrigger(taskType)}
+ disabled={triggering === taskType || !isEnabled}
+ className="px-2 py-1 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded text-xs disabled:opacity-50 inline-flex items-center gap-1"
+ >
+ <Play size={12} />
+ {triggering === taskType ? '...' : 'Run Now'}
+ </button>
+ </td>
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/client/src/components/apps/tabs/DocumentsTab.jsx b/client/src/components/apps/tabs/DocumentsTab.jsx
new file mode 100644
index 0000000000..90a4c6de68
--- /dev/null
+++ b/client/src/components/apps/tabs/DocumentsTab.jsx
@@ -0,0 +1,115 @@
+import { useState, useEffect } from 'react';
+import { RefreshCw, FileText } from 'lucide-react';
+import BrailleSpinner from '../../BrailleSpinner';
+import MarkdownOutput from '../../cos/MarkdownOutput';
+import * as api from '../../../services/api';
+
+export default function DocumentsTab({ appId, repoPath }) {
+ const [documents, setDocuments] = useState([]);
+ const [hasPlanning, setHasPlanning] = useState(false);
+ const [loading, setLoading] = useState(true);
+ const [selectedDoc, setSelectedDoc] = useState(null);
+ const [docContent, setDocContent] = useState(null);
+ const [loadingDoc, setLoadingDoc] = useState(false);
+
+ const fetchDocuments = async () => {
+ setLoading(true);
+ const data = await api.getAppDocuments(appId).catch(() => ({ documents: [], hasPlanning: false }));
+ setDocuments(data.documents || []);
+ setHasPlanning(data.hasPlanning || false);
+ setLoading(false);
+
+ // Auto-select first existing document
+ const firstExisting = (data.documents || []).find(d => d.exists);
+ if (firstExisting && !selectedDoc) {
+ loadDocument(firstExisting.filename);
+ }
+ };
+
+ const loadDocument = async (filename) => {
+ setSelectedDoc(filename);
+ setLoadingDoc(true);
+ const data = await api.getAppDocument(appId, filename).catch(() => null);
+ setDocContent(data?.content || null);
+ setLoadingDoc(false);
+ };
+
+ useEffect(() => {
+ fetchDocuments();
+ }, [appId]);
+
+ if (loading) {
+ return <BrailleSpinner text="Loading documents" />;
+ }
+
+ const existingDocs = documents.filter(d => d.exists);
+ const missingDocs = documents.filter(d => !d.exists);
+
+ return (
+ <div className="max-w-5xl space-y-4">
+ <div className="flex items-center justify-between">
+ <div>
+ <h3 className="text-lg font-semibold text-white">Documents</h3>
+ <p className="text-sm text-gray-500">
+ Key project documents from {repoPath ? repoPath.split('/').pop() : 'repo'}
+ {hasPlanning && <span className="text-port-accent ml-2">.planning/ exists</span>}
+ </p>
+ </div>
+ <button
+ onClick={fetchDocuments}
+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"
+ >
+ <RefreshCw size={14} /> Refresh
+ </button>
+ </div>
+
+ {existingDocs.length === 0 ? (
+ <div className="bg-port-card border border-port-border rounded-lg p-8 text-center">
+ <FileText size={32} className="text-gray-600 mx-auto mb-3" />
+ <p className="text-gray-400 mb-2">No documents found</p>
+ <p className="text-xs text-gray-500">
+ Looking for: {documents.map(d => d.filename).join(', ')}
+ </p>
+ </div>
+ ) : (
+ <div className="flex flex-col sm:flex-row gap-4">
+ {/* Document selector */}
+ <div className="sm:w-48 flex sm:flex-col gap-2">
+ {existingDocs.map(doc => (
+ <button
+ key={doc.filename}
+ onClick={() => loadDocument(doc.filename)}
+ className={`px-3 py-2 rounded-lg text-sm text-left transition-colors ${
+ selectedDoc === doc.filename
+ ? 'bg-port-accent/20 text-port-accent border border-port-accent/30'
+ : 'bg-port-card border border-port-border text-gray-300 hover:text-white hover:bg-port-border/50'
+ }`}
+ >
+ <FileText size={14} className="inline mr-2" />
+ {doc.filename}
+ </button>
+ ))}
+ {missingDocs.length > 0 && (
+ <div className="text-xs text-gray-600 mt-2 hidden sm:block">
+ Not found: {missingDocs.map(d => d.filename).join(', ')}
+ </div>
+ )}
+ </div>
+
+ {/* Document content */}
+ <div className="flex-1 bg-port-card border border-port-border rounded-lg p-4 min-h-[300px] overflow-auto">
+ {loadingDoc ? (
+ <BrailleSpinner text="Loading document" />
+ ) : docContent ? (
+ <MarkdownOutput content={docContent} />
+ ) : selectedDoc ? (
+ <p className="text-gray-500 text-sm">Failed to load document</p>
+ ) : (
+ <p className="text-gray-500 text-sm">Select a document to view</p>
+ )}
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/client/src/components/apps/tabs/GsdTab.jsx b/client/src/components/apps/tabs/GsdTab.jsx
new file mode 100644
index 0000000000..6ca92c0718
--- /dev/null
+++ b/client/src/components/apps/tabs/GsdTab.jsx
@@ -0,0 +1,99 @@
+import { useState, useEffect } from 'react';
+import { RefreshCw, Compass } from 'lucide-react';
+import toast from 'react-hot-toast';
+import BrailleSpinner from '../../BrailleSpinner';
+import PhaseTimeline from '../../gsd/PhaseTimeline';
+import GsdConcernsPanel from '../../cos/tabs/GsdConcernsPanel';
+import * as api from '../../../services/api';
+
+export default function GsdTab({ appId }) {
+ const [project, setProject] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [notFound, setNotFound] = useState(false);
+
+ const fetchProject = async () => {
+ setLoading(true);
+ const data = await api.getGsdProject(appId).catch(() => null);
+ if (!data) {
+ setNotFound(true);
+ } else {
+ setProject(data);
+ setNotFound(false);
+ }
+ setLoading(false);
+ };
+
+ useEffect(() => {
+ fetchProject();
+ }, [appId]);
+
+ if (loading) {
+ return <BrailleSpinner text="Loading GSD project" />;
+ }
+
+ if (notFound) {
+ return (
+ <div className="max-w-5xl">
+ <div className="bg-port-card border border-port-border rounded-lg p-8 text-center">
+ <Compass size={32} className="text-gray-600 mx-auto mb-3" />
+ <p className="text-gray-400 mb-2">No GSD project found</p>
+ <p className="text-xs text-gray-500">This app does not have a .planning/ directory</p>
+ </div>
+ </div>
+ );
+ }
+
+ const phaseCount = project?.phases?.length || 0;
+ const completedPhases = project?.phases?.filter(p => p.status === 'completed').length || 0;
+
+ return (
+ <div className="max-w-5xl space-y-6">
+ <div className="flex items-center justify-between">
+ <div>
+ <h3 className="text-lg font-semibold text-white">GSD Project</h3>
+ <p className="text-sm text-gray-500">{completedPhases}/{phaseCount} phases completed</p>
+ </div>
+ <button
+ onClick={fetchProject}
+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"
+ >
+ <RefreshCw size={14} /> Refresh
+ </button>
+ </div>
+
+ {/* Phase Timeline */}
+ {project?.phases && (
+ <div className="bg-port-card border border-port-border rounded-lg p-4">
+ <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mb-3">Phases</h4>
+ <PhaseTimeline phases={project.phases} />
+ </div>
+ )}
+
+ {/* Concerns */}
+ {project?.concerns && (
+ <div className="bg-port-card border border-port-border rounded-lg p-4">
+ <GsdConcernsPanel
+ appId={appId}
+ concerns={project.concerns}
+ onTaskCreated={fetchProject}
+ />
+ </div>
+ )}
+
+ {/* State Frontmatter */}
+ {project?.state?.frontmatter && (
+ <div className="bg-port-card border border-port-border rounded-lg p-4">
+ <h4 className="text-sm font-semibold text-gray-400 uppercase tracking-wider mb-3">State</h4>
+ <div className="grid grid-cols-2 gap-2 text-xs">
+ {Object.entries(project.state.frontmatter).map(([key, value]) => (
+ <div key={key} className="bg-port-bg rounded px-2 py-1">
+ <span className="text-gray-500">{key}:</span>{' '}
+ <span className="text-gray-300">{String(value)}</span>
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/client/src/components/apps/tabs/OverviewTab.jsx b/client/src/components/apps/tabs/OverviewTab.jsx
new file mode 100644
index 0000000000..2d957097ed
--- /dev/null
+++ b/client/src/components/apps/tabs/OverviewTab.jsx
@@ -0,0 +1,325 @@
+import { useState, useEffect } from 'react';
+import { FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Ticket, ExternalLink, Download } from 'lucide-react';
+import toast from 'react-hot-toast';
+import BrailleSpinner from '../../BrailleSpinner';
+import EditAppModal from '../EditAppModal';
+import * as api from '../../../services/api';
+
+function KanbanBoard({ tickets }) {
+ const columns = {
+ 'To Do': tickets.filter(t => t.statusCategory === 'To Do'),
+ 'In Progress': tickets.filter(t => t.statusCategory === 'In Progress'),
+ 'Done': tickets.filter(t => t.statusCategory === 'Done')
+ };
+
+ const columnConfig = {
+ 'To Do': { bg: 'bg-gray-500/10', border: 'border-gray-500/30', dot: 'bg-gray-500' },
+ 'In Progress': { bg: 'bg-port-accent/10', border: 'border-port-accent/30', dot: 'bg-port-accent' },
+ 'Done': { bg: 'bg-port-success/10', border: 'border-port-success/30', dot: 'bg-port-success' }
+ };
+
+ return (
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
+ {Object.entries(columns).map(([category, categoryTickets]) => {
+ const config = columnConfig[category];
+ return (
+ <div key={category} className={`${config.bg} border ${config.border} rounded-lg p-3 min-h-[120px]`}>
+ <div className="flex items-center gap-2 mb-3">
+ <span className={`w-2 h-2 rounded-full ${config.dot}`} />
+ <span className="text-sm font-medium text-white">{category}</span>
+ <span className="text-xs text-gray-500">({categoryTickets.length})</span>
+ </div>
+ <div className="space-y-2">
+ {categoryTickets.map(ticket => (
+ <a
+ key={ticket.key}
+ href={ticket.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="block p-2 bg-port-card border border-port-border rounded-lg hover:border-port-accent/50 transition-colors"
+ >
+ <div className="flex items-start justify-between gap-1">
+ <div className="flex-1 min-w-0">
+ <div className="flex items-center gap-2 mb-1">
+ <span className="text-xs font-mono text-port-accent">{ticket.key}</span>
+ {ticket.priority && (
+ <span className={`text-xs ${
+ ticket.priority === 'Highest' || ticket.priority === 'High' ? 'text-port-error' :
+ ticket.priority === 'Medium' ? 'text-port-warning' : 'text-gray-500'
+ }`}>{ticket.priority}</span>
+ )}
+ {ticket.storyPoints && (
+ <span className="text-xs text-cyan-400">{ticket.storyPoints}pt</span>
+ )}
+ </div>
+ <div className="text-xs text-white line-clamp-2">{ticket.summary}</div>
+ <div className="text-xs text-gray-500 mt-1">{ticket.issueType}</div>
+ </div>
+ <ExternalLink size={12} className="text-gray-500 flex-shrink-0" />
+ </div>
+ </a>
+ ))}
+ {categoryTickets.length === 0 && (
+ <div className="text-xs text-gray-500 text-center py-4">No tickets</div>
+ )}
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ );
+}
+
+export default function OverviewTab({ app, onRefresh }) {
+ const [editingApp, setEditingApp] = useState(null);
+ const [updating, setUpdating] = useState(false);
+ const [refreshingConfig, setRefreshingConfig] = useState(false);
+ const [standardizing, setStandardizing] = useState(false);
+ const [archiving, setArchiving] = useState(false);
+ const [jiraTickets, setJiraTickets] = useState(null);
+ const [loadingTickets, setLoadingTickets] = useState(false);
+
+ useEffect(() => {
+ if (app?.jira?.enabled && app.jira.instanceId && app.jira.projectKey) {
+ setLoadingTickets(true);
+ api.getMySprintTickets(app.jira.instanceId, app.jira.projectKey)
+ .then(setJiraTickets)
+ .catch(() => setJiraTickets([]))
+ .finally(() => setLoadingTickets(false));
+ }
+ }, [app?.jira?.enabled, app?.jira?.instanceId, app?.jira?.projectKey]);
+
+ const handleUpdate = async () => {
+ setUpdating(true);
+ const result = await api.pullAndUpdateApp(app.id).catch(() => null);
+ setUpdating(false);
+ if (result?.success) {
+ toast.success(`Updated ${app.name} (${result.steps?.length || 0} steps)`);
+ }
+ };
+
+ const handleRefreshConfig = async () => {
+ setRefreshingConfig(true);
+ await api.refreshAppConfig(app.id).catch(() => null);
+ setRefreshingConfig(false);
+ onRefresh();
+ };
+
+ const handleStandardize = async () => {
+ setStandardizing(true);
+ const analysis = await api.analyzeStandardizationByApp(app.id).catch(err => {
+ toast.error(`Analysis failed: ${err.message}`);
+ return null;
+ });
+ if (!analysis?.success) {
+ setStandardizing(false);
+ return;
+ }
+ const result = await api.applyStandardizationByApp(app.id, analysis).catch(err => {
+ toast.error(`Apply failed: ${err.message}`);
+ return null;
+ });
+ setStandardizing(false);
+ if (result?.success) {
+ const msg = result.backupBranch
+ ? `Standardized! Backup: ${result.backupBranch}`
+ : `Standardized ${result.filesModified?.length || 0} files`;
+ toast.success(msg);
+ onRefresh();
+ }
+ };
+
+ const handleArchive = async () => {
+ setArchiving(true);
+ await api.archiveApp(app.id).catch(() => null);
+ setArchiving(false);
+ toast.success(`${app.name} archived - excluded from COS tasks`);
+ onRefresh();
+ };
+
+ const handleUnarchive = async () => {
+ setArchiving(true);
+ await api.unarchiveApp(app.id).catch(() => null);
+ setArchiving(false);
+ toast.success(`${app.name} unarchived - included in COS tasks`);
+ onRefresh();
+ };
+
+ return (
+ <div className="space-y-6 max-w-5xl">
+ {/* Details Grid */}
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4 sm:gap-6">
+ <div>
+ <div className="text-xs text-gray-500 uppercase tracking-wide mb-2">Repository Path</div>
+ <div className="flex items-start gap-2">
+ <FolderOpen size={16} className="text-yellow-400 flex-shrink-0 mt-0.5" />
+ <code className="text-sm text-gray-300 font-mono break-all">{app.repoPath}</code>
+ </div>
+ </div>
+ <div>
+ <div className="text-xs text-gray-500 uppercase tracking-wide mb-2">Editor Command</div>
+ <div className="flex items-center gap-2">
+ <Code size={16} className="text-blue-400 flex-shrink-0" />
+ <code className="text-sm text-gray-300 font-mono">{app.editorCommand || 'code .'}</code>
+ </div>
+ </div>
+ </div>
+
+ {/* Start Commands */}
+ {app.startCommands?.length > 0 && (
+ <div>
+ <div className="text-xs text-gray-500 uppercase tracking-wide mb-2">Start Commands</div>
+ <div className="bg-port-card border border-port-border rounded-lg p-3">
+ {app.startCommands.map((cmd, i) => (
+ <div key={i} className="flex items-start gap-2 py-1">
+ <Terminal size={14} className="text-green-400 flex-shrink-0 mt-0.5" />
+ <code className="text-sm text-cyan-300 font-mono break-all">{cmd}</code>
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+
+ {/* PM2 Processes Status */}
+ {app.pm2Status && Object.keys(app.pm2Status).length > 0 && (
+ <div>
+ <div className="text-xs text-gray-500 uppercase tracking-wide mb-2">PM2 Processes</div>
+ <div className="flex flex-wrap gap-2">
+ {Object.values(app.pm2Status).map((proc, i) => {
+ const processConfig = app.processes?.find(p => p.name === proc.name);
+ return (
+ <div
+ key={i}
+ className="flex flex-wrap items-center gap-2 px-3 py-1.5 bg-port-card border border-port-border rounded-lg"
+ >
+ <span className={`w-2 h-2 rounded-full flex-shrink-0 ${
+ proc.status === 'online' ? 'bg-port-success' :
+ proc.status === 'stopped' ? 'bg-gray-500' : 'bg-port-error'
+ }`} />
+ <span className="text-sm text-white font-mono">{proc.name}</span>
+ {processConfig?.ports && Object.keys(processConfig.ports).length > 0 && (
+ <span className="text-xs text-cyan-400 font-mono">
+ {Object.entries(processConfig.ports).length > 1
+ ? ` (${Object.entries(processConfig.ports).map(([label, port]) => `${label}:${port}`).join(', ')})`
+ : `:${Object.values(processConfig.ports)[0]}`}
+ </span>
+ )}
+ <span className="text-xs text-gray-500">{proc.status}</span>
+ {proc.cpu !== undefined && (
+ <span className="text-xs text-green-400">{proc.cpu}%</span>
+ )}
+ {proc.memory !== undefined && (
+ <span className="text-xs text-blue-400">{(proc.memory / 1024 / 1024).toFixed(0)}MB</span>
+ )}
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ )}
+
+ {/* JIRA Integration */}
+ {app.jira?.enabled && (
+ <div>
+ <div className="text-xs text-gray-500 uppercase tracking-wide mb-2">JIRA Integration</div>
+ <div className="flex flex-wrap items-center gap-3 px-3 py-2 bg-port-card border border-port-border rounded-lg">
+ <Ticket size={16} className="text-blue-400 flex-shrink-0" />
+ <span className="text-sm text-white font-mono">{app.jira.projectKey || '-'}</span>
+ {app.jira.issueType && <span className="text-xs text-gray-400">{app.jira.issueType}</span>}
+ {app.jira.createPR !== false && <span className="text-xs text-green-400">+ PR</span>}
+ {app.jira.labels?.length > 0 && (
+ <span className="text-xs text-cyan-400">{app.jira.labels.join(', ')}</span>
+ )}
+ </div>
+
+ {app.jira.instanceId && app.jira.projectKey && (
+ <div className="mt-3">
+ <div className="text-xs text-gray-500 uppercase tracking-wide mb-2">My Sprint Tickets</div>
+ {loadingTickets ? (
+ <div className="flex items-center gap-2 px-3 py-2 text-sm text-gray-400">
+ <BrailleSpinner text="" />
+ <span>Loading tickets...</span>
+ </div>
+ ) : jiraTickets?.length > 0 ? (
+ <KanbanBoard tickets={jiraTickets} />
+ ) : (
+ <div className="px-3 py-2 text-sm text-gray-500 bg-port-card border border-port-border rounded-lg">
+ No tickets assigned to you in the current sprint
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ )}
+
+ {/* Quick Actions */}
+ <div className="flex flex-wrap gap-2 pt-2">
+ <button
+ onClick={() => api.openAppInEditor(app.id).catch(() => null)}
+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"
+ >
+ <Code size={14} /> Open in Editor
+ </button>
+ <button
+ onClick={() => api.openAppFolder(app.id).catch(() => null)}
+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"
+ >
+ <FolderOpen size={14} /> Open Folder
+ </button>
+ <button
+ onClick={handleUpdate}
+ disabled={updating}
+ className="px-3 py-1.5 bg-port-success/20 text-port-success hover:bg-port-success/30 rounded-lg text-xs flex items-center gap-1 disabled:opacity-50"
+ >
+ <Download size={14} className={updating ? 'animate-bounce' : ''} />
+ {updating ? 'Updating...' : 'Update'}
+ </button>
+ <button
+ onClick={handleRefreshConfig}
+ disabled={refreshingConfig}
+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1 disabled:opacity-50"
+ >
+ <RefreshCw size={14} className={refreshingConfig ? 'animate-spin' : ''} />
+ Refresh Config
+ </button>
+ <button
+ onClick={handleStandardize}
+ disabled={standardizing}
+ className="px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded-lg text-xs flex items-center gap-1 disabled:opacity-50"
+ >
+ <Wrench size={14} className={standardizing ? 'animate-spin' : ''} />
+ {standardizing ? 'Standardizing...' : 'Standardize PM2'}
+ </button>
+ <button
+ onClick={() => setEditingApp(app)}
+ className="px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded-lg text-xs flex items-center gap-1"
+ >
+ Edit
+ </button>
+ {app.id !== api.PORTOS_APP_ID && (
+ <button
+ onClick={app.archived ? handleUnarchive : handleArchive}
+ disabled={archiving}
+ 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'
+ }`}
+ >
+ {app.archived ? <ArchiveRestore size={14} /> : <Archive size={14} />}
+ {archiving ? '...' : app.archived ? 'Unarchive' : 'Archive'}
+ </button>
+ )}
+ </div>
+
+ {/* Edit Modal */}
+ {editingApp && (
+ <EditAppModal
+ app={editingApp}
+ onClose={() => setEditingApp(null)}
+ onSave={() => { setEditingApp(null); onRefresh(); }}
+ />
+ )}
+ </div>
+ );
+}
diff --git a/client/src/components/apps/tabs/TasksTab.jsx b/client/src/components/apps/tabs/TasksTab.jsx
new file mode 100644
index 0000000000..56d4ba5aa1
--- /dev/null
+++ b/client/src/components/apps/tabs/TasksTab.jsx
@@ -0,0 +1,159 @@
+import { useState, useEffect } from 'react';
+import { Link } from 'react-router-dom';
+import { RefreshCw, Clock, CheckCircle, XCircle, Activity } from 'lucide-react';
+import BrailleSpinner from '../../BrailleSpinner';
+import * as api from '../../../services/api';
+
+const STATUS_CONFIG = {
+ running: { color: 'bg-port-accent', text: 'Running' },
+ spawning: { color: 'bg-port-warning', text: 'Spawning' },
+ completed: { color: 'bg-port-success', text: 'Completed' },
+ failed: { color: 'bg-port-error', text: 'Failed' },
+ error: { color: 'bg-port-error', text: 'Error' },
+ cancelled: { color: 'bg-gray-500', text: 'Cancelled' }
+};
+
+function formatDuration(ms) {
+ if (!ms) return '-';
+ const seconds = Math.floor(ms / 1000);
+ if (seconds < 60) return `${seconds}s`;
+ const minutes = Math.floor(seconds / 60);
+ if (minutes < 60) return `${minutes}m ${seconds % 60}s`;
+ const hours = Math.floor(minutes / 60);
+ return `${hours}h ${minutes % 60}m`;
+}
+
+function formatTime(dateStr) {
+ if (!dateStr) return '-';
+ const d = new Date(dateStr);
+ const now = new Date();
+ const diff = now - d;
+ if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`;
+ if (diff < 86400000) return `${Math.floor(diff / 3600000)}h ago`;
+ return d.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
+}
+
+export default function TasksTab({ appId }) {
+ const [data, setData] = useState(null);
+ const [loading, setLoading] = useState(true);
+
+ const fetchAgents = async () => {
+ setLoading(true);
+ const result = await api.getAppAgents(appId).catch(() => ({ agents: [], summary: {} }));
+ setData(result);
+ setLoading(false);
+ };
+
+ useEffect(() => {
+ fetchAgents();
+ }, [appId]);
+
+ if (loading) {
+ return <BrailleSpinner text="Loading agent history" />;
+ }
+
+ const { agents = [], summary = {} } = data || {};
+ const successRate = summary.total > 0
+ ? Math.round((summary.succeeded / summary.total) * 100)
+ : 0;
+
+ return (
+ <div className="max-w-5xl space-y-4">
+ <div className="flex items-center justify-between">
+ <h3 className="text-lg font-semibold text-white">Recent Agent Tasks</h3>
+ <button
+ onClick={fetchAgents}
+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"
+ >
+ <RefreshCw size={14} /> Refresh
+ </button>
+ </div>
+
+ {/* Summary Stats */}
+ <div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
+ <div className="bg-port-card border border-port-border rounded-lg p-3 text-center">
+ <div className="text-2xl font-bold text-white">{summary.total || 0}</div>
+ <div className="text-xs text-gray-500">Total</div>
+ </div>
+ <div className="bg-port-card border border-port-border rounded-lg p-3 text-center">
+ <div className="text-2xl font-bold text-port-accent">{summary.running || 0}</div>
+ <div className="text-xs text-gray-500">Running</div>
+ </div>
+ <div className="bg-port-card border border-port-border rounded-lg p-3 text-center">
+ <div className="text-2xl font-bold text-port-success">{summary.succeeded || 0}</div>
+ <div className="text-xs text-gray-500">Succeeded</div>
+ </div>
+ <div className="bg-port-card border border-port-border rounded-lg p-3 text-center">
+ <div className="text-2xl font-bold text-white">{successRate}%</div>
+ <div className="text-xs text-gray-500">Success Rate</div>
+ </div>
+ </div>
+
+ {/* Agent List */}
+ {agents.length === 0 ? (
+ <div className="bg-port-card border border-port-border rounded-lg p-8 text-center">
+ <Activity size={32} className="text-gray-600 mx-auto mb-3" />
+ <p className="text-gray-400">No agent tasks found for this app in the last 14 days</p>
+ </div>
+ ) : (
+ <div className="bg-port-card border border-port-border rounded-lg overflow-hidden">
+ <div className="overflow-x-auto">
+ <table className="w-full text-sm">
+ <thead>
+ <tr className="border-b border-port-border">
+ <th className="text-left px-4 py-3 text-xs text-gray-500 uppercase tracking-wide font-medium">Description</th>
+ <th className="text-left px-4 py-3 text-xs text-gray-500 uppercase tracking-wide font-medium">Type</th>
+ <th className="text-center px-4 py-3 text-xs text-gray-500 uppercase tracking-wide font-medium">Status</th>
+ <th className="text-right px-4 py-3 text-xs text-gray-500 uppercase tracking-wide font-medium">Duration</th>
+ <th className="text-right px-4 py-3 text-xs text-gray-500 uppercase tracking-wide font-medium">When</th>
+ </tr>
+ </thead>
+ <tbody>
+ {agents.map(agent => {
+ const statusCfg = STATUS_CONFIG[agent.status] || { color: 'bg-gray-600', text: agent.status };
+ const duration = agent.completedAt && agent.startedAt
+ ? new Date(agent.completedAt) - new Date(agent.startedAt)
+ : null;
+ const taskType = agent.metadata?.taskType || agent.metadata?.type || '-';
+ const description = agent.metadata?.taskDescription || agent.metadata?.description || agent.id;
+
+ return (
+ <tr key={agent.id} className="border-b border-port-border/50 hover:bg-white/5">
+ <td className="px-4 py-3">
+ <Link
+ to={`/cos/agents`}
+ className="text-gray-300 hover:text-port-accent text-xs line-clamp-2"
+ >
+ {description}
+ </Link>
+ </td>
+ <td className="px-4 py-3">
+ <span className="text-xs text-gray-400 font-mono">{taskType}</span>
+ </td>
+ <td className="px-4 py-3 text-center">
+ <span className={`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs text-white ${statusCfg.color}`}>
+ {statusCfg.text}
+ </span>
+ </td>
+ <td className="px-4 py-3 text-right">
+ <span className="text-xs text-gray-400 flex items-center justify-end gap-1">
+ <Clock size={12} />
+ {formatDuration(duration)}
+ </span>
+ </td>
+ <td className="px-4 py-3 text-right">
+ <span className="text-xs text-gray-500">
+ {formatTime(agent.completedAt || agent.startedAt)}
+ </span>
+ </td>
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/client/src/components/cos/tabs/GsdProjectCard.jsx b/client/src/components/cos/tabs/GsdProjectCard.jsx
index 8741543886..eec179d718 100644
--- a/client/src/components/cos/tabs/GsdProjectCard.jsx
+++ b/client/src/components/cos/tabs/GsdProjectCard.jsx
@@ -1,48 +1,10 @@
import { useState } from 'react';
-import { ChevronDown, ChevronUp } from 'lucide-react';
+import { Link } from 'react-router-dom';
+import { ChevronDown, ChevronUp, ExternalLink } from 'lucide-react';
import toast from 'react-hot-toast';
import * as api from '../../../services/api';
import GsdConcernsPanel from './GsdConcernsPanel';
-
-const PHASE_STATUS_COLORS = {
- completed: 'bg-port-success',
- 'in-progress': 'bg-port-accent',
- planned: 'bg-port-warning',
- pending: 'bg-gray-600'
-};
-
-const LIFECYCLE_STEPS = ['research', 'plan', 'execute', 'verify'];
-
-function PhaseTimeline({ phases = [] }) {
- if (phases.length === 0) return <p className="text-xs text-gray-500 italic">No phases found</p>;
-
- return (
- <div className="space-y-1.5">
- {phases.map(phase => (
- <div key={phase.id || phase.name} className="flex items-center gap-2">
- <div className={`w-2 h-2 rounded-full shrink-0 ${PHASE_STATUS_COLORS[phase.status] || 'bg-gray-600'}`} />
- <span className="text-xs text-gray-400 font-mono w-8 shrink-0">{phase.id || '??'}</span>
- <span className="text-xs text-gray-300 truncate flex-1">{phase.title || phase.name}</span>
- {phase.lifecycle && (
- <div className="flex gap-0.5">
- {LIFECYCLE_STEPS.map(step => (
- <div
- key={step}
- className={`w-1.5 h-1.5 rounded-full ${
- phase.lifecycle[step] === 'done' ? 'bg-port-success' :
- phase.lifecycle[step] === 'active' ? 'bg-port-accent' :
- 'bg-gray-700'
- }`}
- title={`${step}: ${phase.lifecycle[step] || 'pending'}`}
- />
- ))}
- </div>
- )}
- </div>
- ))}
- </div>
- );
-}
+import PhaseTimeline from '../../gsd/PhaseTimeline';
export default function GsdProjectCard({ project, onRefresh }) {
const [expanded, setExpanded] = useState(false);
@@ -83,6 +45,13 @@ export default function GsdProjectCard({ project, onRefresh }) {
)}
</div>
<div className="flex items-center gap-2">
+ <Link
+ to={`/apps/${project.appId}/gsd`}
+ onClick={e => e.stopPropagation()}
+ className="text-[10px] px-1.5 py-0.5 rounded bg-port-accent/20 text-port-accent hover:bg-port-accent/30 flex items-center gap-1"
+ >
+ Dashboard <ExternalLink size={10} />
+ </Link>
{project.hasConcerns && (
<span className="text-[10px] px-1.5 py-0.5 rounded bg-port-warning/20 text-port-warning">concerns</span>
)}
diff --git a/client/src/components/gsd/PhaseTimeline.jsx b/client/src/components/gsd/PhaseTimeline.jsx
new file mode 100644
index 0000000000..f38c0f1f47
--- /dev/null
+++ b/client/src/components/gsd/PhaseTimeline.jsx
@@ -0,0 +1,39 @@
+const PHASE_STATUS_COLORS = {
+ completed: 'bg-port-success',
+ 'in-progress': 'bg-port-accent',
+ planned: 'bg-port-warning',
+ pending: 'bg-gray-600'
+};
+
+const LIFECYCLE_STEPS = ['research', 'plan', 'execute', 'verify'];
+
+export default function PhaseTimeline({ phases = [] }) {
+ if (phases.length === 0) return <p className="text-xs text-gray-500 italic">No phases found</p>;
+
+ return (
+ <div className="space-y-1.5">
+ {phases.map(phase => (
+ <div key={phase.id || phase.name} className="flex items-center gap-2">
+ <div className={`w-2 h-2 rounded-full shrink-0 ${PHASE_STATUS_COLORS[phase.status] || 'bg-gray-600'}`} />
+ <span className="text-xs text-gray-400 font-mono w-8 shrink-0">{phase.id || '??'}</span>
+ <span className="text-xs text-gray-300 truncate flex-1">{phase.title || phase.name}</span>
+ {phase.lifecycle && (
+ <div className="flex gap-0.5">
+ {LIFECYCLE_STEPS.map(step => (
+ <div
+ key={step}
+ className={`w-1.5 h-1.5 rounded-full ${
+ phase.lifecycle[step] === 'done' ? 'bg-port-success' :
+ phase.lifecycle[step] === 'active' ? 'bg-port-accent' :
+ 'bg-gray-700'
+ }`}
+ title={`${step}: ${phase.lifecycle[step] || 'pending'}`}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ ))}
+ </div>
+ );
+}
diff --git a/client/src/pages/AppDetail.jsx b/client/src/pages/AppDetail.jsx
new file mode 100644
index 0000000000..0d680f9854
--- /dev/null
+++ b/client/src/pages/AppDetail.jsx
@@ -0,0 +1,16 @@
+import { useParams, Navigate } from 'react-router-dom';
+import AppDetailView from '../components/apps/AppDetailView';
+
+export default function AppDetail() {
+ const { appId, tab } = useParams();
+
+ if (!appId) {
+ return <Navigate to="/apps" replace />;
+ }
+
+ if (!tab) {
+ return <Navigate to={`/apps/${appId}/overview`} replace />;
+ }
+
+ return <AppDetailView />;
+}
diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsx
index d3e97a5733..a8e4f9258f 100644
--- a/client/src/pages/Apps.jsx
+++ b/client/src/pages/Apps.jsx
@@ -4,7 +4,6 @@ import { ExternalLink, Play, Square, RotateCcw, FolderOpen, Terminal, Code, Refr
import toast from 'react-hot-toast';
import BrailleSpinner from '../components/BrailleSpinner';
import StatusBadge from '../components/StatusBadge';
-import IconPicker from '../components/IconPicker';
import * as api from '../services/api';
import socket from '../services/socket';
@@ -83,7 +82,6 @@ function KanbanBoard({ tickets }) {
export default function Apps() {
const [apps, setApps] = useState([]);
const [loading, setLoading] = useState(true);
- const [editingApp, setEditingApp] = useState(null);
const [confirmingDelete, setConfirmingDelete] = useState(null);
const [expandedId, setExpandedId] = useState(null);
const [actionLoading, setActionLoading] = useState({});
@@ -305,7 +303,7 @@ export default function Apps() {
</button>
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-center gap-2">
- <span className={`font-medium ${app.archived ? 'text-gray-400' : 'text-white'}`}>{app.name}</span>
+ <Link to={`/apps/${app.id}`} className={`font-medium hover:underline ${app.archived ? 'text-gray-400' : 'text-white'}`}>{app.name}</Link>
{app.archived && (
<span className="px-1.5 py-0.5 bg-port-warning/20 text-port-warning text-xs rounded">
Archived
@@ -427,13 +425,13 @@ export default function Apps() {
</button>
)}
<div className="inline-flex rounded-lg overflow-hidden border border-port-border">
- <button
- onClick={() => setEditingApp(app)}
+ <Link
+ to={`/apps/${app.id}/overview`}
className="px-3 py-1.5 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 transition-colors text-xs focus:outline-none focus:ring-2 focus:ring-port-accent"
- aria-label={`Edit ${app.name}`}
+ aria-label={`Manage ${app.name}`}
>
- Edit
- </button>
+ Manage
+ </Link>
{app.id !== api.PORTOS_APP_ID && (
<button
onClick={() => setConfirmingDelete(app.id)}
@@ -614,452 +612,7 @@ export default function Apps() {
</div>
)}
- {/* Edit Modal */}
- {editingApp && (
- <EditAppModal
- app={editingApp}
- onClose={() => setEditingApp(null)}
- onSave={() => { setEditingApp(null); fetchApps(); }}
- />
- )}
</div>
);
}
-function EditAppModal({ app, onClose, onSave }) {
- const [formData, setFormData] = useState({
- name: app.name,
- icon: app.icon || 'package',
- repoPath: app.repoPath,
- uiPort: app.uiPort || '',
- apiPort: app.apiPort || '',
- startCommands: (app.startCommands || []).join('\n'),
- pm2ProcessNames: (app.pm2ProcessNames || []).join(', '),
- editorCommand: app.editorCommand || 'code .',
- defaultUseWorktree: app.defaultUseWorktree || false,
- jiraEnabled: app.jira?.enabled || false,
- jiraInstanceId: app.jira?.instanceId || '',
- jiraProjectKey: app.jira?.projectKey || '',
- jiraBoardId: app.jira?.boardId || '',
- jiraIssueType: app.jira?.issueType || 'Task',
- jiraLabels: (app.jira?.labels || []).join(', '),
- jiraAssignee: app.jira?.assignee || '',
- jiraEpicKey: app.jira?.epicKey || '',
- jiraCreatePR: app.jira?.createPR !== false
- });
- const [saving, setSaving] = useState(false);
- const [error, setError] = useState(null);
- const [jiraExpanded, setJiraExpanded] = useState(app.jira?.enabled || false);
- const [jiraInstances, setJiraInstances] = useState([]);
- const [jiraProjects, setJiraProjects] = useState([]);
- const [loadingProjects, setLoadingProjects] = useState(false);
- const [projectSearch, setProjectSearch] = useState('');
- const [projectDropdownOpen, setProjectDropdownOpen] = useState(false);
-
- // Fetch JIRA instances on mount
- useEffect(() => {
- api.getJiraInstances().then(data => {
- const instances = data?.instances ? Object.values(data.instances) : [];
- setJiraInstances(instances);
- }).catch(() => setJiraInstances([]));
- }, []);
-
- // Fetch JIRA projects when instance changes
- useEffect(() => {
- if (!formData.jiraInstanceId) {
- setJiraProjects([]);
- return;
- }
- setLoadingProjects(true);
- api.getJiraProjects(formData.jiraInstanceId).then(projects => {
- setJiraProjects(projects || []);
- }).catch(() => setJiraProjects([])).finally(() => setLoadingProjects(false));
- }, [formData.jiraInstanceId]);
-
- // Default assignee to the configured JIRA user when instances load or instance changes
- useEffect(() => {
- if (!formData.jiraInstanceId || formData.jiraAssignee) return;
- const inst = jiraInstances.find(i => i.id === formData.jiraInstanceId);
- if (inst?.email) {
- setFormData(prev => ({ ...prev, jiraAssignee: inst.email }));
- }
- }, [formData.jiraInstanceId, jiraInstances, formData.jiraAssignee]);
-
- const handleSubmit = async (e) => {
- e.preventDefault();
- setError(null);
- setSaving(true);
-
- const data = {
- name: formData.name,
- icon: formData.icon,
- repoPath: formData.repoPath,
- uiPort: formData.uiPort ? parseInt(formData.uiPort, 10) : null,
- apiPort: formData.apiPort ? parseInt(formData.apiPort, 10) : null,
- startCommands: formData.startCommands.split('\n').filter(Boolean),
- pm2ProcessNames: formData.pm2ProcessNames
- ? formData.pm2ProcessNames.split(',').map(s => s.trim()).filter(Boolean)
- : undefined,
- editorCommand: formData.editorCommand || undefined,
- defaultUseWorktree: formData.defaultUseWorktree,
- jira: formData.jiraEnabled ? {
- enabled: true,
- instanceId: formData.jiraInstanceId || undefined,
- projectKey: formData.jiraProjectKey || undefined,
- boardId: formData.jiraBoardId || undefined,
- issueType: formData.jiraIssueType || 'Task',
- labels: formData.jiraLabels ? formData.jiraLabels.split(',').map(s => s.trim()).filter(Boolean) : [],
- assignee: formData.jiraAssignee || undefined,
- epicKey: formData.jiraEpicKey || undefined,
- createPR: formData.jiraCreatePR
- } : { enabled: false }
- };
-
- await api.updateApp(app.id, data).catch(err => {
- setError(err.message);
- setSaving(false);
- throw err;
- });
-
- setSaving(false);
- onSave();
- };
-
- return (
- <div
- className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4"
- role="dialog"
- aria-modal="true"
- aria-labelledby="edit-app-title"
- >
- <div className="bg-port-card border border-port-border rounded-xl p-4 sm:p-6 w-full max-w-lg max-h-[90vh] overflow-auto">
- <h2 id="edit-app-title" className="text-xl font-bold text-white mb-4">Edit App</h2>
-
- {error && (
- <div className="mb-4 p-3 bg-port-error/20 border border-port-error rounded-lg text-port-error text-sm">
- {error}
- </div>
- )}
-
- <form onSubmit={handleSubmit} className="space-y-4">
- <div className="grid grid-cols-1 sm:grid-cols-[1fr_auto] gap-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Name</label>
- <input
- type="text"
- value={formData.name}
- onChange={e => setFormData({ ...formData, name: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- required
- />
- </div>
- <div className="w-full sm:w-32">
- <IconPicker value={formData.icon} onChange={icon => setFormData({ ...formData, icon })} />
- </div>
- </div>
-
- <div>
- <label className="block text-sm text-gray-400 mb-1">Repository Path</label>
- <input
- type="text"
- value={formData.repoPath}
- onChange={e => setFormData({ ...formData, repoPath: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- required
- />
- </div>
-
- <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
- <div>
- <label className="block text-sm text-gray-400 mb-1">UI Port</label>
- <input
- type="number"
- value={formData.uiPort}
- onChange={e => setFormData({ ...formData, uiPort: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- placeholder="3000"
- />
- </div>
-
- <div>
- <label className="block text-sm text-gray-400 mb-1">API Port</label>
- <input
- type="number"
- value={formData.apiPort}
- onChange={e => setFormData({ ...formData, apiPort: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- placeholder="3001"
- />
- </div>
- </div>
-
- <div>
- <label className="block text-sm text-gray-400 mb-1">Start Commands (one per line)</label>
- <textarea
- value={formData.startCommands}
- onChange={e => setFormData({ ...formData, startCommands: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none font-mono text-sm"
- rows={2}
- />
- </div>
-
- <div>
- <label className="block text-sm text-gray-400 mb-1">PM2 Process Names (comma-separated)</label>
- <input
- type="text"
- value={formData.pm2ProcessNames}
- onChange={e => setFormData({ ...formData, pm2ProcessNames: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- />
- </div>
-
- <div>
- <label className="block text-sm text-gray-400 mb-1">Editor Command</label>
- <input
- type="text"
- value={formData.editorCommand}
- onChange={e => setFormData({ ...formData, editorCommand: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- />
- </div>
-
- {/* Git Worktree Default */}
- <label className="flex items-center gap-2 cursor-pointer">
- <input
- type="checkbox"
- checked={formData.defaultUseWorktree}
- onChange={e => setFormData({ ...formData, defaultUseWorktree: e.target.checked })}
- className="rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent"
- />
- <GitBranch size={14} className="text-emerald-400" />
- <span className="text-sm text-white">Default to Branch + PR for new tasks</span>
- </label>
-
- {/* JIRA Integration Section */}
- <div className="border border-port-border rounded-lg overflow-hidden">
- <button
- type="button"
- onClick={() => setJiraExpanded(prev => !prev)}
- className="w-full flex items-center justify-between px-4 py-3 bg-port-bg hover:bg-port-border/50 transition-colors"
- >
- <span className="text-sm font-medium text-gray-300">JIRA Integration</span>
- <div className="flex items-center gap-2">
- {formData.jiraEnabled && (
- <span className="text-xs px-2 py-0.5 bg-port-accent/20 text-port-accent rounded">Enabled</span>
- )}
- {jiraExpanded ? <ChevronUp size={16} className="text-gray-400" /> : <ChevronDown size={16} className="text-gray-400" />}
- </div>
- </button>
-
- {jiraExpanded && (
- <div className="p-4 space-y-3 border-t border-port-border">
- <label className="flex items-center gap-2 cursor-pointer">
- <input
- type="checkbox"
- checked={formData.jiraEnabled}
- onChange={e => setFormData({ ...formData, jiraEnabled: e.target.checked })}
- className="rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent"
- />
- <span className="text-sm text-white">Enable JIRA Integration</span>
- </label>
-
- {formData.jiraEnabled && (
- <>
- {jiraInstances.length === 0 ? (
- <div className="p-3 bg-port-warning/10 border border-port-warning/30 rounded-lg text-sm text-port-warning">
- No JIRA instances configured. <Link to="/jira" className="underline hover:text-white">Configure JIRA</Link> first.
- </div>
- ) : (
- <>
- <div>
- <label className="block text-sm text-gray-400 mb-1">JIRA Instance</label>
- <select
- value={formData.jiraInstanceId}
- onChange={e => setFormData({ ...formData, jiraInstanceId: e.target.value, jiraProjectKey: '' })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- >
- <option value="">Select instance...</option>
- {jiraInstances.map(inst => (
- <option key={inst.id} value={inst.id}>{inst.name} ({inst.baseUrl})</option>
- ))}
- </select>
- </div>
-
- <div className="relative">
- <label className="block text-sm text-gray-400 mb-1">Project Key</label>
- {loadingProjects ? (
- <div className="text-xs text-gray-500">Loading projects...</div>
- ) : jiraProjects.length > 0 ? (
- <div>
- <input
- type="text"
- value={projectDropdownOpen ? projectSearch : (
- formData.jiraProjectKey
- ? `${formData.jiraProjectKey} - ${jiraProjects.find(p => p.key === formData.jiraProjectKey)?.name || ''}`
- : ''
- )}
- onChange={e => {
- setProjectSearch(e.target.value);
- if (!projectDropdownOpen) setProjectDropdownOpen(true);
- }}
- onFocus={() => {
- setProjectDropdownOpen(true);
- setProjectSearch('');
- }}
- onBlur={() => setTimeout(() => setProjectDropdownOpen(false), 150)}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- placeholder="Search projects..."
- />
- {formData.jiraProjectKey && !projectDropdownOpen && (
- <button
- type="button"
- onClick={() => setFormData({ ...formData, jiraProjectKey: '' })}
- className="absolute right-2 top-8 text-gray-500 hover:text-white text-sm"
- >
- ✕
- </button>
- )}
- {projectDropdownOpen && (
- <div className="absolute z-50 w-full mt-1 bg-port-bg border border-port-border rounded-lg max-h-48 overflow-auto shadow-lg">
- {jiraProjects
- .filter(proj => {
- if (!projectSearch) return true;
- const q = projectSearch.toLowerCase();
- return proj.key.toLowerCase().includes(q) || proj.name.toLowerCase().includes(q);
- })
- .sort((a, b) => a.key.localeCompare(b.key))
- .slice(0, 100)
- .map(proj => (
- <button
- key={proj.key}
- type="button"
- onMouseDown={e => {
- e.preventDefault();
- setFormData({ ...formData, jiraProjectKey: proj.key });
- setProjectDropdownOpen(false);
- setProjectSearch('');
- }}
- className={`w-full text-left px-3 py-2 text-sm hover:bg-port-accent/20 ${
- formData.jiraProjectKey === proj.key ? 'bg-port-accent/10 text-port-accent' : 'text-white'
- }`}
- >
- <span className="font-mono">{proj.key}</span>
- <span className="text-gray-400 ml-2">{proj.name}</span>
- </button>
- ))
- }
- {jiraProjects.filter(proj => {
- if (!projectSearch) return true;
- const q = projectSearch.toLowerCase();
- return proj.key.toLowerCase().includes(q) || proj.name.toLowerCase().includes(q);
- }).length === 0 && (
- <div className="px-3 py-2 text-sm text-gray-500">No matching projects</div>
- )}
- </div>
- )}
- </div>
- ) : (
- <input
- type="text"
- value={formData.jiraProjectKey}
- onChange={e => setFormData({ ...formData, jiraProjectKey: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- placeholder="e.g. CONTECH"
- />
- )}
- </div>
-
- <div>
- <label className="block text-sm text-gray-400 mb-1">Board ID</label>
- <input
- type="text"
- value={formData.jiraBoardId}
- onChange={e => setFormData({ ...formData, jiraBoardId: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- placeholder="e.g. 11810 (from JIRA board URL rapidView param)"
- />
- </div>
-
- <div className="grid grid-cols-2 gap-3">
- <div>
- <label className="block text-sm text-gray-400 mb-1">Issue Type</label>
- <input
- type="text"
- value={formData.jiraIssueType}
- onChange={e => setFormData({ ...formData, jiraIssueType: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- placeholder="Task"
- />
- </div>
- <div>
- <label className="block text-sm text-gray-400 mb-1">Assignee</label>
- <input
- type="text"
- value={formData.jiraAssignee}
- onChange={e => setFormData({ ...formData, jiraAssignee: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- placeholder="Optional"
- />
- </div>
- </div>
-
- <div>
- <label className="block text-sm text-gray-400 mb-1">Labels (comma-separated)</label>
- <input
- type="text"
- value={formData.jiraLabels}
- onChange={e => setFormData({ ...formData, jiraLabels: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- placeholder="e.g. cos-auto, feature"
- />
- </div>
-
- <div>
- <label className="block text-sm text-gray-400 mb-1">Epic Key</label>
- <input
- type="text"
- value={formData.jiraEpicKey}
- onChange={e => setFormData({ ...formData, jiraEpicKey: e.target.value })}
- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-none"
- placeholder="e.g. CONTECH-100"
- />
- </div>
-
- <label className="flex items-center gap-2 cursor-pointer">
- <input
- type="checkbox"
- checked={formData.jiraCreatePR}
- onChange={e => setFormData({ ...formData, jiraCreatePR: e.target.checked })}
- className="rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent"
- />
- <span className="text-sm text-white">Create Pull Request on completion</span>
- </label>
- </>
- )}
- </>
- )}
- </div>
- )}
- </div>
-
- <div className="flex justify-end gap-3 pt-4">
- <button
- type="button"
- onClick={onClose}
- className="px-4 py-2 text-gray-400 hover:text-white"
- >
- Cancel
- </button>
- <button
- type="submit"
- disabled={saving}
- className="px-6 py-2 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors disabled:opacity-50"
- >
- {saving ? 'Saving...' : 'Save Changes'}
- </button>
- </div>
- </form>
- </div>
- </div>
- );
-}
diff --git a/client/src/services/api.js b/client/src/services/api.js
index 700b02b57d..20a1915e04 100644
--- a/client/src/services/api.js
+++ b/client/src/services/api.js
@@ -130,6 +130,10 @@ export const getAppLogs = (id, lines = 100, processName) => {
return request(`/apps/${id}/logs?${params}`);
};
+export const getAppDocuments = (id) => request(`/apps/${id}/documents`);
+export const getAppDocument = (id, filename) => request(`/apps/${id}/documents/${filename}`);
+export const getAppAgents = (id, limit = 50) => request(`/apps/${id}/agents?limit=${limit}`);
+
// Ports
export const scanPorts = () => request('/ports/scan');
export const checkPorts = (ports) => request('/ports/check', {
diff --git a/package-lock.json b/package-lock.json
index 4f8f58d15f..3aa1f61d72 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "1.18.1",
+ "version": "1.19.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "1.18.1",
+ "version": "1.19.0",
"license": "MIT",
"dependencies": {
"express": "^4.21.2",
diff --git a/package.json b/package.json
index 1efeefedb0..2032cad25e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "1.18.1",
+ "version": "1.19.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 3c3abdd60f..963d810678 100644
--- a/server/routes/apps.js
+++ b/server/routes/apps.js
@@ -1,10 +1,13 @@
import { Router } from 'express';
import { spawn } from 'child_process';
import { existsSync } from 'fs';
+import { readFile } from 'fs/promises';
+import { join, resolve } from 'path';
import * as appsService from '../services/apps.js';
import { notifyAppsChanged, PORTOS_APP_ID } from '../services/apps.js';
import * as pm2Service from '../services/pm2.js';
import * as appUpdater from '../services/appUpdater.js';
+import * as cos from '../services/cos.js';
import { logAction } from '../services/history.js';
import { validateRequest, appSchema, appUpdateSchema } from '../lib/validation.js';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
@@ -504,4 +507,106 @@ router.post('/:id/refresh-config', loadApp, asyncHandler(async (req, res) => {
}
}));
+// ============================================================
+// Document Endpoints
+// ============================================================
+
+const ALLOWED_DOCUMENTS = ['PLAN.md', 'CLAUDE.md', 'GOALS.md'];
+
+// GET /api/apps/:id/documents - List which documents exist
+router.get('/:id/documents', loadApp, asyncHandler(async (req, res) => {
+ const app = req.loadedApp;
+
+ if (!app.repoPath || !existsSync(app.repoPath)) {
+ return res.json({ documents: [], hasPlanning: false });
+ }
+
+ const documents = ALLOWED_DOCUMENTS.map(filename => ({
+ filename,
+ exists: existsSync(join(app.repoPath, filename))
+ }));
+
+ const hasPlanning = existsSync(join(app.repoPath, '.planning'));
+
+ res.json({ documents, hasPlanning });
+}));
+
+// GET /api/apps/:id/documents/:filename - Read a single document
+router.get('/:id/documents/:filename', loadApp, asyncHandler(async (req, res) => {
+ const app = req.loadedApp;
+ const { filename } = req.params;
+
+ if (!ALLOWED_DOCUMENTS.includes(filename)) {
+ throw new ServerError('Document not in allowlist', { status: 400, code: 'INVALID_DOCUMENT' });
+ }
+
+ if (!app.repoPath || !existsSync(app.repoPath)) {
+ throw new ServerError('App repo path does not exist', { status: 400, code: 'PATH_NOT_FOUND' });
+ }
+
+ const filePath = join(app.repoPath, filename);
+ const resolved = resolve(filePath);
+
+ // Path traversal guard
+ if (!resolved.startsWith(resolve(app.repoPath))) {
+ throw new ServerError('Invalid document path', { status: 400, code: 'PATH_TRAVERSAL' });
+ }
+
+ if (!existsSync(resolved)) {
+ throw new ServerError('Document not found', { status: 404, code: 'NOT_FOUND' });
+ }
+
+ const content = await readFile(resolved, 'utf-8');
+ res.json({ filename, content });
+}));
+
+// ============================================================
+// Agent History Endpoints
+// ============================================================
+
+// GET /api/apps/:id/agents - Recent CoS agents for this app
+router.get('/:id/agents', loadApp, asyncHandler(async (req, res) => {
+ const app = req.loadedApp;
+ const limit = parseInt(req.query.limit, 10) || 50;
+
+ // Get running agents filtered by this app
+ const runningAgents = await cos.getAgents().catch(() => []);
+ const appRunning = runningAgents.filter(a =>
+ a.metadata?.app === app.id || a.metadata?.taskApp === app.id
+ );
+
+ // Scan last 14 days of agent history for this app
+ const dates = await cos.getAgentDates().catch(() => []);
+ const recentDates = dates.slice(0, 14);
+ const historyAgents = [];
+
+ for (const { date } of recentDates) {
+ if (historyAgents.length >= limit) break;
+ const dayAgents = await cos.getAgentsByDate(date).catch(() => []);
+ const appAgents = dayAgents.filter(a =>
+ a.metadata?.app === app.id || a.metadata?.taskApp === app.id
+ );
+ historyAgents.push(...appAgents);
+ }
+
+ // Combine running + history, deduplicate by id, limit
+ const seenIds = new Set();
+ const combined = [];
+ for (const agent of [...appRunning, ...historyAgents]) {
+ if (seenIds.has(agent.id)) continue;
+ seenIds.add(agent.id);
+ combined.push(agent);
+ if (combined.length >= limit) break;
+ }
+
+ const running = combined.filter(a => a.status === 'running' || a.status === 'spawning').length;
+ const succeeded = combined.filter(a => a.status === 'completed').length;
+ const failed = combined.filter(a => a.status === 'failed' || a.status === 'error').length;
+
+ res.json({
+ agents: combined,
+ summary: { total: combined.length, running, succeeded, failed }
+ });
+}));
+
export default router;