Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: make Apps collection-first with truthful load states (#7860)
[._.]/ Adam Eivy11ca64919a04
diff --git a/client/src/components/apps/AppDetailView.jsx b/client/src/components/apps/AppDetailView.jsxindex 71122a5531..1ede319e74 100644--- a/client/src/components/apps/AppDetailView.jsx+++ b/client/src/components/apps/AppDetailView.jsx@@ -70,6 +70,7 @@ function AppDetail() {const [app, setApp] = useState(null);const [loading, setLoading] = useState(true);const [notFound, setNotFound] = useState(false);+ const [loadError, setLoadError] = useState(null);const [actionLoading, setActionLoading] = useState(null);// PM2 process whose live output the desktop launch panel is tailing (null = hidden).const [launchProcess, setLaunchProcess] = useState(null);@@ -85,16 +86,27 @@ function AppDetail() {const { features: instanceFeatures, error: instanceFeaturesError } = useInstanceFeatures();const fetchSeqRef = useRef(0);+ const appRef = useRef(null);const fetchApp = useCallback(async () => {const seq = ++fetchSeqRef.current;- const data = await api.getApp(appId, { includeQuality: true, silent: true }).catch(() => null);+ if (!appRef.current) setLoading(true);+ const result = await api.getApp(appId, { includeQuality: true, silent: true })+ .then(data => ({ data }))+ .catch(error => ({ error }));if (seq !== fetchSeqRef.current) return;- setNotFound(!data);- if (!data) {+ if (result.error) {+ const missing = result.error.status === 404;+ appRef.current = null;+ setApp(null);+ setNotFound(missing);+ setLoadError(missing ? null : result.error);setLoading(false);return;}- setApp(data);+ appRef.current = result.data;+ setNotFound(!result.data);+ setLoadError(null);+ setApp(result.data);setLoading(false);}, [appId]);@@ -269,9 +281,37 @@ function AppDetail() {);}+ if (loadError) {+ return (+ <div className="p-4 sm:p-6">+ <div role="alert" className="mx-auto max-w-2xl rounded-xl border border-port-error/40 bg-port-card p-6">+ <div className="flex items-start gap-3">+ <AlertTriangle size={20} aria-hidden="true" className="mt-0.5 shrink-0 text-port-error" />+ <div className="min-w-0">+ <h1 className="text-xl font-semibold text-white">App unavailable</h1>+ <p className="mt-2 text-sm text-gray-400">+ This app could not be loaded. {loadError.message || 'Check the connection and try again.'}+ </p>+ <div className="mt-4 flex flex-wrap items-center gap-3">+ <button+ onClick={fetchApp}+ className="inline-flex min-h-[40px] items-center gap-2 rounded-lg bg-port-accent px-4 py-2 text-sm text-white hover:bg-port-accent/80"+ >+ <RefreshCw size={16} aria-hidden="true" />+ Retry+ </button>+ <Link to="/apps" className="text-sm text-port-accent hover:underline">Back to Apps</Link>+ </div>+ </div>+ </div>+ </div>+ </div>+ );+ }+if (notFound) {return (- <div className="p-6 text-center">+ <div role="status" 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>diff --git a/client/src/components/apps/AppDetailView.test.jsx b/client/src/components/apps/AppDetailView.test.jsxindex 26635ec5b3..861825b3e3 100644--- a/client/src/components/apps/AppDetailView.test.jsx+++ b/client/src/components/apps/AppDetailView.test.jsx@@ -216,6 +216,31 @@ describe('AppDetailView fetch lifecycle', () => {api.getApp.mockReset();});+ it('shows a retryable unavailable state for a failed detail request and recovers', async () => {+ api.getApp+ .mockRejectedValueOnce(Object.assign(new Error('Server unreachable'), { status: 503 }))+ .mockResolvedValueOnce(APP);+ renderDetail();++ const unavailable = await screen.findByRole('alert');+ expect(unavailable).toHaveTextContent('App unavailable');+ expect(unavailable).toHaveTextContent('Server unreachable');+ expect(screen.queryByText('App not found')).toBeNull();++ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));+ expect(await screen.findByRole('heading', { name: APP.name })).toBeInTheDocument();+ });++ it('keeps a confirmed 404 distinct from an unavailable detail request', async () => {+ api.getApp.mockRejectedValue(Object.assign(new Error('App not found'), { status: 404 }));+ renderDetail();++ const missing = await screen.findByText('App not found');+ expect(missing).toHaveTextContent('App not found');+ expect(screen.queryByText('App unavailable')).toBeNull();+ expect(screen.queryByRole('button', { name: 'Retry' })).toBeNull();+ });+it('clears old child props immediately on navigation and ignores a late old-app refresh', async () => {let resolveOld;let resolveNew;diff --git a/client/src/components/apps/tabs/OverviewTab.jsx b/client/src/components/apps/tabs/OverviewTab.jsxindex 0dd04aca34..8d8a33c2a6 100644--- a/client/src/components/apps/tabs/OverviewTab.jsx+++ b/client/src/components/apps/tabs/OverviewTab.jsx@@ -1,9 +1,9 @@import { useState, useEffect, useMemo } from 'react';import { Link, useNavigate } from 'react-router';-import { FolderOpen, Gamepad2, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Download, Tag, AlertTriangle, Rocket, Camera, Image, Sparkles, Trash2 } from 'lucide-react';+import { FolderOpen, Gamepad2, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Download, Tag, AlertTriangle, Rocket, Camera, Image, Sparkles, Trash2, Smartphone } from 'lucide-react';import toast from '../../ui/Toast';import InlineConfirmRow from '../../ui/InlineConfirmRow';-import { isStandardizable } from '../constants';+import { isStandardizable, NON_PM2_TYPES } from '../constants';import ActivityLog from '../ActivityLog';import SlashDoPanel from '../SlashDoPanel';import Banner from '../../ui/Banner';@@ -56,6 +56,12 @@ export default function OverviewTab({ app, onRefresh }) {const handleStandardize = () => startStandardize(app.id, app.name);+ const handleOpenXcode = () => api.openAppInXcode(app.id, { silent: true })+ .then(result => {+ if (result?.success) toast.success(`Opening ${app.name} in Xcode`);+ })+ .catch(() => null);+const handleDetectIcon = async () => {setDetectingIcon(true);const result = await api.detectAppIcon(app.id).catch(() => null);@@ -304,6 +310,15 @@ export default function OverviewTab({ app, onRefresh }) {><FolderOpen size={14} /> Open Folder</button>+ {NON_PM2_TYPES.has(app.type) && (+ <button+ onClick={handleOpenXcode}+ 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"+ aria-label={`Open ${app.name} in Xcode`}+ >+ <Smartphone size={14} /> Open in Xcode+ </button>+ )}<buttononClick={handleUpdate}disabled={isOperating || restarting}diff --git a/client/src/components/apps/tabs/OverviewTab.test.jsx b/client/src/components/apps/tabs/OverviewTab.test.jsxindex 21d1f28b8a..8d04824aaf 100644--- a/client/src/components/apps/tabs/OverviewTab.test.jsx+++ b/client/src/components/apps/tabs/OverviewTab.test.jsx@@ -13,6 +13,7 @@ vi.mock('../../../services/api', () => ({unarchiveApp: vi.fn(() => Promise.resolve({})),openAppInEditor: vi.fn(() => Promise.resolve({})),openAppFolder: vi.fn(() => Promise.resolve({})),+ openAppInXcode: vi.fn(() => Promise.resolve({ success: true })),refreshAppConfig: vi.fn(() => Promise.resolve({})),detectAppIcon: vi.fn(() => Promise.resolve({ detected: false })),installXcodeScripts: vi.fn(() => Promise.resolve({})),@@ -94,3 +95,21 @@ describe('OverviewTab PortOS registration removal', () => {await waitFor(() => expect(api.getAppSpriteBindings).toHaveBeenCalledWith('portos-default'));});});++describe('OverviewTab native app actions', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ api.getAppSpriteBindings.mockResolvedValue({ bindings: [] });+ api.openAppInXcode.mockResolvedValue({ success: true });+ });++ it('keeps the Xcode action available from the native app detail workspace', async () => {+ const user = userEvent.setup();+ renderOverview({ ...APP, id: 'app-ios', name: 'Example iOS App', type: 'ios-native' });++ await user.click(screen.getByRole('button', { name: 'Open Example iOS App in Xcode' }));++ expect(api.openAppInXcode).toHaveBeenCalledWith('app-ios', { silent: true });+ await waitFor(() => expect(toast.success).toHaveBeenCalledWith('Opening Example iOS App in Xcode'));+ });+});diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsxindex 0f2815321f..e908de6b23 100644--- a/client/src/pages/Apps.jsx+++ b/client/src/pages/Apps.jsx@@ -1,15 +1,13 @@import AppQuality from '../components/apps/AppQuality';import { useState, useEffect, useCallback, useRef } from 'react';import { Link } from 'react-router';-import { ExternalLink, Gamepad2, Play, Square, RotateCcw, FolderOpen, Terminal, Code, RefreshCw, Wrench, Archive, ArchiveRestore, Ticket, Download, Hammer, Smartphone, Trash2, AlertTriangle } from 'lucide-react';+import { ExternalLink, Gamepad2, Play, Square, RotateCcw, RefreshCw, Archive, ArchiveRestore, Trash2, AlertTriangle } from 'lucide-react';import toast from '../components/ui/Toast';import InlineConfirmRow from '../components/ui/InlineConfirmRow';import OverflowMenu from '../components/ui/OverflowMenu';import AppIcon from '../components/AppIcon';import PageHeader from '../components/PageHeader';import PageSkeleton from '../components/ui/PageSkeleton';-import { SkeletonBlock, SkeletonRegion, skeletonRepeat } from '../components/ui/Skeleton';-import KanbanBoard from '../components/KanbanBoard';import StatusBadge from '../components/StatusBadge';import AppOperationBanner from '../components/apps/AppOperationBanner';import { useAppOperation } from '../hooks/useAppOperation';@@ -17,18 +15,16 @@ import useUrlParams from '../hooks/useUrlParams';import * as api from '../services/api';import socket from '../services/socket';import { getLaunchUrls } from '../services/appUrls';-import { NON_PM2_TYPES, isStandardizable, getAppTypeLabel } from '../components/apps/constants';-import { formatBytes } from '../utils/formatters';+import { NON_PM2_TYPES, getAppTypeLabel } from '../components/apps/constants';export default function Apps() {const [apps, setApps] = useState([]);const [loading, setLoading] = useState(true);+ const [loadError, setLoadError] = useState(null);+ const [retrying, setRetrying] = useState(false);const [confirmingDelete, setConfirmingDelete] = useState(null);- const [expandedId, setExpandedId] = useState(null);const [actionLoading, setActionLoading] = useState({});const [nativeLaunchLoading, setNativeLaunchLoading] = useState({});- const [refreshingConfig, setRefreshingConfig] = useState({});- const [building, setBuilding] = useState({});const [archiving, setArchiving] = useState({});// The archived filter lives in the URL (`/apps?view=archived`) so the archived// list is linkable/bookmarkable and — critically — survivable: unarchiving the@@ -37,25 +33,36 @@ export default function Apps() {const [searchParams, updateParams] = useUrlParams();const showArchived = searchParams.get('view') === 'archived';const setShowArchived = (next) => updateParams({ view: next ? 'archived' : null });- const [jiraTickets, setJiraTickets] = useState({});- const [loadingTickets, setLoadingTickets] = useState({});- // Parallel to jiraTickets: `undefined` tickets + a message here means "the- // fetch failed", which is a different thing from a fetched empty sprint.- const [ticketErrors, setTicketErrors] = useState({});// Per-row "…" trigger refs, so dismissing a row's delete confirmation hands// focus back to the control that opened it instead of dropping it on <body>.const menuTriggerRefs = useRef({});const menuTriggerRef = (id) => (menuTriggerRefs.current[id] ||= { current: null });- // Per-app sprint-ticket request tracking: `{ generation, active }`.- const ticketRequestsRef = useRef({});+ const fetchSeqRef = useRef(0);- const fetchApps = useCallback(async () => {- const data = await api.getApps({ includeQuality: true }).catch(() => []);- setApps(data);+ const fetchApps = useCallback(async ({ retry = false } = {}) => {+ const seq = ++fetchSeqRef.current;+ if (retry) {+ setRetrying(true);+ setLoading(true);+ }+ const result = await api.getApps({ includeQuality: true, silent: true })+ .then(data => ({ data }))+ .catch(error => ({ error }));+ if (seq !== fetchSeqRef.current) return false;+ if (result.error) {+ setLoadError(result.error);+ setRetrying(false);+ setLoading(false);+ return false;+ }+ setApps(Array.isArray(result.data) ? result.data : []);+ setLoadError(null);+ setRetrying(false);setLoading(false);+ return true;}, []);- const { operations, isOperating, restarting, startUpdate, startStandardize, dismiss } = useAppOperation({ onComplete: fetchApps });+ const { operations, restarting, dismiss } = useAppOperation({ onComplete: fetchApps });useEffect(() => {fetchApps();@@ -112,73 +119,8 @@ export default function Apps() {if (url) window.open(url, '_blank');};- const handleUpdate = (app) => startUpdate(app.id, app.name);-- const handleBuild = async (app) => {- setBuilding(prev => ({ ...prev, [app.id]: true }));- const result = await api.buildApp(app.id).catch(() => null);- setBuilding(prev => ({ ...prev, [app.id]: false }));- if (result?.success) {- toast.success(`${app.name} production build complete`);- }- };-- const handleRefreshConfig = async (app) => {- setRefreshingConfig(prev => ({ ...prev, [app.id]: true }));- await api.refreshAppConfig(app.id).catch(() => null);- setRefreshingConfig(prev => ({ ...prev, [app.id]: false }));- fetchApps();- };-- const handleStandardize = (app) => startStandardize(app.id, app.name);-- // Ticket state is keyed by app + JIRA target, not app id alone: editing an- // app's instance or project key must not serve the previous project's cached- // board (and must not be blocked from fetching by it).- const sprintKey = (app) => `${app.id}:${app.jira?.instanceId}:${app.jira?.projectKey}`;-- // A failed fetch must NOT be cached as `[]` — that read as "you have no- // sprint tickets" and, because the `!jiraTickets[id]` guard was satisfied by- // the cached empty array, never retried for the life of the page (#3437).- // Failure records a message and leaves `jiraTickets[id]` undefined, so both- // Retry and a re-expand re-issue the request; a genuine `[]` is still cached.- // Per-app request generation, so a slow earlier fetch can't land after a newer- // one and overwrite a good board with its stale error (the pending-request- // convention in client/src/AGENTS.md).- const loadSprintTickets = useCallback(async (app) => {- const key = sprintKey(app);- const generation = (ticketRequestsRef.current[key]?.generation || 0) + 1;- ticketRequestsRef.current[key] = { generation, active: true };- const isCurrent = () => ticketRequestsRef.current[key]?.generation === generation;-- setLoadingTickets(prev => ({ ...prev, [key]: true }));- setTicketErrors(prev => ({ ...prev, [key]: null }));- const tickets = await api- .getMySprintTickets(app.jira.instanceId, app.jira.projectKey, { silent: true })- .catch(err => {- if (isCurrent()) setTicketErrors(prev => ({ ...prev, [key]: err?.message || 'Request failed' }));- return null;- });- if (!isCurrent()) return; // superseded — the newer request owns the state- ticketRequestsRef.current[key].active = false;- if (Array.isArray(tickets)) setJiraTickets(prev => ({ ...prev, [key]: tickets }));- setLoadingTickets(prev => ({ ...prev, [key]: false }));- }, []);-- const toggleExpand = (id) => {- const newExpandedId = expandedId === id ? null : id;- setExpandedId(newExpandedId);-- // Fetch JIRA tickets when expanding an app with JIRA enabled- if (!newExpandedId) return;- const app = apps.find(a => a.id === newExpandedId);- if (!app?.jira?.enabled || !app.jira.instanceId || !app.jira.projectKey) return;- const key = sprintKey(app);- if (!jiraTickets[key] && !ticketRequestsRef.current[key]?.active) loadSprintTickets(app);- };-// Archive/unarchive gate their success toast on a response, the way- // handleBuild does: `request()` already toasted the failure, and a green+ // other action handlers do: `request()` already toasted the failure, and a green// "archived" on top of it told the user an app was excluded from CoS// scheduling when it was not (#3436).const setArchived = async (app, archived) => {@@ -199,18 +141,60 @@ export default function Apps() {// The server names the app it is operating on (so a rehydrated operation is// labelled even before the list loads); fall back to the loaded list.const operationName = (op) => op.appName || apps.find(app => app.id === op.appId)?.name;- const liveOperation = operations.find(op => !op.completed && !op.error);-// Filter apps based on archive statusconst activeApps = apps.filter(app => !app.archived);const archivedApps = apps.filter(app => app.archived);const displayedApps = (showArchived ? archivedApps : activeApps).slice().sort((a, b) => a.name.localeCompare(b.name));+ const operationBanners = operations.length > 0 ? (+ <div className="sticky top-0 z-20 mb-4 space-y-2">+ {operations.map(op => (+ <AppOperationBanner+ key={op.appId}+ appName={operationName(op)}+ type={op.type}+ steps={op.steps}+ error={op.error}+ completed={op.completed}+ restarting={restarting && op.appId === api.PORTOS_APP_ID}+ onDismiss={op.error || op.completed ? () => dismiss(op.appId) : null}+ />+ ))}+ </div>+ ) : null;if (loading) {return <PageSkeleton label="Loading apps" titleWidthClass="w-24" showSubtitle cards={4} sidebar={false} />;}+ if (loadError && apps.length === 0) {+ return (+ <div className="p-4 md:p-6">+ {operationBanners}+ <div role="alert" className="mx-auto max-w-2xl rounded-xl border border-port-error/40 bg-port-card p-6">+ <div className="flex items-start gap-3">+ <AlertTriangle size={20} aria-hidden="true" className="mt-0.5 shrink-0 text-port-error" />+ <div className="min-w-0">+ <h1 className="text-xl font-semibold text-white">Apps unavailable</h1>+ <p className="mt-2 text-sm text-gray-400">+ The registered app collection could not be loaded. {loadError.message || 'Check the connection and try again.'}+ </p>+ <button+ onClick={() => fetchApps({ retry: true })}+ disabled={retrying}+ aria-busy={retrying}+ className="mt-4 inline-flex min-h-[40px] items-center gap-2 rounded-lg bg-port-accent px-4 py-2 text-sm text-white hover:bg-port-accent/80 disabled:opacity-50"+ >+ <RefreshCw size={16} aria-hidden="true" className={retrying ? 'animate-spin' : ''} />+ {retrying ? 'Retrying…' : 'Retry'}+ </button>+ </div>+ </div>+ </div>+ </div>+ );+ }+return (<div><PageHeader@@ -244,24 +228,27 @@ export default function Apps() {)}/>+ {loadError && (+ <div role="alert" className="mb-4 flex flex-wrap items-center gap-3 rounded-lg border border-port-warning/40 bg-port-warning/10 p-3 text-sm">+ <AlertTriangle size={16} aria-hidden="true" className="shrink-0 text-port-warning" />+ <span className="min-w-0 flex-1 text-gray-300">+ Apps are unavailable — showing the last loaded collection. {loadError.message || 'Retry when the connection recovers.'}+ </span>+ <button+ onClick={() => fetchApps({ retry: true })}+ disabled={retrying}+ aria-busy={retrying}+ className="inline-flex min-h-[40px] items-center gap-2 rounded-lg bg-port-border px-3 py-1.5 text-xs text-white hover:bg-port-border/80 disabled:opacity-50"+ >+ <RefreshCw size={14} aria-hidden="true" className={retrying ? 'animate-spin' : ''} />+ {retrying ? 'Retrying…' : 'Retry'}+ </button>+ </div>+ )}+{/* In-flight update/standardize — page-level so it survives collapsingthe row and remounting the page. */}- {operations.length > 0 && (- <div className="sticky top-0 z-20 mb-4 space-y-2">- {operations.map(op => (- <AppOperationBanner- key={op.appId}- appName={operationName(op)}- type={op.type}- steps={op.steps}- error={op.error}- completed={op.completed}- restarting={restarting && op.appId === api.PORTOS_APP_ID}- onDismiss={op.error || op.completed ? () => dismiss(op.appId) : null}- />- ))}- </div>- )}+ {operationBanners}{/* App List */}{displayedApps.length === 0 ? (@@ -293,13 +280,6 @@ export default function Apps() {<div className="space-y-4">{displayedApps.map(app => {const isNonPm2 = NON_PM2_TYPES.has(app.type);- // One update/standardize at a time. Rows that aren't the one- // operating say so in the button label — a bare greyed control with- // a tooltip explains nothing on touch.- const rowOperation = operations.find(op => op.appId === app.id);- const rowOperating = !!rowOperation && !rowOperation.completed && !rowOperation.error;- const busyElsewhere = isOperating && !rowOperating;- const busyReason = `${(liveOperation && operationName(liveOperation)) || 'Another app'} is ${liveOperation?.type === 'standardize' ? 'being standardized' : 'updating'}`;const launchUrls = getLaunchUrls(app);const primaryLaunchUrl = launchUrls.https || launchUrls.http;return (@@ -310,16 +290,8 @@ export default function Apps() {{/* Main App Row */}<div className="p-4"><div className="flex flex-col sm:flex-row sm:items-center gap-4">- {/* Expand + Name + Status */}+ {/* Identity + Status */}<div className="flex items-center gap-3 flex-1 min-w-0">- <button- onClick={() => toggleExpand(app.id)}- className="text-gray-400 hover:text-white transition-transform shrink-0"- aria-expanded={expandedId === app.id}- aria-label={`${expandedId === app.id ? 'Collapse' : 'Expand'} ${app.name} details`}- >- <span aria-hidden="true" className={`inline-block transition-transform ${expandedId === app.id ? 'rotate-90' : ''}`}>▶</span>- </button><div className={`w-8 h-8 rounded-[22%] shrink-0 overflow-hidden ${app.appIconPath ? '' : `flex items-center justify-center ${app.archived ? 'bg-port-border/50 text-gray-500' : 'bg-port-border text-port-accent'}`}`}>@@ -528,244 +500,6 @@ export default function Apps() {)}</div>- {/* Expanded Details */}- {expandedId === app.id && (- <div className="bg-port-bg border-t border-port-border">- <div className="p-4 sm:px-6 sm:py-4 space-y-4">- {/* 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} aria-hidden="true" className="text-yellow-400 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} aria-hidden="true" className="text-port-accent 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} aria-hidden="true" className="text-port-success shrink-0 mt-0.5" />- <code className="text-sm text-port-accent/90 font-mono break-all">{cmd}</code>- </div>- ))}- </div>- </div>- )}-- {/* PM2 Processes Status - only for PM2 apps */}- {!isNonPm2 && 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 shrink-0 ${- proc.status === 'online' ? 'bg-port-success' :- proc.status === 'stopped' ? 'bg-gray-500' :- proc.status === 'unknown' ? 'bg-port-warning' : '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-port-accent 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-port-success">{proc.cpu}%</span>- )}- {proc.memory !== undefined && (- <span className="text-xs text-port-accent">{formatBytes(proc.memory)}</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} aria-hidden="true" className="text-port-accent 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-port-success">+ PR</span>- )}- {app.jira.labels?.length > 0 && (- <span className="text-xs text-port-accent">{app.jira.labels.join(', ')}</span>- )}- </div>-- {/* My Sprint Tickets - Kanban Board */}- {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[sprintKey(app)] ? (- // Reserve the board's three columns instead of a- // one-line spinner (#4147) — the board is ~120px- // tall, so the spinner row let everything below- // the expansion jump when the tickets landed.- <SkeletonRegion- label={`Loading sprint tickets for ${app.name}`}- className="flex gap-3 overflow-x-auto pb-2"- >- {skeletonRepeat(3).map((_, col) => (- <div- key={col}- className="flex-1 min-w-[220px] min-h-[120px] rounded-lg border border-port-border p-3"- >- <SkeletonBlock className="h-4 w-24 mb-3" />- <div className="space-y-2">- <SkeletonBlock className="h-10 w-full" />- <SkeletonBlock className="h-10 w-full" />- </div>- </div>- ))}- </SkeletonRegion>- ) : ticketErrors[sprintKey(app)] ? (- <div className="flex flex-wrap items-center gap-3 px-3 py-2 bg-port-card border border-port-error/30 rounded-lg">- <AlertTriangle size={16} aria-hidden="true" className="text-port-error shrink-0" />- <span className="text-sm text-gray-300 min-w-0">- Couldn't load sprint tickets — {ticketErrors[sprintKey(app)]}- </span>- <button- onClick={() => loadSprintTickets(app)}- className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1 focus:outline-hidden focus:ring-2 focus:ring-port-accent"- aria-label={`Retry loading sprint tickets for ${app.name}`}- >- <RefreshCw size={14} aria-hidden="true" /> Retry- </button>- </div>- ) : jiraTickets[sprintKey(app)]?.length > 0 ? (- <KanbanBoard- tickets={jiraTickets[sprintKey(app)]}- instanceId={app.jira.instanceId}- onTicketsChange={(updated) => setJiraTickets(prev => ({ ...prev, [sprintKey(app)]: updated }))}- appId={app.id}- projectKey={app.jira.projectKey}- boardId={app.jira.boardId}- />- ) : (- <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 min-h-[40px] sm:min-h-0 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"- >- <Code size={14} aria-hidden="true" /> Open in Editor- </button>- <button- onClick={() => api.openAppFolder(app.id).catch(() => null)}- className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1"- >- <FolderOpen size={14} aria-hidden="true" /> Open Folder- </button>- <button- onClick={() => handleUpdate(app)}- disabled={isOperating}- className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-success/20 text-port-success enabled:hover:bg-port-success/30 rounded-lg text-xs flex items-center gap-1 disabled:opacity-50"- aria-label={busyElsewhere ? `Update unavailable — ${busyReason}` : 'Pull latest code, install dependencies, run setup, and restart'}- title={busyElsewhere ? busyReason : undefined}- >- <Download size={14} aria-hidden="true" className={rowOperating && rowOperation.type === 'update' ? 'animate-bounce' : ''} />- {rowOperating && rowOperation.type === 'update'- ? 'Updating...'- : busyElsewhere ? 'Update (busy)' : 'Update'}- </button>- {app.buildCommand && (- <button- onClick={() => handleBuild(app)}- disabled={building[app.id]}- aria-busy={building[app.id]}- className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-warning/20 text-port-warning enabled:hover:bg-port-warning/30 transition-colors rounded-lg text-xs flex items-center gap-1 disabled:opacity-50 disabled:cursor-not-allowed"- aria-label={`${building[app.id] ? 'Building' : 'Build'} production UI: ${app.buildCommand}`}- >- <Hammer size={14} aria-hidden="true" className={building[app.id] ? 'animate-bounce' : ''} />- {building[app.id] ? 'Building…' : 'Build'}- </button>- )}- {/* PM2-specific actions */}- {!isNonPm2 && (- <>- <button- onClick={() => handleRefreshConfig(app)}- disabled={refreshingConfig[app.id]}- className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-border hover:bg-port-border/80 text-white rounded-lg text-xs flex items-center gap-1 disabled:opacity-50"- aria-label="Re-scan ecosystem config for PM2 processes and ports"- >- <RefreshCw size={14} aria-hidden="true" className={refreshingConfig[app.id] ? 'animate-spin' : ''} />- Refresh Config- </button>- {/* The standardizer writes a NODE ecosystem config —- never offer it for a Python/Go/Docker/static repo- (the server refuses too). */}- {isStandardizable(app.type) && (!app.processes?.length || app.processes.some(p => !p.ports || Object.keys(p.ports).length === 0)) && (- <button- onClick={() => handleStandardize(app)}- disabled={isOperating}- className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-accent/20 text-port-accent enabled:hover:bg-port-accent/30 rounded-lg text-xs flex items-center gap-1 disabled:opacity-50"- aria-label={busyElsewhere ? `Standardize PM2 unavailable — ${busyReason}` : 'Standardize PM2 config: move all ports to ecosystem.config.cjs'}- title={busyElsewhere ? busyReason : undefined}- >- <Wrench size={14} aria-hidden="true" className={rowOperating && rowOperation.type === 'standardize' ? 'animate-spin' : ''} />- {rowOperating && rowOperation.type === 'standardize'- ? 'Standardizing...'- : busyElsewhere ? 'Standardize PM2 (busy)' : 'Standardize PM2'}- </button>- )}- </>- )}- {/* Xcode-specific actions */}- {isNonPm2 && (- <button- onClick={() => api.openAppInXcode(app.id)- .then(result => { if (result?.success) toast.success(`Opening ${app.name} in Xcode`); })- .catch(() => null)}- className="px-3 py-1.5 min-h-[40px] sm:min-h-0 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded-lg text-xs flex items-center gap-1"- aria-label={`Open ${app.name} in Xcode`}- >- <Smartphone size={14} aria-hidden="true" /> Open in Xcode- </button>- )}- </div>- </div>- </div>- )}</div>);})}diff --git a/client/src/pages/Apps.test.jsx b/client/src/pages/Apps.test.jsxindex 504e8fac4f..7f812db29b 100644--- a/client/src/pages/Apps.test.jsx+++ b/client/src/pages/Apps.test.jsx@@ -2,7 +2,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';import { act, render, screen, waitFor } from '@testing-library/react';import userEvent from '@testing-library/user-event';import { MemoryRouter } from 'react-router';-import { findEnabledByRole } from '../test/enabledBarrier.js';const APPS = [{@@ -37,14 +36,6 @@ vi.mock('../services/api', () => ({stopApp: vi.fn(() => Promise.resolve({})),restartApp: vi.fn(() => Promise.resolve({})),launchNativeApp: vi.fn(() => Promise.resolve({})),- buildApp: vi.fn(() => Promise.resolve({})),- refreshAppConfig: vi.fn(() => Promise.resolve({})),- getMySprintTickets: vi.fn(() => Promise.resolve([])),- getJiraBoardColumns: vi.fn(() => Promise.resolve({ columns: [] })),- updateJiraTicketStatus: vi.fn(() => Promise.resolve({})),- openAppInEditor: vi.fn(() => Promise.resolve({})),- openAppFolder: vi.fn(() => Promise.resolve({})),- openAppInXcode: vi.fn(() => Promise.resolve({ success: true, path: '/srv/example-ios/ExampleIos.xcodeproj' })),handleSelfRestart: vi.fn(),}));@@ -96,6 +87,39 @@ describe('Apps row action hierarchy', () => {expect(nameLink.className).toContain('underline');});+ it('keeps deep diagnostics out of collection rows and routes management to detail', async () => {+ api.getApps.mockResolvedValue([{+ ...APPS[0],+ startCommands: ['npm run start'],+ pm2Status: { 'example-server': { name: 'example-server', status: 'online' } },+ jira: { enabled: true, instanceId: 'jira-1', projectKey: 'EX' },+ }]);+ await renderApps();++ expect(screen.queryByRole('button', { name: /Expand .* details/ })).toBeNull();+ expect(screen.queryByText('Repository Path')).toBeNull();+ expect(screen.queryByText('PM2 Processes')).toBeNull();+ expect(screen.queryByText('My Sprint Tickets')).toBeNull();+ expect(screen.getByRole('link', { name: 'Manage Example App' })).toHaveAttribute('href', '/apps/app-alpha/overview');+ });++ it('keeps a long non-PM2 repository path wrapping within its collection row', async () => {+ api.getApps.mockResolvedValue([{+ ...APPS[0],+ id: 'app-longpath',+ name: 'Example Long Path App',+ type: 'ios-native',+ repoPath: '/srv/thisisaverylongsingledirectorysegmentwithnobreakpoints/example-ios',+ pm2ProcessNames: [],+ processes: [],+ }]);+ render(<MemoryRouter><Apps /></MemoryRouter>);+ await screen.findByRole('link', { name: 'Example Long Path App' });++ const repoPathSpan = screen.getByText('/srv/thisisaverylongsingledirectorysegmentwithnobreakpoints/example-ios');+ expect(repoPathSpan.className).toContain('break-all');+ });+it('exposes Archive and PortOS removal only through the overflow menu', async () => {const user = userEvent.setup();await renderApps();@@ -150,87 +174,64 @@ describe('Apps row action hierarchy', () => {await waitFor(() => expect(api.archiveApp).toHaveBeenCalledWith('app-alpha'));});- it('asks the server to resolve and open the Xcode project instead of guessing the filename', async () => {- // Display name deliberately differs from the on-disk project name — the old- // client-side `<name>.xcodeproj` guess was a silent no-op for exactly this app.- api.getApps.mockResolvedValue([{- ...APPS[0],- id: 'app-ios',- name: 'Example iOS App',- type: 'ios-native',- repoPath: '/srv/example-ios',- pm2ProcessNames: [],- processes: [],- }]);- const user = userEvent.setup();- render(<MemoryRouter><Apps /></MemoryRouter>);- await screen.findByRole('link', { name: 'Example iOS App' });-- await user.click(screen.getByRole('button', { name: 'Expand Example iOS App details' }));- await user.click(screen.getByRole('button', { name: 'Open Example iOS App in Xcode' }));+});- await waitFor(() => expect(api.openAppInXcode).toHaveBeenCalledWith('app-ios'));+describe('Apps collection load states', () => {+ beforeEach(() => {+ vi.clearAllMocks();});- it('keeps a long non-PM2 repository path wrapping within its column instead of overflowing', async () => {- // A single unbroken directory segment can't rely on slash-based line- // breaking, so the fix must allow mid-word wrapping (break-all) — which- // also drops the flex item's min-content width enough for it to shrink- // to the available column instead of forcing the row wider.- api.getApps.mockResolvedValue([{- ...APPS[0],- id: 'app-longpath',- name: 'Example Long Path App',- type: 'ios-native',- repoPath: '/srv/thisisaverylongsingledirectorysegmentwithnobreakpoints/example-ios',- pm2ProcessNames: [],- processes: [],- }]);+ it('distinguishes an unavailable collection from empty and retries in place', async () => {+ api.getApps+ .mockRejectedValueOnce(new Error('Server unreachable'))+ .mockResolvedValueOnce(APPS);+ const user = userEvent.setup();render(<MemoryRouter><Apps /></MemoryRouter>);- await screen.findByRole('link', { name: 'Example Long Path App' });- const repoPathSpan = screen.getByText('/srv/thisisaverylongsingledirectorysegmentwithnobreakpoints/example-ios');- expect(repoPathSpan.className).toEqual(expect.stringContaining('break-all'));+ const unavailable = await screen.findByRole('alert');+ expect(unavailable).toHaveTextContent('Apps unavailable');+ expect(screen.queryByText('No apps registered')).toBeNull();++ await user.click(screen.getByRole('button', { name: 'Retry' }));+ await screen.findByRole('link', { name: 'Example App' });+ expect(api.getApps).toHaveBeenLastCalledWith({ includeQuality: true, silent: true });});- it('withholds the overflow menu for the PortOS baseline app', async () => {- api.getApps.mockResolvedValue([{ ...APPS[0], id: 'portos-default', name: 'PortOS' }]);+ it('keeps a real empty collection distinct from an unavailable collection', async () => {+ api.getApps.mockResolvedValue([]);render(<MemoryRouter><Apps /></MemoryRouter>);- await screen.findByRole('link', { name: 'Manage PortOS' });- expect(screen.queryByRole('button', { name: /More actions/ })).toBeNull();+ expect(await screen.findByText('No apps registered')).toBeTruthy();+ expect(screen.queryByText('Apps unavailable')).toBeNull();});- it('labels the build action as in progress while the build is running', async () => {- let resolveBuild;- api.getApps.mockResolvedValue([{ ...APPS[0], buildCommand: 'npm run build' }]);- api.buildApp.mockImplementation(() => new Promise(resolve => { resolveBuild = resolve; }));- const user = userEvent.setup();+ it('keeps the last loaded collection visible when a refresh fails', async () => {+ api.getApps+ .mockResolvedValueOnce(APPS)+ .mockRejectedValueOnce(new Error('Server unreachable'));render(<MemoryRouter><Apps /></MemoryRouter>);+ await screen.findByRole('link', { name: 'Example App' });- await user.click(await screen.findByRole('button', { name: 'Expand Example App details' }));- await user.click(await screen.findByRole('button', { name: 'Build production UI: npm run build' }));-- const buildingButton = screen.getByRole('button', { name: 'Building production UI: npm run build' });- expect(buildingButton).toBeDisabled();- expect(buildingButton).toHaveAttribute('aria-busy', 'true');- expect(screen.getByText('Building…')).toBeTruthy();+ const [, handleAppsChanged] = socket.on.mock.calls.find(([event]) => event === 'apps:changed');+ await act(async () => { await handleAppsChanged(); });- await act(async () => { resolveBuild({ success: true }); });- await findEnabledByRole('button', { name: 'Build production UI: npm run build' });+ expect(screen.getByRole('link', { name: 'Example App' })).toBeInTheDocument();+ expect(screen.getByRole('alert')).toHaveTextContent('showing the last loaded collection');});- it('opens a plain-HTTP managed app without inheriting PortOS HTTPS', async () => {- api.getApps.mockResolvedValue([{ ...APPS[0], uiPort: 8940 }]);- const open = vi.spyOn(window, 'open').mockImplementation(() => null);- const user = userEvent.setup();+ it('keeps an in-flight operation visible while the initial collection is unavailable', async () => {+ api.getApps.mockRejectedValueOnce(new Error('Server unreachable'));+ render(<MemoryRouter><Apps /></MemoryRouter>);+ await screen.findByRole('alert');- await renderApps();- await user.click(screen.getByRole('button', { name: 'Launch Example App UI' }));+ const [, handleOperations] = socket.on.mock.calls.find(([event]) => event === 'app:operations:active');+ await act(async () => {+ await handleOperations({+ operations: [{ appId: 'app-alpha', appName: 'Example App', type: 'update', steps: [] }],+ });+ });- expect(open).toHaveBeenCalledWith('http://host-alpha.example-tailnet.ts.net:8940', '_blank');- expect(launchUrlMock.getLaunchUrls).toHaveBeenCalledWith(expect.objectContaining({ id: 'app-alpha', uiPort: 8940 }));- open.mockRestore();+ expect(screen.getByRole('status', { name: 'App operation status' })).toHaveTextContent('Updating Example App');});});@@ -323,29 +324,6 @@ describe('Apps in-flight operation banner (#3435)', () => {expect(screen.getByRole('status', { name: 'App operation status' }).textContent).toContain('Installing deps…');});- it('states why another app’s Update is unavailable instead of silently greying it out', async () => {- await renderApps();- await emitSocket('app:operations:active', activeUpdate());-- await act(async () => {- screen.getByRole('button', { name: 'Expand Second App details' }).click();- });-- const busy = screen.getByRole('button', { name: /Update unavailable/ });- expect(busy.textContent).toContain('Update (busy)');- expect(busy.disabled).toBe(true);- });-- it('keeps the completion visible when the server reports nothing in flight', async () => {- await renderApps();- await emitSocket('app:operations:active', activeUpdate());- await emitSocket('app:update:complete', { appId: 'app-alpha', success: true, steps: [] });- // The server clears its in-flight set right after the completion broadcast.- await emitSocket('app:operations:active', { operations: [] });-- expect(screen.getByRole('status', { name: 'App operation status' }).textContent).toContain('Updated Example App');- });-it('clears a stale banner when the server reports no operation and none finished', async () => {await renderApps();await emitSocket('app:operations:active', activeUpdate());@@ -468,170 +446,3 @@ describe('Apps archive result reporting (#3436)', () => {expect(await screen.findByRole('button', { name: /Archived \(1\)/ })).toBeTruthy();});});--describe('Apps sprint-ticket fetch failures (#3437)', () => {- const JIRA_APP = {- ...APPS[0],- jira: { enabled: true, instanceId: 'jira-1', projectKey: 'EX', issueType: 'Task' }- };-- beforeEach(() => {- vi.clearAllMocks();- api.getApps.mockResolvedValue([JIRA_APP]);- });-- // The toggle relabels itself once open, so match either direction.- const toggleRow = async (user) => {- await user.click(screen.getByRole('button', { name: /(Expand|Collapse) Example App details/ }));- };-- it('reports a failed fetch instead of claiming the sprint is empty, and retries on demand', async () => {- api.getMySprintTickets.mockRejectedValue(new Error('JIRA instance unreachable'));- const user = userEvent.setup();- await renderApps();-- await toggleRow(user);- await screen.findByText(/Couldn't load sprint tickets/);- expect(screen.getByText(/JIRA instance unreachable/)).toBeTruthy();- expect(screen.queryByText('No tickets assigned to you in the current sprint')).toBeNull();-- // Retry re-issues the request, and a now-healthy JIRA renders the board.- api.getMySprintTickets.mockResolvedValue([- { key: 'EX-1', summary: 'Example ticket', status: 'To Do' }- ]);- await user.click(screen.getByRole('button', { name: 'Retry loading sprint tickets for Example App' }));-- await waitFor(() => expect(api.getMySprintTickets).toHaveBeenCalledTimes(2));- await waitFor(() => expect(screen.queryByText(/Couldn't load sprint tickets/)).toBeNull());- });-- it('re-issues the request on the next expand after a failure instead of caching it', async () => {- api.getMySprintTickets.mockRejectedValue(new Error('JIRA instance unreachable'));- const user = userEvent.setup();- await renderApps();-- await toggleRow(user);- await screen.findByText(/Couldn't load sprint tickets/);-- await toggleRow(user); // collapse- await toggleRow(user); // re-expand- await waitFor(() => expect(api.getMySprintTickets).toHaveBeenCalledTimes(2));- });-- it('still reports a genuinely empty sprint as empty, and caches it', async () => {- api.getMySprintTickets.mockResolvedValue([]);- const user = userEvent.setup();- await renderApps();-- await toggleRow(user);- expect(await screen.findByText('No tickets assigned to you in the current sprint')).toBeTruthy();-- await toggleRow(user); // collapse- await toggleRow(user); // re-expand — the cached [] is authoritative- expect(api.getMySprintTickets).toHaveBeenCalledTimes(1);- });-- it('renders its own error UI, so the request stays silent', async () => {- api.getMySprintTickets.mockRejectedValue(new Error('JIRA instance unreachable'));- const user = userEvent.setup();- await renderApps();-- await toggleRow(user);- await screen.findByText(/Couldn't load sprint tickets/);- expect(api.getMySprintTickets).toHaveBeenCalledWith('jira-1', 'EX', { silent: true });- });-});--describe('Apps sprint-ticket request races (#3437)', () => {- const JIRA_APP = {- ...APPS[0],- jira: { enabled: true, instanceId: 'jira-1', projectKey: 'EX', issueType: 'Task' }- };-- beforeEach(() => {- vi.clearAllMocks();- api.getApps.mockResolvedValue([JIRA_APP]);- });-- it('does not start a second fetch while one is still in flight, and the in-flight result still lands', async () => {- let resolveFirst;- api.getMySprintTickets.mockImplementation(() => new Promise(resolve => { resolveFirst = resolve; }));-- const user = userEvent.setup();- await renderApps();- const toggle = () => user.click(screen.getByRole('button', { name: /(Expand|Collapse) Example App details/ }));-- await toggle(); // first fetch — hangs- await toggle(); // collapse- await toggle(); // re-expand while the first request is still open-- // One request, not two — so no older response can land after a newer one- // and overwrite it.- expect(api.getMySprintTickets).toHaveBeenCalledTimes(1);-- await act(async () => { resolveFirst([]); });- expect(await screen.findByText('No tickets assigned to you in the current sprint')).toBeTruthy();- });-});--describe('Apps sprint-ticket cache keying (#3437)', () => {- const JIRA_APP = {- ...APPS[0],- jira: { enabled: true, instanceId: 'jira-1', projectKey: 'EX', issueType: 'Task' }- };-- beforeEach(() => {- vi.clearAllMocks();- api.getApps.mockResolvedValue([JIRA_APP]);- });-- it('refetches when the app is repointed at a different JIRA project', async () => {- api.getMySprintTickets.mockResolvedValue([]);- const user = userEvent.setup();- await renderApps();- const toggle = () => user.click(screen.getByRole('button', { name: /(Expand|Collapse) Example App details/ }));-- await toggle();- await waitFor(() => expect(api.getMySprintTickets).toHaveBeenCalledTimes(1));- await toggle(); // collapse-- // The app is edited elsewhere and the list refreshes with a new project key.- api.getApps.mockResolvedValue([{ ...JIRA_APP, jira: { ...JIRA_APP.jira, projectKey: 'OTHER' } }]);- const [, handleAppsChanged] = socket.on.mock.calls.find(([evt]) => evt === 'apps:changed');- await act(async () => { await handleAppsChanged(); });-- await toggle(); // re-expand — the previous project's cache must not answer- await waitFor(() => expect(api.getMySprintTickets).toHaveBeenCalledTimes(2));- expect(api.getMySprintTickets).toHaveBeenLastCalledWith('jira-1', 'OTHER', { silent: true });- });-});--// The Kanban board is a ~120px-tall region that loads after the row expands, so-// the one-line spinner it used to show let everything below the expansion jump-// once the tickets landed (#4147).-describe('Apps sprint-ticket loading state (#4147)', () => {- const JIRA_APP = {- ...APPS[0],- jira: { enabled: true, instanceId: 'jira-1', projectKey: 'EX', issueType: 'Task' }- };-- beforeEach(() => {- vi.clearAllMocks();- api.getApps.mockResolvedValue([JIRA_APP]);- });-- it('reserves the board columns instead of a one-line spinner', async () => {- // Never resolves — hold the expansion on its ticket-loading branch.- api.getMySprintTickets.mockReturnValue(new Promise(() => {}));- const user = userEvent.setup();- await renderApps();-- await user.click(screen.getByRole('button', { name: /Expand Example App details/ }));-- const region = await screen.findByRole('status', { name: 'Loading sprint tickets for Example App' });- expect(region).toHaveAttribute('aria-busy', 'true');- // Three columns, each reserving a heading plus two ticket cards.- expect(region.querySelectorAll('.animate-pulse')).toHaveLength(9);- expect(region.querySelectorAll('.min-h-\\[120px\\]')).toHaveLength(3);- });-});diff --git a/client/src/services/apiApps.js b/client/src/services/apiApps.jsindex 5ffc5f55b3..ede62da544 100644--- a/client/src/services/apiApps.js+++ b/client/src/services/apiApps.js@@ -250,7 +250,7 @@ export const openAppFolder = (id) => request(`/apps/${id}/open-folder`, { method// The server resolves the real .xcworkspace/.xcodeproj name and opens it on the// machine Xcode runs on — so this works from a phone, and a missing project// comes back as a real error instead of a silent `xcode://` no-op.-export const openAppInXcode = (id) => request(`/apps/${id}/open-xcode`, { method: 'POST' });+export const openAppInXcode = (id, options = {}) => request(`/apps/${id}/open-xcode`, { method: 'POST', ...options });export const refreshAppConfig = (id) => request(`/apps/${id}/refresh-config`, { method: 'POST' });// `options` lets a caller suppress request()'s auto-toast with `{ silent: true }`// when it already renders its own error UI.diff --git a/docs/UX_DESIGN_AUDIT.md b/docs/UX_DESIGN_AUDIT.mdindex 688b0813bf..f33402fe82 100644--- a/docs/UX_DESIGN_AUDIT.md+++ b/docs/UX_DESIGN_AUDIT.md@@ -8,7 +8,7 @@ Date: 2026-09-21. Scope: a representative sample to establish reusable patterns,- Performance: live 1,280px-wide browser screenshot/rendered content and checkout component review.- Runtimes: live browser screenshot, checkout component review, and the synthetic validation record in [the Runtimes pilot](validation/7795-runtimes-workspace.md).- CoS Tasks: live browser screenshot and checkout page/task component review.-- Settings General and Backup, Brain Threads and Notes, and the Apps list and detail: current source and rendered-test review only; observations about their rendered behavior remain hypotheses to validate.+- Settings General and Backup, and Brain Threads and Notes: current source and rendered-test review only; observations about their rendered behavior remain hypotheses to validate. The Apps list/detail slice now also has source and synthetic rendered-test evidence in [#7860](https://github.com/atomantic/PortOS/issues/7860), but its viewport behavior remains unverified.- The live application displayed a client/server build mismatch. Its visual evidence and the current checkout are complementary snapshots; no runtime reconciliation or model actions were performed.- These are heuristic findings. No user task timings, complete accessibility audit, or production responsive test pass has been performed.@@ -99,14 +99,25 @@ This is a bounded source-and-test audit after the Runtimes and CoS pilots. `Obse| Settings Backup — `client/src/pages/Settings.jsx`, `client/src/components/settings/BackupTab.jsx` | Operations + Configuration. Inspect backup health; configure schedule/destination/excludes; run or restore a backup. | A long form already contains status, schedule, disclosures, snapshots, and restore controls → put health and the next safe action first, with configuration and recovery detail disclosed below. | `/settings/backup` stays canonical with the Download icon. The Settings content region remains the primary scroll owner; the action bar may stay sticky without covering errors. Saved destination/schedule state, Run Now gating, dry-run restore, and destructive-action confirmation remain unchanged. | `loadFailed` already has an explicit unavailable panel; degraded database status, invalid restore input, and failed restore must remain distinct from an empty snapshot list. Follow-up: [#7858](https://github.com/atomantic/PortOS/issues/7858). || Brain Threads — `client/src/pages/Brain.jsx`, `client/src/components/brain/tabs/ThreadsTab.jsx` | Collection. Capture an open loop; triage by status/tag/search; edit, link, or complete a selected thread. | The collection and URL-backed drawer are an adopted pattern → retain the full-bleed collection, add an explicit unavailable/retry state, and keep the drawer as the selected record's task surface. | `/brain/threads` remains a direct icon destination using ListTodo and `TabPills mobileCompact`. Threads owns its full-bleed scroll. `status`, `tag`, `q`, `thread`, and `threadTab` remain URL-backed; drafts/save/delete and browser Back remain observable. | List failure currently falls through to the same empty copy as “Nothing tracked yet”; a failed refresh must preserve the distinction and offer retry. Follow-up: [#7859](https://github.com/atomantic/PortOS/issues/7859). || Brain Notes — `client/src/pages/Brain.jsx`, `client/src/components/brain/tabs/NotesTab.jsx` | Document or canvas. Switch vault/folder; search and open a note; edit, create, delete, and save. | A local split pane provides vault/list/editor work → retain independent editor and list scrolling while making vault/note selection URL-shareable and keeping the active note visible on narrow screens. | `/brain/notes` remains a direct FileText destination with `TabPills mobileCompact`. The full-bleed shell owns the workspace; list and editor panes keep their own scroll only because this is a genuine list/detail editor. Note drafts, force-save, and request-lifetime behavior remain. | Vault, scan, and read failures currently become empty or stale state; delete failure can also report success after a swallowed request. Follow-up: [#7859](https://github.com/atomantic/PortOS/issues/7859) captures the deep-link and truthful-state repair. |-| Apps list — `client/src/pages/Apps.jsx`, `client/src/lib/layoutRoutes.js` | Collection. Inspect health; start/stop/restart or launch; open Manage/archive. | Rows currently mix collection identity/actions with repository, configuration, PM2, and board detail → keep identity, health, primary lifecycle actions, and Manage in the collection; route deep diagnostics to the detail workspace. | `/apps` remains the collection route with archive state in `?view=archived`, existing operation banners, and normal Layout scrolling. Keep lifecycle feedback, overflow confirmation, and feature-aware action availability. | `getApps` failure currently renders `No apps registered`, which is indistinguishable from a genuine empty collection. Follow-up: [#7860](https://github.com/atomantic/PortOS/issues/7860) separates unavailable, empty, and loaded states. |-| App detail — `client/src/pages/AppDetail.jsx`, `client/src/components/apps/AppDetailView.jsx` | Operations + Workbench. Identify status and execute lifecycle/build/launch; inspect task, Git, quality, and configuration tabs. | The route-backed detail workspace already gives deep work a home → preserve its header, contextual lifecycle action, edit drawer, and feature-gated tabs while making unavailable distinct from missing. | `/apps/:id/:tab` and its aliases remain shareable. `TabPills mobileCompact`, unique tab icons, full-width detail scrolling, and `?edit=1`/`appTab` drawer state remain. No provider work starts from navigation. | Any failed detail request currently becomes “App not found”; a transport/server failure needs retry while a confirmed 404 keeps recovery to Apps. Follow-up: [#7860](https://github.com/atomantic/PortOS/issues/7860). |+| Apps list — `client/src/pages/Apps.jsx`, `client/src/lib/layoutRoutes.js` | Collection. Inspect health; start/stop/restart or launch; open Manage/archive. | Implemented in [#7860](https://github.com/atomantic/PortOS/issues/7860): rows keep identity, health, primary lifecycle actions, and Manage; repository, configuration, PM2, and board detail stay in the detail workspace. | `/apps` remains the collection route with archive state in `?view=archived`, existing operation banners, and normal Layout scrolling. Lifecycle feedback, overflow confirmation, and feature-aware action availability remain intact. | Collection failures now render an unavailable/retry state; a successful empty array remains `No apps registered`; a failed refresh keeps the last loaded rows visible with a stale warning. |+| App detail — `client/src/pages/AppDetail.jsx`, `client/src/components/apps/AppDetailView.jsx` | Operations + Workbench. Identify status and execute lifecycle/build/launch; inspect task, Git, quality, and configuration tabs. | Implemented in [#7860](https://github.com/atomantic/PortOS/issues/7860): the route-backed detail workspace owns deep work while preserving its header, contextual lifecycle action, edit drawer, and feature-gated tabs. | `/apps/:id/:tab` and its aliases remain shareable. `TabPills mobileCompact`, unique tab icons, full-width detail scrolling, and `?edit=1`/`appTab` drawer state remain. No provider work starts from navigation. | Non-404 detail failures now render a retryable unavailable state; a confirmed 404 remains “App not found” with recovery to Apps. |++### Apps follow-up verification (#7860)++The Apps slice is implemented in [#7860](https://github.com/atomantic/PortOS/issues/7860):++- `/apps` is collection-first: identity/health, primary lifecycle and launch controls, Manage, archive, and removal remain; repository/configuration/PM2/JIRA detail is reached through the detail workspace.+- Collection load failures are explicit and retryable, remain distinct from a successful empty collection, and preserve a previously loaded list with a stale warning when a refresh fails.+- `/apps/:id/:tab` keeps route, tab, feature, and drawer contracts; non-404 detail failures are retryable unavailable states and 404 is confirmed missing.+- Synthetic rendered coverage is in `client/src/pages/Apps.test.jsx` and `client/src/components/apps/AppDetailView.test.jsx`.++This verifies source and rendered-test contracts only; the 1,920/1,440/1,024/390/320 viewport matrix still requires browser validation and is not claimed here.### Adopted lessons from the pilots- Runtimes and CoS now demonstrate that selected work belongs in the URL and that local form/progress owners must survive sibling-view changes; the six surfaces above must preserve that contract where they already have it.- Desktop destinations keep icon prefixes, and fixed mobile destinations keep their distinct `TabPills mobileCompact` icons and accessible names. A supplemental sheet cannot replace direct navigation.-- Empty, loading, unavailable, partial, stale, and confirmed-missing states are different evidence states. The Threads, Notes, Apps list, and App detail gaps are concrete follow-up work, not a reason to infer a universal component.+- Empty, loading, unavailable, partial, stale, and confirmed-missing states are different evidence states. Threads and Notes remain concrete follow-up work; Apps list and detail now carry those distinctions explicitly.- Saved-state gates and destructive recovery are behavior boundaries: Settings Backup must not run or restore against unresolved state, Brain edits must preserve drafts, and Apps lifecycle actions must report their actual operation state.### Follow-up issue register@@ -115,6 +126,6 @@ This is a bounded source-and-test audit after the Runtimes and CoS pilots. `Obse| --- | --- | --- || [#7858](https://github.com/atomantic/PortOS/issues/7858) | Settings General and Backup composition, save/error evidence, and responsive validation. | Open; follows this audit. || [#7859](https://github.com/atomantic/PortOS/issues/7859) | Brain Notes deep links plus Threads/Notes unavailable and empty-state truthfulness. | Open; follows this audit. |-| [#7860](https://github.com/atomantic/PortOS/issues/7860) | Apps collection-first hierarchy plus truthful list/detail unavailable states. | Open; follows this audit. |+| [#7860](https://github.com/atomantic/PortOS/issues/7860) | Apps collection-first hierarchy plus truthful list/detail unavailable states. | Implemented; source/rendered tests updated; viewport matrix remains open. |The [synthetic validation record](validation/7797-settings-brain-apps-audit.md) lists the existing test evidence, remaining viewport checks, and compatibility checklist. These follow-ups are deliberately implementation slices; #7797 is complete when the audit and evidence register are published, not when those later UI changes merge.diff --git a/docs/validation/7797-settings-brain-apps-audit.md b/docs/validation/7797-settings-brain-apps-audit.mdindex e119522dc1..72ed4f3289 100644--- a/docs/validation/7797-settings-brain-apps-audit.md+++ b/docs/validation/7797-settings-brain-apps-audit.md@@ -17,8 +17,8 @@ This record captures the bounded follow-up audit named by [#7797](https://github| Settings Backup | `client/src/components/settings/BackupTab.test.jsx` | Destination saves, restore dry-run/confirmation, integrity/schema failures, saved-state Run Now gates, degraded status, and resolved schedules have explicit contracts. | Validate status/action priority, sticky action-bar geometry, and keyboard/error visibility. || Brain Threads | `client/src/components/brain/tabs/ThreadsTab.test.jsx`, `client/src/pages/Brain.test.jsx` | Status/tag/search filters and selected thread are URL-backed; drawer selection, in-place completion, race handling, and icon navigation are covered. | Add an unavailable/retry state that cannot be mistaken for “Nothing tracked yet,” then validate the collection at narrow widths. || Brain Notes | `client/src/components/brain/tabs/NotesTab.test.jsx`, `client/src/pages/Brain.test.jsx` | Touch targets, force-save escalation, request lifetimes, stale selection protection, and Brain icon navigation are covered. | Add URL-backed vault/note selection and truthful vault/scan/read/delete failures without weakening force-save or draft behavior. |-| Apps list | `client/src/pages/Apps.test.jsx` | Row action hierarchy, Manage routing, archive query state, lifecycle feedback, operation banners, wrapping paths, and sprint-ticket failure/retry behavior are covered. | Keep the collection row-first, route deep diagnostics to detail, and distinguish unavailable from genuinely empty. |-| App detail | `client/src/components/apps/AppDetailView.test.jsx`, `client/src/pages/Apps.test.jsx` | Detail route lifecycle handling, old/current request races, feature-tab visibility, direct disabled-feature URLs, unique tab icons, and identity/action placement are covered. | Distinguish a failed detail request from a confirmed missing app and validate detail tab/Drawer geometry across widths. |+| Apps list | `client/src/pages/Apps.test.jsx` | Row action hierarchy, Manage routing, archive query state, lifecycle feedback, operation banners, wrapping paths, collection-first composition, and unavailable-versus-empty/retry behavior are covered. | Validate the collection hierarchy, stale-refresh warning, and action geometry across the matrix widths. |+| App detail | `client/src/components/apps/AppDetailView.test.jsx`, `client/src/pages/Apps.test.jsx` | Detail route lifecycle handling, old/current request races, feature-tab visibility, direct disabled-feature URLs, unique tab icons, identity/action placement, and unavailable-versus-404/retry behavior are covered. | Validate detail tab/Drawer geometry across widths. |## Surface contracts@@ -51,6 +51,12 @@ Across each width, test light and dark themes, keyboard focus, copied canonical1. **Settings General and Backup** — `GeneralTab` and `BackupTab` have valuable persistence and recovery contracts, but the audit needs a task-first composition and responsive evidence. Implement in [#7858](https://github.com/atomantic/PortOS/issues/7858).2. **Brain Threads and Notes** — Threads list failure currently lands on empty copy, and Notes selection/error handling is not consistently shareable or truthful. Implement in [#7859](https://github.com/atomantic/PortOS/issues/7859). The follow-up also covers the observed note-delete failure path that can show success after a failed request.-3. **Apps list and detail** — the collection mixes deep diagnostics into rows, the list request failure looks empty, and detail failure looks missing. Implement in [#7860](https://github.com/atomantic/PortOS/issues/7860).+3. **Apps list and detail** — the collection mixed deep diagnostics into rows, the list request failure looked empty, and detail failure looked missing. Implemented in [#7860](https://github.com/atomantic/PortOS/issues/7860); the source and rendered tests now cover the collection-first hierarchy and truthful unavailable/empty/missing states.++### Apps follow-up result (#7860)++The shipped slice keeps `/apps` focused on collection identity, health, primary lifecycle/launch actions, Manage, archive, and removal. Deep repository, configuration, PM2, and JIRA diagnostics remain available from the route-backed detail workspace. A failed collection read is no longer presented as an empty collection, a failed refresh preserves the last loaded rows with an explicit warning, and detail transport/server failures are distinct from confirmed 404s.++The evidence is limited to source and synthetic rendered tests. The required 1,920/1,440/1,024/390/320 viewport matrix remains a browser-validation task and is not claimed by this record.These are independently shippable slices. They preserve the adopted icon navigation, route contracts, optional-feature behavior, privacy boundary, explicit save/run/restore gates, and synthetic-only validation while narrowing each later change to a concrete surface.