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

fix: distinguish Values Alignment load failures from empty suite (#2385)

Adam Eivyb8f5c28f79a2
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index a31c1728f1..15af9e8aa9 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -89,4 +89,5 @@
- **Rounds and Music Video can now turn a reference audio file into MIDI locally via MuScriptor.** MuScriptor (github.com/muscriptor/muscriptor) is a multi-instrument audio → MIDI transcription model that runs in an opt-in venv (`INSTALL_MUSCRIPTOR=1 bash scripts/setup-image-video.sh`, weights auto-download from HuggingFace on first use; small/medium/large tiers). A new shared service (`server/services/audioMidiTranscription.js` + the `scripts/transcribe_muscriptor.py` sidecar, same STAGE:/RESULT: wire protocol as the music-gen sidecars) exposes the kickoff/SSE/cancel job shape in both features: a Rounds reference with attached audio gains a **Transcribe MIDI** control (the resulting `.mid` lands as `references[].midiFilename` on Save, cleared with the audio like segments), and a Music Video project gains a **MIDI** toolbar button + download link (`project.midiTranscription` is persisted server-side on completion and invalidated when the audio source changes, exactly like `audioAnalysis`). When the venv isn't provisioned the kickoff 503s with the install hint instead of a bare spawn error.
- **[issue-2386] ffmpeg render errors are now separated into pre-spawn and post-spawn, so a failed kill can no longer let a replacement render overlap the live process.** The music-video and timeline renderers both routed every `'error'` event through the same immediate finalizer — which released the per-project render mutex and dropped process ownership. But `'error'` fires for two very different cases: a genuine pre-spawn failure (ENOENT — the child never started, no `'close'` follows) and a *later* child-process error such as a failed kill while ffmpeg is still running. Releasing the mutex on the latter let a re-render spawn and overlap the still-live ffmpeg. Both services now track spawn state (a `'spawn'` listener sets a flag) and finalize immediately only for pre-spawn errors; a post-spawn error is recorded but retains process + project-mutex ownership until the pending `'close'` runs the sole terminal finalization. A shared `terminal` guard makes terminal handling exactly-once across the error and close paths, and both handlers wrap their body per the child-process-callback convention. Covered by new error-to-close sequence tests before and after spawn in both services.
+- **[issue-2385] Digital Twin evaluation suites now distinguish a load failure from a genuinely empty suite.** Values-Alignment (and its sibling Adversarial-Boundary / Multi-Turn panels, which share the same hook) caught a failed suite load with `.catch(() => [])`, so a server/network error rendered the same "No suite found" empty state as an install that legitimately has no `VALUES_ALIGNMENT_SUITE.md`. The shared `useTwinEvaluationSuite` hook now uses a `null` sentinel for a failed tests-load (distinct from `[]` = successfully-loaded-but-empty) and exposes a `loadError`; `TwinEvaluationSuitePanel` renders an explicit inline load-error state with a **Retry** button that re-runs the load — while the true empty state stays distinct. Feedback stays non-duplicative (inline only, load calls remain `silent`, no toast). History remains secondary: a failed history load degrades to no history without blocking the panel. Covered by new hook tests (failure vs empty vs history-only failure vs reload recovery) and a component test asserting both the load-error/Retry render and the empty-response render.
- **[issue-2375] Split the ~1,380-line `server/routes/apps.js` into domain-focused sub-routers.** The single apps router (24+ endpoints spanning CRUD/status enrichment, PM2 lifecycle, config repair, Xcode provisioning, icon serving, task-type overrides, document git-commits, editor/folder launch, and agent history) is now assembled from nine mountable sub-routers under `server/routes/apps/` (`crud`, `lifecycle`, `viteTls`, `xcode`, `icons`, `taskTypes`, `launch`, `documents`, `agents`), mirroring the pipeline sub-router pattern. Shared plumbing (`loadApp` middleware, `pathExists`, and the port/overall-status derivation helpers previously duplicated between the list and detail endpoints) lives in one `apps/shared.js`, and the ~130-line ecosystem-config port-rewrite orchestration moved out of the PUT handler into a `server/services/appPortConfig.js` service. The `/api/apps` route contract is byte-for-byte identical (all 35 path+method pairs verified) and the oversized route test file is split along the same domain boundaries. No behavior change.
diff --git a/client/src/components/digital-twin/tabs/TwinEvaluationSuitePanel.jsx b/client/src/components/digital-twin/tabs/TwinEvaluationSuitePanel.jsx
index 30bb28316d..7243f60729 100644
--- a/client/src/components/digital-twin/tabs/TwinEvaluationSuitePanel.jsx
+++ b/client/src/components/digital-twin/tabs/TwinEvaluationSuitePanel.jsx
@@ -6,7 +6,8 @@ import {
Clock,
ChevronDown,
ChevronRight,
- History
+ History,
+ RefreshCw
} from 'lucide-react';
import BrailleSpinner from '../../BrailleSpinner';
import PersonaBadge from '../PersonaBadge';
@@ -93,11 +94,13 @@ export default function TwinEvaluationSuitePanel({
items,
history,
loading,
+ loadError,
running,
results,
expanded,
setExpanded,
- run
+ run,
+ reload
} = useTwinEvaluationSuite({
selectedProviders,
personaId,
@@ -154,7 +157,19 @@ export default function TwinEvaluationSuitePanel({
</button>
</div>
- {items.length === 0 ? (
+ {loadError ? (
+ <div className="p-6 flex flex-col items-center gap-3 text-center">
+ <AlertCircle className="w-6 h-6 text-port-error" />
+ <p className="text-sm text-port-error">{loadError}</p>
+ <button
+ onClick={reload}
+ className="flex items-center justify-center gap-2 px-4 py-2 min-h-[44px] bg-port-card border border-port-border text-white rounded-lg font-medium hover:bg-port-border/40"
+ >
+ <RefreshCw className="w-4 h-4" />
+ Retry
+ </button>
+ </div>
+ ) : items.length === 0 ? (
<div className="p-6 text-center text-sm text-gray-400">{emptyState}</div>
) : (
<>
diff --git a/client/src/components/digital-twin/tabs/TwinEvaluationSuitePanel.test.jsx b/client/src/components/digital-twin/tabs/TwinEvaluationSuitePanel.test.jsx
new file mode 100644
index 0000000000..7fadd90f03
--- /dev/null
+++ b/client/src/components/digital-twin/tabs/TwinEvaluationSuitePanel.test.jsx
@@ -0,0 +1,81 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+
+vi.mock('../../ui/Toast', () => ({
+ default: { success: vi.fn(), error: vi.fn() },
+}));
+
+import TwinEvaluationSuitePanel from './TwinEvaluationSuitePanel';
+
+// #2385 — a suite load FAILURE (server/network) must render a distinct
+// load-error state with Retry, never collapse into the genuinely-empty
+// "No suite" copy. These tests cover both the failure and empty responses.
+
+const StubIcon = (props) => <svg data-testid="stub-icon" {...props} />;
+
+const makeSuite = (overrides = {}) => ({
+ HeaderIcon: StubIcon,
+ title: 'Values-Alignment Tests',
+ description: 'desc',
+ runLabel: 'Run Dilemmas',
+ loadingText: 'Loading values suite',
+ itemLabel: 'Dilemma',
+ emptyState: <span>No values-alignment suite found.</span>,
+ scoreLabel: 'Alignment Score',
+ countField: 'aligned',
+ historyTitle: 'Recent Values Runs',
+ statusMap: {},
+ passResult: 'aligned',
+ failResult: 'misaligned',
+ getTests: vi.fn().mockResolvedValue([]),
+ getHistory: vi.fn().mockResolvedValue([]),
+ runTests: vi.fn(),
+ successToast: 'done',
+ ...overrides,
+});
+
+const renderPanel = (suite) =>
+ render(
+ <TwinEvaluationSuitePanel
+ suite={suite}
+ renderDetail={() => null}
+ selectedProviders={[{ providerId: 'p1', model: 'm1' }]}
+ />
+ );
+
+describe('TwinEvaluationSuitePanel load states', () => {
+ beforeEach(() => vi.clearAllMocks());
+
+ it('renders a distinct load-error state with Retry when the suite load fails', async () => {
+ const getTests = vi.fn().mockRejectedValue(new Error('boom'));
+ renderPanel(makeSuite({ getTests }));
+
+ await waitFor(() =>
+ expect(screen.getByText(/could not load the suite/i)).toBeInTheDocument()
+ );
+ // The empty-suite copy must NOT appear — failure and empty are distinct.
+ expect(screen.queryByText(/no values-alignment suite found/i)).not.toBeInTheDocument();
+
+ const retry = screen.getByRole('button', { name: /retry/i });
+ getTests.mockResolvedValueOnce([]);
+ await userEvent.click(retry);
+
+ await waitFor(() =>
+ expect(screen.queryByText(/could not load the suite/i)).not.toBeInTheDocument()
+ );
+ // Recovered into the (genuinely) empty state, not the error state.
+ expect(screen.getByText(/no values-alignment suite found/i)).toBeInTheDocument();
+ expect(getTests).toHaveBeenCalledTimes(2);
+ });
+
+ it('renders the empty-suite copy (not the error state) for a successful empty response', async () => {
+ renderPanel(makeSuite({ getTests: vi.fn().mockResolvedValue([]) }));
+
+ await waitFor(() =>
+ expect(screen.getByText(/no values-alignment suite found/i)).toBeInTheDocument()
+ );
+ expect(screen.queryByText(/could not load the suite/i)).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: /retry/i })).not.toBeInTheDocument();
+ });
+});
diff --git a/client/src/hooks/useTwinEvaluationSuite.js b/client/src/hooks/useTwinEvaluationSuite.js
index c3df0fef76..a39033e540 100644
--- a/client/src/hooks/useTwinEvaluationSuite.js
+++ b/client/src/hooks/useTwinEvaluationSuite.js
@@ -38,6 +38,10 @@ export function useTwinEvaluationSuite({
const [items, setItems] = useState([]);
const [history, setHistory] = useState([]);
const [loading, setLoading] = useState(true);
+ // Sentinel: `null` = the suite loaded (empty or not); a string = the load
+ // failed. This keeps a server/network failure distinct from a genuinely
+ // empty install so the two never collapse to the same "No suite" state.
+ const [loadError, setLoadError] = useState(null);
const [running, setRunning] = useState(false);
const [results, setResults] = useState([]);
const [expanded, setExpanded] = useState(null);
@@ -48,12 +52,22 @@ export function useTwinEvaluationSuite({
const loadData = async () => {
setLoading(true);
- // These loads own their fallback ([]) so silence the helper's default toast.
+ setLoadError(null);
+ // The suite load owns its error UI (inline load-error state + Retry below)
+ // so silence the helper's default toast — the sentinel `null` on failure is
+ // distinct from `[]`, which is a real, successfully-loaded empty suite.
+ // History is secondary: a failed history load degrades to no history rather
+ // than blocking the whole panel.
const [itemData, historyData] = await Promise.all([
- getTests({ silent: true }).catch(() => []),
+ getTests({ silent: true }).catch(() => null),
getHistory(5, { silent: true }).catch(() => [])
]);
- setItems(itemData);
+ if (itemData === null) {
+ setLoadError('Could not load the suite — check provider/server availability and retry.');
+ setItems([]);
+ } else {
+ setItems(itemData);
+ }
setHistory(historyData);
setLoading(false);
};
@@ -108,5 +122,5 @@ export function useTwinEvaluationSuite({
onRefresh?.();
};
- return { items, history, loading, running, results, expanded, setExpanded, run, reload: loadData };
+ return { items, history, loading, loadError, running, results, expanded, setExpanded, run, reload: loadData };
}
diff --git a/client/src/hooks/useTwinEvaluationSuite.test.js b/client/src/hooks/useTwinEvaluationSuite.test.js
index 710b3f1a77..f839b30a85 100644
--- a/client/src/hooks/useTwinEvaluationSuite.test.js
+++ b/client/src/hooks/useTwinEvaluationSuite.test.js
@@ -40,7 +40,7 @@ describe('useTwinEvaluationSuite', () => {
expect(result.current.items).toHaveLength(1);
});
- it('falls back to empty arrays when a load rejects (no crash, no toast)', async () => {
+ it('surfaces loadError (not a silent empty) when the suite load rejects (no crash, no toast)', async () => {
const cfg = baseCfg({
getTests: vi.fn().mockRejectedValue(new Error('boom')),
getHistory: vi.fn().mockRejectedValue(new Error('boom'))
@@ -48,11 +48,52 @@ describe('useTwinEvaluationSuite', () => {
const { result } = renderHook(() => useTwinEvaluationSuite(cfg));
await waitFor(() => expect(result.current.loading).toBe(false));
+ // A failed load surfaces a distinct error sentinel — NOT the same []/empty
+ // state a genuinely-empty install produces. Feedback stays inline (no toast).
+ expect(result.current.loadError).toBeTruthy();
expect(result.current.items).toEqual([]);
expect(result.current.history).toEqual([]);
expect(toast.error).not.toHaveBeenCalled();
});
+ it('leaves loadError null for a genuinely empty suite (empty is not a failure)', async () => {
+ const cfg = baseCfg({ getTests: vi.fn().mockResolvedValue([]) });
+ const { result } = renderHook(() => useTwinEvaluationSuite(cfg));
+
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ expect(result.current.loadError).toBeNull();
+ expect(result.current.items).toEqual([]);
+ });
+
+ it('degrades to no history when only the history load rejects, without a loadError', async () => {
+ const cfg = baseCfg({
+ getTests: vi.fn().mockResolvedValue([{ testId: 1, testName: 'T1' }]),
+ getHistory: vi.fn().mockRejectedValue(new Error('history down'))
+ });
+ const { result } = renderHook(() => useTwinEvaluationSuite(cfg));
+
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ expect(result.current.loadError).toBeNull();
+ expect(result.current.items).toHaveLength(1);
+ expect(result.current.history).toEqual([]);
+ });
+
+ it('reload clears a prior loadError once the suite load recovers', async () => {
+ const getTests = vi.fn()
+ .mockRejectedValueOnce(new Error('boom'))
+ .mockResolvedValueOnce([{ testId: 1, testName: 'T1' }]);
+ const cfg = baseCfg({ getTests });
+ const { result } = renderHook(() => useTwinEvaluationSuite(cfg));
+
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ expect(result.current.loadError).toBeTruthy();
+
+ await act(async () => { await result.current.reload(); });
+
+ expect(result.current.loadError).toBeNull();
+ expect(result.current.items).toHaveLength(1);
+ });
+
it('runs every selected provider in parallel and silences each call', async () => {
const cfg = baseCfg({
selectedProviders: [