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

2.8 KB
Raw Blame
/**
 * Music studio — generate and organize music with local OSS tools.
 *
 * A hub for the music feature: manage **Artists** (reusable musical personas,
 * like Authors), **Albums** (ordered track collections with cover art), and
 * **Tracks** (singles or album members, with uploaded/attached audio). On-device
 * generation (Ace-Step and friends) wires into the Tracks editor next update.
 *
 * Tabbed via URL param (`/music/:tab`) per the linkable-routes convention, so a
 * tab is deep-linkable and survives reload. `tab` defaults to `artists`.
 */

import { useParams, useNavigate, Navigate } from 'react-router';
import { Mic, Disc3, AudioLines, Wand2 } from 'lucide-react';
import PageHeader from '../components/PageHeader';
import ArtistsManager from '../components/music/ArtistsManager';
import AlbumsManager from '../components/music/AlbumsManager';
import TracksManager from '../components/music/TracksManager';
import MusicDesigner from '../components/music/MusicDesigner';
import TabPills from '../components/ui/TabPills';
import { getPageNavTabs } from '../../../server/lib/navManifest.js';
import { buildPageNavTabs } from '../lib/pageNavTabs.js';

// Icon per tab id. The manifest (`tabGroup: 'music'`) owns id/label/order —
// this page owns only how each tab looks; the short page-local labels (vs the
// manifest's "Music Designer"/"Music Artists"/… , which need the "Music"
// qualifier to be unambiguous in ⌘K) come from the manifest's `tabLabel`.
// Throws at import time on drift.
const TAB_PRESENTATION = {
  generate: { icon: Wand2 },
  artists: { icon: Mic },
  albums: { icon: Disc3 },
  tracks: { icon: AudioLines },
};

export const TABS = buildPageNavTabs(getPageNavTabs('music'), TAB_PRESENTATION, 'Music');

const VALID = new Set(TABS.map((t) => t.id));

export default function Music() {
  const { tab } = useParams();
  const navigate = useNavigate();
  const active = tab || 'generate';
  // Unknown tab → redirect to the default rather than render an empty shell.
  if (!VALID.has(active)) return <Navigate to="/music/generate" replace />;

  return (
    <div className="flex h-full flex-col">
      <PageHeader icon={Mic} title="Music" />

      {/* Selection lives in the URL (`/music/:tab`) — TabPills drives onChange
          callbacks rather than links, so we navigate() to keep the route canonical
          and deep-linkable. */}
      <TabPills
        tabs={TABS}
        activeTab={active}
        onChange={(id) => navigate(`/music/${id}`)}
        ariaLabel="Music sections"
      />

      <div className="flex-1 overflow-auto p-4">
        {active === 'generate' && <MusicDesigner />}
        {active === 'artists' && <ArtistsManager />}
        {active === 'albums' && <AlbumsManager />}
        {active === 'tracks' && <TracksManager />}
      </div>
    </div>
  );
}