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

Refuse concurrent fine-tunes of one voice; Voice Lab tabs use TabPills

Claude918954c0d866
diff --git a/client/src/components/universe/CharacterDetailEditor.jsx b/client/src/components/universe/CharacterDetailEditor.jsx
index f644859f15..de9587acc4 100644
--- a/client/src/components/universe/CharacterDetailEditor.jsx
+++ b/client/src/components/universe/CharacterDetailEditor.jsx
@@ -763,13 +763,21 @@ function VoiceCanonSection({ entry, onPatch, disabled }) {
);
}
+const VOICE_LAB_TABS = [
+ { id: 'overview', label: 'Overview', icon: BadgeCheck },
+ { id: 'design', label: 'Design', icon: WandSparkles },
+ { id: 'clone', label: 'Clone', icon: Mic },
+ { id: 'finetune', label: 'Fine-Tuning', icon: Activity },
+];
+const VOICE_LAB_TAB_IDS = VOICE_LAB_TABS.map((tab) => tab.id);
+
function VoiceProfileSection({ universeId, entry, disabled }) {
const [profile, setProfile] = useState(null);
const [profiles, setProfiles] = useState([]);
const [loading, setLoading] = useState(Boolean(universeId));
const [loadError, setLoadError] = useState(null);
const [_engineCapability, setEngineCapability] = useState(null);
- const [activeTab, setActiveTab] = useState('overview');
+ const [activeTab, setActiveTab] = useDrawerTab(`voiceLab-${entry?.id}`, 'overview', VOICE_LAB_TAB_IDS);
// Voice Design form state
const [designInstructions, setDesignInstructions] = useState('');
@@ -931,19 +939,8 @@ function VoiceProfileSection({ universeId, entry, disabled }) {
</p>
{loadError ? <p className="text-[10px] text-port-error">{loadError}</p> : null}
- {/* Sub-tab navigation */}
- <div className="flex gap-1 border-b border-port-border/40 pb-1 text-[11px]">
- {['overview', 'design', 'clone', 'finetune'].map((tab) => (
- <button
- key={tab}
- type="button"
- onClick={() => setActiveTab(tab)}
- className={`px-2 py-0.5 rounded capitalize ${activeTab === tab ? 'bg-port-accent text-white font-medium' : 'text-gray-400 hover:text-white'}`}
- >
- {tab === 'finetune' ? 'Fine-Tuning' : tab}
- </button>
- ))}
- </div>
+ <TabPills tabs={VOICE_LAB_TABS} activeTab={activeTab} onChange={setActiveTab}
+ variant="pills" size="sm" mobileCompact ariaLabel="Voice Lab" />
{activeTab === 'overview' && (
<div className="space-y-2">
diff --git a/client/src/components/universe/CharacterDetailEditor.test.jsx b/client/src/components/universe/CharacterDetailEditor.test.jsx
index 510a5e5979..5f48280772 100644
--- a/client/src/components/universe/CharacterDetailEditor.test.jsx
+++ b/client/src/components/universe/CharacterDetailEditor.test.jsx
@@ -16,8 +16,6 @@ vi.mock('../../services/apiVoice', () => ({
createVoiceDesignCandidate: vi.fn(),
createClonedVoiceCandidate: vi.fn(),
promoteVoiceProfile: vi.fn(),
-
- startFineTuningJob: vi.fn(),
}));
import {
@@ -243,7 +241,7 @@ describe('CharacterDetailEditor — production package (#5378)', () => {
fireEvent.click(screen.getByRole('tab', { name: 'Voice' }));
// Switch to Design tab
- fireEvent.click(screen.getByRole('button', { name: /Design/i }));
+ fireEvent.click(screen.getByRole('tab', { name: 'Design' }));
fireEvent.change(screen.getByPlaceholderText(/warm low alto/i), {
target: { value: 'calm, measured alto' },
});
@@ -270,7 +268,7 @@ describe('CharacterDetailEditor — production package (#5378)', () => {
expect(await screen.findByText(/Machine-local voice design/i)).toBeInTheDocument();
// Switch to Clone tab
- fireEvent.click(screen.getByRole('button', { name: /Clone/i }));
+ fireEvent.click(screen.getByRole('tab', { name: 'Clone' }));
const cloneBtn = screen.getByRole('button', { name: /Create Cloned Candidate/i });
expect(cloneBtn).toBeDisabled();
@@ -280,6 +278,23 @@ describe('CharacterDetailEditor — production package (#5378)', () => {
expect(cloneBtn).toBeDisabled();
});
+ it('deep-links the Voice Lab sub-tab and writes the selection back to the URL', async () => {
+ listVoiceEngines.mockResolvedValue({ engines: [] });
+ listVoiceProfiles.mockResolvedValue({ profiles: [] });
+ function LocationProbe() {
+ return <output aria-label="Location">{useLocation().search}</output>;
+ }
+ rtlRender(<><CharacterDetailEditor entry={ARIA} universeId="uni-1" characters={[ARIA]} onPatch={() => {}} /><LocationProbe /></>, {
+ wrapper: ({ children }) => <MemoryRouter initialEntries={['/?castSheet-chr-aria=voice&voiceLab-chr-aria=clone']}>{children}</MemoryRouter>,
+ });
+ expect(await screen.findByRole('button', { name: /Create Cloned Candidate/i })).toBeInTheDocument();
+ expect(screen.getByRole('tab', { name: 'Clone' })).toHaveAttribute('aria-selected', 'true');
+
+ fireEvent.click(screen.getByRole('tab', { name: 'Design' }));
+ expect(screen.getByLabelText('Location').textContent).toContain('voiceLab-chr-aria=design');
+ expect(screen.getByRole('button', { name: /Design Candidate Voice/i })).toBeInTheDocument();
+ });
+
it('qualifies interactive route via host latency benchmark', async () => {
listVoiceEngines.mockResolvedValue({ engines: [] });
listVoiceProfiles.mockResolvedValue({
diff --git a/server/services/voice/fineTuning.js b/server/services/voice/fineTuning.js
index 42c9565cb8..56e419587e 100644
--- a/server/services/voice/fineTuning.js
+++ b/server/services/voice/fineTuning.js
@@ -203,6 +203,17 @@ const finalizeJob = (jobState) => {
closeJobAfterDelay(activeJobs, jobState.id);
};
+const assertNoRunningJob = (profileId) => {
+ for (const job of activeJobs.values()) {
+ if (job.profileId === profileId && job.status === 'running') {
+ throw new ServerError('A fine-tuning run is already in progress for this voice profile', {
+ status: 409,
+ code: 'FINE_TUNE_ALREADY_RUNNING',
+ });
+ }
+ }
+};
+
/**
* Validate training dataset readiness for a given voice profile.
*/
@@ -317,6 +328,11 @@ export async function startFineTuningJob({
}
const profile = await getVoiceProfileRequired(profileId);
+ // Two full-parameter trainings of one voice would contend for the same GPU
+ // and write competing checkpoints; refuse before any record or child exists.
+ // Checked again after the awaits below, where nothing yields until the job
+ // registers, so two overlapping starts cannot both pass.
+ assertNoRunningJob(profile.id);
const dataset = buildTrainingDataset(profile, validation.sourceDir);
const jobId = randomUUID();
const profileDir = profileArtifactDirectory(profile.id);
@@ -325,6 +341,7 @@ export async function startFineTuningJob({
const datasetManifest = join(outputDir, DATASET_MANIFEST_FILE);
await atomicWrite(datasetManifest, dataset);
+ assertNoRunningJob(profile.id);
const abortController = new AbortController();
const jobState = {
id: jobId,
diff --git a/server/services/voice/fineTuning.test.js b/server/services/voice/fineTuning.test.js
index 8ca5f72189..2fee1c6374 100644
--- a/server/services/voice/fineTuning.test.js
+++ b/server/services/voice/fineTuning.test.js
@@ -417,6 +417,36 @@ describe('fineTuning', () => {
expect(JSON.parse(await readFile(jobRecordPath(newer), 'utf8')).status).toBe('running');
});
+ it('refuses a second concurrent run of the same voice before spawning it', async () => {
+ queryMock.mockResolvedValue({ rows: [{ data: PROFILE }] });
+ await seedSourceAudio();
+ useScriptedRunner();
+ const spawned = [];
+ const scriptedSpawn = spawnOverride;
+ spawnOverride = (...args) => { const child = scriptedSpawn(...args); spawned.push(child); return child; };
+
+ // Two overlapping starts: exactly one becomes a run.
+ const results = await Promise.allSettled([
+ startFineTuningJob({ profileId: PROFILE.id, epochs: 2 }),
+ startFineTuningJob({ profileId: PROFILE.id, epochs: 2 }),
+ ]);
+ const started = results.filter((result) => result.status === 'fulfilled');
+ expect(started).toHaveLength(1);
+ expect(results.find((result) => result.status === 'rejected').reason)
+ .toMatchObject({ status: 409, code: 'FINE_TUNE_ALREADY_RUNNING' });
+ await expect(startFineTuningJob({ profileId: PROFILE.id, epochs: 2 }))
+ .rejects.toMatchObject({ status: 409, code: 'FINE_TUNE_ALREADY_RUNNING' });
+ expect(spawned).toHaveLength(1);
+
+ // Once the run settles the voice can train again.
+ spawned[0].exit(0);
+ await drainJobRecord(started[0].value.jobId);
+ const next = await startFineTuningJob({ profileId: PROFILE.id, epochs: 2 });
+ expect(spawned).toHaveLength(2);
+ spawned[1].exit(0);
+ await drainJobRecord(next.jobId);
+ });
+
it('persists a job.json sidecar beside the checkpoints when the run finishes', async () => {
queryMock.mockResolvedValue({ rows: [{ data: PROFILE }] });
await seedSourceAudio();