Restored Tailwind UI.
This commit is contained in:
1 parent
eae0787725
commit
473f08e88e
63 files changed
+4721
-4677
No files matched your search
@@ -1199,3 +1199,16 @@ Added rules for:
|
||||
|
||||
- Toggle button positioned at `right: -14` (half outside sidebar) was clipped by `overflow: hidden` on the `<aside>`
|
||||
- Fix: changed aside `overflow: 'visible'`; wrapped the collapsed icon strip in its own `overflow: hidden` div (expanded content already had its own `overflow: hidden`)
|
||||
|
||||
### Frontend swap — restored Tailwind UI as active frontend
|
||||
|
||||
- `frontend` (MetroUI migration) → renamed to `frontend-backup (metroui)`
|
||||
- `frontend-backup (tailwind)` (original) → renamed to `frontend` (now active)
|
||||
- Container restart required to rebuild from restored Tailwind frontend
|
||||
|
||||
### Security: purge legacy plaintext Subsonic config at startup (`main.py`)
|
||||
|
||||
- Added `_purge_legacy_subsonic_config()` — deletes `subsonic.json` if it exists without `_enc: True` (legacy plaintext format written before encryption was added)
|
||||
- Encrypted configs (`_enc: True`) are left untouched
|
||||
- Wired via FastAPI `lifespan` context manager so it runs once at process startup
|
||||
- Logs a WARNING when a legacy file is removed so the operator knows to re-enter credentials in the Settings UI
|
||||
+35
-1
@@ -2,9 +2,11 @@
|
||||
StemEngine — FastAPI application entry point.
|
||||
Mounts all API routers and serves the built React frontend as static files.
|
||||
"""
|
||||
import json
|
||||
import logging
|
||||
import logging.config
|
||||
import warnings
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
|
||||
# Suppress FutureWarnings from third-party libraries that use deprecated
|
||||
@@ -36,8 +38,40 @@ from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.responses import FileResponse
|
||||
|
||||
from .routers import separate, transcribe, abc_convert, pipeline, jobs, lrc, subsonic, projects, models, lyric_transcribe, system, settings
|
||||
from .config import SUBSONIC_CONFIG_PATH
|
||||
|
||||
app = FastAPI(title="StemEngine", version="1.0.0")
|
||||
_log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _purge_legacy_subsonic_config() -> None:
|
||||
"""Delete subsonic.json if it is in the legacy plaintext format.
|
||||
|
||||
Encrypted configs (_enc=True) are kept. Any file that lacks the _enc
|
||||
flag stored the password in cleartext and must be removed so it is never
|
||||
served again.
|
||||
"""
|
||||
if not SUBSONIC_CONFIG_PATH.exists():
|
||||
return
|
||||
try:
|
||||
stored = json.loads(SUBSONIC_CONFIG_PATH.read_text())
|
||||
except Exception:
|
||||
stored = {}
|
||||
if not stored.get('_enc'):
|
||||
SUBSONIC_CONFIG_PATH.unlink()
|
||||
_log.warning(
|
||||
"Deleted legacy plaintext Subsonic config at %s — "
|
||||
"re-enter credentials via the Settings UI.",
|
||||
SUBSONIC_CONFIG_PATH,
|
||||
)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app):
|
||||
_purge_legacy_subsonic_config()
|
||||
yield
|
||||
|
||||
|
||||
app = FastAPI(title="StemEngine", version="1.0.0", lifespan=lifespan)
|
||||
|
||||
# Allow all origins during development; tighten in production if needed.
|
||||
app.add_middleware(
|
||||
|
||||
@@ -14,16 +14,13 @@
|
||||
<!-- Theme color (browser chrome on Android, tab bar tint) -->
|
||||
<meta name="theme-color" content="#3B82F6" />
|
||||
|
||||
<!-- Supports both light and dark OS themes; JS will set the active scheme -->
|
||||
<meta name="color-scheme" content="light dark" />
|
||||
|
||||
<!-- iOS PWA -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta name="apple-mobile-web-app-title" content="StemEngine" />
|
||||
<link rel="apple-touch-icon" href="/icon.svg" />
|
||||
<script type="module" crossorigin src="/assets/index-CBWP_Huh.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-3eSjKY18.css">
|
||||
<script type="module" crossorigin src="/assets/index-CbPgJQFv.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-eZreWOFb.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
<!-- Theme color (browser chrome on Android, tab bar tint) -->
|
||||
<meta name="theme-color" content="#3B82F6" />
|
||||
|
||||
<!-- Supports both light and dark OS themes; JS will set the active scheme -->
|
||||
<meta name="color-scheme" content="light dark" />
|
||||
|
||||
<!-- iOS PWA -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
+117
@@ -17,6 +17,7 @@
|
||||
"@fontsource/roboto": "^5.0.0",
|
||||
"@fontsource/work-sans": "^5.0.0",
|
||||
"@fontsource/young-serif": "^5.0.0",
|
||||
"@olton/metroui": "^5.1.20",
|
||||
"@tanstack/react-query": "^5.0.0",
|
||||
"@tonejs/midi": "^2.0.28",
|
||||
"abcjs": "^6.6.2",
|
||||
@@ -849,6 +850,116 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@olton/datetime": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@olton/datetime/-/datetime-3.3.0.tgz",
|
||||
"integrity": "sha512-YqGLhVp0iisuDjQZ77PQkRciEfFp92znIdwTq4jU86KQisYfzL0Z23MnT9CWDC7mDjxQOZczLh956eR1RsOVAg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/dom": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@olton/dom/-/dom-1.5.1.tgz",
|
||||
"integrity": "sha512-vVXQYluo3id17GTol+0GI2RbD7HS9ajT6avHbnLXKE7ORjQ/NNfaRtvgJqWOnLGC0H+O09gVSm3g8HGOiNaRYQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"web-worker": "^1.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@olton/farbe": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@olton/farbe/-/farbe-1.0.11.tgz",
|
||||
"integrity": "sha512-gYpiDuKUIfONnc21a/q322RLGHGcwN0VABj+g3CoXwO4ysVxDVdAzfrwlOWbe4fFJwswr/HUUG0Ll8iJRo0eiw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "serhii@pimenov.com.ua"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/metroui"
|
||||
},
|
||||
{
|
||||
"type": "subscription",
|
||||
"url": "https://korzh.com/metroui#licensing"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/guardian": {
|
||||
"version": "0.7.3",
|
||||
"resolved": "https://registry.npmjs.org/@olton/guardian/-/guardian-0.7.3.tgz",
|
||||
"integrity": "sha512-ypl1ePJHjhz7Kl+Mo+N4E85bqgjIgdh070zmz22ZrVtv7lMXyvJ5yNJaz33UOvYKPylU9yQfi4MDomPuSfFQkg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/hooks": {
|
||||
"version": "0.13.1",
|
||||
"resolved": "https://registry.npmjs.org/@olton/hooks/-/hooks-0.13.1.tgz",
|
||||
"integrity": "sha512-Mi59Dnmg9N7Yv0FsbrrPKf6GEvRbSv3bNca20whjCUQguQ7qUx4T54XX9KFAkJNqTVDQHbppZgV3pYjRsdb23w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/html": {
|
||||
"version": "0.15.1",
|
||||
"resolved": "https://registry.npmjs.org/@olton/html/-/html-0.15.1.tgz",
|
||||
"integrity": "sha512-jdKda7+O/oOCJDOdIV9BAd5tk1qYuUUNYSVK0KAAY/fkycCjBG7QwStzNGmtaXz8bpIcL1giid+JdcSe4BaNUw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "serhii@pimenov.com.ua"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/metroui"
|
||||
},
|
||||
{
|
||||
"type": "subscription",
|
||||
"url": "https://korzh.com/metroui#licensing"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/metroui": {
|
||||
"version": "5.1.20",
|
||||
"resolved": "https://registry.npmjs.org/@olton/metroui/-/metroui-5.1.20.tgz",
|
||||
"integrity": "sha512-YV49RzUC3Uj4jqTSoADrmK/nHJ90TgJea50flmBKmDn34NxZtkrg3CAz9qy8726+I7ogdwWMBoxBfnqPfaTJYw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@olton/datetime": "^3.3.0",
|
||||
"@olton/dom": "^1.5.1",
|
||||
"@olton/farbe": "^1.0.11",
|
||||
"@olton/guardian": "^0.7.3",
|
||||
"@olton/hooks": "^0.13.1",
|
||||
"@olton/html": "^0.15.1",
|
||||
"@olton/model": "^0.18.1",
|
||||
"@olton/router": "^0.4.1",
|
||||
"@olton/string": "^0.10.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/metroui"
|
||||
}
|
||||
},
|
||||
"node_modules/@olton/model": {
|
||||
"version": "0.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@olton/model/-/model-0.18.1.tgz",
|
||||
"integrity": "sha512-UyvvUrINPC9W5mbf2sZXAbDaUKuRykQ7TCpfqfx2Qd8mPskMt5R65zzmYBtAoapeDfxtvnAYi9PYIwgIraKyZw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/metroui"
|
||||
}
|
||||
},
|
||||
"node_modules/@olton/router": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@olton/router/-/router-0.4.1.tgz",
|
||||
"integrity": "sha512-9pCSomojBBM3kkqlofttpYchF+Qm2D73IYCQq2NBhiPkustnkXua9i4XCSVP3ptXpgvIOsc6+RnPR7AGB+5utA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/string": {
|
||||
"version": "0.10.2",
|
||||
"resolved": "https://registry.npmjs.org/@olton/string/-/string-0.10.2.tgz",
|
||||
"integrity": "sha512-xuBuCOkgyJkEyVBSkjFPIYuAzZiCiGQuks/eWvwgF01A+QMXLv1w+OpR1M40ehCjvKVgz4eXWHqSBL7wfX+KiQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@rolldown/pluginutils": {
|
||||
"version": "1.0.0-beta.27",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz",
|
||||
@@ -2681,6 +2792,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/web-worker": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.5.0.tgz",
|
||||
"integrity": "sha512-RiMReJrTAiA+mBjGONMnjVDP2u3p9R1vkcGz6gDIrOMT3oGuYwX2WRMYI9ipkphSuE5XKEhydbhNEJh4NY9mlw==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/yallist": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
|
||||
@@ -9,6 +9,7 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@olton/metroui": "^5.1.20",
|
||||
"@fontsource/archivo": "^5.0.0",
|
||||
"@fontsource/eb-garamond": "^5.0.0",
|
||||
"@fontsource/inter": "^5.0.0",
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Executable
+295
@@ -0,0 +1,295 @@
|
||||
/**
|
||||
* App.tsx — StemEngine shell
|
||||
*
|
||||
* Phase 1 (MetroUI migration): outer shell uses MetroUI app-bar + CSS classes.
|
||||
* Inner pages (Separator, ProjectDetail, Settings, Sidebar) still use Tailwind;
|
||||
* they will be migrated in subsequent phases.
|
||||
*/
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { Music2, Settings, Cpu } from 'lucide-react'
|
||||
import Separator from './pages/Separator'
|
||||
import ProjectDetail from './pages/ProjectDetail'
|
||||
import SettingsPage, { applyFont, applyAccent } from './pages/Settings'
|
||||
import { ThemeProvider } from './context/ThemeContext'
|
||||
import Sidebar from './components/Sidebar'
|
||||
import GlobalAudioBar from './components/GlobalAudioBar'
|
||||
import { listProjects, deleteProject, getGpuInfo, resetGpu } from './api/client'
|
||||
import type { Project } from './types'
|
||||
|
||||
interface ProjectTab {
|
||||
id: string
|
||||
label: string
|
||||
name: string
|
||||
}
|
||||
|
||||
interface GpuInfo {
|
||||
cuda_available: boolean
|
||||
cuda_ok: boolean
|
||||
name: string | null
|
||||
free_mb: number
|
||||
total_mb: number
|
||||
}
|
||||
|
||||
function AppShell() {
|
||||
const [activeTabId, setActiveTabId] = useState<string>(
|
||||
() => localStorage.getItem('stemengine-active-tab') ?? 'separate'
|
||||
)
|
||||
const [projectTabs, setProjectTabs] = useState<ProjectTab[]>([])
|
||||
const [sidebarOpen, setSidebarOpen] = useState(() => window.innerWidth >= 640)
|
||||
|
||||
const [gpuInfo, setGpuInfo] = useState<GpuInfo | null>(null)
|
||||
const [gpuResetting, setGpuResetting] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('stemengine-active-tab', activeTabId)
|
||||
}, [activeTabId])
|
||||
|
||||
useEffect(() => {
|
||||
applyFont(localStorage.getItem('stemengine-font') ?? 'system')
|
||||
applyAccent(localStorage.getItem('stemengine-accent') ?? 'blue')
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
listProjects()
|
||||
.then((projects: Project[]) => {
|
||||
const tabs = projects.map((p) => ({
|
||||
id: p.id,
|
||||
label: p.tab_label || p.name,
|
||||
name: p.name,
|
||||
}))
|
||||
setProjectTabs(tabs)
|
||||
setActiveTabId((current) => {
|
||||
if (current === 'separate' || current === 'settings') return current
|
||||
return tabs.find((t) => t.id === current) ? current : 'separate'
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchGpu() {
|
||||
try { setGpuInfo(await getGpuInfo()) } catch {}
|
||||
}
|
||||
fetchGpu()
|
||||
const id = setInterval(fetchGpu, 30_000)
|
||||
return () => clearInterval(id)
|
||||
}, [])
|
||||
|
||||
async function handleGpuReset() {
|
||||
setGpuResetting(true)
|
||||
try {
|
||||
await resetGpu()
|
||||
setGpuInfo(await getGpuInfo())
|
||||
} catch {}
|
||||
setGpuResetting(false)
|
||||
}
|
||||
|
||||
const gpuContextFailed = gpuInfo?.cuda_available === true && gpuInfo.cuda_ok === false
|
||||
useEffect(() => {
|
||||
if (gpuContextFailed && !gpuResetting) handleGpuReset()
|
||||
}, [gpuContextFailed])
|
||||
|
||||
const handleSeparationComplete = useCallback(
|
||||
(projectId: string, tabLabel: string, projectName: string) => {
|
||||
setProjectTabs((prev) => {
|
||||
if (prev.find((t) => t.id === projectId)) return prev
|
||||
return [...prev, { id: projectId, label: tabLabel, name: projectName }]
|
||||
})
|
||||
setActiveTabId(projectId)
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
async function handleCloseTab(projectId: string, projectName: string) {
|
||||
const label = projectTabs.find((t) => t.id === projectId)?.label || projectName
|
||||
if (!window.confirm(`Delete "${label}"?\n\nThis will permanently remove the project and all its files.`)) return
|
||||
try { await deleteProject(projectId) } catch {}
|
||||
setProjectTabs((prev) => prev.filter((t) => t.id !== projectId))
|
||||
if (activeTabId === projectId) setActiveTabId('separate')
|
||||
}
|
||||
|
||||
function handleDeleteProjectFromSidebar(project: Project) {
|
||||
setProjectTabs((prev) => prev.filter((t) => t.id !== project.id))
|
||||
if (activeTabId === project.id) setActiveTabId('separate')
|
||||
}
|
||||
|
||||
function handleOpenProject(project: Project) {
|
||||
setProjectTabs((prev) => {
|
||||
if (prev.find((t) => t.id === project.id)) return prev
|
||||
return [...prev, { id: project.id, label: project.tab_label || project.name, name: project.name }]
|
||||
})
|
||||
setActiveTabId(project.id)
|
||||
}
|
||||
|
||||
const gpuError = gpuInfo ? (!gpuInfo.cuda_ok || !gpuInfo.cuda_available) : false
|
||||
const gpuTitle = gpuInfo
|
||||
? gpuInfo.cuda_available
|
||||
? `${gpuInfo.name ?? 'GPU'} · ${gpuInfo.free_mb} / ${gpuInfo.total_mb} MB free${!gpuInfo.cuda_ok ? ' · Context error — click to reset' : ''}`
|
||||
: 'CUDA unavailable — click to attempt reset'
|
||||
: 'GPU status unknown'
|
||||
|
||||
// ── Accent colour: map app accent id to MetroUI colour class ─────────────
|
||||
// Used for the active-settings button highlight via inline style.
|
||||
const accentHex = (() => {
|
||||
const raw = document.documentElement.dataset.accent ?? 'blue'
|
||||
const map: Record<string, string> = {
|
||||
blue: '#3b82f6', violet: '#8b5cf6', rose: '#f43f5e',
|
||||
emerald: '#10b981', amber: '#f59e0b', cyan: '#06b6d4',
|
||||
}
|
||||
return map[raw] ?? map.blue
|
||||
})()
|
||||
|
||||
// ── GPU status dot colour ─────────────────────────────────────────────────
|
||||
const gpuDotColor = !gpuInfo
|
||||
? 'transparent'
|
||||
: !gpuInfo.cuda_available ? '#64748b'
|
||||
: !gpuInfo.cuda_ok ? '#ef4444'
|
||||
: '#34d399'
|
||||
|
||||
return (
|
||||
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
||||
|
||||
{/* ── AppBar ──────────────────────────────────────────────────────────── */}
|
||||
<header style={{ flexShrink: 0, position: 'relative', zIndex: 20 }}>
|
||||
{/* Accent gradient line */}
|
||||
<div style={{
|
||||
height: 3,
|
||||
background: `linear-gradient(90deg, rgb(var(--brand-500, 59 130 246)), #a855f7, #f43f5e)`,
|
||||
}} />
|
||||
|
||||
<div className="app-bar" style={{ background: 'var(--sidebar-background)', borderBottom: '1px solid var(--border-color)' }}>
|
||||
|
||||
{/* Brand */}
|
||||
<div className="app-bar-brand">
|
||||
<button
|
||||
onClick={() => setActiveTabId('separate')}
|
||||
title="Home"
|
||||
className="button flat"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '4px 8px' }}
|
||||
>
|
||||
<div style={{
|
||||
width: 32, height: 32, borderRadius: 8, flexShrink: 0,
|
||||
background: `linear-gradient(135deg, rgb(var(--brand-500, 59 130 246)), rgb(var(--brand-700, 29 78 216)))`,
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
}}>
|
||||
<Music2 size={16} color="white" />
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', lineHeight: 1.2 }}>
|
||||
<span style={{ fontWeight: 700, fontSize: 15 }}>StemEngine</span>
|
||||
<span style={{ fontSize: 11, opacity: 0.45 }}>Audio processing toolkit</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Right-side icon buttons */}
|
||||
<div className="app-bar-item" style={{ display: 'flex', alignItems: 'center', gap: 4, marginLeft: 'auto' }}>
|
||||
|
||||
{/* GPU status */}
|
||||
<button
|
||||
onClick={handleGpuReset}
|
||||
title={gpuTitle}
|
||||
className="button cycle flat"
|
||||
style={{
|
||||
position: 'relative',
|
||||
color: gpuError ? '#ef4444' : undefined,
|
||||
}}
|
||||
>
|
||||
<Cpu size={16} style={{ animation: gpuResetting ? 'pulse 1s infinite' : undefined }} />
|
||||
{/* Status dot */}
|
||||
<span style={{
|
||||
position: 'absolute', top: 4, right: 4,
|
||||
width: 6, height: 6, borderRadius: '50%',
|
||||
background: gpuDotColor,
|
||||
transition: 'background 0.3s',
|
||||
}} />
|
||||
</button>
|
||||
|
||||
{/* Settings */}
|
||||
<button
|
||||
onClick={() => setActiveTabId('settings')}
|
||||
title="Settings"
|
||||
className="button cycle flat"
|
||||
style={{
|
||||
color: activeTabId === 'settings' ? accentHex : undefined,
|
||||
borderColor: activeTabId === 'settings' ? accentHex : undefined,
|
||||
}}
|
||||
>
|
||||
<Settings size={16} />
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* ── Body ────────────────────────────────────────────────────────────── */}
|
||||
<div style={{ display: 'flex', flex: 1, overflow: 'hidden' }}>
|
||||
|
||||
{/* Mobile backdrop — tapping it closes the sidebar (hidden on sm+ where sidebar is in flow) */}
|
||||
{sidebarOpen && (
|
||||
<div
|
||||
className="sm:hidden"
|
||||
style={{ position: 'fixed', inset: 0, zIndex: 20, background: 'rgba(0,0,0,0.4)' }}
|
||||
onClick={() => setSidebarOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Sidebar — Tailwind, migrated in Phase 2 */}
|
||||
<Sidebar
|
||||
isOpen={sidebarOpen}
|
||||
onToggle={() => setSidebarOpen((v) => !v)}
|
||||
onOpenProject={(p) => { handleOpenProject(p); setSidebarOpen(false) }}
|
||||
onDeleteProject={handleDeleteProjectFromSidebar}
|
||||
openTabIds={projectTabs.map((t) => t.id)}
|
||||
/>
|
||||
|
||||
{/* Main content area */}
|
||||
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
||||
<main style={{ flex: 1, overflowY: 'auto', paddingBottom: 48 }}>
|
||||
{activeTabId === 'settings' ? (
|
||||
// Settings page — Tailwind, migrated in Phase 5
|
||||
<SettingsPage />
|
||||
) : (
|
||||
<div style={{ maxWidth: 768, margin: '0 auto', padding: '16px 16px' }}>
|
||||
<div style={{ border: '1px solid var(--border-color)', borderRadius: 16, background: 'var(--body-background, var(--background))', padding: 24, boxShadow: '0 1px 6px rgba(0,0,0,0.08)' }}>
|
||||
{activeTabId === 'separate' ? (
|
||||
<Separator
|
||||
onSeparationComplete={handleSeparationComplete}
|
||||
onOpenSettings={() => {
|
||||
localStorage.setItem('stemengine-settings-initial-tab', 'autopipeline')
|
||||
setActiveTabId('settings')
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<ProjectDetail
|
||||
id={activeTabId}
|
||||
onDelete={() => {
|
||||
const tab = projectTabs.find((t) => t.id === activeTabId)
|
||||
if (tab) handleCloseTab(tab.id, tab.name)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<footer style={{ marginTop: 24, textAlign: 'center', fontSize: 11, opacity: 0.35 }}>
|
||||
StemEngine · Demucs · BS-RoFormer · Omnizart · wav2vec2
|
||||
</footer>
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Floating playback bar — GlobalAudioBar, migrated in Phase 6 */}
|
||||
<GlobalAudioBar />
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<AppShell />
|
||||
</ThemeProvider>
|
||||
)
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+156
-138
@@ -91,10 +91,11 @@ async function pollUntilDone(jobId: string, signal?: AbortSignal): Promise<Job>
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function StepIcon({ step }: { step: AutoStep }) {
|
||||
if (step.type === 'reprocess') return <Music2 className="w-3.5 h-3.5 text-purple-500" />
|
||||
if (step.type === 'midi') return <Mic2 className="w-3.5 h-3.5 text-emerald-500" />
|
||||
if (step.type === 'lyricsAlign') return <BookmarkPlus className="w-3.5 h-3.5 text-teal-500" />
|
||||
return <AlignLeft className="w-3.5 h-3.5 text-sky-500" />
|
||||
const s = { width: 14, height: 14, flexShrink: 0 }
|
||||
if (step.type === 'reprocess') return <Music2 style={{ ...s, color: 'var(--color-violet, #a78bfa)' }} />
|
||||
if (step.type === 'midi') return <Mic2 style={{ ...s, color: 'var(--color-green)' }} />
|
||||
if (step.type === 'lyricsAlign') return <BookmarkPlus style={{ ...s, color: 'var(--color-teal, #2dd4bf)' }} />
|
||||
return <AlignLeft style={{ ...s, color: 'var(--color-blue, #38bdf8)' }} />
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -227,161 +228,178 @@ export default function AutoPipelineDialog({ target, onClose, onComplete, onOpen
|
||||
const finished = phase === 'done' || phase === 'error'
|
||||
const canRun = !!(target.file || target.filePath)
|
||||
|
||||
const brand = 'rgb(var(--brand-500, 59 130 246))'
|
||||
const amber = 'var(--color-amber)'
|
||||
|
||||
const stepColor = (status: StepStatus['status']) => {
|
||||
if (status === 'running') return brand
|
||||
if (status === 'done') return 'var(--color-green)'
|
||||
if (status === 'error') return 'var(--color-red)'
|
||||
return 'inherit'
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="fixed bottom-4 right-4 z-50 w-96 rounded-2xl bg-white dark:bg-gray-900 border border-slate-200 dark:border-gray-700 shadow-2xl flex flex-col max-h-[85vh]">
|
||||
<div style={{
|
||||
position: 'fixed', bottom: 16, right: 16, zIndex: 50, width: 384,
|
||||
borderRadius: 16, border: '1px solid var(--border-color)',
|
||||
background: 'var(--body-background, var(--background))',
|
||||
boxShadow: '0 8px 32px rgba(0,0,0,0.24)',
|
||||
display: 'flex', flexDirection: 'column', maxHeight: '85vh',
|
||||
}}>
|
||||
|
||||
{/* Header */}
|
||||
<div className="flex items-center gap-3 px-5 py-4 border-b border-slate-200 dark:border-gray-800 shrink-0">
|
||||
<Zap className="w-5 h-5 text-amber-500 shrink-0" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<h2 className="text-sm font-bold text-slate-900 dark:text-white">Auto Pipeline</h2>
|
||||
<p className="text-xs text-slate-500 dark:text-gray-400 truncate">{target.filename}</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={running ? cancel : onClose}
|
||||
className="p-1.5 rounded-lg text-slate-400 hover:text-slate-600 dark:hover:text-gray-200 transition-colors"
|
||||
>
|
||||
<X className="w-4 h-4" />
|
||||
</button>
|
||||
{/* Header */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 12, padding: '14px 20px', borderBottom: '1px solid var(--border-color)', flexShrink: 0 }}>
|
||||
<Zap style={{ width: 20, height: 20, color: amber, flexShrink: 0 }} />
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<h2 style={{ margin: 0, fontSize: 13, fontWeight: 700 }}>Auto Pipeline</h2>
|
||||
<p style={{ margin: 0, fontSize: 11, opacity: 0.5, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{target.filename}</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={running ? cancel : onClose}
|
||||
className="button cycle flat"
|
||||
style={{ padding: 6, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
||||
>
|
||||
<X style={{ width: 16, height: 16 }} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Body */}
|
||||
<div className="flex-1 overflow-y-auto p-5 space-y-4">
|
||||
{/* Body */}
|
||||
<div style={{ flex: 1, overflowY: 'auto', padding: 20, display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
|
||||
{/* Project name */}
|
||||
{!running && !finished && (
|
||||
<label className="space-y-1 block">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Project Name</span>
|
||||
<input
|
||||
type="text"
|
||||
value={projName}
|
||||
onChange={e => setProjName(e.target.value)}
|
||||
placeholder="Artist - Title"
|
||||
className="w-full rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-3 py-2 text-sm text-slate-900 dark:text-gray-100 focus:border-brand-500 focus:outline-none"
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
{/* Project name */}
|
||||
{!running && !finished && (
|
||||
<label style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
|
||||
<span style={{ fontSize: 10, fontWeight: 600, opacity: 0.5, textTransform: 'uppercase', letterSpacing: '0.08em' }}>Project Name</span>
|
||||
<input
|
||||
type="text"
|
||||
value={projName}
|
||||
onChange={e => setProjName(e.target.value)}
|
||||
placeholder="Artist - Title"
|
||||
style={{ width: '100%', borderRadius: 6, border: '1px solid var(--border-color)', padding: '7px 12px', fontSize: 13, background: 'transparent', boxSizing: 'border-box' }}
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
|
||||
{/* Pipeline summary (shown before run) */}
|
||||
{!running && !finished && (
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs font-semibold text-slate-500 dark:text-gray-400 uppercase tracking-wider">
|
||||
Pipeline ({1 + steps.length} step{steps.length !== 0 ? 's' : ''})
|
||||
</span>
|
||||
{/* Pipeline summary */}
|
||||
{!running && !finished && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<span style={{ fontSize: 10, fontWeight: 600, opacity: 0.5, textTransform: 'uppercase', letterSpacing: '0.08em' }}>
|
||||
Pipeline ({1 + steps.length} step{steps.length !== 0 ? 's' : ''})
|
||||
</span>
|
||||
{onOpenSettings && (
|
||||
<button
|
||||
onClick={onOpenSettings}
|
||||
style={{ display: 'inline-flex', alignItems: 'center', gap: 4, fontSize: 11, color: brand, background: 'none', border: 'none', cursor: 'pointer', padding: 0 }}
|
||||
>
|
||||
<Settings style={{ width: 12, height: 12 }} />
|
||||
Edit in Settings
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Separation step */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '7px 12px', borderRadius: 6, border: '1px solid var(--border-color)' }}>
|
||||
<Music2 style={{ width: 14, height: 14, color: brand, flexShrink: 0 }} />
|
||||
<span style={{ flex: 1, fontSize: 13 }}>Stem Separation</span>
|
||||
<span style={{ fontSize: 11, opacity: 0.5, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth: 128 }}>
|
||||
{model} · {format}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{steps.length === 0 && (
|
||||
<p style={{ margin: 0, fontSize: 11, opacity: 0.5, fontStyle: 'italic', padding: '0 4px' }}>
|
||||
No extra steps configured.{' '}
|
||||
{onOpenSettings && (
|
||||
<button
|
||||
onClick={onOpenSettings}
|
||||
className="flex items-center gap-1 text-xs text-brand-500 hover:text-brand-600 dark:text-brand-400 transition-colors"
|
||||
>
|
||||
<Settings className="w-3 h-3" />
|
||||
Edit in Settings
|
||||
<button onClick={onOpenSettings} style={{ color: brand, background: 'none', border: 'none', cursor: 'pointer', padding: 0, fontSize: 11, textDecoration: 'underline' }}>
|
||||
Add steps in Settings →
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Separation step */}
|
||||
<div className="flex items-center gap-2.5 px-3 py-2 rounded-lg bg-slate-50 dark:bg-gray-800/50 border border-slate-200 dark:border-gray-700">
|
||||
<Music2 className="w-3.5 h-3.5 text-brand-500 shrink-0" />
|
||||
<span className="text-sm text-slate-700 dark:text-gray-200 flex-1">Stem Separation</span>
|
||||
<span className="text-xs text-slate-400 dark:text-gray-500 truncate max-w-32">
|
||||
{model} · {format}
|
||||
{steps.map((step, i) => (
|
||||
<div key={i} style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '7px 12px', borderRadius: 6, border: '1px solid var(--border-color)' }}>
|
||||
<StepIcon step={step} />
|
||||
<span style={{ flex: 1, fontSize: 13, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{stepLabel(step)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{steps.length === 0 && (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-500 italic px-1">
|
||||
No extra steps configured.{' '}
|
||||
{onOpenSettings && (
|
||||
<button onClick={onOpenSettings} className="text-brand-500 hover:underline">
|
||||
Add steps in Settings →
|
||||
</button>
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{steps.map((step, i) => (
|
||||
<div key={i} className="flex items-center gap-2.5 px-3 py-2 rounded-lg bg-slate-50 dark:bg-gray-800/50 border border-slate-200 dark:border-gray-700">
|
||||
<StepIcon step={step} />
|
||||
<span className="text-sm text-slate-700 dark:text-gray-200 flex-1 truncate">
|
||||
{stepLabel(step)}
|
||||
</span>
|
||||
{/* Live progress */}
|
||||
{stepStats.length > 0 && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||||
<span style={{ fontSize: 10, fontWeight: 600, opacity: 0.5, textTransform: 'uppercase', letterSpacing: '0.08em' }}>Progress</span>
|
||||
{stepStats.map((s, i) => (
|
||||
<div key={i} style={{ display: 'flex', alignItems: 'flex-start', gap: 12 }}>
|
||||
<div style={{ marginTop: 2, flexShrink: 0 }}>
|
||||
{s.status === 'running' && <Loader2 style={{ width: 16, height: 16, color: brand }} />}
|
||||
{s.status === 'done' && <CheckCircle2 style={{ width: 16, height: 16, color: 'var(--color-green)' }} />}
|
||||
{s.status === 'error' && <XCircle style={{ width: 16, height: 16, color: 'var(--color-red)' }} />}
|
||||
{s.status === 'pending' && <div style={{ width: 16, height: 16, borderRadius: '50%', border: '2px solid var(--border-color)' }} />}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Live progress */}
|
||||
{stepStats.length > 0 && (
|
||||
<div className="space-y-2">
|
||||
<span className="text-xs font-semibold text-slate-500 dark:text-gray-400 uppercase tracking-wider">
|
||||
Progress
|
||||
</span>
|
||||
{stepStats.map((s, i) => (
|
||||
<div key={i} className="flex items-start gap-3">
|
||||
<div className="mt-0.5 shrink-0">
|
||||
{s.status === 'running' && <Loader2 className="w-4 h-4 text-brand-500 animate-spin" />}
|
||||
{s.status === 'done' && <CheckCircle2 className="w-4 h-4 text-emerald-500" />}
|
||||
{s.status === 'error' && <XCircle className="w-4 h-4 text-red-500" />}
|
||||
{s.status === 'pending' && <div className="w-4 h-4 rounded-full border-2 border-slate-300 dark:border-gray-600" />}
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className={`text-sm font-medium ${
|
||||
s.status === 'running' ? 'text-brand-600 dark:text-brand-400'
|
||||
: s.status === 'done' ? 'text-emerald-700 dark:text-emerald-300'
|
||||
: s.status === 'error' ? 'text-red-600 dark:text-red-400'
|
||||
: 'text-slate-500 dark:text-gray-500'
|
||||
}`}>{s.label}</p>
|
||||
{s.detail && <p className="text-xs text-slate-400 dark:text-gray-500 truncate">{s.detail}</p>}
|
||||
</div>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<p style={{ margin: 0, fontSize: 13, fontWeight: 500, color: stepColor(s.status) }}>{s.label}</p>
|
||||
{s.detail && <p style={{ margin: '2px 0 0', fontSize: 11, opacity: 0.5, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{s.detail}</p>}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{errMsg && (
|
||||
<div className="rounded-lg bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-800 px-4 py-3 text-sm text-red-700 dark:text-red-300">
|
||||
{errMsg}
|
||||
</div>
|
||||
)}
|
||||
{errMsg && (
|
||||
<div style={{ borderRadius: 6, border: '1px solid var(--color-red)', padding: '10px 16px', fontSize: 13, color: 'var(--color-red)', opacity: 0.85 }}>
|
||||
{errMsg}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{phase === 'done' && (
|
||||
<div className="rounded-lg bg-emerald-50 dark:bg-emerald-950/30 border border-emerald-200 dark:border-emerald-800 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-300 font-medium">
|
||||
Pipeline complete!
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{phase === 'done' && (
|
||||
<div style={{ borderRadius: 6, border: '1px solid var(--color-green)', padding: '10px 16px', fontSize: 13, fontWeight: 500, color: 'var(--color-green)', opacity: 0.9 }}>
|
||||
Pipeline complete!
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="px-5 py-4 border-t border-slate-200 dark:border-gray-800 shrink-0 flex gap-3">
|
||||
{!finished && (
|
||||
<>
|
||||
<button
|
||||
onClick={running ? cancel : onClose}
|
||||
className="flex-1 rounded-lg border border-slate-300 dark:border-gray-600 px-4 py-2.5 text-sm font-medium text-slate-600 dark:text-gray-300 hover:bg-slate-50 dark:hover:bg-gray-800 transition-colors"
|
||||
>
|
||||
{running ? 'Cancel' : 'Dismiss'}
|
||||
</button>
|
||||
<button
|
||||
onClick={run}
|
||||
disabled={running || !canRun}
|
||||
className="flex-1 rounded-lg bg-amber-500 hover:bg-amber-400 disabled:bg-slate-200 disabled:text-slate-400 dark:disabled:bg-gray-800 dark:disabled:text-gray-500 px-4 py-2.5 text-sm font-bold text-white disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2"
|
||||
>
|
||||
{running
|
||||
? <><Loader2 className="w-4 h-4 animate-spin" />Running…</>
|
||||
: <><Zap className="w-4 h-4" />Run Pipeline</>}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{finished && (
|
||||
{/* Footer */}
|
||||
<div style={{ padding: '14px 20px', borderTop: '1px solid var(--border-color)', flexShrink: 0, display: 'flex', gap: 12 }}>
|
||||
{!finished && (
|
||||
<>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="flex-1 rounded-lg bg-brand-600 hover:bg-brand-500 px-4 py-2.5 text-sm font-bold text-white transition-colors"
|
||||
onClick={running ? cancel : onClose}
|
||||
style={{ flex: 1, borderRadius: 6, border: '1px solid var(--border-color)', padding: '9px 16px', fontSize: 13, fontWeight: 500, background: 'transparent', cursor: 'pointer' }}
|
||||
>
|
||||
Close
|
||||
{running ? 'Cancel' : 'Dismiss'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
onClick={run}
|
||||
disabled={running || !canRun}
|
||||
style={{
|
||||
flex: 1, borderRadius: 6, border: 'none', padding: '9px 16px', fontSize: 13, fontWeight: 700,
|
||||
background: running || !canRun ? 'var(--border-color)' : amber,
|
||||
color: running || !canRun ? 'inherit' : '#fff',
|
||||
cursor: running || !canRun ? 'not-allowed' : 'pointer',
|
||||
display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 8,
|
||||
}}
|
||||
>
|
||||
{running
|
||||
? <><Loader2 style={{ width: 16, height: 16 }} />Running…</>
|
||||
: <><Zap style={{ width: 16, height: 16 }} />Run Pipeline</>}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{finished && (
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="button primary"
|
||||
style={{ flex: 1, padding: '9px 16px', fontSize: 13, fontWeight: 700 }}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+37
-27
@@ -226,22 +226,29 @@ export default function DynamicMixPlayer({ stems, title, onLevelChange }: Props)
|
||||
|
||||
const allLoaded = stems.every((s) => loaded[s.name] !== false)
|
||||
|
||||
const brand = 'rgb(var(--brand-500, 59 130 246))'
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
{/* Playback controls */}
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 8 }}>
|
||||
<button
|
||||
onClick={togglePlay}
|
||||
disabled={!allLoaded}
|
||||
className="flex items-center justify-center w-9 h-9 rounded-full bg-brand-500 text-white hover:bg-brand-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0"
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
width: 36, height: 36, borderRadius: '50%', flexShrink: 0,
|
||||
background: brand, color: '#fff', border: 'none', cursor: allLoaded ? 'pointer' : 'not-allowed',
|
||||
opacity: allLoaded ? 1 : 0.5, padding: 0,
|
||||
}}
|
||||
>
|
||||
{isPlaying ? (
|
||||
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 24 24">
|
||||
<svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24">
|
||||
<rect x="6" y="4" width="4" height="16" />
|
||||
<rect x="14" y="4" width="4" height="16" />
|
||||
</svg>
|
||||
) : (
|
||||
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 24 24">
|
||||
<svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M8 5v14l11-7z" />
|
||||
</svg>
|
||||
)}
|
||||
@@ -253,23 +260,24 @@ export default function DynamicMixPlayer({ stems, title, onLevelChange }: Props)
|
||||
step={0.1}
|
||||
value={currentTime}
|
||||
onChange={(e) => handleSeek(parseFloat(e.target.value))}
|
||||
className="flex-1 min-w-[80px] h-2 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-500"
|
||||
style={{ flex: 1, minWidth: 80, cursor: 'pointer', accentColor: brand }}
|
||||
/>
|
||||
<span className="text-xs tabular-nums text-slate-500 dark:text-gray-400 shrink-0">
|
||||
<span style={{ fontSize: 11, fontVariantNumeric: 'tabular-nums', opacity: 0.6, flexShrink: 0 }}>
|
||||
{formatTime(currentTime)} / {formatTime(duration)}
|
||||
</span>
|
||||
|
||||
{/* Master volume */}
|
||||
<div className="flex items-center gap-1.5 pl-2 border-l border-slate-200 dark:border-gray-700 shrink-0">
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, paddingLeft: 8, borderLeft: '1px solid var(--border-color)', flexShrink: 0 }}>
|
||||
<button
|
||||
onClick={toggleMute}
|
||||
className="p-1.5 rounded-md text-slate-500 dark:text-gray-400 hover:text-slate-700 dark:hover:text-gray-200 hover:bg-slate-100 dark:hover:bg-gray-800 transition-colors"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 6, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
||||
title={isMuted ? 'Unmute' : 'Mute'}
|
||||
>
|
||||
{isMuted || masterVolume === 0 ? (
|
||||
<VolumeX className="w-4 h-4" />
|
||||
<VolumeX style={{ width: 16, height: 16 }} />
|
||||
) : (
|
||||
<Volume2 className="w-4 h-4" />
|
||||
<Volume2 style={{ width: 16, height: 16 }} />
|
||||
)}
|
||||
</button>
|
||||
<input
|
||||
@@ -279,38 +287,40 @@ export default function DynamicMixPlayer({ stems, title, onLevelChange }: Props)
|
||||
step={0.05}
|
||||
value={isMuted ? 0 : masterVolume}
|
||||
onChange={(e) => updateMasterVolume(parseFloat(e.target.value))}
|
||||
className="w-16 sm:w-20 h-2 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-500"
|
||||
style={{ width: 72, cursor: 'pointer', accentColor: brand }}
|
||||
title="Master Volume"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Stem level sliders */}
|
||||
<div className="space-y-2 pt-2 border-t border-slate-200 dark:border-gray-700">
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, paddingTop: 8, borderTop: '1px solid var(--border-color)' }}>
|
||||
{stems.map((stem) => (
|
||||
<div key={stem.name} className="flex items-center gap-1.5">
|
||||
<span className="text-xs font-medium text-slate-600 dark:text-gray-400 w-12 sm:w-16 truncate capitalize">
|
||||
<div key={stem.name} style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||
<span style={{ fontSize: 11, fontWeight: 500, opacity: 0.7, width: 52, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', textTransform: 'capitalize', flexShrink: 0 }}>
|
||||
{stem.label}
|
||||
</span>
|
||||
<button
|
||||
onClick={() => toggleStemMute(stem.name)}
|
||||
title={mutedStems[stem.name] ? 'Unmute' : 'Mute'}
|
||||
className={`w-6 h-6 text-xs font-bold rounded transition-colors flex-shrink-0 ${
|
||||
mutedStems[stem.name]
|
||||
? 'bg-red-500 text-white'
|
||||
: 'bg-slate-200 dark:bg-gray-700 text-slate-600 dark:text-gray-400 hover:bg-slate-300 dark:hover:bg-gray-600'
|
||||
}`}
|
||||
style={{
|
||||
width: 24, height: 24, fontSize: 11, fontWeight: 700, borderRadius: 4, flexShrink: 0,
|
||||
border: 'none', cursor: 'pointer', transition: 'background 0.15s',
|
||||
background: mutedStems[stem.name] ? 'var(--color-red)' : 'var(--border-color)',
|
||||
color: mutedStems[stem.name] ? '#fff' : 'inherit',
|
||||
}}
|
||||
>
|
||||
M
|
||||
</button>
|
||||
<button
|
||||
onClick={() => toggleStemSolo(stem.name)}
|
||||
title={soloedStems[stem.name] ? 'Unsolo' : 'Solo'}
|
||||
className={`w-6 h-6 text-xs font-bold rounded transition-colors flex-shrink-0 ${
|
||||
soloedStems[stem.name]
|
||||
? 'bg-yellow-400 text-black'
|
||||
: 'bg-slate-200 dark:bg-gray-700 text-slate-600 dark:text-gray-400 hover:bg-slate-300 dark:hover:bg-gray-600'
|
||||
}`}
|
||||
style={{
|
||||
width: 24, height: 24, fontSize: 11, fontWeight: 700, borderRadius: 4, flexShrink: 0,
|
||||
border: 'none', cursor: 'pointer', transition: 'background 0.15s',
|
||||
background: soloedStems[stem.name] ? 'var(--color-amber)' : 'var(--border-color)',
|
||||
color: soloedStems[stem.name] ? '#000' : 'inherit',
|
||||
}}
|
||||
>
|
||||
S
|
||||
</button>
|
||||
@@ -321,9 +331,9 @@ export default function DynamicMixPlayer({ stems, title, onLevelChange }: Props)
|
||||
step={0.1}
|
||||
value={gains[stem.name] ?? 1.0}
|
||||
onChange={(e) => updateGain(stem.name, parseFloat(e.target.value))}
|
||||
className="flex-1 h-2 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-500"
|
||||
style={{ flex: 1, cursor: 'pointer', accentColor: brand }}
|
||||
/>
|
||||
<span className="text-xs tabular-nums text-slate-500 dark:text-gray-400 w-9 text-right">
|
||||
<span style={{ fontSize: 11, fontVariantNumeric: 'tabular-nums', opacity: 0.6, width: 36, textAlign: 'right', flexShrink: 0 }}>
|
||||
{Math.round((gains[stem.name] ?? 1.0) * 100)}%
|
||||
</span>
|
||||
</div>
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* FileUpload.tsx — Phase 3 MetroUI migration
|
||||
* Drag-and-drop / click-to-upload zone. Logic unchanged.
|
||||
*/
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import { Upload } from 'lucide-react'
|
||||
|
||||
interface Props {
|
||||
label?: string
|
||||
accept?: string
|
||||
onFiles: (files: File[]) => void
|
||||
}
|
||||
|
||||
export default function FileUpload({ label = 'Drop files here', accept, onFiles }: Props) {
|
||||
const [dragOver, setDragOver] = useState(false)
|
||||
|
||||
const handleDrop = useCallback(
|
||||
(e: React.DragEvent) => {
|
||||
e.preventDefault()
|
||||
setDragOver(false)
|
||||
const files = Array.from(e.dataTransfer.files)
|
||||
if (files.length) onFiles(files)
|
||||
},
|
||||
[onFiles]
|
||||
)
|
||||
|
||||
const handleChange = useCallback(
|
||||
(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const files = Array.from(e.target.files || [])
|
||||
if (files.length) onFiles(files)
|
||||
e.target.value = '' // reset for re-upload
|
||||
},
|
||||
[onFiles]
|
||||
)
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
|
||||
return (
|
||||
<label
|
||||
onDragOver={(e) => { e.preventDefault(); setDragOver(true) }}
|
||||
onDragLeave={() => setDragOver(false)}
|
||||
onDrop={handleDrop}
|
||||
style={{
|
||||
display: 'flex', flexDirection: 'column', alignItems: 'center',
|
||||
justifyContent: 'center', gap: 12,
|
||||
padding: '28px 24px',
|
||||
borderRadius: 6,
|
||||
border: `2px dashed ${dragOver ? accentColor : 'var(--border-color)'}`,
|
||||
background: dragOver ? `rgba(var(--brand-500, 59 130 246), 0.05)` : 'var(--background)',
|
||||
cursor: 'pointer',
|
||||
transition: 'border-color 0.15s, background 0.15s',
|
||||
}}
|
||||
>
|
||||
<Upload size={28} style={{ color: dragOver ? accentColor : undefined, opacity: dragOver ? 1 : 0.35, transition: 'opacity 0.15s, color 0.15s' }} />
|
||||
<span style={{ fontSize: 13, opacity: 0.55, textAlign: 'center', lineHeight: 1.4 }}>{label}</span>
|
||||
<input type="file" accept={accept} onChange={handleChange} style={{ display: 'none' }} />
|
||||
</label>
|
||||
)
|
||||
}
|
||||
+32
-15
@@ -28,29 +28,44 @@ export default function GlobalAudioBar() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="fixed bottom-0 left-0 right-0 z-50 border-t border-slate-200 dark:border-gray-800 bg-white/95 dark:bg-gray-950/95 backdrop-blur-sm shadow-[0_-2px_8px_rgba(0,0,0,0.06)] dark:shadow-[0_-2px_8px_rgba(0,0,0,0.4)]">
|
||||
<div className="max-w-3xl mx-auto px-4 h-12 flex items-center gap-3">
|
||||
<div style={{
|
||||
position: 'fixed', bottom: 0, left: 0, right: 0, zIndex: 50,
|
||||
borderTop: '1px solid var(--border-color)',
|
||||
background: 'var(--bar-background)',
|
||||
backdropFilter: 'blur(12px)',
|
||||
boxShadow: '0 -2px 8px rgba(0,0,0,0.12)',
|
||||
}}>
|
||||
<div style={{
|
||||
maxWidth: 768, margin: '0 auto', padding: '0 16px',
|
||||
height: 48, display: 'flex', alignItems: 'center', gap: 12,
|
||||
}}>
|
||||
|
||||
{/* Play / Pause */}
|
||||
<button
|
||||
onClick={() => getActions().toggle()}
|
||||
className="flex items-center justify-center w-7 h-7 rounded-full bg-brand-500 text-white hover:bg-brand-600 transition-colors shrink-0"
|
||||
className="button cycle"
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
width: 28, height: 28, borderRadius: '50%', flexShrink: 0,
|
||||
background: 'rgb(var(--brand-500, 59 130 246))', color: '#fff',
|
||||
border: 'none', cursor: 'pointer', padding: 0,
|
||||
}}
|
||||
title={isPlaying ? 'Pause' : 'Play'}
|
||||
>
|
||||
{isPlaying ? (
|
||||
<svg className="w-3 h-3" fill="currentColor" viewBox="0 0 24 24">
|
||||
<svg width="12" height="12" fill="currentColor" viewBox="0 0 24 24">
|
||||
<rect x="6" y="4" width="4" height="16" />
|
||||
<rect x="14" y="4" width="4" height="16" />
|
||||
</svg>
|
||||
) : (
|
||||
<svg className="w-3 h-3" fill="currentColor" viewBox="0 0 24 24">
|
||||
<svg width="12" height="12" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M8 5v14l11-7z" />
|
||||
</svg>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{/* Current time */}
|
||||
<span className="text-xs tabular-nums text-slate-400 dark:text-gray-500 shrink-0 w-8 text-right">
|
||||
<span style={{ fontSize: 11, fontVariantNumeric: 'tabular-nums', opacity: 0.5, flexShrink: 0, width: 32, textAlign: 'right' }}>
|
||||
{fmtTime(currentTime)}
|
||||
</span>
|
||||
|
||||
@@ -62,30 +77,31 @@ export default function GlobalAudioBar() {
|
||||
step={0.1}
|
||||
value={currentTime}
|
||||
onChange={e => getActions().seek(parseFloat(e.target.value))}
|
||||
className="flex-1 h-1.5 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-500 min-w-0"
|
||||
style={{ flex: 1, minWidth: 0, cursor: 'pointer' }}
|
||||
/>
|
||||
|
||||
{/* Duration */}
|
||||
<span className="text-xs tabular-nums text-slate-400 dark:text-gray-500 shrink-0 w-8">
|
||||
<span style={{ fontSize: 11, fontVariantNumeric: 'tabular-nums', opacity: 0.5, flexShrink: 0, width: 32 }}>
|
||||
{fmtTime(duration)}
|
||||
</span>
|
||||
|
||||
{/* Title */}
|
||||
<span
|
||||
className="text-xs font-medium text-slate-500 dark:text-gray-500 truncate shrink min-w-0 max-w-[120px] sm:max-w-[180px]"
|
||||
style={{ fontSize: 11, fontWeight: 500, opacity: 0.6, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flexShrink: 1, minWidth: 0, maxWidth: 180 }}
|
||||
title={title}
|
||||
>
|
||||
{title}
|
||||
</span>
|
||||
|
||||
{/* Volume */}
|
||||
<div className="flex items-center gap-1 shrink-0 pl-2 border-l border-slate-200 dark:border-gray-700">
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 4, flexShrink: 0, paddingLeft: 8, borderLeft: '1px solid var(--border-color)' }}>
|
||||
<button
|
||||
onClick={handleMuteToggle}
|
||||
className="p-1 rounded text-slate-400 dark:text-gray-500 hover:text-slate-600 dark:hover:text-gray-300 transition-colors"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 4, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
||||
title={volume === 0 ? 'Unmute' : 'Mute'}
|
||||
>
|
||||
{volume === 0 ? <VolumeX className="w-3.5 h-3.5" /> : <Volume2 className="w-3.5 h-3.5" />}
|
||||
{volume === 0 ? <VolumeX style={{ width: 14, height: 14 }} /> : <Volume2 style={{ width: 14, height: 14 }} />}
|
||||
</button>
|
||||
<input
|
||||
type="range"
|
||||
@@ -94,7 +110,7 @@ export default function GlobalAudioBar() {
|
||||
step={0.05}
|
||||
value={volume}
|
||||
onChange={e => getActions().setVolume(parseFloat(e.target.value))}
|
||||
className="w-14 h-1.5 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-500"
|
||||
style={{ width: 56, cursor: 'pointer' }}
|
||||
title="Volume"
|
||||
/>
|
||||
</div>
|
||||
@@ -102,10 +118,11 @@ export default function GlobalAudioBar() {
|
||||
{/* Dismiss */}
|
||||
<button
|
||||
onClick={stopCurrent}
|
||||
className="p-1 rounded text-slate-400 dark:text-gray-500 hover:text-slate-600 dark:hover:text-gray-300 transition-colors shrink-0 ml-1"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0, marginLeft: 4 }}
|
||||
title="Stop and close"
|
||||
>
|
||||
<X className="w-3.5 h-3.5" />
|
||||
<X style={{ width: 14, height: 14 }} />
|
||||
</button>
|
||||
|
||||
</div>
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Loader2, CheckCircle, XCircle, AlertCircle } from 'lucide-react'
|
||||
import { getJob } from '../api/client'
|
||||
import type { Job } from '../types'
|
||||
|
||||
interface Props {
|
||||
jobId: string
|
||||
onDone?: (job: Job) => void
|
||||
}
|
||||
|
||||
export default function JobStatus({ jobId, onDone }: Props) {
|
||||
const [job, setJob] = useState<Job | null>(null)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
let timeout: ReturnType<typeof setTimeout>
|
||||
|
||||
async function poll() {
|
||||
try {
|
||||
const j = await getJob(jobId)
|
||||
if (cancelled) return
|
||||
setJob(j)
|
||||
setError(null)
|
||||
|
||||
if (j.status === 'done' || j.status === 'error' || j.status === 'cancelled') {
|
||||
if (j.status === 'done') onDone?.(j)
|
||||
return
|
||||
}
|
||||
|
||||
timeout = setTimeout(poll, 2000)
|
||||
} catch (e) {
|
||||
if (cancelled) return
|
||||
setError(String(e))
|
||||
timeout = setTimeout(poll, 5000)
|
||||
}
|
||||
}
|
||||
|
||||
poll()
|
||||
return () => {
|
||||
cancelled = true
|
||||
clearTimeout(timeout)
|
||||
}
|
||||
}, [jobId, onDone])
|
||||
|
||||
const row = { display: 'flex', alignItems: 'center', gap: 8, fontSize: 12 }
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div style={{ ...row, color: 'var(--color-red)' }}>
|
||||
<XCircle style={{ width: 16, height: 16, flexShrink: 0 }} />
|
||||
Error: {error}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!job) {
|
||||
return (
|
||||
<div style={{ ...row, opacity: 0.5 }}>
|
||||
<Loader2 style={{ width: 16, height: 16, flexShrink: 0 }} />
|
||||
Loading…
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const STATUS_COLOR: Record<string, string> = {
|
||||
queued: 'var(--color-amber)',
|
||||
running: 'rgb(var(--brand-500, 59 130 246))',
|
||||
done: 'var(--color-green)',
|
||||
error: 'var(--color-red)',
|
||||
cancelled: 'inherit',
|
||||
}
|
||||
|
||||
const STATUS_TEXT: Record<string, string> = {
|
||||
queued: 'Queued…',
|
||||
running: job.progress || 'Running…',
|
||||
done: 'Complete',
|
||||
error: `Error: ${job.error || 'Failed'}`,
|
||||
cancelled: 'Cancelled',
|
||||
}
|
||||
|
||||
const color = STATUS_COLOR[job.status] ?? 'inherit'
|
||||
|
||||
return (
|
||||
<div style={{ ...row, color, opacity: job.status === 'cancelled' ? 0.5 : 1 }}>
|
||||
{(job.status === 'queued' || job.status === 'running') && (
|
||||
<Loader2 style={{ width: 16, height: 16, flexShrink: 0 }} />
|
||||
)}
|
||||
{job.status === 'done' && <CheckCircle style={{ width: 16, height: 16, flexShrink: 0 }} />}
|
||||
{job.status === 'error' && <XCircle style={{ width: 16, height: 16, flexShrink: 0 }} />}
|
||||
{job.status === 'cancelled' && <AlertCircle style={{ width: 16, height: 16, flexShrink: 0 }} />}
|
||||
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{STATUS_TEXT[job.status] ?? job.status}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
File renamed without changes.
+27
-12
@@ -2111,57 +2111,72 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
style={undefined}
|
||||
>
|
||||
{/* Visual style tabs + toolbar — scrollable on narrow screens */}
|
||||
<div className={`flex items-center gap-1 px-2 py-1 border-b overflow-x-auto [&::-webkit-scrollbar]:hidden ${isFullscreen ? 'bg-black/40 border-white/10' : 'bg-slate-100/80 dark:bg-gray-800/80 border-slate-200/30 dark:border-gray-700/50'}`}>
|
||||
<div
|
||||
className="flex items-center gap-1 px-2 py-1 border-b overflow-x-auto [&::-webkit-scrollbar]:hidden"
|
||||
style={isFullscreen
|
||||
? { background: 'rgba(0,0,0,0.4)', borderColor: 'rgba(255,255,255,0.1)' }
|
||||
: { background: 'var(--background)', borderColor: 'var(--border-color)' }}
|
||||
>
|
||||
{VISUAL_STYLES.map(s => (
|
||||
<button
|
||||
key={s.id}
|
||||
onClick={() => { setVisualStyle(s.id); localStorage.setItem('stemengine-lyric-visual-style', s.id) }}
|
||||
title={s.desc}
|
||||
className={`shrink-0 px-2.5 py-1.5 rounded-md text-xs font-medium transition-colors ${
|
||||
visualStyle === s.id
|
||||
? 'bg-brand-500 text-white'
|
||||
: 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'
|
||||
}`}
|
||||
className="lp-btn shrink-0 px-2.5 py-1.5 rounded-md text-xs font-medium transition-colors"
|
||||
style={visualStyle === s.id
|
||||
? { background: 'rgb(var(--brand-500, 59 130 246))', color: '#fff' }
|
||||
: { color: 'var(--foreground-muted)' }}
|
||||
>
|
||||
{s.label}
|
||||
</button>
|
||||
))}
|
||||
{hasElrc && (
|
||||
<span className="ml-2 shrink-0 text-[10px] text-slate-400 dark:text-gray-600">ELRC</span>
|
||||
<span className="ml-2 shrink-0 text-[10px]" style={{ color: 'var(--foreground-muted)', opacity: 0.6 }}>ELRC</span>
|
||||
)}
|
||||
<div className="ml-auto flex gap-0.5 shrink-0 pl-1">
|
||||
<button
|
||||
onClick={handleRecenter}
|
||||
title="Recenter active line"
|
||||
className={`p-1.5 rounded-md transition-colors ${isFullscreen ? 'text-slate-400 hover:bg-white/10' : 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'}`}
|
||||
className="lp-btn p-1.5 rounded-md transition-colors"
|
||||
style={{ color: 'var(--foreground-muted)' }}
|
||||
>
|
||||
<Crosshair className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setShowStylePicker(p => !p); setShowEditor(false) }}
|
||||
title="Style picker"
|
||||
className={`p-1.5 rounded-md transition-colors ${showStylePicker ? 'bg-brand-500 text-white' : isFullscreen ? 'text-slate-400 hover:bg-white/10' : 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'}`}
|
||||
className="lp-btn p-1.5 rounded-md transition-colors"
|
||||
style={showStylePicker
|
||||
? { background: 'rgb(var(--brand-500, 59 130 246))', color: '#fff' }
|
||||
: { color: 'var(--foreground-muted)' }}
|
||||
>
|
||||
<Palette className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setShowEditor(p => !p); setShowStylePicker(false); setShowAegisub(false) }}
|
||||
title="Edit timing / lyrics"
|
||||
className={`p-1.5 rounded-md transition-colors ${showEditor ? 'bg-brand-500 text-white' : isFullscreen ? 'text-slate-400 hover:bg-white/10' : 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'}`}
|
||||
className="lp-btn p-1.5 rounded-md transition-colors"
|
||||
style={showEditor
|
||||
? { background: 'rgb(var(--brand-500, 59 130 246))', color: '#fff' }
|
||||
: { color: 'var(--foreground-muted)' }}
|
||||
>
|
||||
<Pencil className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setShowAegisub(!showAegisub); setShowStylePicker(false); setShowEditor(false) }}
|
||||
title="Waveform editor"
|
||||
className={`p-1.5 rounded-md transition-colors ${showAegisub ? 'bg-brand-500 text-white' : isFullscreen ? 'text-slate-400 hover:bg-white/10' : 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'}`}
|
||||
className="lp-btn p-1.5 rounded-md transition-colors"
|
||||
style={showAegisub
|
||||
? { background: 'rgb(var(--brand-500, 59 130 246))', color: '#fff' }
|
||||
: { color: 'var(--foreground-muted)' }}
|
||||
>
|
||||
<Activity className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={toggleFullscreen}
|
||||
title={isFullscreen ? 'Exit fullscreen' : 'Fullscreen'}
|
||||
className={`p-1.5 rounded-md transition-colors ${isFullscreen ? 'text-slate-400 hover:bg-white/10' : 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'}`}
|
||||
className="lp-btn p-1.5 rounded-md transition-colors"
|
||||
style={{ color: 'var(--foreground-muted)' }}
|
||||
>
|
||||
{isFullscreen ? <Minimize2 className="w-3.5 h-3.5" /> : <Maximize2 className="w-3.5 h-3.5" />}
|
||||
</button>
|
||||
+11
-5
@@ -20,24 +20,30 @@ const FILE_ICONS: Record<string, React.ElementType> = {
|
||||
|
||||
function FileIcon({ type }: { type?: string }) {
|
||||
const Icon = FILE_ICONS[type || ''] || File
|
||||
return <Icon className="w-4 h-4 text-slate-400" />
|
||||
return <Icon style={{ width: 16, height: 16, opacity: 0.5, flexShrink: 0 }} />
|
||||
}
|
||||
|
||||
export default function ResultFiles({ jobId, files }: Props) {
|
||||
if (!files.length) return null
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
{files.map((f) => (
|
||||
<a
|
||||
key={f.name}
|
||||
href={downloadUrl(jobId, f.name)}
|
||||
download={f.name}
|
||||
className="flex items-center gap-3 px-3 py-2 rounded-lg bg-slate-50 dark:bg-gray-800/50 border border-slate-200 dark:border-gray-700 hover:border-brand-400 dark:hover:border-brand-500 transition-colors group"
|
||||
className="button flat"
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 12,
|
||||
padding: '6px 12px', borderRadius: 6,
|
||||
border: '1px solid var(--border-color)',
|
||||
textDecoration: 'none', fontSize: 12,
|
||||
}}
|
||||
>
|
||||
<FileIcon type={f.type} />
|
||||
<span className="flex-1 text-xs text-slate-700 dark:text-gray-300 truncate">{f.name}</span>
|
||||
<Download className="w-3.5 h-3.5 text-slate-400 group-hover:text-brand-500 transition-colors" />
|
||||
<span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{f.name}</span>
|
||||
<Download style={{ width: 14, height: 14, flexShrink: 0, opacity: 0.5 }} />
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
import { X, Sun, Moon, Monitor, Settings, ChevronRight } from 'lucide-react'
|
||||
import { useTheme } from '../context/ThemeContext'
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean
|
||||
onClose: () => void
|
||||
onOpenFullSettings?: () => void
|
||||
}
|
||||
|
||||
export default function SettingsPanel({ isOpen, onClose, onOpenFullSettings }: Props) {
|
||||
const { theme, setTheme } = useTheme()
|
||||
|
||||
const handleOpenFullSettings = () => {
|
||||
onClose()
|
||||
onOpenFullSettings?.()
|
||||
}
|
||||
|
||||
if (!isOpen) return null
|
||||
|
||||
const THEMES = [
|
||||
{ id: 'light' as const, icon: Sun, label: 'Light' },
|
||||
{ id: 'dark' as const, icon: Moon, label: 'Dark' },
|
||||
{ id: 'system'as const, icon: Monitor, label: 'System' },
|
||||
]
|
||||
|
||||
return (
|
||||
<div style={{ position: 'fixed', inset: 0, zIndex: 50, display: 'flex', alignItems: 'flex-start', justifyContent: 'center', paddingTop: 64 }}>
|
||||
{/* Backdrop */}
|
||||
<div style={{ position: 'absolute', inset: 0, background: 'rgba(0,0,0,0.5)' }} onClick={onClose} />
|
||||
|
||||
{/* Panel */}
|
||||
<div style={{ position: 'relative', width: '100%', maxWidth: 420, margin: '0 16px', borderRadius: 12, border: '1px solid var(--border-color)', background: 'var(--body-background, var(--background))', boxShadow: '0 8px 32px rgba(0,0,0,0.2)' }}>
|
||||
|
||||
{/* Header */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '10px 16px', borderBottom: '1px solid var(--border-color)' }}>
|
||||
<h2 style={{ margin: 0, fontSize: 13, fontWeight: 600 }}>Settings</h2>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="button cycle flat"
|
||||
style={{ padding: 4, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
||||
>
|
||||
<X style={{ width: 16, height: 16 }} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div style={{ padding: 16, display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
{/* Theme */}
|
||||
<div>
|
||||
<label style={{ display: 'block', marginBottom: 8, fontSize: 10, fontWeight: 600, opacity: 0.5, textTransform: 'uppercase', letterSpacing: '0.08em' }}>
|
||||
Theme
|
||||
</label>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
{THEMES.map(({ id, icon: Icon, label }) => {
|
||||
const isActive = theme === id
|
||||
return (
|
||||
<button
|
||||
key={id}
|
||||
onClick={() => setTheme(id)}
|
||||
style={{
|
||||
display: 'inline-flex', alignItems: 'center', gap: 6,
|
||||
padding: '6px 12px', borderRadius: 6, fontSize: 12, fontWeight: 500,
|
||||
border: `1px solid ${isActive ? 'rgb(var(--brand-500, 59 130 246))' : 'var(--border-color)'}`,
|
||||
background: isActive ? 'rgba(var(--brand-500, 59 130 246), 0.1)' : 'transparent',
|
||||
color: isActive ? 'rgb(var(--brand-500, 59 130 246))' : 'inherit',
|
||||
cursor: 'pointer', transition: 'border-color 0.15s, background 0.15s',
|
||||
}}
|
||||
>
|
||||
<Icon style={{ width: 14, height: 14 }} />
|
||||
{label}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Full Settings link */}
|
||||
<div style={{ borderTop: '1px solid var(--border-color)', paddingTop: 16, display: 'flex', flexDirection: 'column', gap: 6 }}>
|
||||
<button
|
||||
onClick={handleOpenFullSettings}
|
||||
style={{
|
||||
width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
||||
padding: 12, borderRadius: 8, border: '1px solid var(--border-color)',
|
||||
background: 'transparent', cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<Settings style={{ width: 16, height: 16, opacity: 0.6, flexShrink: 0 }} />
|
||||
<span style={{ fontSize: 13, fontWeight: 500 }}>Full Settings</span>
|
||||
</div>
|
||||
<ChevronRight style={{ width: 16, height: 16, opacity: 0.4 }} />
|
||||
</button>
|
||||
<p style={{ margin: 0, fontSize: 11, opacity: 0.5, padding: '0 4px' }}>
|
||||
Configure Subsonic integration, manage AI models, and more.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+714
@@ -0,0 +1,714 @@
|
||||
/**
|
||||
* Sidebar.tsx — Phase 2 MetroUI migration
|
||||
*
|
||||
* All business logic (state, queries, handlers) unchanged from Phase 1.
|
||||
* Tailwind classes replaced with MetroUI CSS + inline styles.
|
||||
* Accordion sections managed with React state (no data-role, avoids Metro JS
|
||||
* conflicts with React's virtual DOM).
|
||||
*/
|
||||
import React, { useState, useRef, useMemo } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
ChevronLeft, ChevronRight, Loader2, CheckCircle, XCircle,
|
||||
Clock, AlertCircle, X, Music2, Mic2, FileCode, Workflow,
|
||||
FolderOpen, Type, ChevronDown, ChevronUp, Radio, Search,
|
||||
Download, CheckCircle2, Trash2, Zap,
|
||||
} from 'lucide-react'
|
||||
import {
|
||||
listJobs, cancelJob,
|
||||
searchSubsonic, importSubsonicSong,
|
||||
listImports, deleteImport,
|
||||
listProjects, deleteProject,
|
||||
} from '../api/client'
|
||||
import type { Job, Project, SubsonicSong, ImportedFile } from '../types'
|
||||
import AutoPipelineDialog from './AutoPipelineDialog'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const JOB_DOT_COLORS: Record<string, string> = {
|
||||
separate: 'var(--color-blue)',
|
||||
transcribe: 'var(--color-violet)',
|
||||
'abc-convert': 'var(--color-green)',
|
||||
pipeline: 'var(--color-red)',
|
||||
lrc_align: 'var(--color-amber)',
|
||||
mix: 'var(--color-blue)',
|
||||
}
|
||||
|
||||
const JOB_ICONS: Record<string, React.ElementType> = {
|
||||
separate: Music2,
|
||||
transcribe: Mic2,
|
||||
'abc-convert': FileCode,
|
||||
pipeline: Workflow,
|
||||
lrc_align: Type,
|
||||
mix: Music2,
|
||||
}
|
||||
|
||||
const STATUS_ICON_COLOR: Record<Job['status'], string> = {
|
||||
running: 'var(--color-blue)',
|
||||
queued: 'var(--color-amber)',
|
||||
done: 'var(--color-green)',
|
||||
error: 'var(--color-red)',
|
||||
cancelled: 'var(--color-gray)',
|
||||
}
|
||||
|
||||
function StatusDot({ status }: { status: Job['status'] }) {
|
||||
const color = STATUS_ICON_COLOR[status] ?? 'var(--color-gray)'
|
||||
switch (status) {
|
||||
case 'running': return <Loader2 size={12} style={{ color, flexShrink: 0, animation: 'spin 1s linear infinite' }} />
|
||||
case 'queued': return <Clock size={12} style={{ color, flexShrink: 0 }} />
|
||||
case 'done': return <CheckCircle size={12} style={{ color, flexShrink: 0 }} />
|
||||
case 'error': return <XCircle size={12} style={{ color, flexShrink: 0 }} />
|
||||
case 'cancelled': return <AlertCircle size={12} style={{ color, flexShrink: 0 }} />
|
||||
}
|
||||
}
|
||||
|
||||
function timeSince(iso: string | null): string {
|
||||
if (!iso) return ''
|
||||
const ms = Date.now() - new Date(iso).getTime()
|
||||
const m = Math.floor(ms / 60000)
|
||||
if (m < 1) return 'just now'
|
||||
if (m < 60) return `${m}m ago`
|
||||
const h = Math.floor(m / 60)
|
||||
if (h < 24) return `${h}h ago`
|
||||
return `${Math.floor(h / 24)}d ago`
|
||||
}
|
||||
|
||||
// Shared section-header style (accordion trigger row)
|
||||
const sectionHeaderStyle: React.CSSProperties = {
|
||||
display: 'flex', alignItems: 'center', gap: 6,
|
||||
padding: '6px 10px',
|
||||
cursor: 'pointer', userSelect: 'none',
|
||||
borderBottom: '1px solid var(--border-color)',
|
||||
fontSize: 11, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase',
|
||||
width: '100%', background: 'none', border: 'none', textAlign: 'left',
|
||||
color: 'var(--label-color)',
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Active job item (with cancel)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function ActiveJobItem({ job, onCancelled }: { job: Job; onCancelled: () => void }) {
|
||||
const [cancelling, setCancelling] = useState(false)
|
||||
const Icon = JOB_ICONS[job.job_type] ?? FolderOpen
|
||||
const dotColor = JOB_DOT_COLORS[job.job_type] ?? 'var(--color-gray)'
|
||||
|
||||
async function handleCancel(e: React.MouseEvent) {
|
||||
e.stopPropagation()
|
||||
setCancelling(true)
|
||||
try { await cancelJob(job.id) } catch { /* ignore */ }
|
||||
onCancelled()
|
||||
setCancelling(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex', alignItems: 'center', gap: 8,
|
||||
padding: '6px 10px',
|
||||
borderRadius: 6, marginBottom: 4,
|
||||
background: 'var(--background)',
|
||||
border: '1px solid var(--border-color)',
|
||||
}}>
|
||||
<Icon size={13} style={{ color: dotColor, flexShrink: 0 }} />
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 500, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{job.job_type.replace('-', ' ').replace('_', ' ')}
|
||||
</div>
|
||||
{job.progress && (
|
||||
<div style={{ fontSize: 10, opacity: 0.55, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{job.progress}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<StatusDot status={job.status} />
|
||||
<button
|
||||
onClick={handleCancel}
|
||||
disabled={cancelling}
|
||||
title="Cancel"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3, flexShrink: 0 }}
|
||||
>
|
||||
{cancelling
|
||||
? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} />
|
||||
: <X size={11} />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Project tile
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function ProjectTile({
|
||||
project,
|
||||
isOpen,
|
||||
onOpen,
|
||||
onDeleted,
|
||||
}: {
|
||||
project: Project
|
||||
isOpen: boolean
|
||||
onOpen: () => void
|
||||
onDeleted: () => void
|
||||
}) {
|
||||
const [deleting, setDeleting] = useState(false)
|
||||
const [hovered, setHovered] = useState(false)
|
||||
|
||||
async function handleDelete(e: React.MouseEvent) {
|
||||
e.stopPropagation()
|
||||
if (!window.confirm(`Delete "${project.name}"?\n\nThis will permanently remove the project and all its files.`)) return
|
||||
setDeleting(true)
|
||||
try { await deleteProject(project.id) } catch { /* ignore */ }
|
||||
finally { setDeleting(false) }
|
||||
onDeleted()
|
||||
}
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={onOpen}
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 8,
|
||||
padding: '7px 10px',
|
||||
borderRadius: 6, marginBottom: 3, cursor: 'pointer',
|
||||
border: `1px solid ${isOpen ? accentColor : 'var(--border-color)'}`,
|
||||
background: isOpen
|
||||
? `rgba(var(--brand-500, 59 130 246), 0.08)`
|
||||
: hovered ? 'var(--background)' : 'transparent',
|
||||
transition: 'background 0.15s, border-color 0.15s',
|
||||
}}
|
||||
>
|
||||
<Music2 size={13} style={{ color: accentColor, flexShrink: 0 }} />
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{
|
||||
fontSize: 12, fontWeight: 500,
|
||||
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
|
||||
color: isOpen ? accentColor : undefined,
|
||||
}}>
|
||||
{project.name}
|
||||
</div>
|
||||
{project.tab_label && (
|
||||
<div style={{ fontSize: 10, color: accentColor, opacity: 0.8, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{project.tab_label}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ fontSize: 10, opacity: 0.45 }}>{timeSince(project.created_at)}</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
disabled={deleting}
|
||||
title="Delete project"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3, flexShrink: 0, opacity: hovered ? 1 : 0, transition: 'opacity 0.15s' }}
|
||||
>
|
||||
{deleting
|
||||
? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} />
|
||||
: <Trash2 size={11} />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Subsonic import panel
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function formatDuration(secs: number): string {
|
||||
const m = Math.floor(secs / 60)
|
||||
const s = secs % 60
|
||||
return `${m}:${String(s).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
function SubsonicPanel() {
|
||||
const queryClient = useQueryClient()
|
||||
const [open, setOpen] = useState(false)
|
||||
const [query, setQuery] = useState('')
|
||||
const [results, setResults] = useState<SubsonicSong[]>([])
|
||||
const [searching, setSearching] = useState(false)
|
||||
const [searchErr, setSearchErr] = useState<string | null>(null)
|
||||
const [importing, setImporting] = useState<string | null>(null)
|
||||
const [importedIds, setImportedIds] = useState<Set<string>>(new Set())
|
||||
const [importErr, setImportErr] = useState<string | null>(null)
|
||||
const [deletingFile, setDeletingFile] = useState<string | null>(null)
|
||||
const [autoTarget, setAutoTarget] = useState<ImportedFile | null>(null)
|
||||
const inputRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
const { data: importedFiles = [], refetch: refetchImports } = useQuery<ImportedFile[]>({
|
||||
queryKey: ['imports'],
|
||||
queryFn: listImports,
|
||||
enabled: open,
|
||||
refetchInterval: open ? 10000 : false,
|
||||
})
|
||||
|
||||
async function doSearch() {
|
||||
if (!query.trim()) return
|
||||
setSearching(true); setSearchErr(null); setResults([])
|
||||
try {
|
||||
const res = await searchSubsonic(query.trim())
|
||||
setResults(res)
|
||||
if (res.length === 0) setSearchErr('No results found.')
|
||||
} catch (e) {
|
||||
setSearchErr(String(e))
|
||||
} finally {
|
||||
setSearching(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function doImport(song: SubsonicSong) {
|
||||
setImporting(song.id); setImportErr(null)
|
||||
try {
|
||||
await importSubsonicSong(song)
|
||||
setImportedIds((prev) => new Set(prev).add(song.id))
|
||||
refetchImports()
|
||||
queryClient.invalidateQueries({ queryKey: ['imports'] })
|
||||
} catch (e) {
|
||||
setImportErr(String(e))
|
||||
} finally {
|
||||
setImporting(null)
|
||||
}
|
||||
}
|
||||
|
||||
async function doDeleteImport(filename: string) {
|
||||
setDeletingFile(filename)
|
||||
try {
|
||||
await deleteImport(filename)
|
||||
refetchImports()
|
||||
queryClient.invalidateQueries({ queryKey: ['imports'] })
|
||||
} catch { /* ignore */ }
|
||||
finally { setDeletingFile(null) }
|
||||
}
|
||||
|
||||
const skyColor = 'var(--color-blue, #0ea5e9)'
|
||||
|
||||
return (
|
||||
<div style={{ borderBottom: '1px solid var(--border-color)' }}>
|
||||
{/* Accordion header */}
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
style={{ ...sectionHeaderStyle, color: skyColor }}
|
||||
>
|
||||
<Radio size={13} style={{ color: skyColor, flexShrink: 0 }} />
|
||||
<span style={{ flex: 1 }}>Subsonic Import</span>
|
||||
{open
|
||||
? <ChevronUp size={11} style={{ opacity: 0.5 }} />
|
||||
: <ChevronDown size={11} style={{ opacity: 0.5 }} />}
|
||||
</button>
|
||||
|
||||
{open && (
|
||||
<div style={{ padding: '8px 10px 10px' }}>
|
||||
{/* Search row */}
|
||||
<div style={{ display: 'flex', gap: 6, marginBottom: 6 }}>
|
||||
<input
|
||||
ref={inputRef}
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && doSearch()}
|
||||
placeholder="Search songs…"
|
||||
style={{
|
||||
flex: 1, padding: '5px 8px', fontSize: 12, borderRadius: 4,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--input-background, var(--background))',
|
||||
color: 'inherit', outline: 'none',
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
onClick={doSearch}
|
||||
disabled={searching || !query.trim()}
|
||||
className="button"
|
||||
style={{ background: skyColor, color: '#fff', padding: '5px 10px', borderRadius: 4, border: 'none', flexShrink: 0 }}
|
||||
>
|
||||
{searching
|
||||
? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} />
|
||||
: <Search size={11} />}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Error messages */}
|
||||
{searchErr && <p style={{ fontSize: 11, color: 'var(--color-red)', marginBottom: 4 }}>{searchErr}</p>}
|
||||
{importErr && <p style={{ fontSize: 11, color: 'var(--color-red)', marginBottom: 4, wordBreak: 'break-all' }}>{importErr}</p>}
|
||||
|
||||
{/* Search results */}
|
||||
{results.length > 0 && (
|
||||
<div style={{ maxHeight: 200, overflowY: 'auto', marginBottom: 6 }}>
|
||||
{results.map((song) => {
|
||||
const done = importedIds.has(song.id)
|
||||
const busy = importing === song.id
|
||||
return (
|
||||
<div
|
||||
key={song.id}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'flex-start', gap: 8,
|
||||
padding: '7px 8px', marginBottom: 3, borderRadius: 5,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--background)',
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 500, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{song.title}
|
||||
</div>
|
||||
{song.artist && (
|
||||
<div style={{ fontSize: 10, opacity: 0.55, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{song.artist}{song.album ? ` · ${song.album}` : ''}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ fontSize: 10, opacity: 0.4 }}>
|
||||
{song.duration ? formatDuration(song.duration) : ''}
|
||||
{song.bitRate ? ` · ${song.bitRate} kbps` : ''}
|
||||
{song.suffix ? ` · ${song.suffix.toUpperCase()}` : ''}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => doImport(song)}
|
||||
disabled={busy || done}
|
||||
title={done ? 'Imported' : 'Import'}
|
||||
className="button cycle flat"
|
||||
style={{ flexShrink: 0, padding: 5 }}
|
||||
>
|
||||
{busy
|
||||
? <Loader2 size={11} style={{ color: skyColor, animation: 'spin 1s linear infinite' }} />
|
||||
: done
|
||||
? <CheckCircle2 size={11} style={{ color: 'var(--color-green)' }} />
|
||||
: <Download size={11} />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Imported files */}
|
||||
{importedFiles.length > 0 && (
|
||||
<div>
|
||||
<div style={{
|
||||
fontSize: 10, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase',
|
||||
opacity: 0.45, marginBottom: 4,
|
||||
}}>
|
||||
Imported Files
|
||||
</div>
|
||||
<div style={{ maxHeight: 160, overflowY: 'auto' }}>
|
||||
{importedFiles.map((f) => {
|
||||
const isDeleting = deletingFile === f.filename
|
||||
return (
|
||||
<ImportedFileRow
|
||||
key={f.path}
|
||||
file={f}
|
||||
isDeleting={isDeleting}
|
||||
onDelete={() => doDeleteImport(f.filename)}
|
||||
onAutoPipeline={() => setAutoTarget(f)}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
{autoTarget && (
|
||||
<AutoPipelineDialog
|
||||
target={{
|
||||
filePath: autoTarget.path,
|
||||
filename: autoTarget.filename,
|
||||
initialProjectName: autoTarget.artist && autoTarget.title
|
||||
? `${autoTarget.artist} - ${autoTarget.title}`
|
||||
: autoTarget.filename.replace(/\.[^/.]+$/, ''),
|
||||
}}
|
||||
onClose={() => setAutoTarget(null)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ImportedFileRow({
|
||||
file, isDeleting, onDelete, onAutoPipeline,
|
||||
}: {
|
||||
file: ImportedFile
|
||||
isDeleting: boolean
|
||||
onDelete: () => void
|
||||
onAutoPipeline: () => void
|
||||
}) {
|
||||
const [hovered, setHovered] = useState(false)
|
||||
return (
|
||||
<div
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 6,
|
||||
padding: '5px 8px', marginBottom: 3, borderRadius: 5,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--background)',
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 500, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{file.filename}
|
||||
</div>
|
||||
<div style={{ fontSize: 10, opacity: 0.45 }}>{(file.size / 1024 / 1024).toFixed(1)} MB</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={onAutoPipeline}
|
||||
title="Auto pipeline"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3, flexShrink: 0, opacity: hovered ? 1 : 0, transition: 'opacity 0.15s', color: 'var(--color-amber)' }}
|
||||
>
|
||||
<Zap size={11} />
|
||||
</button>
|
||||
<button
|
||||
onClick={onDelete}
|
||||
disabled={isDeleting}
|
||||
title="Delete import"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3, flexShrink: 0, opacity: hovered ? 1 : 0, transition: 'opacity 0.15s', color: 'var(--color-red)' }}
|
||||
>
|
||||
{isDeleting
|
||||
? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} />
|
||||
: <Trash2 size={11} />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Sidebar
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean
|
||||
onToggle: () => void
|
||||
onOpenProject: (project: Project) => void
|
||||
onDeleteProject: (project: Project) => void
|
||||
openTabIds: string[] // IDs of project tabs currently open in the tab bar
|
||||
}
|
||||
|
||||
export default function Sidebar({ isOpen, onToggle, onOpenProject, onDeleteProject, openTabIds }: Props) {
|
||||
const queryClient = useQueryClient()
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
const [jobsOpen, setJobsOpen] = useState(true)
|
||||
|
||||
const { data: jobs = [] } = useQuery({
|
||||
queryKey: ['jobs'],
|
||||
queryFn: listJobs,
|
||||
refetchInterval: 3000,
|
||||
})
|
||||
|
||||
const { data: projects = [] } = useQuery<Project[]>({
|
||||
queryKey: ['projects'],
|
||||
queryFn: listProjects,
|
||||
refetchInterval: 8000,
|
||||
})
|
||||
|
||||
const filteredProjects = useMemo(() => {
|
||||
if (!searchQuery.trim()) return projects
|
||||
const q = searchQuery.toLowerCase()
|
||||
return projects.filter(p =>
|
||||
p.name.toLowerCase().includes(q) ||
|
||||
p.tab_label.toLowerCase().includes(q)
|
||||
)
|
||||
}, [projects, searchQuery])
|
||||
|
||||
const activeJobs = jobs.filter((j) => j.status === 'running' || j.status === 'queued')
|
||||
|
||||
function invalidate() { queryClient.invalidateQueries({ queryKey: ['jobs'] }) }
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
|
||||
return (
|
||||
<aside
|
||||
className={isOpen ? 'sidebar-open' : 'sidebar-closed'}
|
||||
style={{
|
||||
position: 'relative',
|
||||
flexShrink: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
borderRight: '1px solid var(--border-color)',
|
||||
background: 'var(--sidebar-background, var(--body-background))',
|
||||
transition: 'width 0.2s ease-in-out',
|
||||
overflow: 'visible',
|
||||
}}
|
||||
>
|
||||
{/* Toggle tab — always visible */}
|
||||
<button
|
||||
onClick={onToggle}
|
||||
title={isOpen ? 'Collapse sidebar' : 'Expand sidebar'}
|
||||
className="button cycle flat"
|
||||
style={{
|
||||
position: 'absolute', right: -14, top: 24, zIndex: 10,
|
||||
width: 28, height: 28, borderRadius: '50%',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
padding: 0,
|
||||
background: 'var(--body-background)',
|
||||
border: '1px solid var(--border-color)',
|
||||
boxShadow: '0 1px 3px rgba(0,0,0,0.12)',
|
||||
}}
|
||||
>
|
||||
{isOpen
|
||||
? <ChevronLeft size={14} />
|
||||
: <ChevronRight size={14} />}
|
||||
</button>
|
||||
|
||||
{/* ── Collapsed indicator strip ──────────────────────────────────────── */}
|
||||
{!isOpen && (
|
||||
<div style={{ overflow: 'hidden', flex: 1 }}>
|
||||
<div style={{
|
||||
display: 'flex', flexDirection: 'column', alignItems: 'center',
|
||||
gap: 12, paddingTop: 64, paddingLeft: 8, paddingRight: 8,
|
||||
}}>
|
||||
{activeJobs.length > 0 && (
|
||||
<div style={{ position: 'relative' }}>
|
||||
<Loader2 size={18} style={{ color: accentColor, animation: 'spin 1s linear infinite' }} />
|
||||
<span style={{
|
||||
position: 'absolute', top: -4, right: -4,
|
||||
width: 14, height: 14, borderRadius: '50%',
|
||||
background: accentColor, color: '#fff',
|
||||
fontSize: 9, fontWeight: 700,
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
}}>
|
||||
{activeJobs.length}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<Radio size={18} style={{ opacity: 0.35 }} />
|
||||
{projects.length > 0 && (
|
||||
<div style={{ position: 'relative' }}>
|
||||
<FolderOpen size={18} style={{ opacity: 0.35 }} />
|
||||
<span style={{
|
||||
position: 'absolute', top: -4, right: -4,
|
||||
width: 14, height: 14, borderRadius: '50%',
|
||||
background: 'var(--color-gray, #64748b)', color: '#fff',
|
||||
fontSize: 9, fontWeight: 700,
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
}}>
|
||||
{projects.length}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Expanded content ───────────────────────────────────────────────── */}
|
||||
{isOpen && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', flex: 1, overflow: 'hidden' }}>
|
||||
|
||||
{/* Active jobs accordion */}
|
||||
<div style={{ borderBottom: '1px solid var(--border-color)' }}>
|
||||
<button
|
||||
onClick={() => setJobsOpen((v) => !v)}
|
||||
style={{ ...sectionHeaderStyle, color: 'var(--color-amber, #f59e0b)', borderBottom: 'none' }}
|
||||
>
|
||||
<span style={{ flex: 1 }}>In Progress</span>
|
||||
{activeJobs.length > 0 && (
|
||||
<span style={{
|
||||
background: 'var(--color-amber, #f59e0b)', color: '#fff',
|
||||
fontSize: 10, fontWeight: 700, borderRadius: 10,
|
||||
padding: '1px 6px',
|
||||
}}>
|
||||
{activeJobs.length}
|
||||
</span>
|
||||
)}
|
||||
{jobsOpen
|
||||
? <ChevronUp size={11} style={{ opacity: 0.5, marginLeft: 4 }} />
|
||||
: <ChevronDown size={11} style={{ opacity: 0.5, marginLeft: 4 }} />}
|
||||
</button>
|
||||
|
||||
{jobsOpen && (
|
||||
<div style={{ padding: '4px 8px 8px' }}>
|
||||
{activeJobs.length === 0 ? (
|
||||
<p style={{ fontSize: 11, opacity: 0.4, fontStyle: 'italic', textAlign: 'center', padding: '6px 0' }}>
|
||||
No active jobs
|
||||
</p>
|
||||
) : (
|
||||
activeJobs.map((job) => (
|
||||
<ActiveJobItem key={job.id} job={job} onCancelled={invalidate} />
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Subsonic import accordion */}
|
||||
<SubsonicPanel />
|
||||
|
||||
{/* Projects list */}
|
||||
<div style={{ flex: 1, overflowY: 'auto', padding: '8px 8px 8px' }}>
|
||||
{/* Section header */}
|
||||
<div style={{
|
||||
display: 'flex', alignItems: 'center', gap: 6,
|
||||
marginBottom: 6, paddingLeft: 2,
|
||||
}}>
|
||||
<span style={{
|
||||
fontSize: 11, fontWeight: 700, letterSpacing: '0.08em',
|
||||
textTransform: 'uppercase', color: accentColor,
|
||||
}}>
|
||||
Projects
|
||||
</span>
|
||||
{projects.length > 0 && (
|
||||
<span style={{ marginLeft: 'auto', fontSize: 10, opacity: 0.45 }}>
|
||||
{filteredProjects.length}/{projects.length}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Search input */}
|
||||
<div style={{ position: 'relative', marginBottom: 8 }}>
|
||||
<Search size={11} style={{
|
||||
position: 'absolute', left: 8, top: '50%', transform: 'translateY(-50%)',
|
||||
opacity: 0.4, pointerEvents: 'none',
|
||||
}} />
|
||||
<input
|
||||
type="text"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
placeholder="Search projects…"
|
||||
style={{
|
||||
width: '100%', padding: '5px 28px 5px 26px', fontSize: 12, borderRadius: 5,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--input-background, var(--background))',
|
||||
color: 'inherit', outline: 'none', boxSizing: 'border-box',
|
||||
}}
|
||||
/>
|
||||
{searchQuery && (
|
||||
<button
|
||||
onClick={() => setSearchQuery('')}
|
||||
style={{
|
||||
position: 'absolute', right: 6, top: '50%', transform: 'translateY(-50%)',
|
||||
background: 'none', border: 'none', cursor: 'pointer', opacity: 0.45, padding: 2,
|
||||
}}
|
||||
>
|
||||
<X size={10} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Project items */}
|
||||
{filteredProjects.length === 0 ? (
|
||||
<p style={{ fontSize: 11, opacity: 0.4, fontStyle: 'italic', textAlign: 'center', padding: '12px 0' }}>
|
||||
{searchQuery ? 'No projects match.' : 'Completed separations appear here.'}
|
||||
</p>
|
||||
) : (
|
||||
filteredProjects.map((project) => (
|
||||
<ProjectTile
|
||||
key={project.id}
|
||||
project={project}
|
||||
isOpen={openTabIds.includes(project.id)}
|
||||
onOpen={() => onOpenProject(project)}
|
||||
onDeleted={() => {
|
||||
queryClient.invalidateQueries({ queryKey: ['projects'] })
|
||||
onDeleteProject(project)
|
||||
}}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
import React, { createContext, useContext, useEffect, useState } from 'react'
|
||||
|
||||
type Theme = 'light' | 'dark' | 'system'
|
||||
|
||||
interface ThemeContextType {
|
||||
theme: Theme
|
||||
resolved: 'light' | 'dark'
|
||||
setTheme: (t: Theme) => void
|
||||
}
|
||||
|
||||
const ThemeContext = createContext<ThemeContextType | undefined>(undefined)
|
||||
|
||||
export function ThemeProvider({ children }: { children: React.ReactNode }) {
|
||||
const [theme, setThemeState] = useState<Theme>(() => {
|
||||
if (typeof window === 'undefined') return 'system'
|
||||
return (localStorage.getItem('theme') as Theme) || 'system'
|
||||
})
|
||||
|
||||
const [resolved, setResolved] = useState<'light' | 'dark'>('dark')
|
||||
|
||||
useEffect(() => {
|
||||
const root = document.documentElement
|
||||
const media = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
|
||||
function apply() {
|
||||
let r: 'light' | 'dark'
|
||||
if (theme === 'system') {
|
||||
r = media.matches ? 'dark' : 'light'
|
||||
} else {
|
||||
r = theme
|
||||
}
|
||||
setResolved(r)
|
||||
// Tailwind dark mode (for components not yet migrated to MetroUI)
|
||||
if (r === 'dark') {
|
||||
root.classList.add('dark')
|
||||
} else {
|
||||
root.classList.remove('dark')
|
||||
}
|
||||
// MetroUI dark mode
|
||||
root.setAttribute('data-theme', r)
|
||||
// color-scheme: tells the browser to use dark OS chrome (scrollbars, native tooltips, form controls)
|
||||
root.style.colorScheme = r
|
||||
// Explicit CSS custom properties — guaranteed regardless of MetroUI var availability
|
||||
const dark = r === 'dark'
|
||||
root.style.setProperty('--body-background', dark ? '#0f172a' : '#ffffff')
|
||||
root.style.setProperty('--background', dark ? '#1e293b' : '#f8fafc')
|
||||
root.style.setProperty('--border-color', dark ? '#334155' : '#e2e8f0')
|
||||
root.style.setProperty('--sidebar-background', dark ? '#0f172a' : '#f1f5f9')
|
||||
// Semi-transparent variant for frosted-glass bars (backdropFilter needs transparency)
|
||||
root.style.setProperty('--bar-background', dark ? 'rgba(15,23,42,0.92)' : 'rgba(255,255,255,0.92)')
|
||||
// Text colours — set directly on body (inline style beats MetroUI stylesheet)
|
||||
// Also exposed as CSS vars for components that need to reference them explicitly
|
||||
const fg = dark ? '#e2e8f0' : '#1e293b'
|
||||
document.body.style.color = fg
|
||||
root.style.setProperty('--foreground', fg)
|
||||
root.style.setProperty('--foreground-muted', dark ? '#94a3b8' : '#64748b')
|
||||
root.style.setProperty('--label-color', dark ? '#94a3b8' : '#64748b')
|
||||
root.style.setProperty('--color-gray', '#64748b')
|
||||
root.style.setProperty('--color-green', '#22c55e')
|
||||
root.style.setProperty('--color-red', '#ef4444')
|
||||
root.style.setProperty('--color-amber', '#f59e0b')
|
||||
root.style.setProperty('--color-blue', '#0ea5e9')
|
||||
root.style.setProperty('--color-violet', '#8b5cf6')
|
||||
root.style.setProperty('--color-teal', '#14b8a6')
|
||||
}
|
||||
|
||||
apply()
|
||||
localStorage.setItem('theme', theme)
|
||||
|
||||
const listener = () => apply()
|
||||
media.addEventListener('change', listener)
|
||||
return () => media.removeEventListener('change', listener)
|
||||
}, [theme])
|
||||
|
||||
function setTheme(t: Theme) {
|
||||
setThemeState(t)
|
||||
}
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={{ theme, resolved, setTheme }}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useTheme() {
|
||||
const ctx = useContext(ThemeContext)
|
||||
if (!ctx) throw new Error('useTheme must be used within ThemeProvider')
|
||||
return ctx
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* index.css — StemEngine global styles
|
||||
*
|
||||
* Phase 1 (MetroUI migration): Tailwind stays active for inner pages
|
||||
* (Separator, ProjectDetail, Settings, Sidebar). MetroUI is loaded in
|
||||
* main.tsx after this file. Both systems coexist during the migration;
|
||||
* @tailwind directives are removed in Phase 6 once all components are migrated.
|
||||
*/
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
@@ -95,25 +103,21 @@
|
||||
--brand-950: 8 51 68;
|
||||
}
|
||||
|
||||
@layer base {
|
||||
html {
|
||||
@apply h-full;
|
||||
}
|
||||
body {
|
||||
@apply h-full antialiased;
|
||||
}
|
||||
#root {
|
||||
@apply h-full;
|
||||
}
|
||||
/* Phase 7: converted from @layer base + @apply */
|
||||
html, body, #root {
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
.sidebar-open {
|
||||
@apply w-72;
|
||||
}
|
||||
.sidebar-closed {
|
||||
@apply w-14;
|
||||
}
|
||||
/* Phase 7: converted from @layer utilities + @apply / theme() */
|
||||
.sidebar-open {
|
||||
width: 18rem; /* was: @apply w-72 */
|
||||
}
|
||||
.sidebar-closed {
|
||||
width: 3.5rem; /* was: @apply w-14 */
|
||||
}
|
||||
|
||||
/* On small screens the sidebar overlays content instead of pushing it */
|
||||
@@ -124,10 +128,10 @@
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 30;
|
||||
width: theme('spacing.72');
|
||||
width: 18rem; /* was: theme('spacing.72') */
|
||||
}
|
||||
.sidebar-closed {
|
||||
width: theme('spacing.10');
|
||||
width: 2.5rem; /* was: theme('spacing.10') */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,26 +142,44 @@
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
@apply bg-transparent;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
@apply bg-slate-300 dark:bg-gray-600 rounded-full;
|
||||
background: var(--border-color, #cbd5e1);
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
@apply bg-slate-400 dark:bg-gray-500;
|
||||
background: color-mix(in srgb, var(--border-color, #94a3b8) 80%, #000);
|
||||
}
|
||||
|
||||
/* Range input styling */
|
||||
/* Range input styling — appearance: none so we fully control thumb shape.
|
||||
Height must be set explicitly; without it the track collapses to ~0px.
|
||||
accent-color is NOT used here because it is ignored when appearance: none is active. */
|
||||
input[type="range"] {
|
||||
@apply bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer;
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
background: var(--border-color, #e2e8f0);
|
||||
height: 6px;
|
||||
border-radius: 9999px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[type="range"]::-webkit-slider-thumb {
|
||||
@apply appearance-none w-4 h-4 rounded-full bg-brand-500 cursor-pointer;
|
||||
-webkit-appearance: none;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
background: rgb(var(--brand-500, 59 130 246));
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[type="range"]::-moz-range-thumb {
|
||||
@apply w-4 h-4 rounded-full bg-brand-500 cursor-pointer border-0;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
background: rgb(var(--brand-500, 59 130 246));
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
}
|
||||
@@ -3,6 +3,11 @@ import ReactDOM from 'react-dom/client'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import App from './App'
|
||||
import './index.css'
|
||||
// MetroUI — Phase 1 shell redesign
|
||||
import '@olton/metroui/lib/metro.css'
|
||||
import '@olton/metroui/lib/icons.css'
|
||||
// Dark-mode overrides — must come after metro.css so un-layered rules win
|
||||
import './theme-overrides.css'
|
||||
import '@fontsource/archivo'
|
||||
import '@fontsource/eb-garamond'
|
||||
import '@fontsource/inter'
|
||||
+237
-169
@@ -11,6 +11,14 @@ import type { ProjectDetail as PD, Job, JobFile } from '../types'
|
||||
import DynamicMixPlayer from '../components/DynamicMixPlayer'
|
||||
import LyricsLivePreview from '../components/LyricsLivePreview'
|
||||
|
||||
// ─── shared form-field style (overrides MetroUI/Tailwind bg in dark mode) ───
|
||||
const fieldStyle = {
|
||||
background: 'var(--background)',
|
||||
color: 'var(--foreground)',
|
||||
borderColor: 'var(--border-color)',
|
||||
colorScheme: 'inherit' as const,
|
||||
} as const
|
||||
|
||||
// ─── helpers ────────────────────────────────────────────────────────────────
|
||||
|
||||
function formatTime(s: number): string {
|
||||
@@ -34,13 +42,13 @@ const STATIC_OPTIONS = [
|
||||
|
||||
|
||||
// Color classes for each stem type
|
||||
const STEM_COLORS: Record<string, string> = {
|
||||
vocals: 'bg-sky-50 dark:bg-sky-950/40 border-sky-300/50 text-sky-700 dark:text-sky-300 hover:border-sky-400',
|
||||
drums: 'bg-orange-50 dark:bg-orange-950/40 border-orange-300/50 text-orange-700 dark:text-orange-300 hover:border-orange-400',
|
||||
bass: 'bg-purple-50 dark:bg-purple-950/40 border-purple-300/50 text-purple-700 dark:text-purple-300 hover:border-purple-400',
|
||||
other: 'bg-slate-50 dark:bg-gray-800 border-slate-200 dark:border-gray-700 text-slate-600 dark:text-gray-300 hover:border-slate-400',
|
||||
guitar: 'bg-emerald-50 dark:bg-emerald-950/40 border-emerald-300/50 text-emerald-700 dark:text-emerald-300 hover:border-emerald-400',
|
||||
piano: 'bg-rose-50 dark:bg-rose-950/40 border-rose-300/50 text-rose-700 dark:text-rose-300 hover:border-rose-400',
|
||||
const STEM_COLORS: Record<string, { bg: string; border: string; color: string }> = {
|
||||
vocals: { bg: 'rgba(14, 165, 233, 0.09)', border: 'rgba(14, 165, 233, 0.35)', color: '#0ea5e9' },
|
||||
drums: { bg: 'rgba(249, 115, 22, 0.09)', border: 'rgba(249, 115, 22, 0.35)', color: '#f97316' },
|
||||
bass: { bg: 'rgba(168, 85, 247, 0.09)', border: 'rgba(168, 85, 247, 0.35)', color: '#a855f7' },
|
||||
other: { bg: 'var(--background)', border: 'var(--border-color)', color: 'inherit' },
|
||||
guitar: { bg: 'rgba(16, 185, 129, 0.09)', border: 'rgba(16, 185, 129, 0.35)', color: '#10b981' },
|
||||
piano: { bg: 'rgba(244, 63, 94, 0.09)', border: 'rgba(244, 63, 94, 0.35)', color: '#f43f5e' },
|
||||
}
|
||||
|
||||
function isActive(job: Job | null | undefined) {
|
||||
@@ -49,22 +57,27 @@ function isActive(job: Job | null | undefined) {
|
||||
|
||||
function JobBadge({ job }: { job: Job | null }) {
|
||||
if (!job) return null
|
||||
const styles: Record<string, string> = {
|
||||
done: 'bg-emerald-50 dark:bg-emerald-950/30 text-emerald-600 dark:text-emerald-400 border-emerald-300/50',
|
||||
running: 'bg-brand-50 dark:bg-brand-950/30 text-brand-600 dark:text-brand-400 border-brand-300/50',
|
||||
queued: 'bg-amber-50 dark:bg-amber-950/30 text-amber-600 dark:text-amber-400 border-amber-300/50',
|
||||
error: 'bg-red-50 dark:bg-red-950/30 text-red-600 dark:text-red-400 border-red-300/50',
|
||||
cancelled: 'bg-slate-50 dark:bg-gray-900 text-slate-500 dark:text-gray-500 border-slate-200 dark:border-gray-700',
|
||||
const colors: Record<string, { bg: string; color: string; border: string }> = {
|
||||
done: { bg: 'rgba(16, 185, 129, 0.1)', color: 'var(--color-green, #10b981)', border: 'rgba(16, 185, 129, 0.35)' },
|
||||
running: { bg: 'rgba(59, 130, 246, 0.1)', color: 'rgb(var(--brand-500,59 130 246))', border: 'rgba(59,130,246,0.35)' },
|
||||
queued: { bg: 'rgba(245, 158, 11, 0.1)', color: 'var(--color-amber, #f59e0b)', border: 'rgba(245, 158, 11, 0.35)' },
|
||||
error: { bg: 'rgba(239, 68, 68, 0.1)', color: 'var(--color-red, #ef4444)', border: 'rgba(239, 68, 68, 0.35)' },
|
||||
cancelled: { bg: 'var(--background)', color: 'var(--label-color)', border: 'var(--border-color)' },
|
||||
}
|
||||
const icons: Record<string, React.ReactNode> = {
|
||||
done: <CheckCircle className="w-3 h-3" />,
|
||||
running: <Loader2 className="w-3 h-3 animate-spin" />,
|
||||
queued: <Clock className="w-3 h-3" />,
|
||||
error: <XCircle className="w-3 h-3" />,
|
||||
cancelled: <AlertCircle className="w-3 h-3" />,
|
||||
done: <CheckCircle size={11} />,
|
||||
running: <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} />,
|
||||
queued: <Clock size={11} />,
|
||||
error: <XCircle size={11} />,
|
||||
cancelled: <AlertCircle size={11} />,
|
||||
}
|
||||
const c = colors[job.status] ?? colors.cancelled
|
||||
return (
|
||||
<span className={`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border font-medium ${styles[job.status] ?? ''}`}>
|
||||
<span style={{
|
||||
display: 'inline-flex', alignItems: 'center', gap: 4,
|
||||
fontSize: 11, padding: '2px 8px', borderRadius: 12,
|
||||
border: `1px solid ${c.border}`, background: c.bg, color: c.color, fontWeight: 500,
|
||||
}}>
|
||||
{icons[job.status]}
|
||||
{job.status}
|
||||
</span>
|
||||
@@ -76,9 +89,10 @@ function DownloadButton({ file, jobId }: { file: JobFile; jobId: string }) {
|
||||
<a
|
||||
href={downloadUrl(jobId, file.name)}
|
||||
download={file.name}
|
||||
className="inline-flex items-center gap-1.5 rounded-lg bg-slate-100 dark:bg-gray-800 border border-slate-200 dark:border-gray-700 px-2.5 py-1.5 text-xs font-medium text-slate-700 dark:text-gray-300 hover:border-brand-400 hover:text-brand-600 dark:hover:text-brand-400 transition-colors"
|
||||
className="button flat"
|
||||
style={{ display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 12 }}
|
||||
>
|
||||
<Download className="w-3 h-3" />
|
||||
<Download size={12} />
|
||||
{file.name}
|
||||
</a>
|
||||
)
|
||||
@@ -670,17 +684,23 @@ function MidiGroupPlayer({ stems }: { stems: MidiGroupStem[] }) {
|
||||
|
||||
// Color-coded stem download chip — shows just the part name, not the full filename
|
||||
function StemChipButton({ file, jobId }: { file: JobFile; jobId: string }) {
|
||||
const stemKey = (file.stem ?? file.name).toLowerCase().split('.')[0]
|
||||
const label = stemKey.charAt(0).toUpperCase() + stemKey.slice(1)
|
||||
const colorCls = STEM_COLORS[stemKey] ?? STEM_COLORS.other
|
||||
const stemKey = (file.stem ?? file.name).toLowerCase().split('.')[0]
|
||||
const label = stemKey.charAt(0).toUpperCase() + stemKey.slice(1)
|
||||
const c = STEM_COLORS[stemKey] ?? STEM_COLORS.other
|
||||
return (
|
||||
<a
|
||||
href={downloadUrl(jobId, file.name)}
|
||||
download={file.name}
|
||||
title={file.name}
|
||||
className={`inline-flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-xs font-semibold transition-colors ${colorCls}`}
|
||||
style={{
|
||||
display: 'inline-flex', alignItems: 'center', gap: 6,
|
||||
borderRadius: 5, border: `1px solid ${c.border}`,
|
||||
background: c.bg, color: c.color,
|
||||
padding: '5px 12px', fontSize: 12, fontWeight: 600,
|
||||
textDecoration: 'none',
|
||||
}}
|
||||
>
|
||||
<Download className="w-3 h-3" />
|
||||
<Download size={12} />
|
||||
{label}
|
||||
</a>
|
||||
)
|
||||
@@ -719,61 +739,65 @@ function StemReprocessButton({
|
||||
}
|
||||
}
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
return (
|
||||
<div className="relative">
|
||||
<div style={{ position: 'relative' }}>
|
||||
<button
|
||||
onClick={() => setShowMenu(v => !v)}
|
||||
disabled={busy}
|
||||
className="flex items-center gap-1 rounded-lg bg-slate-100 dark:bg-gray-800 border border-slate-200 dark:border-gray-700 px-2 py-1 text-[10px] font-medium text-slate-600 dark:text-gray-400 hover:border-brand-400 hover:text-brand-600 transition-colors"
|
||||
className="button flat"
|
||||
title="Reprocess with different model"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 5, fontSize: 11, padding: '4px 8px' }}
|
||||
>
|
||||
{busy ? <Loader2 className="w-3 h-3 animate-spin" /> : <Wand2 className="w-3 h-3" />}
|
||||
{busy ? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} /> : <Wand2 size={11} />}
|
||||
Reprocess
|
||||
</button>
|
||||
|
||||
{showMenu && (
|
||||
<div className="absolute right-0 top-full mt-1 z-20 w-64 rounded-lg border border-slate-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-lg">
|
||||
<div className="p-2 space-y-2">
|
||||
{/* Family tabs */}
|
||||
<p className="text-[10px] font-medium text-slate-500 dark:text-gray-500 uppercase tracking-wider">
|
||||
<div style={{
|
||||
position: 'absolute', right: 0, top: '100%', marginTop: 4, zIndex: 20,
|
||||
width: 240, borderRadius: 6, border: '1px solid var(--border-color)',
|
||||
background: 'var(--body-background)', boxShadow: '0 4px 16px rgba(0,0,0,0.2)',
|
||||
}}>
|
||||
<div style={{ padding: 10, display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<p style={{ fontSize: 10, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', opacity: 0.5, margin: 0 }}>
|
||||
Model Family
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>
|
||||
{groups.map(g => (
|
||||
<button
|
||||
key={g}
|
||||
onClick={() => setSelectedGroup(g)}
|
||||
className={`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${
|
||||
activeGroup === g
|
||||
? 'bg-brand-500 text-white'
|
||||
: 'bg-slate-100 dark:bg-gray-800 text-slate-600 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'
|
||||
}`}
|
||||
style={{
|
||||
padding: '2px 8px', borderRadius: 4, fontSize: 10, fontWeight: 600, border: 'none', cursor: 'pointer',
|
||||
background: activeGroup === g ? accentColor : 'var(--background)',
|
||||
color: activeGroup === g ? '#fff' : 'inherit',
|
||||
}}
|
||||
>
|
||||
{g}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Model list for selected family */}
|
||||
<p className="text-[10px] font-medium text-slate-500 dark:text-gray-500 uppercase tracking-wider">
|
||||
<p style={{ fontSize: 10, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', opacity: 0.5, margin: 0 }}>
|
||||
Model
|
||||
</p>
|
||||
<div className="space-y-0.5 max-h-40 overflow-y-auto">
|
||||
<div style={{ maxHeight: 160, overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: 2 }}>
|
||||
{filteredModels.map((model) => (
|
||||
<button
|
||||
key={model.id}
|
||||
onClick={() => handleReprocess(model.id)}
|
||||
className="w-full text-left px-2 py-1.5 rounded text-xs text-slate-700 dark:text-gray-300 hover:bg-slate-100 dark:hover:bg-gray-800 transition-colors font-medium"
|
||||
className="button flat"
|
||||
style={{ textAlign: 'left', fontSize: 12, padding: '5px 8px' }}
|
||||
>
|
||||
{model.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={() => setShowMenu(false)}
|
||||
className="w-full py-1.5 text-[10px] text-slate-500 hover:text-slate-700 dark:text-gray-500 dark:hover:text-gray-300 border-t border-slate-200 dark:border-gray-700"
|
||||
className="button flat"
|
||||
style={{ width: '100%', fontSize: 11, padding: '6px 0', borderTop: '1px solid var(--border-color)', borderRadius: 0 }}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
@@ -819,7 +843,7 @@ function StemRenameButton({
|
||||
|
||||
if (isEditing) {
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
|
||||
<input
|
||||
type="text"
|
||||
value={newName}
|
||||
@@ -828,21 +852,28 @@ function StemRenameButton({
|
||||
if (e.key === 'Enter') handleSubmit()
|
||||
if (e.key === 'Escape') setIsEditing(false)
|
||||
}}
|
||||
className="w-24 rounded border border-slate-300 dark:border-gray-600 px-1.5 py-0.5 text-xs bg-white dark:bg-gray-900 text-slate-900 dark:text-gray-100"
|
||||
style={{
|
||||
width: 96, padding: '3px 7px', fontSize: 12, borderRadius: 4,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--input-background, var(--background))',
|
||||
color: 'inherit', outline: 'none',
|
||||
}}
|
||||
autoFocus
|
||||
/>
|
||||
<button
|
||||
onClick={handleSubmit}
|
||||
disabled={busy}
|
||||
className="p-0.5 rounded text-emerald-500 hover:text-emerald-600"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3, color: 'var(--color-green, #10b981)' }}
|
||||
>
|
||||
{busy ? <Loader2 className="w-3 h-3 animate-spin" /> : <Check className="w-3 h-3" />}
|
||||
{busy ? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} /> : <Check size={11} />}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setIsEditing(false)}
|
||||
className="p-0.5 rounded text-slate-400 hover:text-slate-600"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3 }}
|
||||
>
|
||||
<XIcon className="w-3 h-3" />
|
||||
<XIcon size={11} />
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
@@ -851,10 +882,11 @@ function StemRenameButton({
|
||||
return (
|
||||
<button
|
||||
onClick={() => setIsEditing(true)}
|
||||
className="p-1 rounded text-slate-400 hover:text-brand-500 transition-colors"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 4 }}
|
||||
title="Rename stem"
|
||||
>
|
||||
<Edit2 className="w-3 h-3" />
|
||||
<Edit2 size={12} />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
@@ -873,40 +905,48 @@ function StemsSection({
|
||||
const stems = sepJob.files.filter((f) => f.type === 'stem')
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
return (
|
||||
<section>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
className="w-full flex items-center justify-between mb-3 text-left group"
|
||||
>
|
||||
<h3 className="text-sm font-semibold text-slate-700 dark:text-gray-200 flex items-center gap-2 group-hover:text-brand-500 transition-colors">
|
||||
<Music2 className="w-4 h-4 text-brand-500" /> Stems
|
||||
</h3>
|
||||
{open ? <ChevronUp className="w-3.5 h-3.5 text-slate-400" /> : <ChevronDown className="w-3.5 h-3.5 text-slate-400" />}
|
||||
</button>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, background: 'none', border: 'none', cursor: 'pointer', fontSize: 13, fontWeight: 600, color: accentColor }}
|
||||
>
|
||||
<Music2 size={15} style={{ color: accentColor }} /> Stems
|
||||
</button>
|
||||
<button onClick={() => setOpen((v) => !v)} className="button cycle flat" style={{ padding: 3 }}>
|
||||
{open ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
|
||||
</button>
|
||||
</div>
|
||||
{open && (stems.length === 0 ? (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic">No stem files found.</p>
|
||||
<p style={{ fontSize: 12, opacity: 0.45, fontStyle: 'italic' }}>No stem files found.</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
|
||||
{stems.map((f) => (
|
||||
<div
|
||||
key={f.name}
|
||||
className="flex items-center gap-2 p-2 rounded-lg border border-slate-200 dark:border-gray-700 bg-slate-50/50 dark:bg-gray-800/30"
|
||||
>
|
||||
<StemChipButton file={f} jobId={sepJob.id} />
|
||||
<div className="flex-1" />
|
||||
<StemRenameButton
|
||||
projectId={project.id}
|
||||
stemName={f.stem ?? f.name}
|
||||
currentLabel={f.stem ?? f.name}
|
||||
onRename={onAction}
|
||||
/>
|
||||
<StemReprocessButton
|
||||
projectId={project.id}
|
||||
stemName={f.stem ?? f.name}
|
||||
onReprocess={onAction}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
key={f.name}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 8,
|
||||
padding: '6px 8px', borderRadius: 6,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--background)',
|
||||
}}
|
||||
>
|
||||
<StemChipButton file={f} jobId={sepJob.id} />
|
||||
<div style={{ flex: 1 }} />
|
||||
<StemRenameButton
|
||||
projectId={project.id}
|
||||
stemName={f.stem ?? f.name}
|
||||
currentLabel={f.stem ?? f.name}
|
||||
onRename={onAction}
|
||||
/>
|
||||
<StemReprocessButton
|
||||
projectId={project.id}
|
||||
stemName={f.stem ?? f.name}
|
||||
onReprocess={onAction}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
@@ -965,30 +1005,34 @@ function MixesSection({
|
||||
const currentMixType = mixFiles[0]?.type // 'static' | 'dynamic'
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
return (
|
||||
<section>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
className="w-full flex items-center justify-between mb-3 text-left group"
|
||||
>
|
||||
<h3 className="text-sm font-semibold text-slate-700 dark:text-gray-200 flex items-center gap-2 group-hover:text-brand-500 transition-colors">
|
||||
<Music2 className="w-4 h-4 text-brand-500" /> Mixes
|
||||
</h3>
|
||||
{open ? <ChevronUp className="w-3.5 h-3.5 text-slate-400" /> : <ChevronDown className="w-3.5 h-3.5 text-slate-400" />}
|
||||
</button>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, background: 'none', border: 'none', cursor: 'pointer', fontSize: 13, fontWeight: 600, color: accentColor }}
|
||||
>
|
||||
<Music2 size={15} style={{ color: accentColor }} /> Mixes
|
||||
</button>
|
||||
<button onClick={() => setOpen((v) => !v)} className="button cycle flat" style={{ padding: 3 }}>
|
||||
{open ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{open && (<>
|
||||
{/* Sub-tabs */}
|
||||
<div className="flex gap-1 mb-4">
|
||||
<div style={{ display: 'flex', gap: 4, marginBottom: 14 }}>
|
||||
{(['static', 'dynamic'] as const).map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
onClick={() => setMixTab(t)}
|
||||
className={`px-3 py-1 rounded-lg text-xs font-medium capitalize transition-colors ${
|
||||
mixTab === t
|
||||
? 'bg-brand-500 text-white'
|
||||
: 'bg-slate-100 dark:bg-gray-800 text-slate-600 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'
|
||||
}`}
|
||||
style={{
|
||||
padding: '4px 12px', borderRadius: 4, fontSize: 12, fontWeight: 600,
|
||||
border: 'none', cursor: 'pointer', textTransform: 'capitalize',
|
||||
background: mixTab === t ? accentColor : 'var(--background)',
|
||||
color: mixTab === t ? '#fff' : 'inherit',
|
||||
}}
|
||||
>
|
||||
{t}
|
||||
</button>
|
||||
@@ -996,30 +1040,31 @@ function MixesSection({
|
||||
</div>
|
||||
|
||||
{mixTab === 'static' ? (
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<label className="text-xs font-medium text-slate-600 dark:text-gray-400 block mb-1">Remove</label>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||||
<label>
|
||||
<span style={{ display: 'block', fontSize: 11, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', opacity: 0.5, marginBottom: 5 }}>Remove</span>
|
||||
<select
|
||||
value={staticOption}
|
||||
onChange={(e) => setStaticOption(e.target.value)}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-3 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-brand-400"
|
||||
style={{ padding: '6px 10px', fontSize: 12, borderRadius: 4, border: '1px solid var(--border-color)', background: 'var(--background)', color: 'var(--foreground)', outline: 'none', colorScheme: 'inherit' }}
|
||||
>
|
||||
{STATIC_OPTIONS.map((o) => (
|
||||
<option key={o.id} value={o.id}>{o.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</label>
|
||||
<button
|
||||
onClick={handleGenerate}
|
||||
disabled={busy || !!isActive(mixJob)}
|
||||
className="flex items-center gap-1.5 rounded-lg bg-brand-500/10 border border-brand-400/30 px-3 py-1.5 text-xs font-medium text-brand-600 dark:text-brand-400 hover:bg-brand-500/20 transition-colors disabled:opacity-50"
|
||||
className="button"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, padding: '6px 14px', width: 'fit-content', opacity: (busy || !!isActive(mixJob)) ? 0.5 : 1 }}
|
||||
>
|
||||
{busy ? <Loader2 className="w-3 h-3 animate-spin" /> : null}
|
||||
{busy ? <Loader2 size={12} style={{ animation: 'spin 1s linear infinite' }} /> : null}
|
||||
Generate
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||||
<DynamicMixPlayer
|
||||
stems={stemEntries}
|
||||
title={project.name}
|
||||
@@ -1028,37 +1073,38 @@ function MixesSection({
|
||||
<button
|
||||
onClick={handleGenerate}
|
||||
disabled={busy || !!isActive(mixJob)}
|
||||
className="flex items-center gap-1.5 rounded-lg bg-brand-500/10 border border-brand-400/30 px-3 py-1.5 text-xs font-medium text-brand-600 dark:text-brand-400 hover:bg-brand-500/20 transition-colors disabled:opacity-50"
|
||||
className="button"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, padding: '6px 14px', width: 'fit-content', opacity: (busy || !!isActive(mixJob)) ? 0.5 : 1 }}
|
||||
>
|
||||
{busy ? <Loader2 className="w-3 h-3 animate-spin" /> : null}
|
||||
{busy ? <Loader2 size={12} style={{ animation: 'spin 1s linear infinite' }} /> : null}
|
||||
Export Mix
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{err && <p className="mt-2 text-xs text-red-500 dark:text-red-400">{err}</p>}
|
||||
{err && <p style={{ fontSize: 12, color: 'var(--color-red, #ef4444)', marginTop: 6 }}>{err}</p>}
|
||||
|
||||
{/* Current mix job */}
|
||||
{mixJob && (
|
||||
<div className="mt-3 rounded-xl bg-slate-50 dark:bg-gray-900 border border-slate-200 dark:border-gray-800 p-3 space-y-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400">
|
||||
<div style={{ marginTop: 12, borderRadius: 6, border: '1px solid var(--border-color)', background: 'var(--background)', padding: '10px 12px', display: 'flex', flexDirection: 'column', gap: 6 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<span style={{ fontSize: 12, opacity: 0.55 }}>
|
||||
{currentMixType === 'dynamic' ? 'Dynamic' : 'Static'} mix
|
||||
</span>
|
||||
<JobBadge job={mixJob} />
|
||||
</div>
|
||||
{isActive(mixJob) && (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-500 truncate">{mixJob.progress}</p>
|
||||
<p style={{ fontSize: 12, opacity: 0.5, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{mixJob.progress}</p>
|
||||
)}
|
||||
{mixJob.status === 'done' && (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
|
||||
{mixJob.files.map((f) => (
|
||||
<DownloadButton key={f.name} file={f} jobId={mixJob.id} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{mixJob.status === 'error' && (
|
||||
<p className="text-xs text-red-400 break-all">{mixJob.error}</p>
|
||||
<p style={{ fontSize: 11, color: 'var(--color-red, #ef4444)', wordBreak: 'break-all' }}>{mixJob.error}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
@@ -1108,6 +1154,7 @@ function StemMidiRow({
|
||||
value={mode}
|
||||
onChange={(e) => setMode(e.target.value)}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-purple-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
{TRANSCRIBE_MODES.map((m) => (
|
||||
<option key={m.id} value={m.id}>{m.label}</option>
|
||||
@@ -1171,35 +1218,37 @@ function MidiSection({
|
||||
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const violetColor = 'var(--color-violet, #a855f7)'
|
||||
return (
|
||||
<section>
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
className="flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-gray-200 hover:text-brand-500 transition-colors"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, background: 'none', border: 'none', cursor: 'pointer', fontSize: 13, fontWeight: 600, color: violetColor }}
|
||||
>
|
||||
<Mic2 className="w-4 h-4 text-purple-500" /> MIDI
|
||||
<Mic2 size={15} style={{ color: violetColor }} /> MIDI
|
||||
</button>
|
||||
<div className="flex items-center gap-2">
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
{open && stems.length > 1 && (
|
||||
<button
|
||||
onClick={handleTranscribeAll}
|
||||
disabled={bulkBusy || anyActive}
|
||||
className="flex items-center gap-1.5 rounded-lg bg-purple-500/10 border border-purple-400/30 px-3 py-1 text-xs font-medium text-purple-600 dark:text-purple-400 hover:bg-purple-500/20 transition-colors disabled:opacity-50"
|
||||
className="button flat"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 5, fontSize: 11, padding: '4px 10px', color: violetColor, opacity: (bulkBusy || anyActive) ? 0.5 : 1 }}
|
||||
>
|
||||
{bulkBusy ? <Loader2 className="w-3 h-3 animate-spin" /> : <ListMusic className="w-3 h-3" />}
|
||||
{bulkBusy ? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} /> : <ListMusic size={11} />}
|
||||
Transcribe All
|
||||
</button>
|
||||
)}
|
||||
<button onClick={() => setOpen((v) => !v)} className="text-slate-400 hover:text-slate-600 dark:hover:text-gray-300 transition-colors">
|
||||
{open ? <ChevronUp className="w-3.5 h-3.5" /> : <ChevronDown className="w-3.5 h-3.5" />}
|
||||
<button onClick={() => setOpen((v) => !v)} className="button cycle flat" style={{ padding: 3 }}>
|
||||
{open ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{open && (<>
|
||||
{bulkErr && <p className="mb-2 text-xs text-red-500 dark:text-red-400">{bulkErr}</p>}
|
||||
{bulkErr && <p style={{ fontSize: 12, color: 'var(--color-red, #ef4444)', marginBottom: 6 }}>{bulkErr}</p>}
|
||||
{stems.length === 0 ? (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic">No stems available.</p>
|
||||
<p style={{ fontSize: 12, opacity: 0.45, fontStyle: 'italic' }}>No stems available.</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{stems.map((stem) => {
|
||||
@@ -1285,6 +1334,7 @@ function StemAbcRow({
|
||||
placeholder={`Title (default: ${projectName})`}
|
||||
disabled={!canConvert}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 placeholder-slate-400 focus:outline-none focus:border-emerald-400 w-40 disabled:opacity-50"
|
||||
style={fieldStyle}
|
||||
/>
|
||||
<button
|
||||
onClick={handleConvert}
|
||||
@@ -1364,35 +1414,37 @@ function AbcSection({
|
||||
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const greenColor = 'var(--color-green, #10b981)'
|
||||
return (
|
||||
<section>
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
className="flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-gray-200 hover:text-brand-500 transition-colors"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, background: 'none', border: 'none', cursor: 'pointer', fontSize: 13, fontWeight: 600, color: greenColor }}
|
||||
>
|
||||
<FileCode className="w-4 h-4 text-emerald-500" /> ABC Notation
|
||||
<FileCode size={15} style={{ color: greenColor }} /> ABC Notation
|
||||
</button>
|
||||
<div className="flex items-center gap-2">
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
{open && convertableStems.length > 1 && (
|
||||
<button
|
||||
onClick={handleConvertAll}
|
||||
disabled={bulkBusy || anyActive}
|
||||
className="flex items-center gap-1.5 rounded-lg bg-emerald-500/10 border border-emerald-400/30 px-3 py-1 text-xs font-medium text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 transition-colors disabled:opacity-50"
|
||||
className="button flat"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 5, fontSize: 11, padding: '4px 10px', color: greenColor, opacity: (bulkBusy || anyActive) ? 0.5 : 1 }}
|
||||
>
|
||||
{bulkBusy ? <Loader2 className="w-3 h-3 animate-spin" /> : <ListMusic className="w-3 h-3" />}
|
||||
{bulkBusy ? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} /> : <ListMusic size={11} />}
|
||||
Convert All
|
||||
</button>
|
||||
)}
|
||||
<button onClick={() => setOpen((v) => !v)} className="text-slate-400 hover:text-slate-600 dark:hover:text-gray-300 transition-colors">
|
||||
{open ? <ChevronUp className="w-3.5 h-3.5" /> : <ChevronDown className="w-3.5 h-3.5" />}
|
||||
<button onClick={() => setOpen((v) => !v)} className="button cycle flat" style={{ padding: 3 }}>
|
||||
{open ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{open && (<>
|
||||
{bulkErr && <p className="mb-2 text-xs text-red-500 dark:text-red-400">{bulkErr}</p>}
|
||||
{bulkErr && <p style={{ fontSize: 12, color: 'var(--color-red, #ef4444)', marginBottom: 6 }}>{bulkErr}</p>}
|
||||
{stems.length === 0 ? (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic">No stems available.</p>
|
||||
<p style={{ fontSize: 12, opacity: 0.45, fontStyle: 'italic' }}>No stems available.</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{stems.map((stem) => {
|
||||
@@ -1454,7 +1506,7 @@ function AbcFileViewer({
|
||||
return (
|
||||
<div className="rounded-lg border border-slate-200 dark:border-gray-700 overflow-hidden">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between px-3 py-2 bg-white dark:bg-gray-900">
|
||||
<div className="flex items-center justify-between px-3 py-2" style={{ background: 'var(--background)' }}>
|
||||
<button
|
||||
onClick={load}
|
||||
className="flex items-center gap-1.5 text-xs font-medium text-slate-700 dark:text-gray-300 hover:text-emerald-600 dark:hover:text-emerald-400 transition-colors"
|
||||
@@ -1469,11 +1521,13 @@ function AbcFileViewer({
|
||||
<div className="flex rounded overflow-hidden border border-slate-200 dark:border-gray-700 text-[10px] font-medium">
|
||||
<button
|
||||
onClick={() => setView('sheet')}
|
||||
className={`px-2 py-0.5 transition-colors ${view === 'sheet' ? 'bg-emerald-500 text-white' : 'bg-white dark:bg-gray-900 text-slate-500 dark:text-gray-400 hover:bg-slate-50 dark:hover:bg-gray-800'}`}
|
||||
className="px-2 py-0.5 transition-colors"
|
||||
style={view === 'sheet' ? { background: '#10b981', color: '#fff' } : { background: 'var(--background)', color: 'var(--foreground-muted)' }}
|
||||
>Sheet</button>
|
||||
<button
|
||||
onClick={() => setView('text')}
|
||||
className={`px-2 py-0.5 transition-colors ${view === 'text' ? 'bg-emerald-500 text-white' : 'bg-white dark:bg-gray-900 text-slate-500 dark:text-gray-400 hover:bg-slate-50 dark:hover:bg-gray-800'}`}
|
||||
className="px-2 py-0.5 transition-colors"
|
||||
style={view === 'text' ? { background: '#10b981', color: '#fff' } : { background: 'var(--background)', color: 'var(--foreground-muted)' }}
|
||||
>Text</button>
|
||||
</div>
|
||||
)}
|
||||
@@ -1635,7 +1689,7 @@ function TranscribeLog({ progress }: { progress: string }) {
|
||||
<Loader2 className="w-3 h-3 text-slate-400 dark:text-gray-500 animate-spin" />
|
||||
</div>
|
||||
{/* log body */}
|
||||
<div className="px-2.5 py-2 max-h-40 overflow-y-auto space-y-0.5 bg-white dark:bg-gray-950">
|
||||
<div className="px-2.5 py-2 max-h-40 overflow-y-auto space-y-0.5" style={{ background: 'var(--body-background)', color: 'var(--foreground)' }}>
|
||||
{lines.length === 0
|
||||
? <span className="text-xs text-slate-400 dark:text-gray-500">Waiting for output…</span>
|
||||
: lines.map((line, i) => (
|
||||
@@ -1881,6 +1935,7 @@ function StemLyricsRow({
|
||||
value={source}
|
||||
onChange={(e) => setSource(e.target.value)}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-sky-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
<option value="text">Paste lyrics</option>
|
||||
<option value="auto">Auto (from file tags / LRC)</option>
|
||||
@@ -1911,6 +1966,7 @@ function StemLyricsRow({
|
||||
placeholder="Paste plain lyrics here, one line per lyric line…"
|
||||
rows={5}
|
||||
className="w-full rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-2 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-sky-400 resize-y font-mono"
|
||||
style={fieldStyle}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -1923,6 +1979,7 @@ function StemLyricsRow({
|
||||
value={whisperModel}
|
||||
onChange={(e) => setWhisperModel(e.target.value)}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-violet-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
{WHISPER_MODELS.map((m) => (
|
||||
<option key={m.id} value={m.id}>{m.label}</option>
|
||||
@@ -1932,6 +1989,7 @@ function StemLyricsRow({
|
||||
value={whisperLang}
|
||||
onChange={(e) => setWhisperLang(e.target.value)}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-violet-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
{WHISPER_LANGS.map((l) => (
|
||||
<option key={l.id} value={l.id}>{l.label}</option>
|
||||
@@ -1941,6 +1999,7 @@ function StemLyricsRow({
|
||||
value={whisperTask}
|
||||
onChange={(e) => setWhisperTask(e.target.value as 'transcribe' | 'translate')}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-violet-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
<option value="transcribe">Transcribe</option>
|
||||
<option value="translate">Translate → English</option>
|
||||
@@ -1950,6 +2009,7 @@ function StemLyricsRow({
|
||||
onChange={(e) => setVocalStyle(e.target.value as 'general' | 'hiphop')}
|
||||
title="Vocal style — tunes VAD thresholds and ASR priors for the genre"
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-violet-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
<option value="general">General</option>
|
||||
<option value="hiphop">Hip-hop / Rap</option>
|
||||
@@ -2061,6 +2121,7 @@ function StemLyricsRow({
|
||||
onChange={(e) => setSpeakerNames((prev) => ({ ...prev, [id]: e.target.value }))}
|
||||
placeholder="Name…"
|
||||
className="w-20 text-xs bg-white dark:bg-gray-800 border border-slate-300 dark:border-gray-700 rounded px-1.5 py-0.5 text-slate-700 dark:text-gray-200 focus:outline-none focus:border-violet-400"
|
||||
style={fieldStyle}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
@@ -2069,7 +2130,7 @@ function StemLyricsRow({
|
||||
|
||||
{/* Transcript body */}
|
||||
{hasSpeakers && transcriptSegs ? (
|
||||
<div className="px-2.5 py-2 space-y-0.5 max-h-48 overflow-y-auto bg-white dark:bg-gray-950">
|
||||
<div className="px-2.5 py-2 space-y-0.5 max-h-48 overflow-y-auto" style={{ background: 'var(--body-background)', color: 'var(--foreground)' }}>
|
||||
{(() => {
|
||||
// Group consecutive segments by speaker
|
||||
const groups: Array<{ speaker?: string; lines: string[] }> = []
|
||||
@@ -2093,7 +2154,7 @@ function StemLyricsRow({
|
||||
})()}
|
||||
</div>
|
||||
) : (
|
||||
<pre className="px-2.5 py-2 text-xs text-slate-700 dark:text-gray-200 whitespace-pre-wrap leading-relaxed max-h-48 overflow-y-auto bg-white dark:bg-gray-950 select-text">
|
||||
<pre className="px-2.5 py-2 text-xs whitespace-pre-wrap leading-relaxed max-h-48 overflow-y-auto select-text" style={{ background: 'var(--body-background)', color: 'var(--foreground)' }}>
|
||||
{transcriptText}
|
||||
</pre>
|
||||
)}
|
||||
@@ -2150,19 +2211,22 @@ function LyricsSection({
|
||||
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const skyColor = 'var(--color-blue, #0ea5e9)'
|
||||
return (
|
||||
<section>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
className="w-full flex items-center justify-between mb-3 text-left group"
|
||||
>
|
||||
<h3 className="text-sm font-semibold text-slate-700 dark:text-gray-200 flex items-center gap-2 group-hover:text-brand-500 transition-colors">
|
||||
<FileText className="w-4 h-4 text-sky-500" /> Lyrics Sync
|
||||
</h3>
|
||||
{open ? <ChevronUp className="w-3.5 h-3.5 text-slate-400" /> : <ChevronDown className="w-3.5 h-3.5 text-slate-400" />}
|
||||
</button>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, background: 'none', border: 'none', cursor: 'pointer', fontSize: 13, fontWeight: 600, color: skyColor }}
|
||||
>
|
||||
<FileText size={15} style={{ color: skyColor }} /> Lyrics Sync
|
||||
</button>
|
||||
<button onClick={() => setOpen((v) => !v)} className="button cycle flat" style={{ padding: 3 }}>
|
||||
{open ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
|
||||
</button>
|
||||
</div>
|
||||
{open && (vocalStems.length === 0 ? (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic">No vocals stem available.</p>
|
||||
<p style={{ fontSize: 12, opacity: 0.45, fontStyle: 'italic' }}>No vocals stem available.</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{vocalStems.map((stem) => {
|
||||
@@ -2227,27 +2291,27 @@ export default function ProjectDetail({ id, onDelete }: Props) {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-16">
|
||||
<Loader2 className="w-6 h-6 animate-spin text-brand-400" />
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '48px 0' }}>
|
||||
<Loader2 size={24} style={{ animation: 'spin 1s linear infinite', color: `rgb(var(--brand-500, 59 130 246))` }} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (error || !project) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<p className="text-sm text-red-500">Failed to load project.</p>
|
||||
</div>
|
||||
<p style={{ fontSize: 13, color: 'var(--color-red, #ef4444)' }}>Failed to load project.</p>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 0 }}>
|
||||
{/* Header */}
|
||||
<div className="flex items-start gap-3">
|
||||
<div className="flex-1 min-w-0">
|
||||
<h2 className="text-base font-bold text-slate-900 dark:text-white leading-tight truncate">{project.name}</h2>
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 mt-0.5">
|
||||
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 12, marginBottom: 20 }}>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<h2 style={{ fontSize: 15, fontWeight: 700, margin: '0 0 2px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{project.name}
|
||||
</h2>
|
||||
<p style={{ fontSize: 11, opacity: 0.45, margin: 0 }}>
|
||||
{project.created_at ? new Date(project.created_at).toLocaleDateString() : ''}
|
||||
</p>
|
||||
</div>
|
||||
@@ -2255,19 +2319,23 @@ export default function ProjectDetail({ id, onDelete }: Props) {
|
||||
<button
|
||||
onClick={onDelete}
|
||||
title="Delete project"
|
||||
className="shrink-0 p-1.5 rounded-lg text-slate-300 dark:text-gray-600 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-950/30 transition-colors"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 6, flexShrink: 0, color: 'var(--color-red, #ef4444)' }}
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
<Trash2 size={15} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="divide-y divide-slate-100 dark:divide-gray-800 space-y-6">
|
||||
{/* Sections */}
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 0 }}>
|
||||
{/* 1 — Stems */}
|
||||
<StemsSection project={project} sepJob={project.sep_job} onAction={invalidate} />
|
||||
<div style={{ padding: '16px 0', borderTop: '1px solid var(--border-color)' }}>
|
||||
<StemsSection project={project} sepJob={project.sep_job} onAction={invalidate} />
|
||||
</div>
|
||||
|
||||
{/* 2 — Mixes */}
|
||||
<div className="pt-6">
|
||||
<div style={{ padding: '16px 0', borderTop: '1px solid var(--border-color)' }}>
|
||||
<MixesSection
|
||||
project={project}
|
||||
sepJob={project.sep_job}
|
||||
@@ -2277,7 +2345,7 @@ export default function ProjectDetail({ id, onDelete }: Props) {
|
||||
</div>
|
||||
|
||||
{/* 3 — MIDI */}
|
||||
<div className="pt-6">
|
||||
<div style={{ padding: '16px 0', borderTop: '1px solid var(--border-color)' }}>
|
||||
<MidiSection
|
||||
project={project}
|
||||
sepJob={project.sep_job}
|
||||
@@ -2287,7 +2355,7 @@ export default function ProjectDetail({ id, onDelete }: Props) {
|
||||
</div>
|
||||
|
||||
{/* 4 — ABC */}
|
||||
<div className="pt-6">
|
||||
<div style={{ padding: '16px 0', borderTop: '1px solid var(--border-color)' }}>
|
||||
<AbcSection
|
||||
project={project}
|
||||
sepJob={project.sep_job}
|
||||
@@ -2298,7 +2366,7 @@ export default function ProjectDetail({ id, onDelete }: Props) {
|
||||
</div>
|
||||
|
||||
{/* 5 — Lyrics Sync */}
|
||||
<div className="pt-6">
|
||||
<div style={{ padding: '16px 0', borderTop: '1px solid var(--border-color)' }}>
|
||||
<LyricsSection
|
||||
project={project}
|
||||
sepJob={project.sep_job}
|
||||
+611
@@ -0,0 +1,611 @@
|
||||
/**
|
||||
* Separator.tsx — Phase 3 MetroUI migration
|
||||
*
|
||||
* All business logic (state, queries, handlers, effects) unchanged.
|
||||
* Tailwind classes replaced with MetroUI CSS + inline styles.
|
||||
* Sub-components JobStatus, ResultFiles are not yet migrated (Phase 4+).
|
||||
*/
|
||||
import { useState, useEffect, useRef, type CSSProperties } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { RefreshCw, Radio, Zap } from 'lucide-react'
|
||||
import FileUpload from '../components/FileUpload'
|
||||
import JobStatus from '../components/JobStatus'
|
||||
import ResultFiles from '../components/ResultFiles'
|
||||
import AutoPipelineDialog from '../components/AutoPipelineDialog'
|
||||
import {
|
||||
getSepModels, getSepFormats, getPresets, submitSeparate, extractLyrics,
|
||||
listImports, submitSeparateFromPath,
|
||||
} from '../api/client'
|
||||
import type { Job, ModelOption, PresetsResponse, DynamicLevels, ImportedFile } from '../types'
|
||||
|
||||
// ── Shared style helpers ────────────────────────────────────────────────────
|
||||
|
||||
const fieldLabel: CSSProperties = {
|
||||
display: 'block', fontSize: 11, fontWeight: 700,
|
||||
letterSpacing: '0.08em', textTransform: 'uppercase',
|
||||
opacity: 0.5, marginBottom: 5,
|
||||
}
|
||||
|
||||
const ctrl: CSSProperties = {
|
||||
width: '100%', padding: '6px 10px', fontSize: 13, borderRadius: 4,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--background)',
|
||||
color: 'var(--foreground)', outline: 'none', boxSizing: 'border-box',
|
||||
colorScheme: 'inherit',
|
||||
}
|
||||
|
||||
const card: CSSProperties = {
|
||||
borderRadius: 6, border: '1px solid var(--border-color)',
|
||||
background: 'var(--background)', padding: '12px 14px',
|
||||
}
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────────────────────
|
||||
|
||||
function groupModels(models: ModelOption[]) {
|
||||
const groups: Record<string, ModelOption[]> = {}
|
||||
for (const m of models) {
|
||||
const g = m.group ?? 'Other'
|
||||
if (!groups[g]) groups[g] = []
|
||||
groups[g].push(m)
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
const DEFAULT_DYNAMIC_LEVELS: DynamicLevels = {
|
||||
vocals: 1.0,
|
||||
drums: 1.0,
|
||||
bass: 1.0,
|
||||
other: 1.0,
|
||||
}
|
||||
|
||||
interface Props {
|
||||
onSeparationComplete?: (projectId: string, tabLabel: string, projectName: string) => void
|
||||
onOpenSettings?: () => void
|
||||
}
|
||||
|
||||
export default function Separator({ onSeparationComplete, onOpenSettings }: Props) {
|
||||
const [inputMode, setInputMode] = useState<'upload' | 'imported'>('upload')
|
||||
const [file, setFile] = useState<File | null>(null)
|
||||
const [importedFile, setImportedFile] = useState<ImportedFile | null>(null)
|
||||
const [model, setModel] = useState('htdemucs')
|
||||
const [format, setFormat] = useState('mp3')
|
||||
const [presetType, setPresetType] = useState('stems_only')
|
||||
const [staticOption, setStaticOption] = useState('no_vocals')
|
||||
const [dynamicLevels, setDynamicLevels] = useState<DynamicLevels>(DEFAULT_DYNAMIC_LEVELS)
|
||||
const [projectName, setProjectName] = useState('')
|
||||
const [metadata, setMetadata] = useState<{artist?: string; title?: string}>({})
|
||||
const [jobId, setJobId] = useState<string | null>(null)
|
||||
const [result, setResult] = useState<Job | null>(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [showAuto, setShowAuto] = useState(false)
|
||||
|
||||
const { data: models = [] } = useQuery({ queryKey: ['sep-models'], queryFn: getSepModels })
|
||||
const { data: formats = [] } = useQuery({ queryKey: ['sep-formats'], queryFn: getSepFormats })
|
||||
const { data: presets } = useQuery<PresetsResponse>({ queryKey: ['sep-presets'], queryFn: getPresets })
|
||||
const { data: imports = [], refetch: refetchImports } = useQuery<ImportedFile[]>({
|
||||
queryKey: ['imports'],
|
||||
queryFn: listImports,
|
||||
enabled: inputMode === 'imported',
|
||||
refetchInterval: inputMode === 'imported' ? 5000 : false,
|
||||
})
|
||||
|
||||
const grouped = groupModels(models)
|
||||
|
||||
const hiddenGroups = new Set<string>((() => {
|
||||
try { return JSON.parse(localStorage.getItem('se-model-hidden-groups') || '[]') as string[] }
|
||||
catch { return [] }
|
||||
})())
|
||||
const hiddenModels = new Set<string>((() => {
|
||||
try { return JSON.parse(localStorage.getItem('se-model-hidden-models') || '[]') as string[] }
|
||||
catch { return [] }
|
||||
})())
|
||||
const groupOrder: string[] = (() => {
|
||||
try { return JSON.parse(localStorage.getItem('se-model-group-order') || 'null') || [] }
|
||||
catch { return [] }
|
||||
})()
|
||||
const modelOrder: Record<string, string[]> = (() => {
|
||||
try { return JSON.parse(localStorage.getItem('se-model-model-order') || 'null') || {} }
|
||||
catch { return {} }
|
||||
})()
|
||||
|
||||
const allGroupNames = Object.keys(grouped)
|
||||
const orderedGroupNames = [
|
||||
...groupOrder.filter(g => allGroupNames.includes(g)),
|
||||
...allGroupNames.filter(g => !groupOrder.includes(g)),
|
||||
]
|
||||
const visibleGrouped: Record<string, ModelOption[]> = {}
|
||||
for (const group of orderedGroupNames) {
|
||||
if (hiddenGroups.has(group)) continue
|
||||
const rawModels = grouped[group] || []
|
||||
const order = modelOrder[group] || rawModels.map(m => m.id)
|
||||
const ids = rawModels.map(m => m.id)
|
||||
const sorted = [
|
||||
...order.filter(id => ids.includes(id)).map(id => rawModels.find(m => m.id === id)!),
|
||||
...rawModels.filter(m => !order.includes(m.id)),
|
||||
]
|
||||
const visible = sorted.filter(m => !hiddenModels.has(m.id))
|
||||
if (visible.length > 0) visibleGrouped[group] = visible
|
||||
}
|
||||
|
||||
const rawGroup = models.find(m => m.id === model)?.group
|
||||
const selectedGroup = (rawGroup && visibleGrouped[rawGroup])
|
||||
? rawGroup
|
||||
: Object.keys(visibleGrouped)[0] ?? ''
|
||||
const isBSR = model.startsWith('bs_roformer_')
|
||||
|
||||
function handleGroupChange(group: string) {
|
||||
const first = visibleGrouped[group]?.[0]
|
||||
if (first) setModel(first.id)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!models.length) return
|
||||
const foundGroup = models.find(m => m.id === model)?.group
|
||||
const isVisible = foundGroup && visibleGrouped[foundGroup]?.some(m => m.id === model)
|
||||
if (!isVisible) {
|
||||
const firstGroup = Object.keys(visibleGrouped)[0]
|
||||
const firstModel = firstGroup ? visibleGrouped[firstGroup]?.[0] : undefined
|
||||
if (firstModel) setModel(firstModel.id)
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [models])
|
||||
|
||||
const firedRef = useRef<string | null>(null)
|
||||
useEffect(() => {
|
||||
if (
|
||||
result?.status === 'done' &&
|
||||
result.result?.project_id &&
|
||||
result.result?.tab_label &&
|
||||
onSeparationComplete &&
|
||||
firedRef.current !== result.id
|
||||
) {
|
||||
firedRef.current = result.id
|
||||
onSeparationComplete(
|
||||
result.result.project_id,
|
||||
result.result.tab_label,
|
||||
result.result.project_name ?? '',
|
||||
)
|
||||
}
|
||||
}, [result, onSeparationComplete])
|
||||
|
||||
useEffect(() => {
|
||||
if (!file) {
|
||||
setMetadata({})
|
||||
setProjectName('')
|
||||
return
|
||||
}
|
||||
extractLyrics(file).then(() => {
|
||||
const filename = file.name.replace(/\.[^/.]+$/, '')
|
||||
setMetadata({ artist: '', title: filename })
|
||||
}).catch(() => {
|
||||
const filename = file.name.replace(/\.[^/.]+$/, '')
|
||||
setMetadata({ artist: '', title: filename })
|
||||
})
|
||||
}, [file])
|
||||
|
||||
useEffect(() => {
|
||||
if (metadata.artist && metadata.title) {
|
||||
setProjectName(`${metadata.artist} - ${metadata.title}`)
|
||||
} else if (metadata.title) {
|
||||
setProjectName(metadata.title)
|
||||
} else if (file) {
|
||||
setProjectName(file.name.replace(/\.[^/.]+$/, ''))
|
||||
}
|
||||
}, [metadata, file])
|
||||
|
||||
async function submit() {
|
||||
if (inputMode === 'upload' && !file) return
|
||||
if (inputMode === 'imported' && !importedFile) return
|
||||
setError(null); setResult(null); setJobId(null); setLoading(true)
|
||||
try {
|
||||
const sepPowerPreset = localStorage.getItem('stemengine-sep-power') ?? 'standard'
|
||||
const opts = {
|
||||
presetType,
|
||||
projectName: projectName || undefined,
|
||||
staticOption: presetType === 'static' ? staticOption : undefined,
|
||||
dynamicLevels: presetType === 'dynamic' ? dynamicLevels : undefined,
|
||||
sepPowerPreset,
|
||||
}
|
||||
let job_id: string
|
||||
if (inputMode === 'imported' && importedFile) {
|
||||
const res = await submitSeparateFromPath(importedFile.path, model, format, opts)
|
||||
job_id = res.job_id
|
||||
} else {
|
||||
const res = await submitSeparate(file!, model, format, opts)
|
||||
job_id = res.job_id
|
||||
}
|
||||
setJobId(job_id)
|
||||
} catch (e) {
|
||||
setError(String(e))
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleDynamicChange = (stem: keyof DynamicLevels, value: number) => {
|
||||
setDynamicLevels(prev => ({ ...prev, [stem]: value }))
|
||||
}
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
const hasInput = inputMode === 'upload' ? !!file : !!importedFile
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 20 }}>
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────────── */}
|
||||
<div>
|
||||
<h2 style={{ fontSize: 20, fontWeight: 600, margin: '0 0 4px' }}>Stem Separator</h2>
|
||||
<p style={{ fontSize: 13, opacity: 0.55, margin: 0, lineHeight: 1.5 }}>
|
||||
Separate an audio track into individual stems using Demucs, BS-RoFormer, MelBand, or MDX-Net.
|
||||
Create presets like Instrumental, Static mixes, or Dynamic volume-adjusted mixes.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* ── Input mode toggle ─────────────────────────────────────────────────── */}
|
||||
<div style={{ display: 'flex', borderRadius: 5, overflow: 'hidden', border: '1px solid var(--border-color)' }}>
|
||||
<button
|
||||
onClick={() => setInputMode('upload')}
|
||||
style={{
|
||||
flex: 1, padding: '7px 12px', fontSize: 12, fontWeight: 600,
|
||||
border: 'none', cursor: 'pointer', transition: 'background 0.15s, color 0.15s',
|
||||
background: inputMode === 'upload' ? accentColor : 'transparent',
|
||||
color: inputMode === 'upload' ? '#fff' : 'inherit',
|
||||
}}
|
||||
>
|
||||
Upload File
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setInputMode('imported'); refetchImports() }}
|
||||
style={{
|
||||
flex: 1, padding: '7px 12px', fontSize: 12, fontWeight: 600,
|
||||
border: 'none', borderLeft: '1px solid var(--border-color)', cursor: 'pointer',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6,
|
||||
transition: 'background 0.15s, color 0.15s',
|
||||
background: inputMode === 'imported' ? 'var(--color-blue, #0ea5e9)' : 'transparent',
|
||||
color: inputMode === 'imported' ? '#fff' : 'inherit',
|
||||
}}
|
||||
>
|
||||
<Radio size={12} />
|
||||
Imported Files
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* ── Upload mode ───────────────────────────────────────────────────────── */}
|
||||
{inputMode === 'upload' && (
|
||||
<>
|
||||
<FileUpload
|
||||
label="Drop an audio file here, or click to select (MP3, FLAC, WAV, OGG…)"
|
||||
accept="audio/*"
|
||||
onFiles={([f]) => { setFile(f); setJobId(null); setResult(null) }}
|
||||
/>
|
||||
{file && (
|
||||
<div style={{ ...card, borderColor: `rgba(var(--brand-500, 59 130 246), 0.35)` }}>
|
||||
<span style={{ fontSize: 13, fontWeight: 500 }}>Selected: </span>
|
||||
<span style={{ fontSize: 13, opacity: 0.7 }}>{file.name}</span>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* ── Imported mode ─────────────────────────────────────────────────────── */}
|
||||
{inputMode === 'imported' && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<span style={{ fontSize: 11, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', opacity: 0.5 }}>
|
||||
Select imported file
|
||||
</span>
|
||||
<button
|
||||
onClick={() => refetchImports()}
|
||||
title="Refresh"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 4, marginLeft: 'auto' }}
|
||||
>
|
||||
<RefreshCw size={13} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{imports.length === 0 ? (
|
||||
<div style={{
|
||||
borderRadius: 6, border: '2px dashed var(--border-color)',
|
||||
padding: '24px 16px', textAlign: 'center',
|
||||
}}>
|
||||
<Radio size={22} style={{ opacity: 0.25, margin: '0 auto 8px', display: 'block' }} />
|
||||
<p style={{ fontSize: 13, opacity: 0.45, margin: '0 0 4px' }}>No imported files yet.</p>
|
||||
<p style={{ fontSize: 11, opacity: 0.35, margin: 0 }}>
|
||||
Use the Subsonic panel in the sidebar to import songs.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div style={{
|
||||
maxHeight: 192, overflowY: 'auto',
|
||||
borderRadius: 6, border: '1px solid var(--border-color)',
|
||||
}}>
|
||||
{imports.map((f) => (
|
||||
<ImportedFileButton
|
||||
key={f.path}
|
||||
file={f}
|
||||
selected={importedFile?.path === f.path}
|
||||
onSelect={() => {
|
||||
setImportedFile(f)
|
||||
setProjectName(f.filename.replace(/\.[^/.]+$/, ''))
|
||||
setJobId(null); setResult(null)
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Model + Format selectors ─────────────────────────────────────────── */}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 12 }}>
|
||||
<label>
|
||||
<span style={fieldLabel}>Model Family</span>
|
||||
<select value={selectedGroup} onChange={(e) => handleGroupChange(e.target.value)} style={ctrl}>
|
||||
{Object.keys(visibleGrouped).map((g) => (
|
||||
<option key={g} value={g}>{g}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span style={fieldLabel}>Model</span>
|
||||
<select value={model} onChange={(e) => setModel(e.target.value)} style={ctrl}>
|
||||
{(visibleGrouped[selectedGroup] ?? []).map((m) => (
|
||||
<option key={m.id} value={m.id}>{m.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span style={fieldLabel}>Output Format</span>
|
||||
<select value={format} onChange={(e) => setFormat(e.target.value)} style={ctrl}>
|
||||
{formats.map((f) => <option key={f.id} value={f.id}>{f.label}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* ── BS-RoFormer info ─────────────────────────────────────────────────── */}
|
||||
{isBSR && (
|
||||
<div style={{
|
||||
borderRadius: 6,
|
||||
border: '1px solid rgba(139, 92, 246, 0.45)',
|
||||
background: 'rgba(139, 92, 246, 0.07)',
|
||||
padding: '10px 14px', fontSize: 12,
|
||||
color: 'var(--color-violet, #8b5cf6)',
|
||||
}}>
|
||||
<p style={{ fontWeight: 700, margin: '0 0 4px' }}>BS-RoFormer selected</p>
|
||||
<p style={{ opacity: 0.8, margin: '0 0 6px' }}>
|
||||
State-of-the-art transformer model. Runs in-process — may take longer on CPU.
|
||||
</p>
|
||||
<ul style={{ margin: 0, paddingLeft: 18, opacity: 0.75, lineHeight: 1.7 }}>
|
||||
<li><strong>4-stem</strong> — vocals · drums · bass · other</li>
|
||||
<li><strong>5-stem (guitar)</strong> — + guitar as separate stem</li>
|
||||
<li><strong>5-stem (piano)</strong> — + piano as separate stem</li>
|
||||
<li><strong>6-stem (full)</strong> — vocals · drums · bass · guitar · piano · other</li>
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Project name ─────────────────────────────────────────────────────── */}
|
||||
<div>
|
||||
<label>
|
||||
<span style={fieldLabel}>Project Name</span>
|
||||
<input
|
||||
type="text"
|
||||
value={projectName}
|
||||
onChange={(e) => setProjectName(e.target.value)}
|
||||
placeholder="Artist - Title"
|
||||
style={ctrl}
|
||||
/>
|
||||
</label>
|
||||
<p style={{ fontSize: 11, opacity: 0.45, margin: '5px 0 0' }}>
|
||||
Used for folder naming. Auto-generated from metadata if available.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* ── Output preset ────────────────────────────────────────────────────── */}
|
||||
<div>
|
||||
<label>
|
||||
<span style={fieldLabel}>Output Preset</span>
|
||||
<select value={presetType} onChange={(e) => setPresetType(e.target.value)} style={ctrl}>
|
||||
{presets?.preset_types.map((p) => (
|
||||
<option key={p.id} value={p.id}>{p.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p style={{ fontSize: 12, opacity: 0.5, margin: '6px 0 0', lineHeight: 1.4 }}>
|
||||
{presets?.preset_types.find(p => p.id === presetType)?.description}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* ── Static options ───────────────────────────────────────────────────── */}
|
||||
{presetType === 'static' && (
|
||||
<div style={card}>
|
||||
<label>
|
||||
<span style={fieldLabel}>Remove Elements</span>
|
||||
<select value={staticOption} onChange={(e) => setStaticOption(e.target.value)} style={ctrl}>
|
||||
{presets?.static_options.map((o) => (
|
||||
<option key={o.id} value={o.id}>{o.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p style={{ fontSize: 12, opacity: 0.5, margin: '6px 0 0', lineHeight: 1.4 }}>
|
||||
{presets?.static_options.find(o => o.id === staticOption)?.description}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Dynamic options ──────────────────────────────────────────────────── */}
|
||||
{presetType === 'dynamic' && (
|
||||
<div style={card}>
|
||||
<p style={{ fontSize: 13, fontWeight: 600, margin: '0 0 4px' }}>Volume Levels</p>
|
||||
<p style={{ fontSize: 12, opacity: 0.5, margin: '0 0 14px' }}>
|
||||
Adjust the volume of each stem (0 = mute, 1 = original, 2 = double)
|
||||
</p>
|
||||
{Object.entries(dynamicLevels).map(([stem, value]) => (
|
||||
<div key={stem} style={{ marginBottom: 12 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 4 }}>
|
||||
<label style={{ fontSize: 13, textTransform: 'capitalize' }}>{stem}</label>
|
||||
<span style={{ fontSize: 13, opacity: 0.55 }}>{Math.round(value * 100)}%</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min="0"
|
||||
max="2"
|
||||
step="0.1"
|
||||
value={value}
|
||||
onChange={(e) => handleDynamicChange(stem as keyof DynamicLevels, parseFloat(e.target.value))}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Preset output preview ────────────────────────────────────────────── */}
|
||||
{presetType !== 'stems_only' && (
|
||||
<div style={{
|
||||
borderRadius: 6,
|
||||
border: `1px solid rgba(var(--brand-500, 59 130 246), 0.35)`,
|
||||
background: `rgba(var(--brand-500, 59 130 246), 0.06)`,
|
||||
padding: '10px 14px', fontSize: 13,
|
||||
}}>
|
||||
<p style={{ fontWeight: 600, margin: '0 0 6px', color: accentColor }}>Output Structure Preview:</p>
|
||||
<code style={{
|
||||
display: 'block', fontSize: 11, whiteSpace: 'pre',
|
||||
color: accentColor, opacity: 0.85, fontFamily: 'monospace', lineHeight: 1.7,
|
||||
}}>
|
||||
{projectName || 'Project Name'}/{'\n'}
|
||||
{' Stems/ (always created)'}
|
||||
{presetType === 'instrumental' && '\n Instrumental/ (vocals removed)'}
|
||||
{presetType === 'static' && `\n Static/ (${presets?.static_options.find(o => o.id === staticOption)?.label})`}
|
||||
{presetType === 'dynamic' && '\n Dynamic/ (volume adjusted mix)'}
|
||||
</code>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Error message ────────────────────────────────────────────────────── */}
|
||||
{error && (
|
||||
<p style={{ fontSize: 13, color: 'var(--color-red, #ef4444)', margin: 0 }}>{error}</p>
|
||||
)}
|
||||
|
||||
{/* ── Submit button ────────────────────────────────────────────────────── */}
|
||||
<button
|
||||
onClick={submit}
|
||||
disabled={!hasInput || loading}
|
||||
className="button primary"
|
||||
style={{ width: '100%', padding: '10px 16px', fontSize: 14, fontWeight: 600 }}
|
||||
>
|
||||
{loading
|
||||
? 'Submitting…'
|
||||
: presetType === 'stems_only'
|
||||
? 'Separate Stems'
|
||||
: `Separate & Create ${presets?.preset_types.find(p => p.id === presetType)?.label}`}
|
||||
</button>
|
||||
|
||||
{/* ── Auto pipeline button ─────────────────────────────────────────────── */}
|
||||
<button
|
||||
onClick={() => setShowAuto(true)}
|
||||
disabled={!hasInput}
|
||||
style={{
|
||||
width: '100%', padding: '9px 16px', fontSize: 13, fontWeight: 600,
|
||||
borderRadius: 4, cursor: hasInput ? 'pointer' : 'not-allowed',
|
||||
border: '1px solid var(--color-amber, #f59e0b)',
|
||||
background: 'rgba(245, 158, 11, 0.07)',
|
||||
color: 'var(--color-amber, #f59e0b)',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
|
||||
opacity: hasInput ? 1 : 0.4, transition: 'opacity 0.15s',
|
||||
}}
|
||||
>
|
||||
<Zap size={15} />
|
||||
Auto Pipeline
|
||||
</button>
|
||||
|
||||
{/* ── Dialogs / job status / results ───────────────────────────────────── */}
|
||||
{showAuto && (
|
||||
<AutoPipelineDialog
|
||||
target={{
|
||||
file: inputMode === 'upload' ? file ?? undefined : undefined,
|
||||
filePath: inputMode === 'imported' ? importedFile?.path : undefined,
|
||||
filename: inputMode === 'upload'
|
||||
? (file?.name ?? '')
|
||||
: (importedFile?.filename ?? ''),
|
||||
initialModel: model,
|
||||
initialFormat: format,
|
||||
initialProjectName: projectName || undefined,
|
||||
}}
|
||||
onClose={() => setShowAuto(false)}
|
||||
onComplete={(projectId, name) => {
|
||||
setShowAuto(false)
|
||||
onSeparationComplete?.(projectId, `Auto Pipeline`, name)
|
||||
}}
|
||||
onOpenSettings={onOpenSettings}
|
||||
/>
|
||||
)}
|
||||
|
||||
{jobId && <JobStatus jobId={jobId} onDone={setResult} />}
|
||||
|
||||
{result && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
{result.result?.project_name && (
|
||||
<div style={{
|
||||
borderRadius: 6, border: '1px solid rgba(16, 185, 129, 0.4)',
|
||||
background: 'rgba(16, 185, 129, 0.07)', padding: '10px 14px',
|
||||
}}>
|
||||
<p style={{ fontSize: 13, fontWeight: 600, color: 'var(--color-green, #10b981)', margin: '0 0 3px' }}>
|
||||
Project: {result.result.project_name}
|
||||
</p>
|
||||
<p style={{ fontSize: 11, color: 'var(--color-green, #10b981)', opacity: 0.7, margin: 0 }}>
|
||||
Location: {result.result.project_path}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<ResultFiles jobId={result.id} files={result.files} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ── Imported file selector row ───────────────────────────────────────────────
|
||||
|
||||
function ImportedFileButton({
|
||||
file, selected, onSelect,
|
||||
}: {
|
||||
file: ImportedFile
|
||||
selected: boolean
|
||||
onSelect: () => void
|
||||
}) {
|
||||
const [hovered, setHovered] = useState(false)
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={onSelect}
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'flex-start', gap: 10,
|
||||
width: '100%', padding: '8px 12px', textAlign: 'left',
|
||||
border: 'none', borderLeft: `3px solid ${selected ? accentColor : 'transparent'}`,
|
||||
background: selected
|
||||
? `rgba(var(--brand-500, 59 130 246), 0.08)`
|
||||
: hovered ? 'var(--background)' : 'transparent',
|
||||
cursor: 'pointer', transition: 'background 0.12s, border-color 0.12s',
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<p style={{ fontSize: 12, fontWeight: 500, margin: '0 0 2px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{file.filename}
|
||||
</p>
|
||||
<p style={{ fontSize: 10, opacity: 0.45, margin: 0 }}>
|
||||
{(file.size / 1024 / 1024).toFixed(1)} MB
|
||||
</p>
|
||||
</div>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
+570
-628
File diff suppressed because it is too large.
Load diff
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,273 +0,0 @@
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { Music2, Settings, Cpu } from 'lucide-react'
|
||||
import Separator from './pages/Separator'
|
||||
import ProjectDetail from './pages/ProjectDetail'
|
||||
import SettingsPage, { applyFont, applyAccent } from './pages/Settings'
|
||||
import { ThemeProvider } from './context/ThemeContext'
|
||||
import Sidebar from './components/Sidebar'
|
||||
import GlobalAudioBar from './components/GlobalAudioBar'
|
||||
import { listProjects, deleteProject, getGpuInfo, resetGpu } from './api/client'
|
||||
import type { Project } from './types'
|
||||
|
||||
interface ProjectTab {
|
||||
id: string
|
||||
label: string // e.g. "Demucs v4_MP3 (256 kbps)"
|
||||
name: string // e.g. "Artist - Title"
|
||||
}
|
||||
|
||||
interface GpuInfo {
|
||||
cuda_available: boolean
|
||||
cuda_ok: boolean
|
||||
name: string | null
|
||||
free_mb: number
|
||||
total_mb: number
|
||||
}
|
||||
|
||||
function AppShell() {
|
||||
const [activeTabId, setActiveTabId] = useState<string>(
|
||||
() => localStorage.getItem('stemengine-active-tab') ?? 'separate'
|
||||
)
|
||||
const [projectTabs, setProjectTabs] = useState<ProjectTab[]>([])
|
||||
const [sidebarOpen, setSidebarOpen] = useState(() => window.innerWidth >= 640)
|
||||
|
||||
// GPU state
|
||||
const [gpuInfo, setGpuInfo] = useState<GpuInfo | null>(null)
|
||||
const [gpuResetting, setGpuResetting] = useState(false)
|
||||
|
||||
// Persist active tab so it survives a page refresh
|
||||
useEffect(() => {
|
||||
localStorage.setItem('stemengine-active-tab', activeTabId)
|
||||
}, [activeTabId])
|
||||
|
||||
// Apply saved font and accent color on mount
|
||||
useEffect(() => {
|
||||
applyFont(localStorage.getItem('stemengine-font') ?? 'system')
|
||||
applyAccent(localStorage.getItem('stemengine-accent') ?? 'blue')
|
||||
}, [])
|
||||
|
||||
// Load all projects from DB on mount → restore persistent tabs
|
||||
useEffect(() => {
|
||||
listProjects()
|
||||
.then((projects: Project[]) => {
|
||||
const tabs = projects.map((p) => ({
|
||||
id: p.id,
|
||||
label: p.tab_label || p.name,
|
||||
name: p.name,
|
||||
}))
|
||||
setProjectTabs(tabs)
|
||||
// If the restored tab is a project that no longer exists, go home
|
||||
setActiveTabId((current) => {
|
||||
if (current === 'separate' || current === 'settings') return current
|
||||
return tabs.find((t) => t.id === current) ? current : 'separate'
|
||||
})
|
||||
})
|
||||
.catch(() => {/* ignore – server may not be ready yet */})
|
||||
}, [])
|
||||
|
||||
// Poll GPU info on mount + every 30 s
|
||||
useEffect(() => {
|
||||
async function fetchGpu() {
|
||||
try {
|
||||
setGpuInfo(await getGpuInfo())
|
||||
} catch { /* server not ready yet */ }
|
||||
}
|
||||
fetchGpu()
|
||||
const id = setInterval(fetchGpu, 30_000)
|
||||
return () => clearInterval(id)
|
||||
}, [])
|
||||
|
||||
async function handleGpuReset() {
|
||||
setGpuResetting(true)
|
||||
try {
|
||||
await resetGpu()
|
||||
setGpuInfo(await getGpuInfo())
|
||||
} catch { /* ignore */ }
|
||||
setGpuResetting(false)
|
||||
}
|
||||
|
||||
// Auto-reset when the GPU context is marked failed (e.g. after Whisper fallback)
|
||||
const gpuContextFailed = gpuInfo?.cuda_available === true && gpuInfo.cuda_ok === false
|
||||
useEffect(() => {
|
||||
if (gpuContextFailed && !gpuResetting) {
|
||||
handleGpuReset()
|
||||
}
|
||||
}, [gpuContextFailed])
|
||||
|
||||
// Called by Separator when a separation job finishes
|
||||
const handleSeparationComplete = useCallback(
|
||||
(projectId: string, tabLabel: string, projectName: string) => {
|
||||
setProjectTabs((prev) => {
|
||||
if (prev.find((t) => t.id === projectId)) return prev
|
||||
return [...prev, { id: projectId, label: tabLabel, name: projectName }]
|
||||
})
|
||||
setActiveTabId(projectId)
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
// Close (delete) a project tab
|
||||
async function handleCloseTab(projectId: string, projectName: string) {
|
||||
const label = projectTabs.find((t) => t.id === projectId)?.label || projectName
|
||||
if (!window.confirm(`Delete "${label}"?\n\nThis will permanently remove the project and all its files.`)) return
|
||||
|
||||
try {
|
||||
await deleteProject(projectId)
|
||||
} catch {
|
||||
// If delete fails, still remove from tabs (project may already be gone)
|
||||
}
|
||||
setProjectTabs((prev) => prev.filter((t) => t.id !== projectId))
|
||||
if (activeTabId === projectId) setActiveTabId('separate')
|
||||
}
|
||||
|
||||
// Called from sidebar when a project is deleted there
|
||||
function handleDeleteProjectFromSidebar(project: Project) {
|
||||
setProjectTabs((prev) => prev.filter((t) => t.id !== project.id))
|
||||
if (activeTabId === project.id) setActiveTabId('separate')
|
||||
}
|
||||
|
||||
// Open a project tab from sidebar click — adds it if not already open
|
||||
function handleOpenProject(project: Project) {
|
||||
setProjectTabs((prev) => {
|
||||
if (prev.find((t) => t.id === project.id)) return prev
|
||||
return [...prev, {
|
||||
id: project.id,
|
||||
label: project.tab_label || project.name,
|
||||
name: project.name,
|
||||
}]
|
||||
})
|
||||
setActiveTabId(project.id)
|
||||
}
|
||||
|
||||
// Derive GPU button appearance
|
||||
const gpuError = gpuInfo ? (!gpuInfo.cuda_ok || !gpuInfo.cuda_available) : false
|
||||
const gpuTitle = gpuInfo
|
||||
? gpuInfo.cuda_available
|
||||
? `${gpuInfo.name ?? 'GPU'} · ${gpuInfo.free_mb} / ${gpuInfo.total_mb} MB free${!gpuInfo.cuda_ok ? ' · Context error — click to reset' : ''}`
|
||||
: 'CUDA unavailable — click to attempt reset'
|
||||
: 'GPU status unknown'
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col overflow-hidden">
|
||||
{/* ── Header ── */}
|
||||
<header className="shrink-0 border-b border-slate-200 dark:border-gray-800 bg-white dark:bg-gray-950 z-20">
|
||||
<div className="h-1 bg-gradient-to-r from-brand-500 via-purple-500 to-rose-500" />
|
||||
|
||||
<div className="px-4 py-2.5 flex items-center gap-3">
|
||||
<button
|
||||
onClick={() => setActiveTabId('separate')}
|
||||
title="Home"
|
||||
className="flex items-center gap-2 flex-1 min-w-0 hover:opacity-80 transition-opacity text-left"
|
||||
>
|
||||
<div className="w-8 h-8 rounded-lg bg-gradient-to-br from-brand-500 to-brand-700 flex items-center justify-center shrink-0 shadow-md shadow-brand-500/30">
|
||||
<Music2 className="w-4 h-4 text-white" />
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<span className="text-base font-bold text-slate-900 dark:text-white tracking-tight">StemEngine</span>
|
||||
<span className="text-xs text-slate-400 dark:text-gray-600 ml-2 hidden sm:inline">Audio processing toolkit</span>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
{/* GPU status button */}
|
||||
<button
|
||||
onClick={handleGpuReset}
|
||||
title={gpuTitle}
|
||||
className={`relative p-2 rounded-xl border transition-all ${
|
||||
gpuError
|
||||
? 'border-red-400 bg-red-50 dark:bg-red-950/30 text-red-500 dark:text-red-400 hover:border-red-500'
|
||||
: 'border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-900 text-slate-400 dark:text-gray-600 hover:text-brand-600 dark:hover:text-brand-400 hover:border-brand-400'
|
||||
}`}
|
||||
>
|
||||
<Cpu className={`w-4 h-4 ${gpuResetting ? 'animate-pulse' : ''}`} />
|
||||
{/* status dot */}
|
||||
{gpuInfo && (
|
||||
<span className={`absolute top-1 right-1 w-1.5 h-1.5 rounded-full ${
|
||||
!gpuInfo.cuda_available ? 'bg-slate-400 dark:bg-gray-600'
|
||||
: !gpuInfo.cuda_ok ? 'bg-red-500 animate-pulse'
|
||||
: 'bg-emerald-400'
|
||||
}`} />
|
||||
)}
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTabId('settings')}
|
||||
title="Settings"
|
||||
className={`p-2 rounded-xl border transition-all ${
|
||||
activeTabId === 'settings'
|
||||
? 'border-brand-500 bg-brand-50 dark:bg-brand-950/30 text-brand-600 dark:text-brand-400'
|
||||
: 'border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-900 text-slate-500 hover:text-brand-600 dark:text-gray-400 dark:hover:text-brand-400 hover:border-brand-400'
|
||||
}`}
|
||||
>
|
||||
<Settings className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* ── Body: sidebar + main ── */}
|
||||
<div className="flex flex-1 overflow-hidden">
|
||||
|
||||
{/* Backdrop — tapping it closes the sidebar on mobile */}
|
||||
{sidebarOpen && (
|
||||
<div
|
||||
className="sm:hidden fixed inset-0 z-20 bg-black/40"
|
||||
onClick={() => setSidebarOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Sidebar
|
||||
isOpen={sidebarOpen}
|
||||
onToggle={() => setSidebarOpen((v) => !v)}
|
||||
onOpenProject={(p) => { handleOpenProject(p); setSidebarOpen(false) }}
|
||||
onDeleteProject={handleDeleteProjectFromSidebar}
|
||||
openTabIds={projectTabs.map((t) => t.id)}
|
||||
/>
|
||||
|
||||
<div className="flex-1 flex flex-col overflow-hidden bg-slate-100 dark:bg-gray-950">
|
||||
|
||||
{/* Page content */}
|
||||
<main className="flex-1 overflow-y-auto pb-12">
|
||||
{activeTabId === 'settings' ? (
|
||||
<SettingsPage />
|
||||
) : (
|
||||
<div className="max-w-3xl mx-auto px-2 sm:px-4 py-4 sm:py-6">
|
||||
<div className="rounded-2xl border border-slate-200 dark:border-gray-800 bg-white dark:bg-gray-900/60 p-3 sm:p-6 shadow-sm dark:shadow-xl">
|
||||
{activeTabId === 'separate' ? (
|
||||
<Separator
|
||||
onSeparationComplete={handleSeparationComplete}
|
||||
onOpenSettings={() => {
|
||||
localStorage.setItem('stemengine-settings-initial-tab', 'autopipeline')
|
||||
setActiveTabId('settings')
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<ProjectDetail
|
||||
id={activeTabId}
|
||||
onDelete={() => {
|
||||
const tab = projectTabs.find((t) => t.id === activeTabId)
|
||||
if (tab) handleCloseTab(tab.id, tab.name)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<footer className="mt-6 text-center text-xs text-slate-400 dark:text-gray-700">
|
||||
StemEngine · Demucs · BS-RoFormer · Omnizart · wav2vec2
|
||||
</footer>
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Floating playback bar — persists across page navigation */}
|
||||
<GlobalAudioBar />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<AppShell />
|
||||
</ThemeProvider>
|
||||
)
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import React, { useCallback } from 'react'
|
||||
import { Upload } from 'lucide-react'
|
||||
|
||||
interface Props {
|
||||
label?: string
|
||||
accept?: string
|
||||
onFiles: (files: File[]) => void
|
||||
}
|
||||
|
||||
export default function FileUpload({ label = 'Drop files here', accept, onFiles }: Props) {
|
||||
const handleDrop = useCallback(
|
||||
(e: React.DragEvent) => {
|
||||
e.preventDefault()
|
||||
const files = Array.from(e.dataTransfer.files)
|
||||
if (files.length) onFiles(files)
|
||||
},
|
||||
[onFiles]
|
||||
)
|
||||
|
||||
const handleChange = useCallback(
|
||||
(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const files = Array.from(e.target.files || [])
|
||||
if (files.length) onFiles(files)
|
||||
e.target.value = '' // reset for re-upload
|
||||
},
|
||||
[onFiles]
|
||||
)
|
||||
|
||||
return (
|
||||
<label
|
||||
onDragOver={(e) => e.preventDefault()}
|
||||
onDrop={handleDrop}
|
||||
className="flex flex-col items-center justify-center gap-3 px-6 py-10 rounded-xl border-2 border-dashed border-slate-300 dark:border-gray-700 bg-slate-50 dark:bg-gray-900/50 hover:border-brand-400 dark:hover:border-brand-500 hover:bg-slate-100 dark:hover:bg-gray-800/50 transition-colors cursor-pointer"
|
||||
>
|
||||
<Upload className="w-8 h-8 text-slate-400 dark:text-gray-600" />
|
||||
<span className="text-sm text-slate-600 dark:text-gray-400 text-center">{label}</span>
|
||||
<input type="file" accept={accept} onChange={handleChange} className="hidden" />
|
||||
</label>
|
||||
)
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Loader2, CheckCircle, XCircle, AlertCircle } from 'lucide-react'
|
||||
import { getJob } from '../api/client'
|
||||
import type { Job } from '../types'
|
||||
|
||||
interface Props {
|
||||
jobId: string
|
||||
onDone?: (job: Job) => void
|
||||
}
|
||||
|
||||
export default function JobStatus({ jobId, onDone }: Props) {
|
||||
const [job, setJob] = useState<Job | null>(null)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
let timeout: ReturnType<typeof setTimeout>
|
||||
|
||||
async function poll() {
|
||||
try {
|
||||
const j = await getJob(jobId)
|
||||
if (cancelled) return
|
||||
setJob(j)
|
||||
setError(null)
|
||||
|
||||
if (j.status === 'done' || j.status === 'error' || j.status === 'cancelled') {
|
||||
if (j.status === 'done') onDone?.(j)
|
||||
return
|
||||
}
|
||||
|
||||
timeout = setTimeout(poll, 2000)
|
||||
} catch (e) {
|
||||
if (cancelled) return
|
||||
setError(String(e))
|
||||
timeout = setTimeout(poll, 5000)
|
||||
}
|
||||
}
|
||||
|
||||
poll()
|
||||
return () => {
|
||||
cancelled = true
|
||||
clearTimeout(timeout)
|
||||
}
|
||||
}, [jobId, onDone])
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 text-xs text-red-500">
|
||||
<XCircle className="w-4 h-4" />
|
||||
Error: {error}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!job) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 text-xs text-slate-500">
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
Loading…
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const statusConfig: Record<string, { icon: React.ReactNode; text: string; color: string }> = {
|
||||
queued: { icon: <Loader2 className="w-4 h-4 animate-spin text-amber-500" />, text: 'Queued…', color: 'text-amber-600' },
|
||||
running: { icon: <Loader2 className="w-4 h-4 animate-spin text-brand-500" />, text: job.progress || 'Running…', color: 'text-brand-600' },
|
||||
done: { icon: <CheckCircle className="w-4 h-4 text-emerald-500" />, text: 'Complete', color: 'text-emerald-600' },
|
||||
error: { icon: <XCircle className="w-4 h-4 text-red-500" />, text: `Error: ${job.error || 'Failed'}`, color: 'text-red-600' },
|
||||
cancelled: { icon: <AlertCircle className="w-4 h-4 text-slate-400" />, text: 'Cancelled', color: 'text-slate-500' },
|
||||
}
|
||||
|
||||
const config = statusConfig[job.status]
|
||||
|
||||
return (
|
||||
<div className={`flex items-center gap-2 text-xs ${config.color}`}>
|
||||
{config.icon}
|
||||
<span className="truncate">{config.text}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
|
||||
import { X, Sun, Moon, Monitor, Settings, ChevronRight } from 'lucide-react'
|
||||
import { useTheme } from '../context/ThemeContext'
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean
|
||||
onClose: () => void
|
||||
onOpenFullSettings?: () => void
|
||||
}
|
||||
|
||||
export default function SettingsPanel({ isOpen, onClose, onOpenFullSettings }: Props) {
|
||||
const { theme, setTheme } = useTheme()
|
||||
|
||||
const handleOpenFullSettings = () => {
|
||||
onClose()
|
||||
onOpenFullSettings?.()
|
||||
}
|
||||
|
||||
if (!isOpen) return null
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-start justify-center pt-16">
|
||||
<div className="absolute inset-0 bg-black/50" onClick={onClose} />
|
||||
<div className="relative w-full max-w-md mx-4 rounded-xl bg-white dark:bg-gray-900 shadow-2xl border border-slate-200 dark:border-gray-800">
|
||||
<div className="flex items-center justify-between px-4 py-3 border-b border-slate-200 dark:border-gray-800">
|
||||
<h2 className="text-sm font-semibold text-slate-900 dark:text-white">Settings</h2>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="p-1 rounded text-slate-400 hover:text-slate-600 dark:text-gray-500 dark:hover:text-gray-300"
|
||||
>
|
||||
<X className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="p-4 space-y-4">
|
||||
{/* Theme */}
|
||||
<div>
|
||||
<label className="text-xs font-medium text-slate-500 dark:text-gray-400 uppercase tracking-wider block mb-2">
|
||||
Theme
|
||||
</label>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
onClick={() => setTheme('light')}
|
||||
className={`flex items-center gap-2 px-3 py-2 rounded-lg border text-xs font-medium transition-colors ${
|
||||
theme === 'light'
|
||||
? 'bg-brand-50 dark:bg-brand-950/30 border-brand-400 text-brand-600 dark:text-brand-400'
|
||||
: 'bg-white dark:bg-gray-800 border-slate-200 dark:border-gray-700 text-slate-600 dark:text-gray-400 hover:border-brand-400'
|
||||
}`}
|
||||
>
|
||||
<Sun className="w-3.5 h-3.5" />
|
||||
Light
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setTheme('dark')}
|
||||
className={`flex items-center gap-2 px-3 py-2 rounded-lg border text-xs font-medium transition-colors ${
|
||||
theme === 'dark'
|
||||
? 'bg-brand-50 dark:bg-brand-950/30 border-brand-400 text-brand-600 dark:text-brand-400'
|
||||
: 'bg-white dark:bg-gray-800 border-slate-200 dark:border-gray-700 text-slate-600 dark:text-gray-400 hover:border-brand-400'
|
||||
}`}
|
||||
>
|
||||
<Moon className="w-3.5 h-3.5" />
|
||||
Dark
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setTheme('system')}
|
||||
className={`flex items-center gap-2 px-3 py-2 rounded-lg border text-xs font-medium transition-colors ${
|
||||
theme === 'system'
|
||||
? 'bg-brand-50 dark:bg-brand-950/30 border-brand-400 text-brand-600 dark:text-brand-400'
|
||||
: 'bg-white dark:bg-gray-800 border-slate-200 dark:border-gray-700 text-slate-600 dark:text-gray-400 hover:border-brand-400'
|
||||
}`}
|
||||
>
|
||||
<Monitor className="w-3.5 h-3.5" />
|
||||
System
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Divider */}
|
||||
<div className="border-t border-slate-200 dark:border-gray-800 pt-4">
|
||||
<button
|
||||
onClick={handleOpenFullSettings}
|
||||
className="w-full flex items-center justify-between p-3 rounded-lg bg-slate-50 dark:bg-gray-800 hover:bg-slate-100 dark:hover:bg-gray-750 transition-colors group"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<Settings className="w-4 h-4 text-slate-500 dark:text-gray-400" />
|
||||
<span className="text-sm font-medium text-slate-700 dark:text-gray-300">
|
||||
Full Settings
|
||||
</span>
|
||||
</div>
|
||||
<ChevronRight className="w-4 h-4 text-slate-400 group-hover:text-slate-600 dark:group-hover:text-gray-300 transition-colors" />
|
||||
</button>
|
||||
<p className="mt-1.5 text-xs text-slate-400 dark:text-gray-500 px-1">
|
||||
Configure Subsonic integration, manage AI models, and more.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,528 +0,0 @@
|
||||
import React, { useState, useRef, useMemo } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
ChevronLeft, ChevronRight, Loader2, CheckCircle, XCircle,
|
||||
Clock, AlertCircle, X, Music2, Mic2, FileCode, Workflow,
|
||||
FolderOpen, Type, ChevronDown, ChevronUp, Radio, Search,
|
||||
Download, CheckCircle2, Trash2, Zap,
|
||||
} from 'lucide-react'
|
||||
import {
|
||||
listJobs, cancelJob,
|
||||
searchSubsonic, importSubsonicSong,
|
||||
listImports, deleteImport,
|
||||
listProjects, deleteProject,
|
||||
} from '../api/client'
|
||||
import type { Job, Project, SubsonicSong, ImportedFile } from '../types'
|
||||
import AutoPipelineDialog from './AutoPipelineDialog'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const JOB_COLORS: Record<string, string> = {
|
||||
separate: 'text-brand-500',
|
||||
transcribe: 'text-purple-500',
|
||||
'abc-convert': 'text-emerald-500',
|
||||
pipeline: 'text-rose-500',
|
||||
lrc_align: 'text-amber-500',
|
||||
mix: 'text-brand-500',
|
||||
}
|
||||
|
||||
const JOB_ICONS: Record<string, React.ElementType> = {
|
||||
separate: Music2,
|
||||
transcribe: Mic2,
|
||||
'abc-convert': FileCode,
|
||||
pipeline: Workflow,
|
||||
lrc_align: Type,
|
||||
mix: Music2,
|
||||
}
|
||||
|
||||
function StatusDot({ status }: { status: Job['status'] }) {
|
||||
switch (status) {
|
||||
case 'running': return <Loader2 className="w-3 h-3 text-brand-400 animate-spin shrink-0" />
|
||||
case 'queued': return <Clock className="w-3 h-3 text-amber-400 shrink-0" />
|
||||
case 'done': return <CheckCircle className="w-3 h-3 text-emerald-400 shrink-0" />
|
||||
case 'error': return <XCircle className="w-3 h-3 text-red-400 shrink-0" />
|
||||
case 'cancelled': return <AlertCircle className="w-3 h-3 text-gray-400 shrink-0" />
|
||||
}
|
||||
}
|
||||
|
||||
function timeSince(iso: string | null): string {
|
||||
if (!iso) return ''
|
||||
const ms = Date.now() - new Date(iso).getTime()
|
||||
const m = Math.floor(ms / 60000)
|
||||
if (m < 1) return 'just now'
|
||||
if (m < 60) return `${m}m ago`
|
||||
const h = Math.floor(m / 60)
|
||||
if (h < 24) return `${h}h ago`
|
||||
return `${Math.floor(h / 24)}d ago`
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Active job item (with cancel)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function ActiveJobItem({ job, onCancelled }: { job: Job; onCancelled: () => void }) {
|
||||
const [cancelling, setCancelling] = useState(false)
|
||||
const Icon = JOB_ICONS[job.job_type] ?? FolderOpen
|
||||
const colorCls = JOB_COLORS[job.job_type] ?? 'text-gray-400'
|
||||
|
||||
async function handleCancel(e: React.MouseEvent) {
|
||||
e.stopPropagation()
|
||||
setCancelling(true)
|
||||
try { await cancelJob(job.id) } catch { /* ignore */ }
|
||||
onCancelled()
|
||||
setCancelling(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2 px-3 py-2 rounded-lg bg-slate-50 dark:bg-gray-800/60 border border-slate-200 dark:border-gray-700/50">
|
||||
<Icon className={`w-3.5 h-3.5 shrink-0 ${colorCls}`} />
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-slate-700 dark:text-gray-200 truncate">
|
||||
{job.job_type.replace('-', ' ').replace('_', ' ')}
|
||||
</p>
|
||||
{job.progress && (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-500 truncate leading-tight">{job.progress}</p>
|
||||
)}
|
||||
</div>
|
||||
<StatusDot status={job.status} />
|
||||
<button
|
||||
onClick={handleCancel}
|
||||
disabled={cancelling}
|
||||
title="Cancel"
|
||||
className="p-1 rounded text-slate-300 hover:text-red-400 dark:text-gray-600 dark:hover:text-red-400 transition-colors shrink-0"
|
||||
>
|
||||
{cancelling ? <Loader2 className="w-3 h-3 animate-spin" /> : <X className="w-3 h-3" />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Project item
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function ProjectItem({
|
||||
project,
|
||||
isOpen,
|
||||
onOpen,
|
||||
onDeleted,
|
||||
}: {
|
||||
project: Project
|
||||
isOpen: boolean
|
||||
onOpen: () => void
|
||||
onDeleted: () => void
|
||||
}) {
|
||||
const [deleting, setDeleting] = useState(false)
|
||||
|
||||
async function handleDelete(e: React.MouseEvent) {
|
||||
e.stopPropagation()
|
||||
if (!window.confirm(`Delete "${project.name}"?\n\nThis will permanently remove the project and all its files.`)) return
|
||||
setDeleting(true)
|
||||
try { await deleteProject(project.id) } catch { /* ignore */ }
|
||||
finally { setDeleting(false) }
|
||||
onDeleted()
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={onOpen}
|
||||
className={`group w-full flex items-center gap-2 px-3 py-2 rounded-lg border text-left transition-colors cursor-pointer ${
|
||||
isOpen
|
||||
? 'border-brand-400/50 bg-brand-50 dark:bg-brand-950/20 text-brand-700 dark:text-brand-300'
|
||||
: 'border-slate-200 dark:border-gray-700/60 hover:bg-slate-50 dark:hover:bg-gray-800/50 hover:border-brand-400/50'
|
||||
}`}
|
||||
>
|
||||
<Music2 className="w-3.5 h-3.5 shrink-0 text-brand-500" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-slate-700 dark:text-gray-200 truncate">{project.name}</p>
|
||||
{project.tab_label && (
|
||||
<p className="text-[10px] text-brand-500 dark:text-brand-400 truncate leading-tight">{project.tab_label}</p>
|
||||
)}
|
||||
<p className="text-[10px] text-slate-400 dark:text-gray-500">{timeSince(project.created_at)}</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
disabled={deleting}
|
||||
title="Delete project"
|
||||
className="shrink-0 p-1 rounded text-slate-300 dark:text-gray-600 hover:text-red-500 dark:hover:text-red-400 transition-colors opacity-0 group-hover:opacity-100"
|
||||
>
|
||||
{deleting ? <Loader2 className="w-3 h-3 animate-spin" /> : <Trash2 className="w-3 h-3" />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Subsonic import panel
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function formatDuration(secs: number): string {
|
||||
const m = Math.floor(secs / 60)
|
||||
const s = secs % 60
|
||||
return `${m}:${String(s).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
function SubsonicPanel() {
|
||||
const queryClient = useQueryClient()
|
||||
const [open, setOpen] = useState(false)
|
||||
const [query, setQuery] = useState('')
|
||||
const [results, setResults] = useState<SubsonicSong[]>([])
|
||||
const [searching, setSearching] = useState(false)
|
||||
const [searchErr, setSearchErr] = useState<string | null>(null)
|
||||
const [importing, setImporting] = useState<string | null>(null)
|
||||
const [importedIds, setImportedIds] = useState<Set<string>>(new Set())
|
||||
const [importErr, setImportErr] = useState<string | null>(null)
|
||||
const [deletingFile, setDeletingFile] = useState<string | null>(null)
|
||||
const [autoTarget, setAutoTarget] = useState<ImportedFile | null>(null)
|
||||
const inputRef = useRef<HTMLInputElement>(null)
|
||||
|
||||
const { data: importedFiles = [], refetch: refetchImports } = useQuery<ImportedFile[]>({
|
||||
queryKey: ['imports'],
|
||||
queryFn: listImports,
|
||||
enabled: open,
|
||||
refetchInterval: open ? 10000 : false,
|
||||
})
|
||||
|
||||
async function doSearch() {
|
||||
if (!query.trim()) return
|
||||
setSearching(true); setSearchErr(null); setResults([])
|
||||
try {
|
||||
const res = await searchSubsonic(query.trim())
|
||||
setResults(res)
|
||||
if (res.length === 0) setSearchErr('No results found.')
|
||||
} catch (e) {
|
||||
setSearchErr(String(e))
|
||||
} finally {
|
||||
setSearching(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function doImport(song: SubsonicSong) {
|
||||
setImporting(song.id); setImportErr(null)
|
||||
try {
|
||||
await importSubsonicSong(song)
|
||||
setImportedIds((prev) => new Set(prev).add(song.id))
|
||||
refetchImports()
|
||||
queryClient.invalidateQueries({ queryKey: ['imports'] })
|
||||
} catch (e) {
|
||||
setImportErr(String(e))
|
||||
} finally {
|
||||
setImporting(null)
|
||||
}
|
||||
}
|
||||
|
||||
async function doDeleteImport(filename: string) {
|
||||
setDeletingFile(filename)
|
||||
try {
|
||||
await deleteImport(filename)
|
||||
refetchImports()
|
||||
queryClient.invalidateQueries({ queryKey: ['imports'] })
|
||||
} catch { /* ignore */ }
|
||||
finally { setDeletingFile(null) }
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="border-b border-slate-200 dark:border-gray-800">
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
className="w-full flex items-center gap-2 px-3 py-2.5 text-left hover:bg-slate-100 dark:hover:bg-gray-900/50 transition-colors"
|
||||
>
|
||||
<Radio className="w-3.5 h-3.5 text-sky-500 shrink-0" />
|
||||
<span className="text-xs font-bold uppercase tracking-widest text-sky-500 flex-1">Subsonic Import</span>
|
||||
{open
|
||||
? <ChevronUp className="w-3 h-3 text-slate-400 shrink-0" />
|
||||
: <ChevronDown className="w-3 h-3 text-slate-400 shrink-0" />}
|
||||
</button>
|
||||
|
||||
{open && (
|
||||
<div className="px-3 pb-3 space-y-2">
|
||||
{/* Search input */}
|
||||
<div className="flex gap-1.5">
|
||||
<input
|
||||
ref={inputRef}
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && doSearch()}
|
||||
placeholder="Search songs…"
|
||||
className="flex-1 rounded-md bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 placeholder-slate-400 focus:border-sky-400 focus:outline-none"
|
||||
/>
|
||||
<button
|
||||
onClick={doSearch}
|
||||
disabled={searching || !query.trim()}
|
||||
className="rounded-md bg-sky-500 hover:bg-sky-400 disabled:bg-slate-200 dark:disabled:bg-gray-800 disabled:text-slate-400 px-2.5 py-1.5 text-xs font-medium text-white transition-colors shrink-0"
|
||||
>
|
||||
{searching ? <Loader2 className="w-3 h-3 animate-spin" /> : <Search className="w-3 h-3" />}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Errors */}
|
||||
{searchErr && <p className="text-xs text-red-500 dark:text-red-400">{searchErr}</p>}
|
||||
{importErr && <p className="text-xs text-red-500 dark:text-red-400 break-all">{importErr}</p>}
|
||||
|
||||
{/* Search results */}
|
||||
{results.length > 0 && (
|
||||
<div className="space-y-1 max-h-52 overflow-y-auto pr-0.5">
|
||||
{results.map((song) => {
|
||||
const done = importedIds.has(song.id)
|
||||
const busy = importing === song.id
|
||||
return (
|
||||
<div
|
||||
key={song.id}
|
||||
className="flex items-start gap-2 rounded-lg border border-slate-200 dark:border-gray-700/60 bg-white dark:bg-gray-900/50 px-2.5 py-2"
|
||||
>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-slate-700 dark:text-gray-200 truncate leading-tight">
|
||||
{song.title}
|
||||
</p>
|
||||
{song.artist && (
|
||||
<p className="text-[10px] text-slate-400 dark:text-gray-500 truncate leading-tight">
|
||||
{song.artist}{song.album ? ` · ${song.album}` : ''}
|
||||
</p>
|
||||
)}
|
||||
<p className="text-[10px] text-slate-400 dark:text-gray-600 mt-0.5">
|
||||
{song.duration ? formatDuration(song.duration) : ''}{song.bitRate ? ` · ${song.bitRate} kbps` : ''}{song.suffix ? ` · ${song.suffix.toUpperCase()}` : ''}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => doImport(song)}
|
||||
disabled={busy || done}
|
||||
title={done ? 'Imported' : 'Import'}
|
||||
className="shrink-0 p-1.5 rounded-md border border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-800 hover:border-sky-400 hover:text-sky-500 disabled:opacity-60 transition-colors"
|
||||
>
|
||||
{busy
|
||||
? <Loader2 className="w-3 h-3 animate-spin text-sky-400" />
|
||||
: done
|
||||
? <CheckCircle2 className="w-3 h-3 text-emerald-500" />
|
||||
: <Download className="w-3 h-3 text-slate-500 dark:text-gray-400" />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Imported files list */}
|
||||
{importedFiles.length > 0 && (
|
||||
<div>
|
||||
<p className="text-[10px] font-bold uppercase tracking-widest text-slate-400 dark:text-gray-600 mb-1">Imported Files</p>
|
||||
<div className="space-y-1 max-h-40 overflow-y-auto">
|
||||
{importedFiles.map((f) => {
|
||||
const isDeleting = deletingFile === f.filename
|
||||
return (
|
||||
<div
|
||||
key={f.path}
|
||||
className="group flex items-center gap-2 rounded-lg border border-slate-200 dark:border-gray-700/60 bg-white dark:bg-gray-900/50 px-2.5 py-1.5"
|
||||
>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-slate-700 dark:text-gray-200 truncate">{f.filename}</p>
|
||||
<p className="text-[10px] text-slate-400 dark:text-gray-500">{(f.size / 1024 / 1024).toFixed(1)} MB</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setAutoTarget(f)}
|
||||
title="Auto pipeline"
|
||||
className="shrink-0 p-1 rounded text-slate-300 dark:text-gray-600 hover:text-amber-500 dark:hover:text-amber-400 transition-colors opacity-0 group-hover:opacity-100"
|
||||
>
|
||||
<Zap className="w-3 h-3" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => doDeleteImport(f.filename)}
|
||||
disabled={isDeleting}
|
||||
title="Delete import"
|
||||
className="shrink-0 p-1 rounded text-slate-300 dark:text-gray-600 hover:text-red-500 dark:hover:text-red-400 transition-colors opacity-0 group-hover:opacity-100"
|
||||
>
|
||||
{isDeleting
|
||||
? <Loader2 className="w-3 h-3 animate-spin" />
|
||||
: <Trash2 className="w-3 h-3" />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
{autoTarget && (
|
||||
<AutoPipelineDialog
|
||||
target={{
|
||||
filePath: autoTarget.path,
|
||||
filename: autoTarget.filename,
|
||||
initialProjectName: autoTarget.artist && autoTarget.title
|
||||
? `${autoTarget.artist} - ${autoTarget.title}`
|
||||
: autoTarget.filename.replace(/\.[^/.]+$/, ''),
|
||||
}}
|
||||
onClose={() => setAutoTarget(null)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Sidebar
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean
|
||||
onToggle: () => void
|
||||
onOpenProject: (project: Project) => void
|
||||
onDeleteProject: (project: Project) => void
|
||||
openTabIds: string[] // IDs of project tabs currently open in the tab bar
|
||||
}
|
||||
|
||||
export default function Sidebar({ isOpen, onToggle, onOpenProject, onDeleteProject, openTabIds }: Props) {
|
||||
const queryClient = useQueryClient()
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
|
||||
const { data: jobs = [] } = useQuery({
|
||||
queryKey: ['jobs'],
|
||||
queryFn: listJobs,
|
||||
refetchInterval: 3000,
|
||||
})
|
||||
|
||||
const { data: projects = [] } = useQuery<Project[]>({
|
||||
queryKey: ['projects'],
|
||||
queryFn: listProjects,
|
||||
refetchInterval: 8000,
|
||||
})
|
||||
|
||||
// Filter projects based on search query
|
||||
const filteredProjects = useMemo(() => {
|
||||
if (!searchQuery.trim()) return projects
|
||||
const query = searchQuery.toLowerCase()
|
||||
return projects.filter(p =>
|
||||
p.name.toLowerCase().includes(query) ||
|
||||
p.tab_label.toLowerCase().includes(query)
|
||||
)
|
||||
}, [projects, searchQuery])
|
||||
|
||||
const activeJobs = jobs.filter((j) => j.status === 'running' || j.status === 'queued')
|
||||
|
||||
function invalidate() { queryClient.invalidateQueries({ queryKey: ['jobs'] }) }
|
||||
|
||||
return (
|
||||
<aside
|
||||
className={`relative flex-shrink-0 flex flex-col border-r border-slate-200 dark:border-gray-800 bg-slate-50 dark:bg-gray-950 transition-all duration-200 ease-in-out ${
|
||||
isOpen ? 'sidebar-open' : 'sidebar-closed'
|
||||
}`}
|
||||
>
|
||||
{/* Toggle tab — always visible */}
|
||||
<button
|
||||
onClick={onToggle}
|
||||
title={isOpen ? 'Collapse sidebar' : 'Expand sidebar'}
|
||||
className={`absolute -right-3.5 top-6 z-10 flex items-center justify-center w-7 h-7 rounded-full bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 shadow-sm text-slate-400 hover:text-brand-500 dark:text-gray-500 dark:hover:text-brand-400 transition-colors`}
|
||||
>
|
||||
{isOpen ? <ChevronLeft className="w-4 h-4" /> : <ChevronRight className="w-4 h-4" />}
|
||||
</button>
|
||||
|
||||
{/* Collapsed indicator strip */}
|
||||
{!isOpen && (
|
||||
<div className="flex flex-col items-center gap-3 pt-16 px-2">
|
||||
{activeJobs.length > 0 && (
|
||||
<div className="relative">
|
||||
<Loader2 className="w-5 h-5 text-brand-400 animate-spin" />
|
||||
<span className="absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full bg-brand-500 text-white text-[9px] flex items-center justify-center font-bold">
|
||||
{activeJobs.length}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<Radio className="w-5 h-5 text-slate-400 dark:text-gray-600" />
|
||||
{projects.length > 0 && (
|
||||
<div className="relative">
|
||||
<FolderOpen className="w-5 h-5 text-slate-400 dark:text-gray-600" />
|
||||
<span className="absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full bg-slate-400 dark:bg-gray-600 text-white text-[9px] flex items-center justify-center font-bold">
|
||||
{projects.length}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Expanded content */}
|
||||
{isOpen && (
|
||||
<div className="flex flex-col flex-1 overflow-hidden">
|
||||
{/* Active jobs */}
|
||||
<div className="p-3 border-b border-slate-200 dark:border-gray-800">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<span className="text-xs font-bold uppercase tracking-widest text-amber-500">
|
||||
In Progress
|
||||
</span>
|
||||
{activeJobs.length > 0 && (
|
||||
<span className="ml-auto text-xs bg-amber-500 text-white px-1.5 py-0.5 rounded-full font-bold">
|
||||
{activeJobs.length}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{activeJobs.length === 0 ? (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic text-center py-2">No active jobs</p>
|
||||
) : (
|
||||
<div className="space-y-1.5">
|
||||
{activeJobs.map((job) => (
|
||||
<ActiveJobItem key={job.id} job={job} onCancelled={invalidate} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Subsonic import */}
|
||||
<SubsonicPanel />
|
||||
|
||||
{/* Projects */}
|
||||
<div className="flex-1 overflow-y-auto p-3 space-y-1.5">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<span className="text-xs font-bold uppercase tracking-widest text-brand-500">Projects</span>
|
||||
{projects.length > 0 && (
|
||||
<span className="ml-auto text-xs text-slate-400 dark:text-gray-600">
|
||||
{filteredProjects.length}/{projects.length}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Search box for projects */}
|
||||
<div className="relative mb-2">
|
||||
<Search className="absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-slate-400" />
|
||||
<input
|
||||
type="text"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
placeholder="Search projects..."
|
||||
className="w-full rounded-md bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 pl-7 pr-2 py-1.5 text-xs text-slate-900 dark:text-gray-100 placeholder-slate-400 focus:border-brand-400 focus:outline-none"
|
||||
/>
|
||||
{searchQuery && (
|
||||
<button
|
||||
onClick={() => setSearchQuery('')}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600"
|
||||
>
|
||||
<X className="w-3 h-3" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{filteredProjects.length === 0 ? (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic text-center py-4">
|
||||
{searchQuery ? 'No projects match your search.' : 'Completed separations appear here.'}
|
||||
</p>
|
||||
) : (
|
||||
filteredProjects.map((project) => (
|
||||
<ProjectItem
|
||||
key={project.id}
|
||||
project={project}
|
||||
isOpen={openTabIds.includes(project.id)}
|
||||
onOpen={() => onOpenProject(project)}
|
||||
onDeleted={() => {
|
||||
queryClient.invalidateQueries({ queryKey: ['projects'] })
|
||||
onDeleteProject(project)
|
||||
}}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
import React, { createContext, useContext, useEffect, useState } from 'react'
|
||||
|
||||
type Theme = 'light' | 'dark' | 'system'
|
||||
|
||||
interface ThemeContextType {
|
||||
theme: Theme
|
||||
resolved: 'light' | 'dark'
|
||||
setTheme: (t: Theme) => void
|
||||
}
|
||||
|
||||
const ThemeContext = createContext<ThemeContextType | undefined>(undefined)
|
||||
|
||||
export function ThemeProvider({ children }: { children: React.ReactNode }) {
|
||||
const [theme, setThemeState] = useState<Theme>(() => {
|
||||
if (typeof window === 'undefined') return 'system'
|
||||
return (localStorage.getItem('theme') as Theme) || 'system'
|
||||
})
|
||||
|
||||
const [resolved, setResolved] = useState<'light' | 'dark'>('dark')
|
||||
|
||||
useEffect(() => {
|
||||
const root = document.documentElement
|
||||
const media = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
|
||||
function apply() {
|
||||
let r: 'light' | 'dark'
|
||||
if (theme === 'system') {
|
||||
r = media.matches ? 'dark' : 'light'
|
||||
} else {
|
||||
r = theme
|
||||
}
|
||||
setResolved(r)
|
||||
if (r === 'dark') {
|
||||
root.classList.add('dark')
|
||||
} else {
|
||||
root.classList.remove('dark')
|
||||
}
|
||||
}
|
||||
|
||||
apply()
|
||||
localStorage.setItem('theme', theme)
|
||||
|
||||
const listener = () => apply()
|
||||
media.addEventListener('change', listener)
|
||||
return () => media.removeEventListener('change', listener)
|
||||
}, [theme])
|
||||
|
||||
function setTheme(t: Theme) {
|
||||
setThemeState(t)
|
||||
}
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={{ theme, resolved, setTheme }}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useTheme() {
|
||||
const ctx = useContext(ThemeContext)
|
||||
if (!ctx) throw new Error('useTheme must be used within ThemeProvider')
|
||||
return ctx
|
||||
}
|
||||
@@ -1,501 +0,0 @@
|
||||
import { useState, useEffect, useRef } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { RefreshCw, Radio, Zap } from 'lucide-react'
|
||||
import FileUpload from '../components/FileUpload'
|
||||
import JobStatus from '../components/JobStatus'
|
||||
import ResultFiles from '../components/ResultFiles'
|
||||
import AutoPipelineDialog from '../components/AutoPipelineDialog'
|
||||
import {
|
||||
getSepModels, getSepFormats, getPresets, submitSeparate, extractLyrics,
|
||||
listImports, submitSeparateFromPath,
|
||||
} from '../api/client'
|
||||
import type { Job, ModelOption, PresetsResponse, DynamicLevels, ImportedFile } from '../types'
|
||||
|
||||
const SELECT_CLS = 'w-full rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-3 py-2 text-sm text-slate-900 dark:text-gray-100 focus:border-brand-500 focus:outline-none'
|
||||
const INPUT_CLS = 'w-full rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-3 py-2 text-sm text-slate-900 dark:text-gray-100 focus:border-brand-500 focus:outline-none'
|
||||
const SLIDER_CLS = 'w-full h-2 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-600'
|
||||
|
||||
function groupModels(models: ModelOption[]) {
|
||||
const groups: Record<string, ModelOption[]> = {}
|
||||
for (const m of models) {
|
||||
const g = m.group ?? 'Other'
|
||||
if (!groups[g]) groups[g] = []
|
||||
groups[g].push(m)
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
const DEFAULT_DYNAMIC_LEVELS: DynamicLevels = {
|
||||
vocals: 1.0,
|
||||
drums: 1.0,
|
||||
bass: 1.0,
|
||||
other: 1.0,
|
||||
}
|
||||
|
||||
interface Props {
|
||||
onSeparationComplete?: (projectId: string, tabLabel: string, projectName: string) => void
|
||||
onOpenSettings?: () => void
|
||||
}
|
||||
|
||||
export default function Separator({ onSeparationComplete, onOpenSettings }: Props) {
|
||||
const [inputMode, setInputMode] = useState<'upload' | 'imported'>('upload')
|
||||
const [file, setFile] = useState<File | null>(null)
|
||||
const [importedFile, setImportedFile] = useState<ImportedFile | null>(null)
|
||||
const [model, setModel] = useState('htdemucs')
|
||||
const [format, setFormat] = useState('mp3')
|
||||
const [presetType, setPresetType] = useState('stems_only')
|
||||
const [staticOption, setStaticOption] = useState('no_vocals')
|
||||
const [dynamicLevels, setDynamicLevels] = useState<DynamicLevels>(DEFAULT_DYNAMIC_LEVELS)
|
||||
const [projectName, setProjectName] = useState('')
|
||||
const [metadata, setMetadata] = useState<{artist?: string; title?: string}>({})
|
||||
const [jobId, setJobId] = useState<string | null>(null)
|
||||
const [result, setResult] = useState<Job | null>(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [showAuto, setShowAuto] = useState(false)
|
||||
|
||||
const { data: models = [] } = useQuery({ queryKey: ['sep-models'], queryFn: getSepModels })
|
||||
const { data: formats = [] } = useQuery({ queryKey: ['sep-formats'], queryFn: getSepFormats })
|
||||
const { data: presets } = useQuery<PresetsResponse>({ queryKey: ['sep-presets'], queryFn: getPresets })
|
||||
const { data: imports = [], refetch: refetchImports } = useQuery<ImportedFile[]>({
|
||||
queryKey: ['imports'],
|
||||
queryFn: listImports,
|
||||
enabled: inputMode === 'imported',
|
||||
refetchInterval: inputMode === 'imported' ? 5000 : false,
|
||||
})
|
||||
|
||||
const grouped = groupModels(models)
|
||||
|
||||
// Read layout preferences saved in Settings → Model Settings
|
||||
const hiddenGroups = new Set<string>((() => {
|
||||
try { return JSON.parse(localStorage.getItem('se-model-hidden-groups') || '[]') as string[] }
|
||||
catch { return [] }
|
||||
})())
|
||||
const hiddenModels = new Set<string>((() => {
|
||||
try { return JSON.parse(localStorage.getItem('se-model-hidden-models') || '[]') as string[] }
|
||||
catch { return [] }
|
||||
})())
|
||||
const groupOrder: string[] = (() => {
|
||||
try { return JSON.parse(localStorage.getItem('se-model-group-order') || 'null') || [] }
|
||||
catch { return [] }
|
||||
})()
|
||||
const modelOrder: Record<string, string[]> = (() => {
|
||||
try { return JSON.parse(localStorage.getItem('se-model-model-order') || 'null') || {} }
|
||||
catch { return {} }
|
||||
})()
|
||||
|
||||
// Build visible + ordered groups (mirrors Settings ModelDownloader logic)
|
||||
const allGroupNames = Object.keys(grouped)
|
||||
const orderedGroupNames = [
|
||||
...groupOrder.filter(g => allGroupNames.includes(g)),
|
||||
...allGroupNames.filter(g => !groupOrder.includes(g)),
|
||||
]
|
||||
const visibleGrouped: Record<string, ModelOption[]> = {}
|
||||
for (const group of orderedGroupNames) {
|
||||
if (hiddenGroups.has(group)) continue
|
||||
const rawModels = grouped[group] || []
|
||||
const order = modelOrder[group] || rawModels.map(m => m.id)
|
||||
const ids = rawModels.map(m => m.id)
|
||||
const sorted = [
|
||||
...order.filter(id => ids.includes(id)).map(id => rawModels.find(m => m.id === id)!),
|
||||
...rawModels.filter(m => !order.includes(m.id)),
|
||||
]
|
||||
const visible = sorted.filter(m => !hiddenModels.has(m.id))
|
||||
if (visible.length > 0) visibleGrouped[group] = visible
|
||||
}
|
||||
|
||||
const rawGroup = models.find(m => m.id === model)?.group
|
||||
const selectedGroup = (rawGroup && visibleGrouped[rawGroup])
|
||||
? rawGroup
|
||||
: Object.keys(visibleGrouped)[0] ?? ''
|
||||
const isBSR = model.startsWith('bs_roformer_')
|
||||
|
||||
function handleGroupChange(group: string) {
|
||||
const first = visibleGrouped[group]?.[0]
|
||||
if (first) setModel(first.id)
|
||||
}
|
||||
|
||||
// Reset selected model when it becomes hidden/invisible
|
||||
useEffect(() => {
|
||||
if (!models.length) return
|
||||
const foundGroup = models.find(m => m.id === model)?.group
|
||||
const isVisible = foundGroup && visibleGrouped[foundGroup]?.some(m => m.id === model)
|
||||
if (!isVisible) {
|
||||
const firstGroup = Object.keys(visibleGrouped)[0]
|
||||
const firstModel = firstGroup ? visibleGrouped[firstGroup]?.[0] : undefined
|
||||
if (firstModel) setModel(firstModel.id)
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [models])
|
||||
|
||||
// Fire callback when a separation job completes
|
||||
const firedRef = useRef<string | null>(null)
|
||||
useEffect(() => {
|
||||
if (
|
||||
result?.status === 'done' &&
|
||||
result.result?.project_id &&
|
||||
result.result?.tab_label &&
|
||||
onSeparationComplete &&
|
||||
firedRef.current !== result.id
|
||||
) {
|
||||
firedRef.current = result.id
|
||||
onSeparationComplete(
|
||||
result.result.project_id,
|
||||
result.result.tab_label,
|
||||
result.result.project_name ?? '',
|
||||
)
|
||||
}
|
||||
}, [result, onSeparationComplete])
|
||||
|
||||
// Extract metadata when file changes
|
||||
useEffect(() => {
|
||||
if (!file) {
|
||||
setMetadata({})
|
||||
setProjectName('')
|
||||
return
|
||||
}
|
||||
|
||||
// Try to extract metadata from the file
|
||||
extractLyrics(file).then(() => {
|
||||
// Use filename as fallback
|
||||
const filename = file.name.replace(/\.[^/.]+$/, '')
|
||||
setMetadata({ artist: '', title: filename })
|
||||
}).catch(() => {
|
||||
const filename = file.name.replace(/\.[^/.]+$/, '')
|
||||
setMetadata({ artist: '', title: filename })
|
||||
})
|
||||
}, [file])
|
||||
|
||||
// Auto-generate project name from metadata
|
||||
useEffect(() => {
|
||||
if (metadata.artist && metadata.title) {
|
||||
setProjectName(`${metadata.artist} - ${metadata.title}`)
|
||||
} else if (metadata.title) {
|
||||
setProjectName(metadata.title)
|
||||
} else if (file) {
|
||||
setProjectName(file.name.replace(/\.[^/.]+$/, ''))
|
||||
}
|
||||
}, [metadata, file])
|
||||
|
||||
async function submit() {
|
||||
if (inputMode === 'upload' && !file) return
|
||||
if (inputMode === 'imported' && !importedFile) return
|
||||
setError(null); setResult(null); setJobId(null); setLoading(true)
|
||||
try {
|
||||
const sepPowerPreset = localStorage.getItem('stemengine-sep-power') ?? 'standard'
|
||||
const opts = {
|
||||
presetType,
|
||||
projectName: projectName || undefined,
|
||||
staticOption: presetType === 'static' ? staticOption : undefined,
|
||||
dynamicLevels: presetType === 'dynamic' ? dynamicLevels : undefined,
|
||||
sepPowerPreset,
|
||||
}
|
||||
|
||||
let job_id: string
|
||||
if (inputMode === 'imported' && importedFile) {
|
||||
const res = await submitSeparateFromPath(importedFile.path, model, format, opts)
|
||||
job_id = res.job_id
|
||||
} else {
|
||||
const res = await submitSeparate(file!, model, format, opts)
|
||||
job_id = res.job_id
|
||||
}
|
||||
setJobId(job_id)
|
||||
} catch (e) {
|
||||
setError(String(e))
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleDynamicChange = (stem: keyof DynamicLevels, value: number) => {
|
||||
setDynamicLevels(prev => ({ ...prev, [stem]: value }))
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h2 className="text-xl font-semibold text-slate-900 dark:text-white mb-1">Stem Separator</h2>
|
||||
<p className="text-sm text-slate-500 dark:text-gray-400">
|
||||
Separate an audio track into individual stems using Demucs, BS-RoFormer, MelBand, or MDX-Net.
|
||||
Create presets like Instrumental, Static mixes, or Dynamic volume-adjusted mixes.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Input mode toggle */}
|
||||
<div className="flex rounded-lg border border-slate-200 dark:border-gray-700 overflow-hidden">
|
||||
<button
|
||||
onClick={() => setInputMode('upload')}
|
||||
className={`flex-1 py-2 text-xs font-medium transition-colors ${
|
||||
inputMode === 'upload'
|
||||
? 'bg-brand-600 text-white'
|
||||
: 'bg-white dark:bg-gray-900 text-slate-600 dark:text-gray-400 hover:bg-slate-50 dark:hover:bg-gray-800'
|
||||
}`}
|
||||
>
|
||||
Upload File
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setInputMode('imported'); refetchImports() }}
|
||||
className={`flex-1 py-2 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${
|
||||
inputMode === 'imported'
|
||||
? 'bg-sky-600 text-white'
|
||||
: 'bg-white dark:bg-gray-900 text-slate-600 dark:text-gray-400 hover:bg-slate-50 dark:hover:bg-gray-800'
|
||||
}`}
|
||||
>
|
||||
<Radio className="w-3 h-3" />
|
||||
Imported Files
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{inputMode === 'upload' && (
|
||||
<>
|
||||
<FileUpload
|
||||
label="Drop an audio file here, or click to select (MP3, FLAC, WAV, OGG…)"
|
||||
accept="audio/*"
|
||||
onFiles={([f]) => { setFile(f); setJobId(null); setResult(null) }}
|
||||
/>
|
||||
{file && (
|
||||
<div className="rounded-lg border border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-800/50 px-4 py-3">
|
||||
<p className="text-sm font-medium text-slate-700 dark:text-gray-300">
|
||||
Selected: {file.name}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{inputMode === 'imported' && (
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Select imported file</span>
|
||||
<button
|
||||
onClick={() => refetchImports()}
|
||||
title="Refresh"
|
||||
className="p-1 rounded text-slate-400 hover:text-brand-500 transition-colors"
|
||||
>
|
||||
<RefreshCw className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{imports.length === 0 ? (
|
||||
<div className="rounded-lg border border-dashed border-slate-200 dark:border-gray-700 px-4 py-6 text-center">
|
||||
<Radio className="w-6 h-6 text-slate-300 dark:text-gray-600 mx-auto mb-2" />
|
||||
<p className="text-sm text-slate-400 dark:text-gray-600">No imported files yet.</p>
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 mt-1">Use the Subsonic panel in the sidebar to import songs.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-1 max-h-48 overflow-y-auto rounded-lg border border-slate-200 dark:border-gray-700">
|
||||
{imports.map((f) => (
|
||||
<button
|
||||
key={f.path}
|
||||
onClick={() => {
|
||||
setImportedFile(f)
|
||||
setProjectName(f.filename.replace(/\.[^/.]+$/, ''))
|
||||
setJobId(null); setResult(null)
|
||||
}}
|
||||
className={`w-full flex items-start gap-2 px-3 py-2 text-left transition-colors ${
|
||||
importedFile?.path === f.path
|
||||
? 'bg-sky-50 dark:bg-sky-950/30 border-l-2 border-sky-500'
|
||||
: 'hover:bg-slate-50 dark:hover:bg-gray-800/50'
|
||||
}`}
|
||||
>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-slate-700 dark:text-gray-200 truncate">{f.filename}</p>
|
||||
<p className="text-[10px] text-slate-400 dark:text-gray-500">
|
||||
{(f.size / 1024 / 1024).toFixed(1)} MB
|
||||
</p>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Model Family</span>
|
||||
<select value={selectedGroup} onChange={(e) => handleGroupChange(e.target.value)} className={SELECT_CLS}>
|
||||
{Object.keys(visibleGrouped).map((g) => (
|
||||
<option key={g} value={g}>{g}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Model</span>
|
||||
<select value={model} onChange={(e) => setModel(e.target.value)} className={SELECT_CLS}>
|
||||
{(visibleGrouped[selectedGroup] ?? []).map((m) => (
|
||||
<option key={m.id} value={m.id}>{m.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Output Format</span>
|
||||
<select value={format} onChange={(e) => setFormat(e.target.value)} className={SELECT_CLS}>
|
||||
{formats.map((f) => <option key={f.id} value={f.id}>{f.label}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{isBSR && (
|
||||
<div className="rounded-lg border border-purple-300 dark:border-purple-800 bg-purple-50 dark:bg-purple-950/30 px-4 py-3 text-xs text-purple-700 dark:text-purple-300 space-y-1">
|
||||
<p className="font-semibold">BS-RoFormer selected</p>
|
||||
<p>State-of-the-art transformer model. Runs in-process — may take longer on CPU.</p>
|
||||
<ul className="list-disc list-inside mt-1 space-y-0.5 text-purple-600 dark:text-purple-400">
|
||||
<li><strong>4-stem</strong> — vocals · drums · bass · other</li>
|
||||
<li><strong>5-stem (guitar)</strong> — + guitar as separate stem</li>
|
||||
<li><strong>5-stem (piano)</strong> — + piano as separate stem</li>
|
||||
<li><strong>6-stem (full)</strong> — vocals · drums · bass · guitar · piano · other</li>
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Project Name */}
|
||||
<div className="space-y-2">
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Project Name</span>
|
||||
<input
|
||||
type="text"
|
||||
value={projectName}
|
||||
onChange={(e) => setProjectName(e.target.value)}
|
||||
placeholder="Artist - Title"
|
||||
className={INPUT_CLS}
|
||||
/>
|
||||
</label>
|
||||
<p className="text-xs text-slate-500 dark:text-gray-500">
|
||||
Used for folder naming. Auto-generated from metadata if available.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Preset Type */}
|
||||
<div className="space-y-3">
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Output Preset</span>
|
||||
<select value={presetType} onChange={(e) => setPresetType(e.target.value)} className={SELECT_CLS}>
|
||||
{presets?.preset_types.map((p) => (
|
||||
<option key={p.id} value={p.id}>{p.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p className="text-xs text-slate-500 dark:text-gray-500">
|
||||
{presets?.preset_types.find(p => p.id === presetType)?.description}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Static Options */}
|
||||
{presetType === 'static' && (
|
||||
<div className="space-y-3 rounded-lg border border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-800/50 p-4">
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Remove Elements</span>
|
||||
<select value={staticOption} onChange={(e) => setStaticOption(e.target.value)} className={SELECT_CLS}>
|
||||
{presets?.static_options.map((o) => (
|
||||
<option key={o.id} value={o.id}>{o.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p className="text-xs text-slate-500 dark:text-gray-500">
|
||||
{presets?.static_options.find(o => o.id === staticOption)?.description}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Dynamic Options */}
|
||||
{presetType === 'dynamic' && (
|
||||
<div className="space-y-4 rounded-lg border border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-800/50 p-4">
|
||||
<p className="text-sm font-medium text-slate-700 dark:text-gray-300">Volume Levels</p>
|
||||
<p className="text-xs text-slate-500 dark:text-gray-500">Adjust the volume of each stem (0 = mute, 1 = original, 2 = double)</p>
|
||||
|
||||
{Object.entries(dynamicLevels).map(([stem, value]) => (
|
||||
<div key={stem} className="space-y-1">
|
||||
<div className="flex justify-between items-center">
|
||||
<label className="text-sm capitalize text-slate-700 dark:text-gray-300">{stem}</label>
|
||||
<span className="text-sm text-slate-500 dark:text-gray-400">{Math.round(value * 100)}%</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min="0"
|
||||
max="2"
|
||||
step="0.1"
|
||||
value={value}
|
||||
onChange={(e) => handleDynamicChange(stem as keyof DynamicLevels, parseFloat(e.target.value))}
|
||||
className={SLIDER_CLS}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Preset Preview */}
|
||||
{presetType !== 'stems_only' && (
|
||||
<div className="rounded-lg border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-950/30 px-4 py-3 text-sm text-blue-700 dark:text-blue-300">
|
||||
<p className="font-medium">Output Structure Preview:</p>
|
||||
<code className="block mt-2 text-xs whitespace-pre text-blue-600 dark:text-blue-400">
|
||||
{projectName || 'Project Name'}/
|
||||
{'\n'} Stems/ (always created)
|
||||
{presetType === 'instrumental' && "\n Instrumental/ (vocals removed)"}
|
||||
{presetType === 'static' && `\n Static/ (${presets?.static_options.find(o => o.id === staticOption)?.label})`}
|
||||
{presetType === 'dynamic' && "\n Dynamic/ (volume adjusted mix)"}
|
||||
</code>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{error && <p className="text-sm text-red-500 dark:text-red-400">{error}</p>}
|
||||
|
||||
<button
|
||||
onClick={submit}
|
||||
disabled={(inputMode === 'upload' ? !file : !importedFile) || loading}
|
||||
className="w-full rounded-lg bg-brand-600 hover:bg-brand-500 disabled:bg-slate-200 disabled:text-slate-400 dark:disabled:bg-gray-800 dark:disabled:text-gray-500 px-4 py-2.5 text-sm font-semibold text-white disabled:cursor-not-allowed transition-colors"
|
||||
>
|
||||
{loading ? 'Submitting…' : presetType === 'stems_only' ? 'Separate Stems' : `Separate & Create ${presets?.preset_types.find(p => p.id === presetType)?.label}`}
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setShowAuto(true)}
|
||||
disabled={(inputMode === 'upload' ? !file : !importedFile)}
|
||||
className="w-full rounded-lg border border-amber-400 dark:border-amber-600 bg-amber-50 dark:bg-amber-950/30 hover:bg-amber-100 dark:hover:bg-amber-900/40 disabled:opacity-40 disabled:cursor-not-allowed px-4 py-2.5 text-sm font-semibold text-amber-700 dark:text-amber-400 transition-colors flex items-center justify-center gap-2"
|
||||
>
|
||||
<Zap className="w-4 h-4" />
|
||||
Auto Pipeline
|
||||
</button>
|
||||
|
||||
{showAuto && (
|
||||
<AutoPipelineDialog
|
||||
target={{
|
||||
file: inputMode === 'upload' ? file ?? undefined : undefined,
|
||||
filePath: inputMode === 'imported' ? importedFile?.path : undefined,
|
||||
filename: inputMode === 'upload'
|
||||
? (file?.name ?? '')
|
||||
: (importedFile?.filename ?? ''),
|
||||
initialModel: model,
|
||||
initialFormat: format,
|
||||
initialProjectName: projectName || undefined,
|
||||
}}
|
||||
onClose={() => setShowAuto(false)}
|
||||
onComplete={(projectId, name) => {
|
||||
setShowAuto(false)
|
||||
onSeparationComplete?.(projectId, `Auto Pipeline`, name)
|
||||
}}
|
||||
onOpenSettings={onOpenSettings}
|
||||
/>
|
||||
)}
|
||||
|
||||
{jobId && <JobStatus jobId={jobId} onDone={setResult} />}
|
||||
{result && (
|
||||
<div className="space-y-4">
|
||||
{result.result?.project_name && (
|
||||
<div className="rounded-lg border border-green-200 dark:border-green-800 bg-green-50 dark:bg-green-950/30 px-4 py-3">
|
||||
<p className="text-sm font-medium text-green-800 dark:text-green-300">
|
||||
Project: {result.result.project_name}
|
||||
</p>
|
||||
<p className="text-xs text-green-600 dark:text-green-400 mt-1">
|
||||
Location: {result.result.project_path}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<ResultFiles jobId={result.id} files={result.files} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -14,9 +14,6 @@
|
||||
<!-- Theme color (browser chrome on Android, tab bar tint) -->
|
||||
<meta name="theme-color" content="#3B82F6" />
|
||||
|
||||
<!-- Supports both light and dark OS themes; JS will set the active scheme -->
|
||||
<meta name="color-scheme" content="light dark" />
|
||||
|
||||
<!-- iOS PWA -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
|
||||
Generated
-117
@@ -17,7 +17,6 @@
|
||||
"@fontsource/roboto": "^5.0.0",
|
||||
"@fontsource/work-sans": "^5.0.0",
|
||||
"@fontsource/young-serif": "^5.0.0",
|
||||
"@olton/metroui": "^5.1.20",
|
||||
"@tanstack/react-query": "^5.0.0",
|
||||
"@tonejs/midi": "^2.0.28",
|
||||
"abcjs": "^6.6.2",
|
||||
@@ -850,116 +849,6 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@olton/datetime": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@olton/datetime/-/datetime-3.3.0.tgz",
|
||||
"integrity": "sha512-YqGLhVp0iisuDjQZ77PQkRciEfFp92znIdwTq4jU86KQisYfzL0Z23MnT9CWDC7mDjxQOZczLh956eR1RsOVAg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/dom": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@olton/dom/-/dom-1.5.1.tgz",
|
||||
"integrity": "sha512-vVXQYluo3id17GTol+0GI2RbD7HS9ajT6avHbnLXKE7ORjQ/NNfaRtvgJqWOnLGC0H+O09gVSm3g8HGOiNaRYQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"web-worker": "^1.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@olton/farbe": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@olton/farbe/-/farbe-1.0.11.tgz",
|
||||
"integrity": "sha512-gYpiDuKUIfONnc21a/q322RLGHGcwN0VABj+g3CoXwO4ysVxDVdAzfrwlOWbe4fFJwswr/HUUG0Ll8iJRo0eiw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "serhii@pimenov.com.ua"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/metroui"
|
||||
},
|
||||
{
|
||||
"type": "subscription",
|
||||
"url": "https://korzh.com/metroui#licensing"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/guardian": {
|
||||
"version": "0.7.3",
|
||||
"resolved": "https://registry.npmjs.org/@olton/guardian/-/guardian-0.7.3.tgz",
|
||||
"integrity": "sha512-ypl1ePJHjhz7Kl+Mo+N4E85bqgjIgdh070zmz22ZrVtv7lMXyvJ5yNJaz33UOvYKPylU9yQfi4MDomPuSfFQkg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/hooks": {
|
||||
"version": "0.13.1",
|
||||
"resolved": "https://registry.npmjs.org/@olton/hooks/-/hooks-0.13.1.tgz",
|
||||
"integrity": "sha512-Mi59Dnmg9N7Yv0FsbrrPKf6GEvRbSv3bNca20whjCUQguQ7qUx4T54XX9KFAkJNqTVDQHbppZgV3pYjRsdb23w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/html": {
|
||||
"version": "0.15.1",
|
||||
"resolved": "https://registry.npmjs.org/@olton/html/-/html-0.15.1.tgz",
|
||||
"integrity": "sha512-jdKda7+O/oOCJDOdIV9BAd5tk1qYuUUNYSVK0KAAY/fkycCjBG7QwStzNGmtaXz8bpIcL1giid+JdcSe4BaNUw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "serhii@pimenov.com.ua"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/metroui"
|
||||
},
|
||||
{
|
||||
"type": "subscription",
|
||||
"url": "https://korzh.com/metroui#licensing"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/metroui": {
|
||||
"version": "5.1.20",
|
||||
"resolved": "https://registry.npmjs.org/@olton/metroui/-/metroui-5.1.20.tgz",
|
||||
"integrity": "sha512-YV49RzUC3Uj4jqTSoADrmK/nHJ90TgJea50flmBKmDn34NxZtkrg3CAz9qy8726+I7ogdwWMBoxBfnqPfaTJYw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@olton/datetime": "^3.3.0",
|
||||
"@olton/dom": "^1.5.1",
|
||||
"@olton/farbe": "^1.0.11",
|
||||
"@olton/guardian": "^0.7.3",
|
||||
"@olton/hooks": "^0.13.1",
|
||||
"@olton/html": "^0.15.1",
|
||||
"@olton/model": "^0.18.1",
|
||||
"@olton/router": "^0.4.1",
|
||||
"@olton/string": "^0.10.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/metroui"
|
||||
}
|
||||
},
|
||||
"node_modules/@olton/model": {
|
||||
"version": "0.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@olton/model/-/model-0.18.1.tgz",
|
||||
"integrity": "sha512-UyvvUrINPC9W5mbf2sZXAbDaUKuRykQ7TCpfqfx2Qd8mPskMt5R65zzmYBtAoapeDfxtvnAYi9PYIwgIraKyZw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/metroui"
|
||||
}
|
||||
},
|
||||
"node_modules/@olton/router": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@olton/router/-/router-0.4.1.tgz",
|
||||
"integrity": "sha512-9pCSomojBBM3kkqlofttpYchF+Qm2D73IYCQq2NBhiPkustnkXua9i4XCSVP3ptXpgvIOsc6+RnPR7AGB+5utA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@olton/string": {
|
||||
"version": "0.10.2",
|
||||
"resolved": "https://registry.npmjs.org/@olton/string/-/string-0.10.2.tgz",
|
||||
"integrity": "sha512-xuBuCOkgyJkEyVBSkjFPIYuAzZiCiGQuks/eWvwgF01A+QMXLv1w+OpR1M40ehCjvKVgz4eXWHqSBL7wfX+KiQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@rolldown/pluginutils": {
|
||||
"version": "1.0.0-beta.27",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz",
|
||||
@@ -2792,12 +2681,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/web-worker": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.5.0.tgz",
|
||||
"integrity": "sha512-RiMReJrTAiA+mBjGONMnjVDP2u3p9R1vkcGz6gDIrOMT3oGuYwX2WRMYI9ipkphSuE5XKEhydbhNEJh4NY9mlw==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/yallist": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@olton/metroui": "^5.1.20",
|
||||
"@fontsource/archivo": "^5.0.0",
|
||||
"@fontsource/eb-garamond": "^5.0.0",
|
||||
"@fontsource/inter": "^5.0.0",
|
||||
|
||||
+100
-122
@@ -1,10 +1,3 @@
|
||||
/**
|
||||
* App.tsx — StemEngine shell
|
||||
*
|
||||
* Phase 1 (MetroUI migration): outer shell uses MetroUI app-bar + CSS classes.
|
||||
* Inner pages (Separator, ProjectDetail, Settings, Sidebar) still use Tailwind;
|
||||
* they will be migrated in subsequent phases.
|
||||
*/
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { Music2, Settings, Cpu } from 'lucide-react'
|
||||
import Separator from './pages/Separator'
|
||||
@@ -18,8 +11,8 @@ import type { Project } from './types'
|
||||
|
||||
interface ProjectTab {
|
||||
id: string
|
||||
label: string
|
||||
name: string
|
||||
label: string // e.g. "Demucs v4_MP3 (256 kbps)"
|
||||
name: string // e.g. "Artist - Title"
|
||||
}
|
||||
|
||||
interface GpuInfo {
|
||||
@@ -31,24 +24,28 @@ interface GpuInfo {
|
||||
}
|
||||
|
||||
function AppShell() {
|
||||
const [activeTabId, setActiveTabId] = useState<string>(
|
||||
const [activeTabId, setActiveTabId] = useState<string>(
|
||||
() => localStorage.getItem('stemengine-active-tab') ?? 'separate'
|
||||
)
|
||||
const [projectTabs, setProjectTabs] = useState<ProjectTab[]>([])
|
||||
const [sidebarOpen, setSidebarOpen] = useState(() => window.innerWidth >= 640)
|
||||
const [projectTabs, setProjectTabs] = useState<ProjectTab[]>([])
|
||||
const [sidebarOpen, setSidebarOpen] = useState(() => window.innerWidth >= 640)
|
||||
|
||||
const [gpuInfo, setGpuInfo] = useState<GpuInfo | null>(null)
|
||||
// GPU state
|
||||
const [gpuInfo, setGpuInfo] = useState<GpuInfo | null>(null)
|
||||
const [gpuResetting, setGpuResetting] = useState(false)
|
||||
|
||||
// Persist active tab so it survives a page refresh
|
||||
useEffect(() => {
|
||||
localStorage.setItem('stemengine-active-tab', activeTabId)
|
||||
}, [activeTabId])
|
||||
|
||||
// Apply saved font and accent color on mount
|
||||
useEffect(() => {
|
||||
applyFont(localStorage.getItem('stemengine-font') ?? 'system')
|
||||
applyAccent(localStorage.getItem('stemengine-accent') ?? 'blue')
|
||||
}, [])
|
||||
|
||||
// Load all projects from DB on mount → restore persistent tabs
|
||||
useEffect(() => {
|
||||
listProjects()
|
||||
.then((projects: Project[]) => {
|
||||
@@ -58,17 +55,21 @@ function AppShell() {
|
||||
name: p.name,
|
||||
}))
|
||||
setProjectTabs(tabs)
|
||||
// If the restored tab is a project that no longer exists, go home
|
||||
setActiveTabId((current) => {
|
||||
if (current === 'separate' || current === 'settings') return current
|
||||
return tabs.find((t) => t.id === current) ? current : 'separate'
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
.catch(() => {/* ignore – server may not be ready yet */})
|
||||
}, [])
|
||||
|
||||
// Poll GPU info on mount + every 30 s
|
||||
useEffect(() => {
|
||||
async function fetchGpu() {
|
||||
try { setGpuInfo(await getGpuInfo()) } catch {}
|
||||
try {
|
||||
setGpuInfo(await getGpuInfo())
|
||||
} catch { /* server not ready yet */ }
|
||||
}
|
||||
fetchGpu()
|
||||
const id = setInterval(fetchGpu, 30_000)
|
||||
@@ -80,15 +81,19 @@ function AppShell() {
|
||||
try {
|
||||
await resetGpu()
|
||||
setGpuInfo(await getGpuInfo())
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
setGpuResetting(false)
|
||||
}
|
||||
|
||||
// Auto-reset when the GPU context is marked failed (e.g. after Whisper fallback)
|
||||
const gpuContextFailed = gpuInfo?.cuda_available === true && gpuInfo.cuda_ok === false
|
||||
useEffect(() => {
|
||||
if (gpuContextFailed && !gpuResetting) handleGpuReset()
|
||||
if (gpuContextFailed && !gpuResetting) {
|
||||
handleGpuReset()
|
||||
}
|
||||
}, [gpuContextFailed])
|
||||
|
||||
// Called by Separator when a separation job finishes
|
||||
const handleSeparationComplete = useCallback(
|
||||
(projectId: string, tabLabel: string, projectName: string) => {
|
||||
setProjectTabs((prev) => {
|
||||
@@ -100,140 +105,114 @@ function AppShell() {
|
||||
[]
|
||||
)
|
||||
|
||||
// Close (delete) a project tab
|
||||
async function handleCloseTab(projectId: string, projectName: string) {
|
||||
const label = projectTabs.find((t) => t.id === projectId)?.label || projectName
|
||||
if (!window.confirm(`Delete "${label}"?\n\nThis will permanently remove the project and all its files.`)) return
|
||||
try { await deleteProject(projectId) } catch {}
|
||||
|
||||
try {
|
||||
await deleteProject(projectId)
|
||||
} catch {
|
||||
// If delete fails, still remove from tabs (project may already be gone)
|
||||
}
|
||||
setProjectTabs((prev) => prev.filter((t) => t.id !== projectId))
|
||||
if (activeTabId === projectId) setActiveTabId('separate')
|
||||
}
|
||||
|
||||
// Called from sidebar when a project is deleted there
|
||||
function handleDeleteProjectFromSidebar(project: Project) {
|
||||
setProjectTabs((prev) => prev.filter((t) => t.id !== project.id))
|
||||
if (activeTabId === project.id) setActiveTabId('separate')
|
||||
}
|
||||
|
||||
// Open a project tab from sidebar click — adds it if not already open
|
||||
function handleOpenProject(project: Project) {
|
||||
setProjectTabs((prev) => {
|
||||
if (prev.find((t) => t.id === project.id)) return prev
|
||||
return [...prev, { id: project.id, label: project.tab_label || project.name, name: project.name }]
|
||||
return [...prev, {
|
||||
id: project.id,
|
||||
label: project.tab_label || project.name,
|
||||
name: project.name,
|
||||
}]
|
||||
})
|
||||
setActiveTabId(project.id)
|
||||
}
|
||||
|
||||
const gpuError = gpuInfo ? (!gpuInfo.cuda_ok || !gpuInfo.cuda_available) : false
|
||||
const gpuTitle = gpuInfo
|
||||
// Derive GPU button appearance
|
||||
const gpuError = gpuInfo ? (!gpuInfo.cuda_ok || !gpuInfo.cuda_available) : false
|
||||
const gpuTitle = gpuInfo
|
||||
? gpuInfo.cuda_available
|
||||
? `${gpuInfo.name ?? 'GPU'} · ${gpuInfo.free_mb} / ${gpuInfo.total_mb} MB free${!gpuInfo.cuda_ok ? ' · Context error — click to reset' : ''}`
|
||||
: 'CUDA unavailable — click to attempt reset'
|
||||
: 'GPU status unknown'
|
||||
|
||||
// ── Accent colour: map app accent id to MetroUI colour class ─────────────
|
||||
// Used for the active-settings button highlight via inline style.
|
||||
const accentHex = (() => {
|
||||
const raw = document.documentElement.dataset.accent ?? 'blue'
|
||||
const map: Record<string, string> = {
|
||||
blue: '#3b82f6', violet: '#8b5cf6', rose: '#f43f5e',
|
||||
emerald: '#10b981', amber: '#f59e0b', cyan: '#06b6d4',
|
||||
}
|
||||
return map[raw] ?? map.blue
|
||||
})()
|
||||
|
||||
// ── GPU status dot colour ─────────────────────────────────────────────────
|
||||
const gpuDotColor = !gpuInfo
|
||||
? 'transparent'
|
||||
: !gpuInfo.cuda_available ? '#64748b'
|
||||
: !gpuInfo.cuda_ok ? '#ef4444'
|
||||
: '#34d399'
|
||||
|
||||
return (
|
||||
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
||||
<div className="h-full flex flex-col overflow-hidden">
|
||||
{/* ── Header ── */}
|
||||
<header className="shrink-0 border-b border-slate-200 dark:border-gray-800 bg-white dark:bg-gray-950 z-20">
|
||||
<div className="h-1 bg-gradient-to-r from-brand-500 via-purple-500 to-rose-500" />
|
||||
|
||||
{/* ── AppBar ──────────────────────────────────────────────────────────── */}
|
||||
<header style={{ flexShrink: 0, position: 'relative', zIndex: 20 }}>
|
||||
{/* Accent gradient line */}
|
||||
<div style={{
|
||||
height: 3,
|
||||
background: `linear-gradient(90deg, rgb(var(--brand-500, 59 130 246)), #a855f7, #f43f5e)`,
|
||||
}} />
|
||||
<div className="px-4 py-2.5 flex items-center gap-3">
|
||||
<button
|
||||
onClick={() => setActiveTabId('separate')}
|
||||
title="Home"
|
||||
className="flex items-center gap-2 flex-1 min-w-0 hover:opacity-80 transition-opacity text-left"
|
||||
>
|
||||
<div className="w-8 h-8 rounded-lg bg-gradient-to-br from-brand-500 to-brand-700 flex items-center justify-center shrink-0 shadow-md shadow-brand-500/30">
|
||||
<Music2 className="w-4 h-4 text-white" />
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<span className="text-base font-bold text-slate-900 dark:text-white tracking-tight">StemEngine</span>
|
||||
<span className="text-xs text-slate-400 dark:text-gray-600 ml-2 hidden sm:inline">Audio processing toolkit</span>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div className="app-bar" style={{ background: 'var(--sidebar-background)', borderBottom: '1px solid var(--border-color)' }}>
|
||||
{/* GPU status button */}
|
||||
<button
|
||||
onClick={handleGpuReset}
|
||||
title={gpuTitle}
|
||||
className={`relative p-2 rounded-xl border transition-all ${
|
||||
gpuError
|
||||
? 'border-red-400 bg-red-50 dark:bg-red-950/30 text-red-500 dark:text-red-400 hover:border-red-500'
|
||||
: 'border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-900 text-slate-400 dark:text-gray-600 hover:text-brand-600 dark:hover:text-brand-400 hover:border-brand-400'
|
||||
}`}
|
||||
>
|
||||
<Cpu className={`w-4 h-4 ${gpuResetting ? 'animate-pulse' : ''}`} />
|
||||
{/* status dot */}
|
||||
{gpuInfo && (
|
||||
<span className={`absolute top-1 right-1 w-1.5 h-1.5 rounded-full ${
|
||||
!gpuInfo.cuda_available ? 'bg-slate-400 dark:bg-gray-600'
|
||||
: !gpuInfo.cuda_ok ? 'bg-red-500 animate-pulse'
|
||||
: 'bg-emerald-400'
|
||||
}`} />
|
||||
)}
|
||||
</button>
|
||||
|
||||
{/* Brand */}
|
||||
<div className="app-bar-brand">
|
||||
<button
|
||||
onClick={() => setActiveTabId('separate')}
|
||||
title="Home"
|
||||
className="button flat"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '4px 8px' }}
|
||||
>
|
||||
<div style={{
|
||||
width: 32, height: 32, borderRadius: 8, flexShrink: 0,
|
||||
background: `linear-gradient(135deg, rgb(var(--brand-500, 59 130 246)), rgb(var(--brand-700, 29 78 216)))`,
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
}}>
|
||||
<Music2 size={16} color="white" />
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', lineHeight: 1.2 }}>
|
||||
<span style={{ fontWeight: 700, fontSize: 15 }}>StemEngine</span>
|
||||
<span style={{ fontSize: 11, opacity: 0.45 }}>Audio processing toolkit</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Right-side icon buttons */}
|
||||
<div className="app-bar-item" style={{ display: 'flex', alignItems: 'center', gap: 4, marginLeft: 'auto' }}>
|
||||
|
||||
{/* GPU status */}
|
||||
<button
|
||||
onClick={handleGpuReset}
|
||||
title={gpuTitle}
|
||||
className="button cycle flat"
|
||||
style={{
|
||||
position: 'relative',
|
||||
color: gpuError ? '#ef4444' : undefined,
|
||||
}}
|
||||
>
|
||||
<Cpu size={16} style={{ animation: gpuResetting ? 'pulse 1s infinite' : undefined }} />
|
||||
{/* Status dot */}
|
||||
<span style={{
|
||||
position: 'absolute', top: 4, right: 4,
|
||||
width: 6, height: 6, borderRadius: '50%',
|
||||
background: gpuDotColor,
|
||||
transition: 'background 0.3s',
|
||||
}} />
|
||||
</button>
|
||||
|
||||
{/* Settings */}
|
||||
<button
|
||||
onClick={() => setActiveTabId('settings')}
|
||||
title="Settings"
|
||||
className="button cycle flat"
|
||||
style={{
|
||||
color: activeTabId === 'settings' ? accentHex : undefined,
|
||||
borderColor: activeTabId === 'settings' ? accentHex : undefined,
|
||||
}}
|
||||
>
|
||||
<Settings size={16} />
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setActiveTabId('settings')}
|
||||
title="Settings"
|
||||
className={`p-2 rounded-xl border transition-all ${
|
||||
activeTabId === 'settings'
|
||||
? 'border-brand-500 bg-brand-50 dark:bg-brand-950/30 text-brand-600 dark:text-brand-400'
|
||||
: 'border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-900 text-slate-500 hover:text-brand-600 dark:text-gray-400 dark:hover:text-brand-400 hover:border-brand-400'
|
||||
}`}
|
||||
>
|
||||
<Settings className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* ── Body ────────────────────────────────────────────────────────────── */}
|
||||
<div style={{ display: 'flex', flex: 1, overflow: 'hidden' }}>
|
||||
{/* ── Body: sidebar + main ── */}
|
||||
<div className="flex flex-1 overflow-hidden">
|
||||
|
||||
{/* Mobile backdrop — tapping it closes the sidebar (hidden on sm+ where sidebar is in flow) */}
|
||||
{/* Backdrop — tapping it closes the sidebar on mobile */}
|
||||
{sidebarOpen && (
|
||||
<div
|
||||
className="sm:hidden"
|
||||
style={{ position: 'fixed', inset: 0, zIndex: 20, background: 'rgba(0,0,0,0.4)' }}
|
||||
className="sm:hidden fixed inset-0 z-20 bg-black/40"
|
||||
onClick={() => setSidebarOpen(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Sidebar — Tailwind, migrated in Phase 2 */}
|
||||
<Sidebar
|
||||
isOpen={sidebarOpen}
|
||||
onToggle={() => setSidebarOpen((v) => !v)}
|
||||
@@ -242,15 +221,15 @@ function AppShell() {
|
||||
openTabIds={projectTabs.map((t) => t.id)}
|
||||
/>
|
||||
|
||||
{/* Main content area */}
|
||||
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
||||
<main style={{ flex: 1, overflowY: 'auto', paddingBottom: 48 }}>
|
||||
<div className="flex-1 flex flex-col overflow-hidden bg-slate-100 dark:bg-gray-950">
|
||||
|
||||
{/* Page content */}
|
||||
<main className="flex-1 overflow-y-auto pb-12">
|
||||
{activeTabId === 'settings' ? (
|
||||
// Settings page — Tailwind, migrated in Phase 5
|
||||
<SettingsPage />
|
||||
) : (
|
||||
<div style={{ maxWidth: 768, margin: '0 auto', padding: '16px 16px' }}>
|
||||
<div style={{ border: '1px solid var(--border-color)', borderRadius: 16, background: 'var(--body-background, var(--background))', padding: 24, boxShadow: '0 1px 6px rgba(0,0,0,0.08)' }}>
|
||||
<div className="max-w-3xl mx-auto px-2 sm:px-4 py-4 sm:py-6">
|
||||
<div className="rounded-2xl border border-slate-200 dark:border-gray-800 bg-white dark:bg-gray-900/60 p-3 sm:p-6 shadow-sm dark:shadow-xl">
|
||||
{activeTabId === 'separate' ? (
|
||||
<Separator
|
||||
onSeparationComplete={handleSeparationComplete}
|
||||
@@ -270,7 +249,7 @@ function AppShell() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<footer style={{ marginTop: 24, textAlign: 'center', fontSize: 11, opacity: 0.35 }}>
|
||||
<footer className="mt-6 text-center text-xs text-slate-400 dark:text-gray-700">
|
||||
StemEngine · Demucs · BS-RoFormer · Omnizart · wav2vec2
|
||||
</footer>
|
||||
</div>
|
||||
@@ -279,9 +258,8 @@ function AppShell() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Floating playback bar — GlobalAudioBar, migrated in Phase 6 */}
|
||||
{/* Floating playback bar — persists across page navigation */}
|
||||
<GlobalAudioBar />
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -91,11 +91,10 @@ async function pollUntilDone(jobId: string, signal?: AbortSignal): Promise<Job>
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function StepIcon({ step }: { step: AutoStep }) {
|
||||
const s = { width: 14, height: 14, flexShrink: 0 }
|
||||
if (step.type === 'reprocess') return <Music2 style={{ ...s, color: 'var(--color-violet, #a78bfa)' }} />
|
||||
if (step.type === 'midi') return <Mic2 style={{ ...s, color: 'var(--color-green)' }} />
|
||||
if (step.type === 'lyricsAlign') return <BookmarkPlus style={{ ...s, color: 'var(--color-teal, #2dd4bf)' }} />
|
||||
return <AlignLeft style={{ ...s, color: 'var(--color-blue, #38bdf8)' }} />
|
||||
if (step.type === 'reprocess') return <Music2 className="w-3.5 h-3.5 text-purple-500" />
|
||||
if (step.type === 'midi') return <Mic2 className="w-3.5 h-3.5 text-emerald-500" />
|
||||
if (step.type === 'lyricsAlign') return <BookmarkPlus className="w-3.5 h-3.5 text-teal-500" />
|
||||
return <AlignLeft className="w-3.5 h-3.5 text-sky-500" />
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -228,178 +227,161 @@ export default function AutoPipelineDialog({ target, onClose, onComplete, onOpen
|
||||
const finished = phase === 'done' || phase === 'error'
|
||||
const canRun = !!(target.file || target.filePath)
|
||||
|
||||
const brand = 'rgb(var(--brand-500, 59 130 246))'
|
||||
const amber = 'var(--color-amber)'
|
||||
|
||||
const stepColor = (status: StepStatus['status']) => {
|
||||
if (status === 'running') return brand
|
||||
if (status === 'done') return 'var(--color-green)'
|
||||
if (status === 'error') return 'var(--color-red)'
|
||||
return 'inherit'
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
position: 'fixed', bottom: 16, right: 16, zIndex: 50, width: 384,
|
||||
borderRadius: 16, border: '1px solid var(--border-color)',
|
||||
background: 'var(--body-background, var(--background))',
|
||||
boxShadow: '0 8px 32px rgba(0,0,0,0.24)',
|
||||
display: 'flex', flexDirection: 'column', maxHeight: '85vh',
|
||||
}}>
|
||||
<div className="fixed bottom-4 right-4 z-50 w-96 rounded-2xl bg-white dark:bg-gray-900 border border-slate-200 dark:border-gray-700 shadow-2xl flex flex-col max-h-[85vh]">
|
||||
|
||||
{/* Header */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 12, padding: '14px 20px', borderBottom: '1px solid var(--border-color)', flexShrink: 0 }}>
|
||||
<Zap style={{ width: 20, height: 20, color: amber, flexShrink: 0 }} />
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<h2 style={{ margin: 0, fontSize: 13, fontWeight: 700 }}>Auto Pipeline</h2>
|
||||
<p style={{ margin: 0, fontSize: 11, opacity: 0.5, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{target.filename}</p>
|
||||
{/* Header */}
|
||||
<div className="flex items-center gap-3 px-5 py-4 border-b border-slate-200 dark:border-gray-800 shrink-0">
|
||||
<Zap className="w-5 h-5 text-amber-500 shrink-0" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<h2 className="text-sm font-bold text-slate-900 dark:text-white">Auto Pipeline</h2>
|
||||
<p className="text-xs text-slate-500 dark:text-gray-400 truncate">{target.filename}</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={running ? cancel : onClose}
|
||||
className="p-1.5 rounded-lg text-slate-400 hover:text-slate-600 dark:hover:text-gray-200 transition-colors"
|
||||
>
|
||||
<X className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
onClick={running ? cancel : onClose}
|
||||
className="button cycle flat"
|
||||
style={{ padding: 6, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
||||
>
|
||||
<X style={{ width: 16, height: 16 }} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Body */}
|
||||
<div style={{ flex: 1, overflowY: 'auto', padding: 20, display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
{/* Body */}
|
||||
<div className="flex-1 overflow-y-auto p-5 space-y-4">
|
||||
|
||||
{/* Project name */}
|
||||
{!running && !finished && (
|
||||
<label style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
|
||||
<span style={{ fontSize: 10, fontWeight: 600, opacity: 0.5, textTransform: 'uppercase', letterSpacing: '0.08em' }}>Project Name</span>
|
||||
<input
|
||||
type="text"
|
||||
value={projName}
|
||||
onChange={e => setProjName(e.target.value)}
|
||||
placeholder="Artist - Title"
|
||||
style={{ width: '100%', borderRadius: 6, border: '1px solid var(--border-color)', padding: '7px 12px', fontSize: 13, background: 'transparent', boxSizing: 'border-box' }}
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
{/* Project name */}
|
||||
{!running && !finished && (
|
||||
<label className="space-y-1 block">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Project Name</span>
|
||||
<input
|
||||
type="text"
|
||||
value={projName}
|
||||
onChange={e => setProjName(e.target.value)}
|
||||
placeholder="Artist - Title"
|
||||
className="w-full rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-3 py-2 text-sm text-slate-900 dark:text-gray-100 focus:border-brand-500 focus:outline-none"
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
|
||||
{/* Pipeline summary */}
|
||||
{!running && !finished && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<span style={{ fontSize: 10, fontWeight: 600, opacity: 0.5, textTransform: 'uppercase', letterSpacing: '0.08em' }}>
|
||||
Pipeline ({1 + steps.length} step{steps.length !== 0 ? 's' : ''})
|
||||
</span>
|
||||
{onOpenSettings && (
|
||||
<button
|
||||
onClick={onOpenSettings}
|
||||
style={{ display: 'inline-flex', alignItems: 'center', gap: 4, fontSize: 11, color: brand, background: 'none', border: 'none', cursor: 'pointer', padding: 0 }}
|
||||
>
|
||||
<Settings style={{ width: 12, height: 12 }} />
|
||||
Edit in Settings
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Separation step */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '7px 12px', borderRadius: 6, border: '1px solid var(--border-color)' }}>
|
||||
<Music2 style={{ width: 14, height: 14, color: brand, flexShrink: 0 }} />
|
||||
<span style={{ flex: 1, fontSize: 13 }}>Stem Separation</span>
|
||||
<span style={{ fontSize: 11, opacity: 0.5, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth: 128 }}>
|
||||
{model} · {format}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{steps.length === 0 && (
|
||||
<p style={{ margin: 0, fontSize: 11, opacity: 0.5, fontStyle: 'italic', padding: '0 4px' }}>
|
||||
No extra steps configured.{' '}
|
||||
{/* Pipeline summary (shown before run) */}
|
||||
{!running && !finished && (
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs font-semibold text-slate-500 dark:text-gray-400 uppercase tracking-wider">
|
||||
Pipeline ({1 + steps.length} step{steps.length !== 0 ? 's' : ''})
|
||||
</span>
|
||||
{onOpenSettings && (
|
||||
<button onClick={onOpenSettings} style={{ color: brand, background: 'none', border: 'none', cursor: 'pointer', padding: 0, fontSize: 11, textDecoration: 'underline' }}>
|
||||
Add steps in Settings →
|
||||
<button
|
||||
onClick={onOpenSettings}
|
||||
className="flex items-center gap-1 text-xs text-brand-500 hover:text-brand-600 dark:text-brand-400 transition-colors"
|
||||
>
|
||||
<Settings className="w-3 h-3" />
|
||||
Edit in Settings
|
||||
</button>
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{steps.map((step, i) => (
|
||||
<div key={i} style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '7px 12px', borderRadius: 6, border: '1px solid var(--border-color)' }}>
|
||||
<StepIcon step={step} />
|
||||
<span style={{ flex: 1, fontSize: 13, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{stepLabel(step)}
|
||||
{/* Separation step */}
|
||||
<div className="flex items-center gap-2.5 px-3 py-2 rounded-lg bg-slate-50 dark:bg-gray-800/50 border border-slate-200 dark:border-gray-700">
|
||||
<Music2 className="w-3.5 h-3.5 text-brand-500 shrink-0" />
|
||||
<span className="text-sm text-slate-700 dark:text-gray-200 flex-1">Stem Separation</span>
|
||||
<span className="text-xs text-slate-400 dark:text-gray-500 truncate max-w-32">
|
||||
{model} · {format}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Live progress */}
|
||||
{stepStats.length > 0 && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||||
<span style={{ fontSize: 10, fontWeight: 600, opacity: 0.5, textTransform: 'uppercase', letterSpacing: '0.08em' }}>Progress</span>
|
||||
{stepStats.map((s, i) => (
|
||||
<div key={i} style={{ display: 'flex', alignItems: 'flex-start', gap: 12 }}>
|
||||
<div style={{ marginTop: 2, flexShrink: 0 }}>
|
||||
{s.status === 'running' && <Loader2 style={{ width: 16, height: 16, color: brand }} />}
|
||||
{s.status === 'done' && <CheckCircle2 style={{ width: 16, height: 16, color: 'var(--color-green)' }} />}
|
||||
{s.status === 'error' && <XCircle style={{ width: 16, height: 16, color: 'var(--color-red)' }} />}
|
||||
{s.status === 'pending' && <div style={{ width: 16, height: 16, borderRadius: '50%', border: '2px solid var(--border-color)' }} />}
|
||||
{steps.length === 0 && (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-500 italic px-1">
|
||||
No extra steps configured.{' '}
|
||||
{onOpenSettings && (
|
||||
<button onClick={onOpenSettings} className="text-brand-500 hover:underline">
|
||||
Add steps in Settings →
|
||||
</button>
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{steps.map((step, i) => (
|
||||
<div key={i} className="flex items-center gap-2.5 px-3 py-2 rounded-lg bg-slate-50 dark:bg-gray-800/50 border border-slate-200 dark:border-gray-700">
|
||||
<StepIcon step={step} />
|
||||
<span className="text-sm text-slate-700 dark:text-gray-200 flex-1 truncate">
|
||||
{stepLabel(step)}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<p style={{ margin: 0, fontSize: 13, fontWeight: 500, color: stepColor(s.status) }}>{s.label}</p>
|
||||
{s.detail && <p style={{ margin: '2px 0 0', fontSize: 11, opacity: 0.5, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{s.detail}</p>}
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Live progress */}
|
||||
{stepStats.length > 0 && (
|
||||
<div className="space-y-2">
|
||||
<span className="text-xs font-semibold text-slate-500 dark:text-gray-400 uppercase tracking-wider">
|
||||
Progress
|
||||
</span>
|
||||
{stepStats.map((s, i) => (
|
||||
<div key={i} className="flex items-start gap-3">
|
||||
<div className="mt-0.5 shrink-0">
|
||||
{s.status === 'running' && <Loader2 className="w-4 h-4 text-brand-500 animate-spin" />}
|
||||
{s.status === 'done' && <CheckCircle2 className="w-4 h-4 text-emerald-500" />}
|
||||
{s.status === 'error' && <XCircle className="w-4 h-4 text-red-500" />}
|
||||
{s.status === 'pending' && <div className="w-4 h-4 rounded-full border-2 border-slate-300 dark:border-gray-600" />}
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className={`text-sm font-medium ${
|
||||
s.status === 'running' ? 'text-brand-600 dark:text-brand-400'
|
||||
: s.status === 'done' ? 'text-emerald-700 dark:text-emerald-300'
|
||||
: s.status === 'error' ? 'text-red-600 dark:text-red-400'
|
||||
: 'text-slate-500 dark:text-gray-500'
|
||||
}`}>{s.label}</p>
|
||||
{s.detail && <p className="text-xs text-slate-400 dark:text-gray-500 truncate">{s.detail}</p>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{errMsg && (
|
||||
<div style={{ borderRadius: 6, border: '1px solid var(--color-red)', padding: '10px 16px', fontSize: 13, color: 'var(--color-red)', opacity: 0.85 }}>
|
||||
{errMsg}
|
||||
</div>
|
||||
)}
|
||||
{errMsg && (
|
||||
<div className="rounded-lg bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-800 px-4 py-3 text-sm text-red-700 dark:text-red-300">
|
||||
{errMsg}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{phase === 'done' && (
|
||||
<div style={{ borderRadius: 6, border: '1px solid var(--color-green)', padding: '10px 16px', fontSize: 13, fontWeight: 500, color: 'var(--color-green)', opacity: 0.9 }}>
|
||||
Pipeline complete!
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{phase === 'done' && (
|
||||
<div className="rounded-lg bg-emerald-50 dark:bg-emerald-950/30 border border-emerald-200 dark:border-emerald-800 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-300 font-medium">
|
||||
Pipeline complete!
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div style={{ padding: '14px 20px', borderTop: '1px solid var(--border-color)', flexShrink: 0, display: 'flex', gap: 12 }}>
|
||||
{!finished && (
|
||||
<>
|
||||
{/* Footer */}
|
||||
<div className="px-5 py-4 border-t border-slate-200 dark:border-gray-800 shrink-0 flex gap-3">
|
||||
{!finished && (
|
||||
<>
|
||||
<button
|
||||
onClick={running ? cancel : onClose}
|
||||
className="flex-1 rounded-lg border border-slate-300 dark:border-gray-600 px-4 py-2.5 text-sm font-medium text-slate-600 dark:text-gray-300 hover:bg-slate-50 dark:hover:bg-gray-800 transition-colors"
|
||||
>
|
||||
{running ? 'Cancel' : 'Dismiss'}
|
||||
</button>
|
||||
<button
|
||||
onClick={run}
|
||||
disabled={running || !canRun}
|
||||
className="flex-1 rounded-lg bg-amber-500 hover:bg-amber-400 disabled:bg-slate-200 disabled:text-slate-400 dark:disabled:bg-gray-800 dark:disabled:text-gray-500 px-4 py-2.5 text-sm font-bold text-white disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2"
|
||||
>
|
||||
{running
|
||||
? <><Loader2 className="w-4 h-4 animate-spin" />Running…</>
|
||||
: <><Zap className="w-4 h-4" />Run Pipeline</>}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{finished && (
|
||||
<button
|
||||
onClick={running ? cancel : onClose}
|
||||
style={{ flex: 1, borderRadius: 6, border: '1px solid var(--border-color)', padding: '9px 16px', fontSize: 13, fontWeight: 500, background: 'transparent', cursor: 'pointer' }}
|
||||
onClick={onClose}
|
||||
className="flex-1 rounded-lg bg-brand-600 hover:bg-brand-500 px-4 py-2.5 text-sm font-bold text-white transition-colors"
|
||||
>
|
||||
{running ? 'Cancel' : 'Dismiss'}
|
||||
Close
|
||||
</button>
|
||||
<button
|
||||
onClick={run}
|
||||
disabled={running || !canRun}
|
||||
style={{
|
||||
flex: 1, borderRadius: 6, border: 'none', padding: '9px 16px', fontSize: 13, fontWeight: 700,
|
||||
background: running || !canRun ? 'var(--border-color)' : amber,
|
||||
color: running || !canRun ? 'inherit' : '#fff',
|
||||
cursor: running || !canRun ? 'not-allowed' : 'pointer',
|
||||
display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 8,
|
||||
}}
|
||||
>
|
||||
{running
|
||||
? <><Loader2 style={{ width: 16, height: 16 }} />Running…</>
|
||||
: <><Zap style={{ width: 16, height: 16 }} />Run Pipeline</>}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{finished && (
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="button primary"
|
||||
style={{ flex: 1, padding: '9px 16px', fontSize: 13, fontWeight: 700 }}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -226,29 +226,22 @@ export default function DynamicMixPlayer({ stems, title, onLevelChange }: Props)
|
||||
|
||||
const allLoaded = stems.every((s) => loaded[s.name] !== false)
|
||||
|
||||
const brand = 'rgb(var(--brand-500, 59 130 246))'
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
<div className="space-y-3">
|
||||
{/* Playback controls */}
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 8 }}>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
onClick={togglePlay}
|
||||
disabled={!allLoaded}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
width: 36, height: 36, borderRadius: '50%', flexShrink: 0,
|
||||
background: brand, color: '#fff', border: 'none', cursor: allLoaded ? 'pointer' : 'not-allowed',
|
||||
opacity: allLoaded ? 1 : 0.5, padding: 0,
|
||||
}}
|
||||
className="flex items-center justify-center w-9 h-9 rounded-full bg-brand-500 text-white hover:bg-brand-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0"
|
||||
>
|
||||
{isPlaying ? (
|
||||
<svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24">
|
||||
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 24 24">
|
||||
<rect x="6" y="4" width="4" height="16" />
|
||||
<rect x="14" y="4" width="4" height="16" />
|
||||
</svg>
|
||||
) : (
|
||||
<svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24">
|
||||
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M8 5v14l11-7z" />
|
||||
</svg>
|
||||
)}
|
||||
@@ -260,24 +253,23 @@ export default function DynamicMixPlayer({ stems, title, onLevelChange }: Props)
|
||||
step={0.1}
|
||||
value={currentTime}
|
||||
onChange={(e) => handleSeek(parseFloat(e.target.value))}
|
||||
style={{ flex: 1, minWidth: 80, cursor: 'pointer', accentColor: brand }}
|
||||
className="flex-1 min-w-[80px] h-2 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-500"
|
||||
/>
|
||||
<span style={{ fontSize: 11, fontVariantNumeric: 'tabular-nums', opacity: 0.6, flexShrink: 0 }}>
|
||||
<span className="text-xs tabular-nums text-slate-500 dark:text-gray-400 shrink-0">
|
||||
{formatTime(currentTime)} / {formatTime(duration)}
|
||||
</span>
|
||||
|
||||
{/* Master volume */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, paddingLeft: 8, borderLeft: '1px solid var(--border-color)', flexShrink: 0 }}>
|
||||
<div className="flex items-center gap-1.5 pl-2 border-l border-slate-200 dark:border-gray-700 shrink-0">
|
||||
<button
|
||||
onClick={toggleMute}
|
||||
className="button cycle flat"
|
||||
style={{ padding: 6, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
||||
className="p-1.5 rounded-md text-slate-500 dark:text-gray-400 hover:text-slate-700 dark:hover:text-gray-200 hover:bg-slate-100 dark:hover:bg-gray-800 transition-colors"
|
||||
title={isMuted ? 'Unmute' : 'Mute'}
|
||||
>
|
||||
{isMuted || masterVolume === 0 ? (
|
||||
<VolumeX style={{ width: 16, height: 16 }} />
|
||||
<VolumeX className="w-4 h-4" />
|
||||
) : (
|
||||
<Volume2 style={{ width: 16, height: 16 }} />
|
||||
<Volume2 className="w-4 h-4" />
|
||||
)}
|
||||
</button>
|
||||
<input
|
||||
@@ -287,40 +279,38 @@ export default function DynamicMixPlayer({ stems, title, onLevelChange }: Props)
|
||||
step={0.05}
|
||||
value={isMuted ? 0 : masterVolume}
|
||||
onChange={(e) => updateMasterVolume(parseFloat(e.target.value))}
|
||||
style={{ width: 72, cursor: 'pointer', accentColor: brand }}
|
||||
className="w-16 sm:w-20 h-2 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-500"
|
||||
title="Master Volume"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Stem level sliders */}
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, paddingTop: 8, borderTop: '1px solid var(--border-color)' }}>
|
||||
<div className="space-y-2 pt-2 border-t border-slate-200 dark:border-gray-700">
|
||||
{stems.map((stem) => (
|
||||
<div key={stem.name} style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||
<span style={{ fontSize: 11, fontWeight: 500, opacity: 0.7, width: 52, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', textTransform: 'capitalize', flexShrink: 0 }}>
|
||||
<div key={stem.name} className="flex items-center gap-1.5">
|
||||
<span className="text-xs font-medium text-slate-600 dark:text-gray-400 w-12 sm:w-16 truncate capitalize">
|
||||
{stem.label}
|
||||
</span>
|
||||
<button
|
||||
onClick={() => toggleStemMute(stem.name)}
|
||||
title={mutedStems[stem.name] ? 'Unmute' : 'Mute'}
|
||||
style={{
|
||||
width: 24, height: 24, fontSize: 11, fontWeight: 700, borderRadius: 4, flexShrink: 0,
|
||||
border: 'none', cursor: 'pointer', transition: 'background 0.15s',
|
||||
background: mutedStems[stem.name] ? 'var(--color-red)' : 'var(--border-color)',
|
||||
color: mutedStems[stem.name] ? '#fff' : 'inherit',
|
||||
}}
|
||||
className={`w-6 h-6 text-xs font-bold rounded transition-colors flex-shrink-0 ${
|
||||
mutedStems[stem.name]
|
||||
? 'bg-red-500 text-white'
|
||||
: 'bg-slate-200 dark:bg-gray-700 text-slate-600 dark:text-gray-400 hover:bg-slate-300 dark:hover:bg-gray-600'
|
||||
}`}
|
||||
>
|
||||
M
|
||||
</button>
|
||||
<button
|
||||
onClick={() => toggleStemSolo(stem.name)}
|
||||
title={soloedStems[stem.name] ? 'Unsolo' : 'Solo'}
|
||||
style={{
|
||||
width: 24, height: 24, fontSize: 11, fontWeight: 700, borderRadius: 4, flexShrink: 0,
|
||||
border: 'none', cursor: 'pointer', transition: 'background 0.15s',
|
||||
background: soloedStems[stem.name] ? 'var(--color-amber)' : 'var(--border-color)',
|
||||
color: soloedStems[stem.name] ? '#000' : 'inherit',
|
||||
}}
|
||||
className={`w-6 h-6 text-xs font-bold rounded transition-colors flex-shrink-0 ${
|
||||
soloedStems[stem.name]
|
||||
? 'bg-yellow-400 text-black'
|
||||
: 'bg-slate-200 dark:bg-gray-700 text-slate-600 dark:text-gray-400 hover:bg-slate-300 dark:hover:bg-gray-600'
|
||||
}`}
|
||||
>
|
||||
S
|
||||
</button>
|
||||
@@ -331,9 +321,9 @@ export default function DynamicMixPlayer({ stems, title, onLevelChange }: Props)
|
||||
step={0.1}
|
||||
value={gains[stem.name] ?? 1.0}
|
||||
onChange={(e) => updateGain(stem.name, parseFloat(e.target.value))}
|
||||
style={{ flex: 1, cursor: 'pointer', accentColor: brand }}
|
||||
className="flex-1 h-2 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-500"
|
||||
/>
|
||||
<span style={{ fontSize: 11, fontVariantNumeric: 'tabular-nums', opacity: 0.6, width: 36, textAlign: 'right', flexShrink: 0 }}>
|
||||
<span className="text-xs tabular-nums text-slate-500 dark:text-gray-400 w-9 text-right">
|
||||
{Math.round((gains[stem.name] ?? 1.0) * 100)}%
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
/**
|
||||
* FileUpload.tsx — Phase 3 MetroUI migration
|
||||
* Drag-and-drop / click-to-upload zone. Logic unchanged.
|
||||
*/
|
||||
import React, { useCallback, useState } from 'react'
|
||||
import React, { useCallback } from 'react'
|
||||
import { Upload } from 'lucide-react'
|
||||
|
||||
interface Props {
|
||||
@@ -12,12 +8,9 @@ interface Props {
|
||||
}
|
||||
|
||||
export default function FileUpload({ label = 'Drop files here', accept, onFiles }: Props) {
|
||||
const [dragOver, setDragOver] = useState(false)
|
||||
|
||||
const handleDrop = useCallback(
|
||||
(e: React.DragEvent) => {
|
||||
e.preventDefault()
|
||||
setDragOver(false)
|
||||
const files = Array.from(e.dataTransfer.files)
|
||||
if (files.length) onFiles(files)
|
||||
},
|
||||
@@ -33,27 +26,15 @@ export default function FileUpload({ label = 'Drop files here', accept, onFiles
|
||||
[onFiles]
|
||||
)
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
|
||||
return (
|
||||
<label
|
||||
onDragOver={(e) => { e.preventDefault(); setDragOver(true) }}
|
||||
onDragLeave={() => setDragOver(false)}
|
||||
onDragOver={(e) => e.preventDefault()}
|
||||
onDrop={handleDrop}
|
||||
style={{
|
||||
display: 'flex', flexDirection: 'column', alignItems: 'center',
|
||||
justifyContent: 'center', gap: 12,
|
||||
padding: '28px 24px',
|
||||
borderRadius: 6,
|
||||
border: `2px dashed ${dragOver ? accentColor : 'var(--border-color)'}`,
|
||||
background: dragOver ? `rgba(var(--brand-500, 59 130 246), 0.05)` : 'var(--background)',
|
||||
cursor: 'pointer',
|
||||
transition: 'border-color 0.15s, background 0.15s',
|
||||
}}
|
||||
className="flex flex-col items-center justify-center gap-3 px-6 py-10 rounded-xl border-2 border-dashed border-slate-300 dark:border-gray-700 bg-slate-50 dark:bg-gray-900/50 hover:border-brand-400 dark:hover:border-brand-500 hover:bg-slate-100 dark:hover:bg-gray-800/50 transition-colors cursor-pointer"
|
||||
>
|
||||
<Upload size={28} style={{ color: dragOver ? accentColor : undefined, opacity: dragOver ? 1 : 0.35, transition: 'opacity 0.15s, color 0.15s' }} />
|
||||
<span style={{ fontSize: 13, opacity: 0.55, textAlign: 'center', lineHeight: 1.4 }}>{label}</span>
|
||||
<input type="file" accept={accept} onChange={handleChange} style={{ display: 'none' }} />
|
||||
<Upload className="w-8 h-8 text-slate-400 dark:text-gray-600" />
|
||||
<span className="text-sm text-slate-600 dark:text-gray-400 text-center">{label}</span>
|
||||
<input type="file" accept={accept} onChange={handleChange} className="hidden" />
|
||||
</label>
|
||||
)
|
||||
}
|
||||
@@ -28,44 +28,29 @@ export default function GlobalAudioBar() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
position: 'fixed', bottom: 0, left: 0, right: 0, zIndex: 50,
|
||||
borderTop: '1px solid var(--border-color)',
|
||||
background: 'var(--bar-background)',
|
||||
backdropFilter: 'blur(12px)',
|
||||
boxShadow: '0 -2px 8px rgba(0,0,0,0.12)',
|
||||
}}>
|
||||
<div style={{
|
||||
maxWidth: 768, margin: '0 auto', padding: '0 16px',
|
||||
height: 48, display: 'flex', alignItems: 'center', gap: 12,
|
||||
}}>
|
||||
<div className="fixed bottom-0 left-0 right-0 z-50 border-t border-slate-200 dark:border-gray-800 bg-white/95 dark:bg-gray-950/95 backdrop-blur-sm shadow-[0_-2px_8px_rgba(0,0,0,0.06)] dark:shadow-[0_-2px_8px_rgba(0,0,0,0.4)]">
|
||||
<div className="max-w-3xl mx-auto px-4 h-12 flex items-center gap-3">
|
||||
|
||||
{/* Play / Pause */}
|
||||
<button
|
||||
onClick={() => getActions().toggle()}
|
||||
className="button cycle"
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
width: 28, height: 28, borderRadius: '50%', flexShrink: 0,
|
||||
background: 'rgb(var(--brand-500, 59 130 246))', color: '#fff',
|
||||
border: 'none', cursor: 'pointer', padding: 0,
|
||||
}}
|
||||
className="flex items-center justify-center w-7 h-7 rounded-full bg-brand-500 text-white hover:bg-brand-600 transition-colors shrink-0"
|
||||
title={isPlaying ? 'Pause' : 'Play'}
|
||||
>
|
||||
{isPlaying ? (
|
||||
<svg width="12" height="12" fill="currentColor" viewBox="0 0 24 24">
|
||||
<svg className="w-3 h-3" fill="currentColor" viewBox="0 0 24 24">
|
||||
<rect x="6" y="4" width="4" height="16" />
|
||||
<rect x="14" y="4" width="4" height="16" />
|
||||
</svg>
|
||||
) : (
|
||||
<svg width="12" height="12" fill="currentColor" viewBox="0 0 24 24">
|
||||
<svg className="w-3 h-3" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M8 5v14l11-7z" />
|
||||
</svg>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{/* Current time */}
|
||||
<span style={{ fontSize: 11, fontVariantNumeric: 'tabular-nums', opacity: 0.5, flexShrink: 0, width: 32, textAlign: 'right' }}>
|
||||
<span className="text-xs tabular-nums text-slate-400 dark:text-gray-500 shrink-0 w-8 text-right">
|
||||
{fmtTime(currentTime)}
|
||||
</span>
|
||||
|
||||
@@ -77,31 +62,30 @@ export default function GlobalAudioBar() {
|
||||
step={0.1}
|
||||
value={currentTime}
|
||||
onChange={e => getActions().seek(parseFloat(e.target.value))}
|
||||
style={{ flex: 1, minWidth: 0, cursor: 'pointer' }}
|
||||
className="flex-1 h-1.5 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-500 min-w-0"
|
||||
/>
|
||||
|
||||
{/* Duration */}
|
||||
<span style={{ fontSize: 11, fontVariantNumeric: 'tabular-nums', opacity: 0.5, flexShrink: 0, width: 32 }}>
|
||||
<span className="text-xs tabular-nums text-slate-400 dark:text-gray-500 shrink-0 w-8">
|
||||
{fmtTime(duration)}
|
||||
</span>
|
||||
|
||||
{/* Title */}
|
||||
<span
|
||||
style={{ fontSize: 11, fontWeight: 500, opacity: 0.6, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flexShrink: 1, minWidth: 0, maxWidth: 180 }}
|
||||
className="text-xs font-medium text-slate-500 dark:text-gray-500 truncate shrink min-w-0 max-w-[120px] sm:max-w-[180px]"
|
||||
title={title}
|
||||
>
|
||||
{title}
|
||||
</span>
|
||||
|
||||
{/* Volume */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 4, flexShrink: 0, paddingLeft: 8, borderLeft: '1px solid var(--border-color)' }}>
|
||||
<div className="flex items-center gap-1 shrink-0 pl-2 border-l border-slate-200 dark:border-gray-700">
|
||||
<button
|
||||
onClick={handleMuteToggle}
|
||||
className="button cycle flat"
|
||||
style={{ padding: 4, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
||||
className="p-1 rounded text-slate-400 dark:text-gray-500 hover:text-slate-600 dark:hover:text-gray-300 transition-colors"
|
||||
title={volume === 0 ? 'Unmute' : 'Mute'}
|
||||
>
|
||||
{volume === 0 ? <VolumeX style={{ width: 14, height: 14 }} /> : <Volume2 style={{ width: 14, height: 14 }} />}
|
||||
{volume === 0 ? <VolumeX className="w-3.5 h-3.5" /> : <Volume2 className="w-3.5 h-3.5" />}
|
||||
</button>
|
||||
<input
|
||||
type="range"
|
||||
@@ -110,7 +94,7 @@ export default function GlobalAudioBar() {
|
||||
step={0.05}
|
||||
value={volume}
|
||||
onChange={e => getActions().setVolume(parseFloat(e.target.value))}
|
||||
style={{ width: 56, cursor: 'pointer' }}
|
||||
className="w-14 h-1.5 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-500"
|
||||
title="Volume"
|
||||
/>
|
||||
</div>
|
||||
@@ -118,11 +102,10 @@ export default function GlobalAudioBar() {
|
||||
{/* Dismiss */}
|
||||
<button
|
||||
onClick={stopCurrent}
|
||||
className="button cycle flat"
|
||||
style={{ padding: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0, marginLeft: 4 }}
|
||||
className="p-1 rounded text-slate-400 dark:text-gray-500 hover:text-slate-600 dark:hover:text-gray-300 transition-colors shrink-0 ml-1"
|
||||
title="Stop and close"
|
||||
>
|
||||
<X style={{ width: 14, height: 14 }} />
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -43,12 +43,10 @@ export default function JobStatus({ jobId, onDone }: Props) {
|
||||
}
|
||||
}, [jobId, onDone])
|
||||
|
||||
const row = { display: 'flex', alignItems: 'center', gap: 8, fontSize: 12 }
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div style={{ ...row, color: 'var(--color-red)' }}>
|
||||
<XCircle style={{ width: 16, height: 16, flexShrink: 0 }} />
|
||||
<div className="flex items-center gap-2 text-xs text-red-500">
|
||||
<XCircle className="w-4 h-4" />
|
||||
Error: {error}
|
||||
</div>
|
||||
)
|
||||
@@ -56,42 +54,27 @@ export default function JobStatus({ jobId, onDone }: Props) {
|
||||
|
||||
if (!job) {
|
||||
return (
|
||||
<div style={{ ...row, opacity: 0.5 }}>
|
||||
<Loader2 style={{ width: 16, height: 16, flexShrink: 0 }} />
|
||||
<div className="flex items-center gap-2 text-xs text-slate-500">
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
Loading…
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const STATUS_COLOR: Record<string, string> = {
|
||||
queued: 'var(--color-amber)',
|
||||
running: 'rgb(var(--brand-500, 59 130 246))',
|
||||
done: 'var(--color-green)',
|
||||
error: 'var(--color-red)',
|
||||
cancelled: 'inherit',
|
||||
const statusConfig: Record<string, { icon: React.ReactNode; text: string; color: string }> = {
|
||||
queued: { icon: <Loader2 className="w-4 h-4 animate-spin text-amber-500" />, text: 'Queued…', color: 'text-amber-600' },
|
||||
running: { icon: <Loader2 className="w-4 h-4 animate-spin text-brand-500" />, text: job.progress || 'Running…', color: 'text-brand-600' },
|
||||
done: { icon: <CheckCircle className="w-4 h-4 text-emerald-500" />, text: 'Complete', color: 'text-emerald-600' },
|
||||
error: { icon: <XCircle className="w-4 h-4 text-red-500" />, text: `Error: ${job.error || 'Failed'}`, color: 'text-red-600' },
|
||||
cancelled: { icon: <AlertCircle className="w-4 h-4 text-slate-400" />, text: 'Cancelled', color: 'text-slate-500' },
|
||||
}
|
||||
|
||||
const STATUS_TEXT: Record<string, string> = {
|
||||
queued: 'Queued…',
|
||||
running: job.progress || 'Running…',
|
||||
done: 'Complete',
|
||||
error: `Error: ${job.error || 'Failed'}`,
|
||||
cancelled: 'Cancelled',
|
||||
}
|
||||
|
||||
const color = STATUS_COLOR[job.status] ?? 'inherit'
|
||||
const config = statusConfig[job.status]
|
||||
|
||||
return (
|
||||
<div style={{ ...row, color, opacity: job.status === 'cancelled' ? 0.5 : 1 }}>
|
||||
{(job.status === 'queued' || job.status === 'running') && (
|
||||
<Loader2 style={{ width: 16, height: 16, flexShrink: 0 }} />
|
||||
)}
|
||||
{job.status === 'done' && <CheckCircle style={{ width: 16, height: 16, flexShrink: 0 }} />}
|
||||
{job.status === 'error' && <XCircle style={{ width: 16, height: 16, flexShrink: 0 }} />}
|
||||
{job.status === 'cancelled' && <AlertCircle style={{ width: 16, height: 16, flexShrink: 0 }} />}
|
||||
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{STATUS_TEXT[job.status] ?? job.status}
|
||||
</span>
|
||||
<div className={`flex items-center gap-2 text-xs ${config.color}`}>
|
||||
{config.icon}
|
||||
<span className="truncate">{config.text}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -2111,72 +2111,57 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
style={undefined}
|
||||
>
|
||||
{/* Visual style tabs + toolbar — scrollable on narrow screens */}
|
||||
<div
|
||||
className="flex items-center gap-1 px-2 py-1 border-b overflow-x-auto [&::-webkit-scrollbar]:hidden"
|
||||
style={isFullscreen
|
||||
? { background: 'rgba(0,0,0,0.4)', borderColor: 'rgba(255,255,255,0.1)' }
|
||||
: { background: 'var(--background)', borderColor: 'var(--border-color)' }}
|
||||
>
|
||||
<div className={`flex items-center gap-1 px-2 py-1 border-b overflow-x-auto [&::-webkit-scrollbar]:hidden ${isFullscreen ? 'bg-black/40 border-white/10' : 'bg-slate-100/80 dark:bg-gray-800/80 border-slate-200/30 dark:border-gray-700/50'}`}>
|
||||
{VISUAL_STYLES.map(s => (
|
||||
<button
|
||||
key={s.id}
|
||||
onClick={() => { setVisualStyle(s.id); localStorage.setItem('stemengine-lyric-visual-style', s.id) }}
|
||||
title={s.desc}
|
||||
className="lp-btn shrink-0 px-2.5 py-1.5 rounded-md text-xs font-medium transition-colors"
|
||||
style={visualStyle === s.id
|
||||
? { background: 'rgb(var(--brand-500, 59 130 246))', color: '#fff' }
|
||||
: { color: 'var(--foreground-muted)' }}
|
||||
className={`shrink-0 px-2.5 py-1.5 rounded-md text-xs font-medium transition-colors ${
|
||||
visualStyle === s.id
|
||||
? 'bg-brand-500 text-white'
|
||||
: 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'
|
||||
}`}
|
||||
>
|
||||
{s.label}
|
||||
</button>
|
||||
))}
|
||||
{hasElrc && (
|
||||
<span className="ml-2 shrink-0 text-[10px]" style={{ color: 'var(--foreground-muted)', opacity: 0.6 }}>ELRC</span>
|
||||
<span className="ml-2 shrink-0 text-[10px] text-slate-400 dark:text-gray-600">ELRC</span>
|
||||
)}
|
||||
<div className="ml-auto flex gap-0.5 shrink-0 pl-1">
|
||||
<button
|
||||
onClick={handleRecenter}
|
||||
title="Recenter active line"
|
||||
className="lp-btn p-1.5 rounded-md transition-colors"
|
||||
style={{ color: 'var(--foreground-muted)' }}
|
||||
className={`p-1.5 rounded-md transition-colors ${isFullscreen ? 'text-slate-400 hover:bg-white/10' : 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'}`}
|
||||
>
|
||||
<Crosshair className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setShowStylePicker(p => !p); setShowEditor(false) }}
|
||||
title="Style picker"
|
||||
className="lp-btn p-1.5 rounded-md transition-colors"
|
||||
style={showStylePicker
|
||||
? { background: 'rgb(var(--brand-500, 59 130 246))', color: '#fff' }
|
||||
: { color: 'var(--foreground-muted)' }}
|
||||
className={`p-1.5 rounded-md transition-colors ${showStylePicker ? 'bg-brand-500 text-white' : isFullscreen ? 'text-slate-400 hover:bg-white/10' : 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'}`}
|
||||
>
|
||||
<Palette className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setShowEditor(p => !p); setShowStylePicker(false); setShowAegisub(false) }}
|
||||
title="Edit timing / lyrics"
|
||||
className="lp-btn p-1.5 rounded-md transition-colors"
|
||||
style={showEditor
|
||||
? { background: 'rgb(var(--brand-500, 59 130 246))', color: '#fff' }
|
||||
: { color: 'var(--foreground-muted)' }}
|
||||
className={`p-1.5 rounded-md transition-colors ${showEditor ? 'bg-brand-500 text-white' : isFullscreen ? 'text-slate-400 hover:bg-white/10' : 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'}`}
|
||||
>
|
||||
<Pencil className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setShowAegisub(!showAegisub); setShowStylePicker(false); setShowEditor(false) }}
|
||||
title="Waveform editor"
|
||||
className="lp-btn p-1.5 rounded-md transition-colors"
|
||||
style={showAegisub
|
||||
? { background: 'rgb(var(--brand-500, 59 130 246))', color: '#fff' }
|
||||
: { color: 'var(--foreground-muted)' }}
|
||||
className={`p-1.5 rounded-md transition-colors ${showAegisub ? 'bg-brand-500 text-white' : isFullscreen ? 'text-slate-400 hover:bg-white/10' : 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'}`}
|
||||
>
|
||||
<Activity className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={toggleFullscreen}
|
||||
title={isFullscreen ? 'Exit fullscreen' : 'Fullscreen'}
|
||||
className="lp-btn p-1.5 rounded-md transition-colors"
|
||||
style={{ color: 'var(--foreground-muted)' }}
|
||||
className={`p-1.5 rounded-md transition-colors ${isFullscreen ? 'text-slate-400 hover:bg-white/10' : 'text-slate-500 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'}`}
|
||||
>
|
||||
{isFullscreen ? <Minimize2 className="w-3.5 h-3.5" /> : <Maximize2 className="w-3.5 h-3.5" />}
|
||||
</button>
|
||||
|
||||
@@ -20,30 +20,24 @@ const FILE_ICONS: Record<string, React.ElementType> = {
|
||||
|
||||
function FileIcon({ type }: { type?: string }) {
|
||||
const Icon = FILE_ICONS[type || ''] || File
|
||||
return <Icon style={{ width: 16, height: 16, opacity: 0.5, flexShrink: 0 }} />
|
||||
return <Icon className="w-4 h-4 text-slate-400" />
|
||||
}
|
||||
|
||||
export default function ResultFiles({ jobId, files }: Props) {
|
||||
if (!files.length) return null
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<div className="space-y-2">
|
||||
{files.map((f) => (
|
||||
<a
|
||||
key={f.name}
|
||||
href={downloadUrl(jobId, f.name)}
|
||||
download={f.name}
|
||||
className="button flat"
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 12,
|
||||
padding: '6px 12px', borderRadius: 6,
|
||||
border: '1px solid var(--border-color)',
|
||||
textDecoration: 'none', fontSize: 12,
|
||||
}}
|
||||
className="flex items-center gap-3 px-3 py-2 rounded-lg bg-slate-50 dark:bg-gray-800/50 border border-slate-200 dark:border-gray-700 hover:border-brand-400 dark:hover:border-brand-500 transition-colors group"
|
||||
>
|
||||
<FileIcon type={f.type} />
|
||||
<span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{f.name}</span>
|
||||
<Download style={{ width: 14, height: 14, flexShrink: 0, opacity: 0.5 }} />
|
||||
<span className="flex-1 text-xs text-slate-700 dark:text-gray-300 truncate">{f.name}</span>
|
||||
<Download className="w-3.5 h-3.5 text-slate-400 group-hover:text-brand-500 transition-colors" />
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
import { X, Sun, Moon, Monitor, Settings, ChevronRight } from 'lucide-react'
|
||||
import { useTheme } from '../context/ThemeContext'
|
||||
|
||||
@@ -9,7 +10,7 @@ interface Props {
|
||||
|
||||
export default function SettingsPanel({ isOpen, onClose, onOpenFullSettings }: Props) {
|
||||
const { theme, setTheme } = useTheme()
|
||||
|
||||
|
||||
const handleOpenFullSettings = () => {
|
||||
onClose()
|
||||
onOpenFullSettings?.()
|
||||
@@ -17,79 +18,78 @@ export default function SettingsPanel({ isOpen, onClose, onOpenFullSettings }: P
|
||||
|
||||
if (!isOpen) return null
|
||||
|
||||
const THEMES = [
|
||||
{ id: 'light' as const, icon: Sun, label: 'Light' },
|
||||
{ id: 'dark' as const, icon: Moon, label: 'Dark' },
|
||||
{ id: 'system'as const, icon: Monitor, label: 'System' },
|
||||
]
|
||||
|
||||
return (
|
||||
<div style={{ position: 'fixed', inset: 0, zIndex: 50, display: 'flex', alignItems: 'flex-start', justifyContent: 'center', paddingTop: 64 }}>
|
||||
{/* Backdrop */}
|
||||
<div style={{ position: 'absolute', inset: 0, background: 'rgba(0,0,0,0.5)' }} onClick={onClose} />
|
||||
|
||||
{/* Panel */}
|
||||
<div style={{ position: 'relative', width: '100%', maxWidth: 420, margin: '0 16px', borderRadius: 12, border: '1px solid var(--border-color)', background: 'var(--body-background, var(--background))', boxShadow: '0 8px 32px rgba(0,0,0,0.2)' }}>
|
||||
|
||||
{/* Header */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '10px 16px', borderBottom: '1px solid var(--border-color)' }}>
|
||||
<h2 style={{ margin: 0, fontSize: 13, fontWeight: 600 }}>Settings</h2>
|
||||
<div className="fixed inset-0 z-50 flex items-start justify-center pt-16">
|
||||
<div className="absolute inset-0 bg-black/50" onClick={onClose} />
|
||||
<div className="relative w-full max-w-md mx-4 rounded-xl bg-white dark:bg-gray-900 shadow-2xl border border-slate-200 dark:border-gray-800">
|
||||
<div className="flex items-center justify-between px-4 py-3 border-b border-slate-200 dark:border-gray-800">
|
||||
<h2 className="text-sm font-semibold text-slate-900 dark:text-white">Settings</h2>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="button cycle flat"
|
||||
style={{ padding: 4, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
||||
className="p-1 rounded text-slate-400 hover:text-slate-600 dark:text-gray-500 dark:hover:text-gray-300"
|
||||
>
|
||||
<X style={{ width: 16, height: 16 }} />
|
||||
<X className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div style={{ padding: 16, display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
<div className="p-4 space-y-4">
|
||||
{/* Theme */}
|
||||
<div>
|
||||
<label style={{ display: 'block', marginBottom: 8, fontSize: 10, fontWeight: 600, opacity: 0.5, textTransform: 'uppercase', letterSpacing: '0.08em' }}>
|
||||
<label className="text-xs font-medium text-slate-500 dark:text-gray-400 uppercase tracking-wider block mb-2">
|
||||
Theme
|
||||
</label>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
{THEMES.map(({ id, icon: Icon, label }) => {
|
||||
const isActive = theme === id
|
||||
return (
|
||||
<button
|
||||
key={id}
|
||||
onClick={() => setTheme(id)}
|
||||
style={{
|
||||
display: 'inline-flex', alignItems: 'center', gap: 6,
|
||||
padding: '6px 12px', borderRadius: 6, fontSize: 12, fontWeight: 500,
|
||||
border: `1px solid ${isActive ? 'rgb(var(--brand-500, 59 130 246))' : 'var(--border-color)'}`,
|
||||
background: isActive ? 'rgba(var(--brand-500, 59 130 246), 0.1)' : 'transparent',
|
||||
color: isActive ? 'rgb(var(--brand-500, 59 130 246))' : 'inherit',
|
||||
cursor: 'pointer', transition: 'border-color 0.15s, background 0.15s',
|
||||
}}
|
||||
>
|
||||
<Icon style={{ width: 14, height: 14 }} />
|
||||
{label}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
onClick={() => setTheme('light')}
|
||||
className={`flex items-center gap-2 px-3 py-2 rounded-lg border text-xs font-medium transition-colors ${
|
||||
theme === 'light'
|
||||
? 'bg-brand-50 dark:bg-brand-950/30 border-brand-400 text-brand-600 dark:text-brand-400'
|
||||
: 'bg-white dark:bg-gray-800 border-slate-200 dark:border-gray-700 text-slate-600 dark:text-gray-400 hover:border-brand-400'
|
||||
}`}
|
||||
>
|
||||
<Sun className="w-3.5 h-3.5" />
|
||||
Light
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setTheme('dark')}
|
||||
className={`flex items-center gap-2 px-3 py-2 rounded-lg border text-xs font-medium transition-colors ${
|
||||
theme === 'dark'
|
||||
? 'bg-brand-50 dark:bg-brand-950/30 border-brand-400 text-brand-600 dark:text-brand-400'
|
||||
: 'bg-white dark:bg-gray-800 border-slate-200 dark:border-gray-700 text-slate-600 dark:text-gray-400 hover:border-brand-400'
|
||||
}`}
|
||||
>
|
||||
<Moon className="w-3.5 h-3.5" />
|
||||
Dark
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setTheme('system')}
|
||||
className={`flex items-center gap-2 px-3 py-2 rounded-lg border text-xs font-medium transition-colors ${
|
||||
theme === 'system'
|
||||
? 'bg-brand-50 dark:bg-brand-950/30 border-brand-400 text-brand-600 dark:text-brand-400'
|
||||
: 'bg-white dark:bg-gray-800 border-slate-200 dark:border-gray-700 text-slate-600 dark:text-gray-400 hover:border-brand-400'
|
||||
}`}
|
||||
>
|
||||
<Monitor className="w-3.5 h-3.5" />
|
||||
System
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Full Settings link */}
|
||||
<div style={{ borderTop: '1px solid var(--border-color)', paddingTop: 16, display: 'flex', flexDirection: 'column', gap: 6 }}>
|
||||
|
||||
{/* Divider */}
|
||||
<div className="border-t border-slate-200 dark:border-gray-800 pt-4">
|
||||
<button
|
||||
onClick={handleOpenFullSettings}
|
||||
style={{
|
||||
width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
||||
padding: 12, borderRadius: 8, border: '1px solid var(--border-color)',
|
||||
background: 'transparent', cursor: 'pointer',
|
||||
}}
|
||||
className="w-full flex items-center justify-between p-3 rounded-lg bg-slate-50 dark:bg-gray-800 hover:bg-slate-100 dark:hover:bg-gray-750 transition-colors group"
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<Settings style={{ width: 16, height: 16, opacity: 0.6, flexShrink: 0 }} />
|
||||
<span style={{ fontSize: 13, fontWeight: 500 }}>Full Settings</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<Settings className="w-4 h-4 text-slate-500 dark:text-gray-400" />
|
||||
<span className="text-sm font-medium text-slate-700 dark:text-gray-300">
|
||||
Full Settings
|
||||
</span>
|
||||
</div>
|
||||
<ChevronRight style={{ width: 16, height: 16, opacity: 0.4 }} />
|
||||
<ChevronRight className="w-4 h-4 text-slate-400 group-hover:text-slate-600 dark:group-hover:text-gray-300 transition-colors" />
|
||||
</button>
|
||||
<p style={{ margin: 0, fontSize: 11, opacity: 0.5, padding: '0 4px' }}>
|
||||
<p className="mt-1.5 text-xs text-slate-400 dark:text-gray-500 px-1">
|
||||
Configure Subsonic integration, manage AI models, and more.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
+144
-330
@@ -1,11 +1,3 @@
|
||||
/**
|
||||
* Sidebar.tsx — Phase 2 MetroUI migration
|
||||
*
|
||||
* All business logic (state, queries, handlers) unchanged from Phase 1.
|
||||
* Tailwind classes replaced with MetroUI CSS + inline styles.
|
||||
* Accordion sections managed with React state (no data-role, avoids Metro JS
|
||||
* conflicts with React's virtual DOM).
|
||||
*/
|
||||
import React, { useState, useRef, useMemo } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
@@ -27,13 +19,13 @@ import AutoPipelineDialog from './AutoPipelineDialog'
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const JOB_DOT_COLORS: Record<string, string> = {
|
||||
separate: 'var(--color-blue)',
|
||||
transcribe: 'var(--color-violet)',
|
||||
'abc-convert': 'var(--color-green)',
|
||||
pipeline: 'var(--color-red)',
|
||||
lrc_align: 'var(--color-amber)',
|
||||
mix: 'var(--color-blue)',
|
||||
const JOB_COLORS: Record<string, string> = {
|
||||
separate: 'text-brand-500',
|
||||
transcribe: 'text-purple-500',
|
||||
'abc-convert': 'text-emerald-500',
|
||||
pipeline: 'text-rose-500',
|
||||
lrc_align: 'text-amber-500',
|
||||
mix: 'text-brand-500',
|
||||
}
|
||||
|
||||
const JOB_ICONS: Record<string, React.ElementType> = {
|
||||
@@ -45,22 +37,13 @@ const JOB_ICONS: Record<string, React.ElementType> = {
|
||||
mix: Music2,
|
||||
}
|
||||
|
||||
const STATUS_ICON_COLOR: Record<Job['status'], string> = {
|
||||
running: 'var(--color-blue)',
|
||||
queued: 'var(--color-amber)',
|
||||
done: 'var(--color-green)',
|
||||
error: 'var(--color-red)',
|
||||
cancelled: 'var(--color-gray)',
|
||||
}
|
||||
|
||||
function StatusDot({ status }: { status: Job['status'] }) {
|
||||
const color = STATUS_ICON_COLOR[status] ?? 'var(--color-gray)'
|
||||
switch (status) {
|
||||
case 'running': return <Loader2 size={12} style={{ color, flexShrink: 0, animation: 'spin 1s linear infinite' }} />
|
||||
case 'queued': return <Clock size={12} style={{ color, flexShrink: 0 }} />
|
||||
case 'done': return <CheckCircle size={12} style={{ color, flexShrink: 0 }} />
|
||||
case 'error': return <XCircle size={12} style={{ color, flexShrink: 0 }} />
|
||||
case 'cancelled': return <AlertCircle size={12} style={{ color, flexShrink: 0 }} />
|
||||
case 'running': return <Loader2 className="w-3 h-3 text-brand-400 animate-spin shrink-0" />
|
||||
case 'queued': return <Clock className="w-3 h-3 text-amber-400 shrink-0" />
|
||||
case 'done': return <CheckCircle className="w-3 h-3 text-emerald-400 shrink-0" />
|
||||
case 'error': return <XCircle className="w-3 h-3 text-red-400 shrink-0" />
|
||||
case 'cancelled': return <AlertCircle className="w-3 h-3 text-gray-400 shrink-0" />
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,17 +58,6 @@ function timeSince(iso: string | null): string {
|
||||
return `${Math.floor(h / 24)}d ago`
|
||||
}
|
||||
|
||||
// Shared section-header style (accordion trigger row)
|
||||
const sectionHeaderStyle: React.CSSProperties = {
|
||||
display: 'flex', alignItems: 'center', gap: 6,
|
||||
padding: '6px 10px',
|
||||
cursor: 'pointer', userSelect: 'none',
|
||||
borderBottom: '1px solid var(--border-color)',
|
||||
fontSize: 11, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase',
|
||||
width: '100%', background: 'none', border: 'none', textAlign: 'left',
|
||||
color: 'var(--label-color)',
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Active job item (with cancel)
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -93,7 +65,7 @@ const sectionHeaderStyle: React.CSSProperties = {
|
||||
function ActiveJobItem({ job, onCancelled }: { job: Job; onCancelled: () => void }) {
|
||||
const [cancelling, setCancelling] = useState(false)
|
||||
const Icon = JOB_ICONS[job.job_type] ?? FolderOpen
|
||||
const dotColor = JOB_DOT_COLORS[job.job_type] ?? 'var(--color-gray)'
|
||||
const colorCls = JOB_COLORS[job.job_type] ?? 'text-gray-400'
|
||||
|
||||
async function handleCancel(e: React.MouseEvent) {
|
||||
e.stopPropagation()
|
||||
@@ -104,22 +76,14 @@ function ActiveJobItem({ job, onCancelled }: { job: Job; onCancelled: () => void
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex', alignItems: 'center', gap: 8,
|
||||
padding: '6px 10px',
|
||||
borderRadius: 6, marginBottom: 4,
|
||||
background: 'var(--background)',
|
||||
border: '1px solid var(--border-color)',
|
||||
}}>
|
||||
<Icon size={13} style={{ color: dotColor, flexShrink: 0 }} />
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 500, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
<div className="flex items-center gap-2 px-3 py-2 rounded-lg bg-slate-50 dark:bg-gray-800/60 border border-slate-200 dark:border-gray-700/50">
|
||||
<Icon className={`w-3.5 h-3.5 shrink-0 ${colorCls}`} />
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-slate-700 dark:text-gray-200 truncate">
|
||||
{job.job_type.replace('-', ' ').replace('_', ' ')}
|
||||
</div>
|
||||
</p>
|
||||
{job.progress && (
|
||||
<div style={{ fontSize: 10, opacity: 0.55, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{job.progress}
|
||||
</div>
|
||||
<p className="text-xs text-slate-400 dark:text-gray-500 truncate leading-tight">{job.progress}</p>
|
||||
)}
|
||||
</div>
|
||||
<StatusDot status={job.status} />
|
||||
@@ -127,22 +91,19 @@ function ActiveJobItem({ job, onCancelled }: { job: Job; onCancelled: () => void
|
||||
onClick={handleCancel}
|
||||
disabled={cancelling}
|
||||
title="Cancel"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3, flexShrink: 0 }}
|
||||
className="p-1 rounded text-slate-300 hover:text-red-400 dark:text-gray-600 dark:hover:text-red-400 transition-colors shrink-0"
|
||||
>
|
||||
{cancelling
|
||||
? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} />
|
||||
: <X size={11} />}
|
||||
{cancelling ? <Loader2 className="w-3 h-3 animate-spin" /> : <X className="w-3 h-3" />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Project tile
|
||||
// Project item
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function ProjectTile({
|
||||
function ProjectItem({
|
||||
project,
|
||||
isOpen,
|
||||
onOpen,
|
||||
@@ -154,7 +115,6 @@ function ProjectTile({
|
||||
onDeleted: () => void
|
||||
}) {
|
||||
const [deleting, setDeleting] = useState(false)
|
||||
const [hovered, setHovered] = useState(false)
|
||||
|
||||
async function handleDelete(e: React.MouseEvent) {
|
||||
e.stopPropagation()
|
||||
@@ -165,50 +125,30 @@ function ProjectTile({
|
||||
onDeleted()
|
||||
}
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={onOpen}
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 8,
|
||||
padding: '7px 10px',
|
||||
borderRadius: 6, marginBottom: 3, cursor: 'pointer',
|
||||
border: `1px solid ${isOpen ? accentColor : 'var(--border-color)'}`,
|
||||
background: isOpen
|
||||
? `rgba(var(--brand-500, 59 130 246), 0.08)`
|
||||
: hovered ? 'var(--background)' : 'transparent',
|
||||
transition: 'background 0.15s, border-color 0.15s',
|
||||
}}
|
||||
className={`group w-full flex items-center gap-2 px-3 py-2 rounded-lg border text-left transition-colors cursor-pointer ${
|
||||
isOpen
|
||||
? 'border-brand-400/50 bg-brand-50 dark:bg-brand-950/20 text-brand-700 dark:text-brand-300'
|
||||
: 'border-slate-200 dark:border-gray-700/60 hover:bg-slate-50 dark:hover:bg-gray-800/50 hover:border-brand-400/50'
|
||||
}`}
|
||||
>
|
||||
<Music2 size={13} style={{ color: accentColor, flexShrink: 0 }} />
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{
|
||||
fontSize: 12, fontWeight: 500,
|
||||
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
|
||||
color: isOpen ? accentColor : undefined,
|
||||
}}>
|
||||
{project.name}
|
||||
</div>
|
||||
<Music2 className="w-3.5 h-3.5 shrink-0 text-brand-500" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-slate-700 dark:text-gray-200 truncate">{project.name}</p>
|
||||
{project.tab_label && (
|
||||
<div style={{ fontSize: 10, color: accentColor, opacity: 0.8, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{project.tab_label}
|
||||
</div>
|
||||
<p className="text-[10px] text-brand-500 dark:text-brand-400 truncate leading-tight">{project.tab_label}</p>
|
||||
)}
|
||||
<div style={{ fontSize: 10, opacity: 0.45 }}>{timeSince(project.created_at)}</div>
|
||||
<p className="text-[10px] text-slate-400 dark:text-gray-500">{timeSince(project.created_at)}</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
disabled={deleting}
|
||||
title="Delete project"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3, flexShrink: 0, opacity: hovered ? 1 : 0, transition: 'opacity 0.15s' }}
|
||||
className="shrink-0 p-1 rounded text-slate-300 dark:text-gray-600 hover:text-red-500 dark:hover:text-red-400 transition-colors opacity-0 group-hover:opacity-100"
|
||||
>
|
||||
{deleting
|
||||
? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} />
|
||||
: <Trash2 size={11} />}
|
||||
{deleting ? <Loader2 className="w-3 h-3 animate-spin" /> : <Trash2 className="w-3 h-3" />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
@@ -283,98 +223,79 @@ function SubsonicPanel() {
|
||||
finally { setDeletingFile(null) }
|
||||
}
|
||||
|
||||
const skyColor = 'var(--color-blue, #0ea5e9)'
|
||||
|
||||
return (
|
||||
<div style={{ borderBottom: '1px solid var(--border-color)' }}>
|
||||
{/* Accordion header */}
|
||||
<div className="border-b border-slate-200 dark:border-gray-800">
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
style={{ ...sectionHeaderStyle, color: skyColor }}
|
||||
className="w-full flex items-center gap-2 px-3 py-2.5 text-left hover:bg-slate-100 dark:hover:bg-gray-900/50 transition-colors"
|
||||
>
|
||||
<Radio size={13} style={{ color: skyColor, flexShrink: 0 }} />
|
||||
<span style={{ flex: 1 }}>Subsonic Import</span>
|
||||
<Radio className="w-3.5 h-3.5 text-sky-500 shrink-0" />
|
||||
<span className="text-xs font-bold uppercase tracking-widest text-sky-500 flex-1">Subsonic Import</span>
|
||||
{open
|
||||
? <ChevronUp size={11} style={{ opacity: 0.5 }} />
|
||||
: <ChevronDown size={11} style={{ opacity: 0.5 }} />}
|
||||
? <ChevronUp className="w-3 h-3 text-slate-400 shrink-0" />
|
||||
: <ChevronDown className="w-3 h-3 text-slate-400 shrink-0" />}
|
||||
</button>
|
||||
|
||||
{open && (
|
||||
<div style={{ padding: '8px 10px 10px' }}>
|
||||
{/* Search row */}
|
||||
<div style={{ display: 'flex', gap: 6, marginBottom: 6 }}>
|
||||
<div className="px-3 pb-3 space-y-2">
|
||||
{/* Search input */}
|
||||
<div className="flex gap-1.5">
|
||||
<input
|
||||
ref={inputRef}
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && doSearch()}
|
||||
placeholder="Search songs…"
|
||||
style={{
|
||||
flex: 1, padding: '5px 8px', fontSize: 12, borderRadius: 4,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--input-background, var(--background))',
|
||||
color: 'inherit', outline: 'none',
|
||||
}}
|
||||
className="flex-1 rounded-md bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 placeholder-slate-400 focus:border-sky-400 focus:outline-none"
|
||||
/>
|
||||
<button
|
||||
onClick={doSearch}
|
||||
disabled={searching || !query.trim()}
|
||||
className="button"
|
||||
style={{ background: skyColor, color: '#fff', padding: '5px 10px', borderRadius: 4, border: 'none', flexShrink: 0 }}
|
||||
className="rounded-md bg-sky-500 hover:bg-sky-400 disabled:bg-slate-200 dark:disabled:bg-gray-800 disabled:text-slate-400 px-2.5 py-1.5 text-xs font-medium text-white transition-colors shrink-0"
|
||||
>
|
||||
{searching
|
||||
? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} />
|
||||
: <Search size={11} />}
|
||||
{searching ? <Loader2 className="w-3 h-3 animate-spin" /> : <Search className="w-3 h-3" />}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Error messages */}
|
||||
{searchErr && <p style={{ fontSize: 11, color: 'var(--color-red)', marginBottom: 4 }}>{searchErr}</p>}
|
||||
{importErr && <p style={{ fontSize: 11, color: 'var(--color-red)', marginBottom: 4, wordBreak: 'break-all' }}>{importErr}</p>}
|
||||
{/* Errors */}
|
||||
{searchErr && <p className="text-xs text-red-500 dark:text-red-400">{searchErr}</p>}
|
||||
{importErr && <p className="text-xs text-red-500 dark:text-red-400 break-all">{importErr}</p>}
|
||||
|
||||
{/* Search results */}
|
||||
{results.length > 0 && (
|
||||
<div style={{ maxHeight: 200, overflowY: 'auto', marginBottom: 6 }}>
|
||||
<div className="space-y-1 max-h-52 overflow-y-auto pr-0.5">
|
||||
{results.map((song) => {
|
||||
const done = importedIds.has(song.id)
|
||||
const busy = importing === song.id
|
||||
return (
|
||||
<div
|
||||
key={song.id}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'flex-start', gap: 8,
|
||||
padding: '7px 8px', marginBottom: 3, borderRadius: 5,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--background)',
|
||||
}}
|
||||
className="flex items-start gap-2 rounded-lg border border-slate-200 dark:border-gray-700/60 bg-white dark:bg-gray-900/50 px-2.5 py-2"
|
||||
>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 500, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-slate-700 dark:text-gray-200 truncate leading-tight">
|
||||
{song.title}
|
||||
</div>
|
||||
</p>
|
||||
{song.artist && (
|
||||
<div style={{ fontSize: 10, opacity: 0.55, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
<p className="text-[10px] text-slate-400 dark:text-gray-500 truncate leading-tight">
|
||||
{song.artist}{song.album ? ` · ${song.album}` : ''}
|
||||
</div>
|
||||
</p>
|
||||
)}
|
||||
<div style={{ fontSize: 10, opacity: 0.4 }}>
|
||||
{song.duration ? formatDuration(song.duration) : ''}
|
||||
{song.bitRate ? ` · ${song.bitRate} kbps` : ''}
|
||||
{song.suffix ? ` · ${song.suffix.toUpperCase()}` : ''}
|
||||
</div>
|
||||
<p className="text-[10px] text-slate-400 dark:text-gray-600 mt-0.5">
|
||||
{song.duration ? formatDuration(song.duration) : ''}{song.bitRate ? ` · ${song.bitRate} kbps` : ''}{song.suffix ? ` · ${song.suffix.toUpperCase()}` : ''}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => doImport(song)}
|
||||
disabled={busy || done}
|
||||
title={done ? 'Imported' : 'Import'}
|
||||
className="button cycle flat"
|
||||
style={{ flexShrink: 0, padding: 5 }}
|
||||
className="shrink-0 p-1.5 rounded-md border border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-800 hover:border-sky-400 hover:text-sky-500 disabled:opacity-60 transition-colors"
|
||||
>
|
||||
{busy
|
||||
? <Loader2 size={11} style={{ color: skyColor, animation: 'spin 1s linear infinite' }} />
|
||||
? <Loader2 className="w-3 h-3 animate-spin text-sky-400" />
|
||||
: done
|
||||
? <CheckCircle2 size={11} style={{ color: 'var(--color-green)' }} />
|
||||
: <Download size={11} />}
|
||||
? <CheckCircle2 className="w-3 h-3 text-emerald-500" />
|
||||
: <Download className="w-3 h-3 text-slate-500 dark:text-gray-400" />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
@@ -382,26 +303,40 @@ function SubsonicPanel() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Imported files */}
|
||||
{/* Imported files list */}
|
||||
{importedFiles.length > 0 && (
|
||||
<div>
|
||||
<div style={{
|
||||
fontSize: 10, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase',
|
||||
opacity: 0.45, marginBottom: 4,
|
||||
}}>
|
||||
Imported Files
|
||||
</div>
|
||||
<div style={{ maxHeight: 160, overflowY: 'auto' }}>
|
||||
<p className="text-[10px] font-bold uppercase tracking-widest text-slate-400 dark:text-gray-600 mb-1">Imported Files</p>
|
||||
<div className="space-y-1 max-h-40 overflow-y-auto">
|
||||
{importedFiles.map((f) => {
|
||||
const isDeleting = deletingFile === f.filename
|
||||
return (
|
||||
<ImportedFileRow
|
||||
<div
|
||||
key={f.path}
|
||||
file={f}
|
||||
isDeleting={isDeleting}
|
||||
onDelete={() => doDeleteImport(f.filename)}
|
||||
onAutoPipeline={() => setAutoTarget(f)}
|
||||
/>
|
||||
className="group flex items-center gap-2 rounded-lg border border-slate-200 dark:border-gray-700/60 bg-white dark:bg-gray-900/50 px-2.5 py-1.5"
|
||||
>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-slate-700 dark:text-gray-200 truncate">{f.filename}</p>
|
||||
<p className="text-[10px] text-slate-400 dark:text-gray-500">{(f.size / 1024 / 1024).toFixed(1)} MB</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setAutoTarget(f)}
|
||||
title="Auto pipeline"
|
||||
className="shrink-0 p-1 rounded text-slate-300 dark:text-gray-600 hover:text-amber-500 dark:hover:text-amber-400 transition-colors opacity-0 group-hover:opacity-100"
|
||||
>
|
||||
<Zap className="w-3 h-3" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => doDeleteImport(f.filename)}
|
||||
disabled={isDeleting}
|
||||
title="Delete import"
|
||||
className="shrink-0 p-1 rounded text-slate-300 dark:text-gray-600 hover:text-red-500 dark:hover:text-red-400 transition-colors opacity-0 group-hover:opacity-100"
|
||||
>
|
||||
{isDeleting
|
||||
? <Loader2 className="w-3 h-3 animate-spin" />
|
||||
: <Trash2 className="w-3 h-3" />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
@@ -426,55 +361,6 @@ function SubsonicPanel() {
|
||||
)
|
||||
}
|
||||
|
||||
function ImportedFileRow({
|
||||
file, isDeleting, onDelete, onAutoPipeline,
|
||||
}: {
|
||||
file: ImportedFile
|
||||
isDeleting: boolean
|
||||
onDelete: () => void
|
||||
onAutoPipeline: () => void
|
||||
}) {
|
||||
const [hovered, setHovered] = useState(false)
|
||||
return (
|
||||
<div
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 6,
|
||||
padding: '5px 8px', marginBottom: 3, borderRadius: 5,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--background)',
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 500, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{file.filename}
|
||||
</div>
|
||||
<div style={{ fontSize: 10, opacity: 0.45 }}>{(file.size / 1024 / 1024).toFixed(1)} MB</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={onAutoPipeline}
|
||||
title="Auto pipeline"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3, flexShrink: 0, opacity: hovered ? 1 : 0, transition: 'opacity 0.15s', color: 'var(--color-amber)' }}
|
||||
>
|
||||
<Zap size={11} />
|
||||
</button>
|
||||
<button
|
||||
onClick={onDelete}
|
||||
disabled={isDeleting}
|
||||
title="Delete import"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3, flexShrink: 0, opacity: hovered ? 1 : 0, transition: 'opacity 0.15s', color: 'var(--color-red)' }}
|
||||
>
|
||||
{isDeleting
|
||||
? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} />
|
||||
: <Trash2 size={11} />}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Sidebar
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -490,7 +376,6 @@ interface Props {
|
||||
export default function Sidebar({ isOpen, onToggle, onOpenProject, onDeleteProject, openTabIds }: Props) {
|
||||
const queryClient = useQueryClient()
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
const [jobsOpen, setJobsOpen] = useState(true)
|
||||
|
||||
const { data: jobs = [] } = useQuery({
|
||||
queryKey: ['jobs'],
|
||||
@@ -504,12 +389,13 @@ export default function Sidebar({ isOpen, onToggle, onOpenProject, onDeleteProje
|
||||
refetchInterval: 8000,
|
||||
})
|
||||
|
||||
// Filter projects based on search query
|
||||
const filteredProjects = useMemo(() => {
|
||||
if (!searchQuery.trim()) return projects
|
||||
const q = searchQuery.toLowerCase()
|
||||
return projects.filter(p =>
|
||||
p.name.toLowerCase().includes(q) ||
|
||||
p.tab_label.toLowerCase().includes(q)
|
||||
const query = searchQuery.toLowerCase()
|
||||
return projects.filter(p =>
|
||||
p.name.toLowerCase().includes(query) ||
|
||||
p.tab_label.toLowerCase().includes(query)
|
||||
)
|
||||
}, [projects, searchQuery])
|
||||
|
||||
@@ -517,184 +403,112 @@ export default function Sidebar({ isOpen, onToggle, onOpenProject, onDeleteProje
|
||||
|
||||
function invalidate() { queryClient.invalidateQueries({ queryKey: ['jobs'] }) }
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
|
||||
return (
|
||||
<aside
|
||||
className={isOpen ? 'sidebar-open' : 'sidebar-closed'}
|
||||
style={{
|
||||
position: 'relative',
|
||||
flexShrink: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
borderRight: '1px solid var(--border-color)',
|
||||
background: 'var(--sidebar-background, var(--body-background))',
|
||||
transition: 'width 0.2s ease-in-out',
|
||||
overflow: 'visible',
|
||||
}}
|
||||
className={`relative flex-shrink-0 flex flex-col border-r border-slate-200 dark:border-gray-800 bg-slate-50 dark:bg-gray-950 transition-all duration-200 ease-in-out ${
|
||||
isOpen ? 'sidebar-open' : 'sidebar-closed'
|
||||
}`}
|
||||
>
|
||||
{/* Toggle tab — always visible */}
|
||||
<button
|
||||
onClick={onToggle}
|
||||
title={isOpen ? 'Collapse sidebar' : 'Expand sidebar'}
|
||||
className="button cycle flat"
|
||||
style={{
|
||||
position: 'absolute', right: -14, top: 24, zIndex: 10,
|
||||
width: 28, height: 28, borderRadius: '50%',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
padding: 0,
|
||||
background: 'var(--body-background)',
|
||||
border: '1px solid var(--border-color)',
|
||||
boxShadow: '0 1px 3px rgba(0,0,0,0.12)',
|
||||
}}
|
||||
className={`absolute -right-3.5 top-6 z-10 flex items-center justify-center w-7 h-7 rounded-full bg-white dark:bg-gray-800 border border-slate-200 dark:border-gray-700 shadow-sm text-slate-400 hover:text-brand-500 dark:text-gray-500 dark:hover:text-brand-400 transition-colors`}
|
||||
>
|
||||
{isOpen
|
||||
? <ChevronLeft size={14} />
|
||||
: <ChevronRight size={14} />}
|
||||
{isOpen ? <ChevronLeft className="w-4 h-4" /> : <ChevronRight className="w-4 h-4" />}
|
||||
</button>
|
||||
|
||||
{/* ── Collapsed indicator strip ──────────────────────────────────────── */}
|
||||
{/* Collapsed indicator strip */}
|
||||
{!isOpen && (
|
||||
<div style={{ overflow: 'hidden', flex: 1 }}>
|
||||
<div style={{
|
||||
display: 'flex', flexDirection: 'column', alignItems: 'center',
|
||||
gap: 12, paddingTop: 64, paddingLeft: 8, paddingRight: 8,
|
||||
}}>
|
||||
<div className="flex flex-col items-center gap-3 pt-16 px-2">
|
||||
{activeJobs.length > 0 && (
|
||||
<div style={{ position: 'relative' }}>
|
||||
<Loader2 size={18} style={{ color: accentColor, animation: 'spin 1s linear infinite' }} />
|
||||
<span style={{
|
||||
position: 'absolute', top: -4, right: -4,
|
||||
width: 14, height: 14, borderRadius: '50%',
|
||||
background: accentColor, color: '#fff',
|
||||
fontSize: 9, fontWeight: 700,
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
}}>
|
||||
<div className="relative">
|
||||
<Loader2 className="w-5 h-5 text-brand-400 animate-spin" />
|
||||
<span className="absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full bg-brand-500 text-white text-[9px] flex items-center justify-center font-bold">
|
||||
{activeJobs.length}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<Radio size={18} style={{ opacity: 0.35 }} />
|
||||
<Radio className="w-5 h-5 text-slate-400 dark:text-gray-600" />
|
||||
{projects.length > 0 && (
|
||||
<div style={{ position: 'relative' }}>
|
||||
<FolderOpen size={18} style={{ opacity: 0.35 }} />
|
||||
<span style={{
|
||||
position: 'absolute', top: -4, right: -4,
|
||||
width: 14, height: 14, borderRadius: '50%',
|
||||
background: 'var(--color-gray, #64748b)', color: '#fff',
|
||||
fontSize: 9, fontWeight: 700,
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
}}>
|
||||
<div className="relative">
|
||||
<FolderOpen className="w-5 h-5 text-slate-400 dark:text-gray-600" />
|
||||
<span className="absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full bg-slate-400 dark:bg-gray-600 text-white text-[9px] flex items-center justify-center font-bold">
|
||||
{projects.length}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Expanded content ───────────────────────────────────────────────── */}
|
||||
{/* Expanded content */}
|
||||
{isOpen && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', flex: 1, overflow: 'hidden' }}>
|
||||
|
||||
{/* Active jobs accordion */}
|
||||
<div style={{ borderBottom: '1px solid var(--border-color)' }}>
|
||||
<button
|
||||
onClick={() => setJobsOpen((v) => !v)}
|
||||
style={{ ...sectionHeaderStyle, color: 'var(--color-amber, #f59e0b)', borderBottom: 'none' }}
|
||||
>
|
||||
<span style={{ flex: 1 }}>In Progress</span>
|
||||
<div className="flex flex-col flex-1 overflow-hidden">
|
||||
{/* Active jobs */}
|
||||
<div className="p-3 border-b border-slate-200 dark:border-gray-800">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<span className="text-xs font-bold uppercase tracking-widest text-amber-500">
|
||||
In Progress
|
||||
</span>
|
||||
{activeJobs.length > 0 && (
|
||||
<span style={{
|
||||
background: 'var(--color-amber, #f59e0b)', color: '#fff',
|
||||
fontSize: 10, fontWeight: 700, borderRadius: 10,
|
||||
padding: '1px 6px',
|
||||
}}>
|
||||
<span className="ml-auto text-xs bg-amber-500 text-white px-1.5 py-0.5 rounded-full font-bold">
|
||||
{activeJobs.length}
|
||||
</span>
|
||||
)}
|
||||
{jobsOpen
|
||||
? <ChevronUp size={11} style={{ opacity: 0.5, marginLeft: 4 }} />
|
||||
: <ChevronDown size={11} style={{ opacity: 0.5, marginLeft: 4 }} />}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{jobsOpen && (
|
||||
<div style={{ padding: '4px 8px 8px' }}>
|
||||
{activeJobs.length === 0 ? (
|
||||
<p style={{ fontSize: 11, opacity: 0.4, fontStyle: 'italic', textAlign: 'center', padding: '6px 0' }}>
|
||||
No active jobs
|
||||
</p>
|
||||
) : (
|
||||
activeJobs.map((job) => (
|
||||
<ActiveJobItem key={job.id} job={job} onCancelled={invalidate} />
|
||||
))
|
||||
)}
|
||||
{activeJobs.length === 0 ? (
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic text-center py-2">No active jobs</p>
|
||||
) : (
|
||||
<div className="space-y-1.5">
|
||||
{activeJobs.map((job) => (
|
||||
<ActiveJobItem key={job.id} job={job} onCancelled={invalidate} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Subsonic import accordion */}
|
||||
{/* Subsonic import */}
|
||||
<SubsonicPanel />
|
||||
|
||||
{/* Projects list */}
|
||||
<div style={{ flex: 1, overflowY: 'auto', padding: '8px 8px 8px' }}>
|
||||
{/* Section header */}
|
||||
<div style={{
|
||||
display: 'flex', alignItems: 'center', gap: 6,
|
||||
marginBottom: 6, paddingLeft: 2,
|
||||
}}>
|
||||
<span style={{
|
||||
fontSize: 11, fontWeight: 700, letterSpacing: '0.08em',
|
||||
textTransform: 'uppercase', color: accentColor,
|
||||
}}>
|
||||
Projects
|
||||
</span>
|
||||
{/* Projects */}
|
||||
<div className="flex-1 overflow-y-auto p-3 space-y-1.5">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<span className="text-xs font-bold uppercase tracking-widest text-brand-500">Projects</span>
|
||||
{projects.length > 0 && (
|
||||
<span style={{ marginLeft: 'auto', fontSize: 10, opacity: 0.45 }}>
|
||||
<span className="ml-auto text-xs text-slate-400 dark:text-gray-600">
|
||||
{filteredProjects.length}/{projects.length}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Search input */}
|
||||
<div style={{ position: 'relative', marginBottom: 8 }}>
|
||||
<Search size={11} style={{
|
||||
position: 'absolute', left: 8, top: '50%', transform: 'translateY(-50%)',
|
||||
opacity: 0.4, pointerEvents: 'none',
|
||||
}} />
|
||||
{/* Search box for projects */}
|
||||
<div className="relative mb-2">
|
||||
<Search className="absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-slate-400" />
|
||||
<input
|
||||
type="text"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
placeholder="Search projects…"
|
||||
style={{
|
||||
width: '100%', padding: '5px 28px 5px 26px', fontSize: 12, borderRadius: 5,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--input-background, var(--background))',
|
||||
color: 'inherit', outline: 'none', boxSizing: 'border-box',
|
||||
}}
|
||||
placeholder="Search projects..."
|
||||
className="w-full rounded-md bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 pl-7 pr-2 py-1.5 text-xs text-slate-900 dark:text-gray-100 placeholder-slate-400 focus:border-brand-400 focus:outline-none"
|
||||
/>
|
||||
{searchQuery && (
|
||||
<button
|
||||
onClick={() => setSearchQuery('')}
|
||||
style={{
|
||||
position: 'absolute', right: 6, top: '50%', transform: 'translateY(-50%)',
|
||||
background: 'none', border: 'none', cursor: 'pointer', opacity: 0.45, padding: 2,
|
||||
}}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600"
|
||||
>
|
||||
<X size={10} />
|
||||
<X className="w-3 h-3" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Project items */}
|
||||
{filteredProjects.length === 0 ? (
|
||||
<p style={{ fontSize: 11, opacity: 0.4, fontStyle: 'italic', textAlign: 'center', padding: '12px 0' }}>
|
||||
{searchQuery ? 'No projects match.' : 'Completed separations appear here.'}
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic text-center py-4">
|
||||
{searchQuery ? 'No projects match your search.' : 'Completed separations appear here.'}
|
||||
</p>
|
||||
) : (
|
||||
filteredProjects.map((project) => (
|
||||
<ProjectTile
|
||||
<ProjectItem
|
||||
key={project.id}
|
||||
project={project}
|
||||
isOpen={openTabIds.includes(project.id)}
|
||||
|
||||
@@ -30,38 +30,11 @@ export function ThemeProvider({ children }: { children: React.ReactNode }) {
|
||||
r = theme
|
||||
}
|
||||
setResolved(r)
|
||||
// Tailwind dark mode (for components not yet migrated to MetroUI)
|
||||
if (r === 'dark') {
|
||||
root.classList.add('dark')
|
||||
} else {
|
||||
root.classList.remove('dark')
|
||||
}
|
||||
// MetroUI dark mode
|
||||
root.setAttribute('data-theme', r)
|
||||
// color-scheme: tells the browser to use dark OS chrome (scrollbars, native tooltips, form controls)
|
||||
root.style.colorScheme = r
|
||||
// Explicit CSS custom properties — guaranteed regardless of MetroUI var availability
|
||||
const dark = r === 'dark'
|
||||
root.style.setProperty('--body-background', dark ? '#0f172a' : '#ffffff')
|
||||
root.style.setProperty('--background', dark ? '#1e293b' : '#f8fafc')
|
||||
root.style.setProperty('--border-color', dark ? '#334155' : '#e2e8f0')
|
||||
root.style.setProperty('--sidebar-background', dark ? '#0f172a' : '#f1f5f9')
|
||||
// Semi-transparent variant for frosted-glass bars (backdropFilter needs transparency)
|
||||
root.style.setProperty('--bar-background', dark ? 'rgba(15,23,42,0.92)' : 'rgba(255,255,255,0.92)')
|
||||
// Text colours — set directly on body (inline style beats MetroUI stylesheet)
|
||||
// Also exposed as CSS vars for components that need to reference them explicitly
|
||||
const fg = dark ? '#e2e8f0' : '#1e293b'
|
||||
document.body.style.color = fg
|
||||
root.style.setProperty('--foreground', fg)
|
||||
root.style.setProperty('--foreground-muted', dark ? '#94a3b8' : '#64748b')
|
||||
root.style.setProperty('--label-color', dark ? '#94a3b8' : '#64748b')
|
||||
root.style.setProperty('--color-gray', '#64748b')
|
||||
root.style.setProperty('--color-green', '#22c55e')
|
||||
root.style.setProperty('--color-red', '#ef4444')
|
||||
root.style.setProperty('--color-amber', '#f59e0b')
|
||||
root.style.setProperty('--color-blue', '#0ea5e9')
|
||||
root.style.setProperty('--color-violet', '#8b5cf6')
|
||||
root.style.setProperty('--color-teal', '#14b8a6')
|
||||
}
|
||||
|
||||
apply()
|
||||
|
||||
+26
-48
@@ -1,11 +1,3 @@
|
||||
/*
|
||||
* index.css — StemEngine global styles
|
||||
*
|
||||
* Phase 1 (MetroUI migration): Tailwind stays active for inner pages
|
||||
* (Separator, ProjectDetail, Settings, Sidebar). MetroUI is loaded in
|
||||
* main.tsx after this file. Both systems coexist during the migration;
|
||||
* @tailwind directives are removed in Phase 6 once all components are migrated.
|
||||
*/
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
@@ -103,21 +95,25 @@
|
||||
--brand-950: 8 51 68;
|
||||
}
|
||||
|
||||
/* Phase 7: converted from @layer base + @apply */
|
||||
html, body, #root {
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
@layer base {
|
||||
html {
|
||||
@apply h-full;
|
||||
}
|
||||
body {
|
||||
@apply h-full antialiased;
|
||||
}
|
||||
#root {
|
||||
@apply h-full;
|
||||
}
|
||||
}
|
||||
|
||||
/* Phase 7: converted from @layer utilities + @apply / theme() */
|
||||
.sidebar-open {
|
||||
width: 18rem; /* was: @apply w-72 */
|
||||
}
|
||||
.sidebar-closed {
|
||||
width: 3.5rem; /* was: @apply w-14 */
|
||||
@layer utilities {
|
||||
.sidebar-open {
|
||||
@apply w-72;
|
||||
}
|
||||
.sidebar-closed {
|
||||
@apply w-14;
|
||||
}
|
||||
}
|
||||
|
||||
/* On small screens the sidebar overlays content instead of pushing it */
|
||||
@@ -128,10 +124,10 @@ body {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 30;
|
||||
width: 18rem; /* was: theme('spacing.72') */
|
||||
width: theme('spacing.72');
|
||||
}
|
||||
.sidebar-closed {
|
||||
width: 2.5rem; /* was: theme('spacing.10') */
|
||||
width: theme('spacing.10');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,44 +138,26 @@ body {
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
@apply bg-transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color, #cbd5e1);
|
||||
border-radius: 9999px;
|
||||
@apply bg-slate-300 dark:bg-gray-600 rounded-full;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: color-mix(in srgb, var(--border-color, #94a3b8) 80%, #000);
|
||||
@apply bg-slate-400 dark:bg-gray-500;
|
||||
}
|
||||
|
||||
/* Range input styling — appearance: none so we fully control thumb shape.
|
||||
Height must be set explicitly; without it the track collapses to ~0px.
|
||||
accent-color is NOT used here because it is ignored when appearance: none is active. */
|
||||
/* Range input styling */
|
||||
input[type="range"] {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
background: var(--border-color, #e2e8f0);
|
||||
height: 6px;
|
||||
border-radius: 9999px;
|
||||
cursor: pointer;
|
||||
@apply bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer;
|
||||
}
|
||||
|
||||
input[type="range"]::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
background: rgb(var(--brand-500, 59 130 246));
|
||||
cursor: pointer;
|
||||
@apply appearance-none w-4 h-4 rounded-full bg-brand-500 cursor-pointer;
|
||||
}
|
||||
|
||||
input[type="range"]::-moz-range-thumb {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
background: rgb(var(--brand-500, 59 130 246));
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
@apply w-4 h-4 rounded-full bg-brand-500 cursor-pointer border-0;
|
||||
}
|
||||
@@ -3,11 +3,6 @@ import ReactDOM from 'react-dom/client'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import App from './App'
|
||||
import './index.css'
|
||||
// MetroUI — Phase 1 shell redesign
|
||||
import '@olton/metroui/lib/metro.css'
|
||||
import '@olton/metroui/lib/icons.css'
|
||||
// Dark-mode overrides — must come after metro.css so un-layered rules win
|
||||
import './theme-overrides.css'
|
||||
import '@fontsource/archivo'
|
||||
import '@fontsource/eb-garamond'
|
||||
import '@fontsource/inter'
|
||||
|
||||
@@ -11,14 +11,6 @@ import type { ProjectDetail as PD, Job, JobFile } from '../types'
|
||||
import DynamicMixPlayer from '../components/DynamicMixPlayer'
|
||||
import LyricsLivePreview from '../components/LyricsLivePreview'
|
||||
|
||||
// ─── shared form-field style (overrides MetroUI/Tailwind bg in dark mode) ───
|
||||
const fieldStyle = {
|
||||
background: 'var(--background)',
|
||||
color: 'var(--foreground)',
|
||||
borderColor: 'var(--border-color)',
|
||||
colorScheme: 'inherit' as const,
|
||||
} as const
|
||||
|
||||
// ─── helpers ────────────────────────────────────────────────────────────────
|
||||
|
||||
function formatTime(s: number): string {
|
||||
@@ -42,13 +34,13 @@ const STATIC_OPTIONS = [
|
||||
|
||||
|
||||
// Color classes for each stem type
|
||||
const STEM_COLORS: Record<string, { bg: string; border: string; color: string }> = {
|
||||
vocals: { bg: 'rgba(14, 165, 233, 0.09)', border: 'rgba(14, 165, 233, 0.35)', color: '#0ea5e9' },
|
||||
drums: { bg: 'rgba(249, 115, 22, 0.09)', border: 'rgba(249, 115, 22, 0.35)', color: '#f97316' },
|
||||
bass: { bg: 'rgba(168, 85, 247, 0.09)', border: 'rgba(168, 85, 247, 0.35)', color: '#a855f7' },
|
||||
other: { bg: 'var(--background)', border: 'var(--border-color)', color: 'inherit' },
|
||||
guitar: { bg: 'rgba(16, 185, 129, 0.09)', border: 'rgba(16, 185, 129, 0.35)', color: '#10b981' },
|
||||
piano: { bg: 'rgba(244, 63, 94, 0.09)', border: 'rgba(244, 63, 94, 0.35)', color: '#f43f5e' },
|
||||
const STEM_COLORS: Record<string, string> = {
|
||||
vocals: 'bg-sky-50 dark:bg-sky-950/40 border-sky-300/50 text-sky-700 dark:text-sky-300 hover:border-sky-400',
|
||||
drums: 'bg-orange-50 dark:bg-orange-950/40 border-orange-300/50 text-orange-700 dark:text-orange-300 hover:border-orange-400',
|
||||
bass: 'bg-purple-50 dark:bg-purple-950/40 border-purple-300/50 text-purple-700 dark:text-purple-300 hover:border-purple-400',
|
||||
other: 'bg-slate-50 dark:bg-gray-800 border-slate-200 dark:border-gray-700 text-slate-600 dark:text-gray-300 hover:border-slate-400',
|
||||
guitar: 'bg-emerald-50 dark:bg-emerald-950/40 border-emerald-300/50 text-emerald-700 dark:text-emerald-300 hover:border-emerald-400',
|
||||
piano: 'bg-rose-50 dark:bg-rose-950/40 border-rose-300/50 text-rose-700 dark:text-rose-300 hover:border-rose-400',
|
||||
}
|
||||
|
||||
function isActive(job: Job | null | undefined) {
|
||||
@@ -57,27 +49,22 @@ function isActive(job: Job | null | undefined) {
|
||||
|
||||
function JobBadge({ job }: { job: Job | null }) {
|
||||
if (!job) return null
|
||||
const colors: Record<string, { bg: string; color: string; border: string }> = {
|
||||
done: { bg: 'rgba(16, 185, 129, 0.1)', color: 'var(--color-green, #10b981)', border: 'rgba(16, 185, 129, 0.35)' },
|
||||
running: { bg: 'rgba(59, 130, 246, 0.1)', color: 'rgb(var(--brand-500,59 130 246))', border: 'rgba(59,130,246,0.35)' },
|
||||
queued: { bg: 'rgba(245, 158, 11, 0.1)', color: 'var(--color-amber, #f59e0b)', border: 'rgba(245, 158, 11, 0.35)' },
|
||||
error: { bg: 'rgba(239, 68, 68, 0.1)', color: 'var(--color-red, #ef4444)', border: 'rgba(239, 68, 68, 0.35)' },
|
||||
cancelled: { bg: 'var(--background)', color: 'var(--label-color)', border: 'var(--border-color)' },
|
||||
const styles: Record<string, string> = {
|
||||
done: 'bg-emerald-50 dark:bg-emerald-950/30 text-emerald-600 dark:text-emerald-400 border-emerald-300/50',
|
||||
running: 'bg-brand-50 dark:bg-brand-950/30 text-brand-600 dark:text-brand-400 border-brand-300/50',
|
||||
queued: 'bg-amber-50 dark:bg-amber-950/30 text-amber-600 dark:text-amber-400 border-amber-300/50',
|
||||
error: 'bg-red-50 dark:bg-red-950/30 text-red-600 dark:text-red-400 border-red-300/50',
|
||||
cancelled: 'bg-slate-50 dark:bg-gray-900 text-slate-500 dark:text-gray-500 border-slate-200 dark:border-gray-700',
|
||||
}
|
||||
const icons: Record<string, React.ReactNode> = {
|
||||
done: <CheckCircle size={11} />,
|
||||
running: <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} />,
|
||||
queued: <Clock size={11} />,
|
||||
error: <XCircle size={11} />,
|
||||
cancelled: <AlertCircle size={11} />,
|
||||
done: <CheckCircle className="w-3 h-3" />,
|
||||
running: <Loader2 className="w-3 h-3 animate-spin" />,
|
||||
queued: <Clock className="w-3 h-3" />,
|
||||
error: <XCircle className="w-3 h-3" />,
|
||||
cancelled: <AlertCircle className="w-3 h-3" />,
|
||||
}
|
||||
const c = colors[job.status] ?? colors.cancelled
|
||||
return (
|
||||
<span style={{
|
||||
display: 'inline-flex', alignItems: 'center', gap: 4,
|
||||
fontSize: 11, padding: '2px 8px', borderRadius: 12,
|
||||
border: `1px solid ${c.border}`, background: c.bg, color: c.color, fontWeight: 500,
|
||||
}}>
|
||||
<span className={`inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border font-medium ${styles[job.status] ?? ''}`}>
|
||||
{icons[job.status]}
|
||||
{job.status}
|
||||
</span>
|
||||
@@ -89,10 +76,9 @@ function DownloadButton({ file, jobId }: { file: JobFile; jobId: string }) {
|
||||
<a
|
||||
href={downloadUrl(jobId, file.name)}
|
||||
download={file.name}
|
||||
className="button flat"
|
||||
style={{ display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 12 }}
|
||||
className="inline-flex items-center gap-1.5 rounded-lg bg-slate-100 dark:bg-gray-800 border border-slate-200 dark:border-gray-700 px-2.5 py-1.5 text-xs font-medium text-slate-700 dark:text-gray-300 hover:border-brand-400 hover:text-brand-600 dark:hover:text-brand-400 transition-colors"
|
||||
>
|
||||
<Download size={12} />
|
||||
<Download className="w-3 h-3" />
|
||||
{file.name}
|
||||
</a>
|
||||
)
|
||||
@@ -684,23 +670,17 @@ function MidiGroupPlayer({ stems }: { stems: MidiGroupStem[] }) {
|
||||
|
||||
// Color-coded stem download chip — shows just the part name, not the full filename
|
||||
function StemChipButton({ file, jobId }: { file: JobFile; jobId: string }) {
|
||||
const stemKey = (file.stem ?? file.name).toLowerCase().split('.')[0]
|
||||
const label = stemKey.charAt(0).toUpperCase() + stemKey.slice(1)
|
||||
const c = STEM_COLORS[stemKey] ?? STEM_COLORS.other
|
||||
const stemKey = (file.stem ?? file.name).toLowerCase().split('.')[0]
|
||||
const label = stemKey.charAt(0).toUpperCase() + stemKey.slice(1)
|
||||
const colorCls = STEM_COLORS[stemKey] ?? STEM_COLORS.other
|
||||
return (
|
||||
<a
|
||||
href={downloadUrl(jobId, file.name)}
|
||||
download={file.name}
|
||||
title={file.name}
|
||||
style={{
|
||||
display: 'inline-flex', alignItems: 'center', gap: 6,
|
||||
borderRadius: 5, border: `1px solid ${c.border}`,
|
||||
background: c.bg, color: c.color,
|
||||
padding: '5px 12px', fontSize: 12, fontWeight: 600,
|
||||
textDecoration: 'none',
|
||||
}}
|
||||
className={`inline-flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-xs font-semibold transition-colors ${colorCls}`}
|
||||
>
|
||||
<Download size={12} />
|
||||
<Download className="w-3 h-3" />
|
||||
{label}
|
||||
</a>
|
||||
)
|
||||
@@ -739,65 +719,61 @@ function StemReprocessButton({
|
||||
}
|
||||
}
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
return (
|
||||
<div style={{ position: 'relative' }}>
|
||||
<div className="relative">
|
||||
<button
|
||||
onClick={() => setShowMenu(v => !v)}
|
||||
disabled={busy}
|
||||
className="button flat"
|
||||
className="flex items-center gap-1 rounded-lg bg-slate-100 dark:bg-gray-800 border border-slate-200 dark:border-gray-700 px-2 py-1 text-[10px] font-medium text-slate-600 dark:text-gray-400 hover:border-brand-400 hover:text-brand-600 transition-colors"
|
||||
title="Reprocess with different model"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 5, fontSize: 11, padding: '4px 8px' }}
|
||||
>
|
||||
{busy ? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} /> : <Wand2 size={11} />}
|
||||
{busy ? <Loader2 className="w-3 h-3 animate-spin" /> : <Wand2 className="w-3 h-3" />}
|
||||
Reprocess
|
||||
</button>
|
||||
|
||||
{showMenu && (
|
||||
<div style={{
|
||||
position: 'absolute', right: 0, top: '100%', marginTop: 4, zIndex: 20,
|
||||
width: 240, borderRadius: 6, border: '1px solid var(--border-color)',
|
||||
background: 'var(--body-background)', boxShadow: '0 4px 16px rgba(0,0,0,0.2)',
|
||||
}}>
|
||||
<div style={{ padding: 10, display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<p style={{ fontSize: 10, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', opacity: 0.5, margin: 0 }}>
|
||||
<div className="absolute right-0 top-full mt-1 z-20 w-64 rounded-lg border border-slate-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-lg">
|
||||
<div className="p-2 space-y-2">
|
||||
{/* Family tabs */}
|
||||
<p className="text-[10px] font-medium text-slate-500 dark:text-gray-500 uppercase tracking-wider">
|
||||
Model Family
|
||||
</p>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{groups.map(g => (
|
||||
<button
|
||||
key={g}
|
||||
onClick={() => setSelectedGroup(g)}
|
||||
style={{
|
||||
padding: '2px 8px', borderRadius: 4, fontSize: 10, fontWeight: 600, border: 'none', cursor: 'pointer',
|
||||
background: activeGroup === g ? accentColor : 'var(--background)',
|
||||
color: activeGroup === g ? '#fff' : 'inherit',
|
||||
}}
|
||||
className={`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${
|
||||
activeGroup === g
|
||||
? 'bg-brand-500 text-white'
|
||||
: 'bg-slate-100 dark:bg-gray-800 text-slate-600 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'
|
||||
}`}
|
||||
>
|
||||
{g}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<p style={{ fontSize: 10, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', opacity: 0.5, margin: 0 }}>
|
||||
|
||||
{/* Model list for selected family */}
|
||||
<p className="text-[10px] font-medium text-slate-500 dark:text-gray-500 uppercase tracking-wider">
|
||||
Model
|
||||
</p>
|
||||
<div style={{ maxHeight: 160, overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: 2 }}>
|
||||
<div className="space-y-0.5 max-h-40 overflow-y-auto">
|
||||
{filteredModels.map((model) => (
|
||||
<button
|
||||
key={model.id}
|
||||
onClick={() => handleReprocess(model.id)}
|
||||
className="button flat"
|
||||
style={{ textAlign: 'left', fontSize: 12, padding: '5px 8px' }}
|
||||
className="w-full text-left px-2 py-1.5 rounded text-xs text-slate-700 dark:text-gray-300 hover:bg-slate-100 dark:hover:bg-gray-800 transition-colors font-medium"
|
||||
>
|
||||
{model.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={() => setShowMenu(false)}
|
||||
className="button flat"
|
||||
style={{ width: '100%', fontSize: 11, padding: '6px 0', borderTop: '1px solid var(--border-color)', borderRadius: 0 }}
|
||||
className="w-full py-1.5 text-[10px] text-slate-500 hover:text-slate-700 dark:text-gray-500 dark:hover:text-gray-300 border-t border-slate-200 dark:border-gray-700"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
@@ -843,7 +819,7 @@ function StemRenameButton({
|
||||
|
||||
if (isEditing) {
|
||||
return (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
|
||||
<div className="flex items-center gap-1">
|
||||
<input
|
||||
type="text"
|
||||
value={newName}
|
||||
@@ -852,28 +828,21 @@ function StemRenameButton({
|
||||
if (e.key === 'Enter') handleSubmit()
|
||||
if (e.key === 'Escape') setIsEditing(false)
|
||||
}}
|
||||
style={{
|
||||
width: 96, padding: '3px 7px', fontSize: 12, borderRadius: 4,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--input-background, var(--background))',
|
||||
color: 'inherit', outline: 'none',
|
||||
}}
|
||||
className="w-24 rounded border border-slate-300 dark:border-gray-600 px-1.5 py-0.5 text-xs bg-white dark:bg-gray-900 text-slate-900 dark:text-gray-100"
|
||||
autoFocus
|
||||
/>
|
||||
<button
|
||||
onClick={handleSubmit}
|
||||
disabled={busy}
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3, color: 'var(--color-green, #10b981)' }}
|
||||
className="p-0.5 rounded text-emerald-500 hover:text-emerald-600"
|
||||
>
|
||||
{busy ? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} /> : <Check size={11} />}
|
||||
{busy ? <Loader2 className="w-3 h-3 animate-spin" /> : <Check className="w-3 h-3" />}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setIsEditing(false)}
|
||||
className="button cycle flat"
|
||||
style={{ padding: 3 }}
|
||||
className="p-0.5 rounded text-slate-400 hover:text-slate-600"
|
||||
>
|
||||
<XIcon size={11} />
|
||||
<XIcon className="w-3 h-3" />
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
@@ -882,11 +851,10 @@ function StemRenameButton({
|
||||
return (
|
||||
<button
|
||||
onClick={() => setIsEditing(true)}
|
||||
className="button cycle flat"
|
||||
style={{ padding: 4 }}
|
||||
className="p-1 rounded text-slate-400 hover:text-brand-500 transition-colors"
|
||||
title="Rename stem"
|
||||
>
|
||||
<Edit2 size={12} />
|
||||
<Edit2 className="w-3 h-3" />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
@@ -905,48 +873,40 @@ function StemsSection({
|
||||
const stems = sepJob.files.filter((f) => f.type === 'stem')
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
return (
|
||||
<section>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, background: 'none', border: 'none', cursor: 'pointer', fontSize: 13, fontWeight: 600, color: accentColor }}
|
||||
>
|
||||
<Music2 size={15} style={{ color: accentColor }} /> Stems
|
||||
</button>
|
||||
<button onClick={() => setOpen((v) => !v)} className="button cycle flat" style={{ padding: 3 }}>
|
||||
{open ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
className="w-full flex items-center justify-between mb-3 text-left group"
|
||||
>
|
||||
<h3 className="text-sm font-semibold text-slate-700 dark:text-gray-200 flex items-center gap-2 group-hover:text-brand-500 transition-colors">
|
||||
<Music2 className="w-4 h-4 text-brand-500" /> Stems
|
||||
</h3>
|
||||
{open ? <ChevronUp className="w-3.5 h-3.5 text-slate-400" /> : <ChevronDown className="w-3.5 h-3.5 text-slate-400" />}
|
||||
</button>
|
||||
{open && (stems.length === 0 ? (
|
||||
<p style={{ fontSize: 12, opacity: 0.45, fontStyle: 'italic' }}>No stem files found.</p>
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic">No stem files found.</p>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
|
||||
<div className="space-y-2">
|
||||
{stems.map((f) => (
|
||||
<div
|
||||
key={f.name}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 8,
|
||||
padding: '6px 8px', borderRadius: 6,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--background)',
|
||||
}}
|
||||
>
|
||||
<StemChipButton file={f} jobId={sepJob.id} />
|
||||
<div style={{ flex: 1 }} />
|
||||
<StemRenameButton
|
||||
projectId={project.id}
|
||||
stemName={f.stem ?? f.name}
|
||||
currentLabel={f.stem ?? f.name}
|
||||
onRename={onAction}
|
||||
/>
|
||||
<StemReprocessButton
|
||||
projectId={project.id}
|
||||
stemName={f.stem ?? f.name}
|
||||
onReprocess={onAction}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
key={f.name}
|
||||
className="flex items-center gap-2 p-2 rounded-lg border border-slate-200 dark:border-gray-700 bg-slate-50/50 dark:bg-gray-800/30"
|
||||
>
|
||||
<StemChipButton file={f} jobId={sepJob.id} />
|
||||
<div className="flex-1" />
|
||||
<StemRenameButton
|
||||
projectId={project.id}
|
||||
stemName={f.stem ?? f.name}
|
||||
currentLabel={f.stem ?? f.name}
|
||||
onRename={onAction}
|
||||
/>
|
||||
<StemReprocessButton
|
||||
projectId={project.id}
|
||||
stemName={f.stem ?? f.name}
|
||||
onReprocess={onAction}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
@@ -1005,34 +965,30 @@ function MixesSection({
|
||||
const currentMixType = mixFiles[0]?.type // 'static' | 'dynamic'
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
return (
|
||||
<section>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, background: 'none', border: 'none', cursor: 'pointer', fontSize: 13, fontWeight: 600, color: accentColor }}
|
||||
>
|
||||
<Music2 size={15} style={{ color: accentColor }} /> Mixes
|
||||
</button>
|
||||
<button onClick={() => setOpen((v) => !v)} className="button cycle flat" style={{ padding: 3 }}>
|
||||
{open ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
className="w-full flex items-center justify-between mb-3 text-left group"
|
||||
>
|
||||
<h3 className="text-sm font-semibold text-slate-700 dark:text-gray-200 flex items-center gap-2 group-hover:text-brand-500 transition-colors">
|
||||
<Music2 className="w-4 h-4 text-brand-500" /> Mixes
|
||||
</h3>
|
||||
{open ? <ChevronUp className="w-3.5 h-3.5 text-slate-400" /> : <ChevronDown className="w-3.5 h-3.5 text-slate-400" />}
|
||||
</button>
|
||||
|
||||
{open && (<>
|
||||
{/* Sub-tabs */}
|
||||
<div style={{ display: 'flex', gap: 4, marginBottom: 14 }}>
|
||||
<div className="flex gap-1 mb-4">
|
||||
{(['static', 'dynamic'] as const).map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
onClick={() => setMixTab(t)}
|
||||
style={{
|
||||
padding: '4px 12px', borderRadius: 4, fontSize: 12, fontWeight: 600,
|
||||
border: 'none', cursor: 'pointer', textTransform: 'capitalize',
|
||||
background: mixTab === t ? accentColor : 'var(--background)',
|
||||
color: mixTab === t ? '#fff' : 'inherit',
|
||||
}}
|
||||
className={`px-3 py-1 rounded-lg text-xs font-medium capitalize transition-colors ${
|
||||
mixTab === t
|
||||
? 'bg-brand-500 text-white'
|
||||
: 'bg-slate-100 dark:bg-gray-800 text-slate-600 dark:text-gray-400 hover:bg-slate-200 dark:hover:bg-gray-700'
|
||||
}`}
|
||||
>
|
||||
{t}
|
||||
</button>
|
||||
@@ -1040,31 +996,30 @@ function MixesSection({
|
||||
</div>
|
||||
|
||||
{mixTab === 'static' ? (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||||
<label>
|
||||
<span style={{ display: 'block', fontSize: 11, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', opacity: 0.5, marginBottom: 5 }}>Remove</span>
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<label className="text-xs font-medium text-slate-600 dark:text-gray-400 block mb-1">Remove</label>
|
||||
<select
|
||||
value={staticOption}
|
||||
onChange={(e) => setStaticOption(e.target.value)}
|
||||
style={{ padding: '6px 10px', fontSize: 12, borderRadius: 4, border: '1px solid var(--border-color)', background: 'var(--background)', color: 'var(--foreground)', outline: 'none', colorScheme: 'inherit' }}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-3 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-brand-400"
|
||||
>
|
||||
{STATIC_OPTIONS.map((o) => (
|
||||
<option key={o.id} value={o.id}>{o.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleGenerate}
|
||||
disabled={busy || !!isActive(mixJob)}
|
||||
className="button"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, padding: '6px 14px', width: 'fit-content', opacity: (busy || !!isActive(mixJob)) ? 0.5 : 1 }}
|
||||
className="flex items-center gap-1.5 rounded-lg bg-brand-500/10 border border-brand-400/30 px-3 py-1.5 text-xs font-medium text-brand-600 dark:text-brand-400 hover:bg-brand-500/20 transition-colors disabled:opacity-50"
|
||||
>
|
||||
{busy ? <Loader2 size={12} style={{ animation: 'spin 1s linear infinite' }} /> : null}
|
||||
{busy ? <Loader2 className="w-3 h-3 animate-spin" /> : null}
|
||||
Generate
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||||
<div className="space-y-3">
|
||||
<DynamicMixPlayer
|
||||
stems={stemEntries}
|
||||
title={project.name}
|
||||
@@ -1073,38 +1028,37 @@ function MixesSection({
|
||||
<button
|
||||
onClick={handleGenerate}
|
||||
disabled={busy || !!isActive(mixJob)}
|
||||
className="button"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, padding: '6px 14px', width: 'fit-content', opacity: (busy || !!isActive(mixJob)) ? 0.5 : 1 }}
|
||||
className="flex items-center gap-1.5 rounded-lg bg-brand-500/10 border border-brand-400/30 px-3 py-1.5 text-xs font-medium text-brand-600 dark:text-brand-400 hover:bg-brand-500/20 transition-colors disabled:opacity-50"
|
||||
>
|
||||
{busy ? <Loader2 size={12} style={{ animation: 'spin 1s linear infinite' }} /> : null}
|
||||
{busy ? <Loader2 className="w-3 h-3 animate-spin" /> : null}
|
||||
Export Mix
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{err && <p style={{ fontSize: 12, color: 'var(--color-red, #ef4444)', marginTop: 6 }}>{err}</p>}
|
||||
{err && <p className="mt-2 text-xs text-red-500 dark:text-red-400">{err}</p>}
|
||||
|
||||
{/* Current mix job */}
|
||||
{mixJob && (
|
||||
<div style={{ marginTop: 12, borderRadius: 6, border: '1px solid var(--border-color)', background: 'var(--background)', padding: '10px 12px', display: 'flex', flexDirection: 'column', gap: 6 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<span style={{ fontSize: 12, opacity: 0.55 }}>
|
||||
<div className="mt-3 rounded-xl bg-slate-50 dark:bg-gray-900 border border-slate-200 dark:border-gray-800 p-3 space-y-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400">
|
||||
{currentMixType === 'dynamic' ? 'Dynamic' : 'Static'} mix
|
||||
</span>
|
||||
<JobBadge job={mixJob} />
|
||||
</div>
|
||||
{isActive(mixJob) && (
|
||||
<p style={{ fontSize: 12, opacity: 0.5, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{mixJob.progress}</p>
|
||||
<p className="text-xs text-slate-400 dark:text-gray-500 truncate">{mixJob.progress}</p>
|
||||
)}
|
||||
{mixJob.status === 'done' && (
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{mixJob.files.map((f) => (
|
||||
<DownloadButton key={f.name} file={f} jobId={mixJob.id} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{mixJob.status === 'error' && (
|
||||
<p style={{ fontSize: 11, color: 'var(--color-red, #ef4444)', wordBreak: 'break-all' }}>{mixJob.error}</p>
|
||||
<p className="text-xs text-red-400 break-all">{mixJob.error}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
@@ -1154,7 +1108,6 @@ function StemMidiRow({
|
||||
value={mode}
|
||||
onChange={(e) => setMode(e.target.value)}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-purple-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
{TRANSCRIBE_MODES.map((m) => (
|
||||
<option key={m.id} value={m.id}>{m.label}</option>
|
||||
@@ -1218,37 +1171,35 @@ function MidiSection({
|
||||
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const violetColor = 'var(--color-violet, #a855f7)'
|
||||
return (
|
||||
<section>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, background: 'none', border: 'none', cursor: 'pointer', fontSize: 13, fontWeight: 600, color: violetColor }}
|
||||
className="flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-gray-200 hover:text-brand-500 transition-colors"
|
||||
>
|
||||
<Mic2 size={15} style={{ color: violetColor }} /> MIDI
|
||||
<Mic2 className="w-4 h-4 text-purple-500" /> MIDI
|
||||
</button>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<div className="flex items-center gap-2">
|
||||
{open && stems.length > 1 && (
|
||||
<button
|
||||
onClick={handleTranscribeAll}
|
||||
disabled={bulkBusy || anyActive}
|
||||
className="button flat"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 5, fontSize: 11, padding: '4px 10px', color: violetColor, opacity: (bulkBusy || anyActive) ? 0.5 : 1 }}
|
||||
className="flex items-center gap-1.5 rounded-lg bg-purple-500/10 border border-purple-400/30 px-3 py-1 text-xs font-medium text-purple-600 dark:text-purple-400 hover:bg-purple-500/20 transition-colors disabled:opacity-50"
|
||||
>
|
||||
{bulkBusy ? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} /> : <ListMusic size={11} />}
|
||||
{bulkBusy ? <Loader2 className="w-3 h-3 animate-spin" /> : <ListMusic className="w-3 h-3" />}
|
||||
Transcribe All
|
||||
</button>
|
||||
)}
|
||||
<button onClick={() => setOpen((v) => !v)} className="button cycle flat" style={{ padding: 3 }}>
|
||||
{open ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
|
||||
<button onClick={() => setOpen((v) => !v)} className="text-slate-400 hover:text-slate-600 dark:hover:text-gray-300 transition-colors">
|
||||
{open ? <ChevronUp className="w-3.5 h-3.5" /> : <ChevronDown className="w-3.5 h-3.5" />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{open && (<>
|
||||
{bulkErr && <p style={{ fontSize: 12, color: 'var(--color-red, #ef4444)', marginBottom: 6 }}>{bulkErr}</p>}
|
||||
{bulkErr && <p className="mb-2 text-xs text-red-500 dark:text-red-400">{bulkErr}</p>}
|
||||
{stems.length === 0 ? (
|
||||
<p style={{ fontSize: 12, opacity: 0.45, fontStyle: 'italic' }}>No stems available.</p>
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic">No stems available.</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{stems.map((stem) => {
|
||||
@@ -1334,7 +1285,6 @@ function StemAbcRow({
|
||||
placeholder={`Title (default: ${projectName})`}
|
||||
disabled={!canConvert}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 placeholder-slate-400 focus:outline-none focus:border-emerald-400 w-40 disabled:opacity-50"
|
||||
style={fieldStyle}
|
||||
/>
|
||||
<button
|
||||
onClick={handleConvert}
|
||||
@@ -1414,37 +1364,35 @@ function AbcSection({
|
||||
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const greenColor = 'var(--color-green, #10b981)'
|
||||
return (
|
||||
<section>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, background: 'none', border: 'none', cursor: 'pointer', fontSize: 13, fontWeight: 600, color: greenColor }}
|
||||
className="flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-gray-200 hover:text-brand-500 transition-colors"
|
||||
>
|
||||
<FileCode size={15} style={{ color: greenColor }} /> ABC Notation
|
||||
<FileCode className="w-4 h-4 text-emerald-500" /> ABC Notation
|
||||
</button>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<div className="flex items-center gap-2">
|
||||
{open && convertableStems.length > 1 && (
|
||||
<button
|
||||
onClick={handleConvertAll}
|
||||
disabled={bulkBusy || anyActive}
|
||||
className="button flat"
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 5, fontSize: 11, padding: '4px 10px', color: greenColor, opacity: (bulkBusy || anyActive) ? 0.5 : 1 }}
|
||||
className="flex items-center gap-1.5 rounded-lg bg-emerald-500/10 border border-emerald-400/30 px-3 py-1 text-xs font-medium text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 transition-colors disabled:opacity-50"
|
||||
>
|
||||
{bulkBusy ? <Loader2 size={11} style={{ animation: 'spin 1s linear infinite' }} /> : <ListMusic size={11} />}
|
||||
{bulkBusy ? <Loader2 className="w-3 h-3 animate-spin" /> : <ListMusic className="w-3 h-3" />}
|
||||
Convert All
|
||||
</button>
|
||||
)}
|
||||
<button onClick={() => setOpen((v) => !v)} className="button cycle flat" style={{ padding: 3 }}>
|
||||
{open ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
|
||||
<button onClick={() => setOpen((v) => !v)} className="text-slate-400 hover:text-slate-600 dark:hover:text-gray-300 transition-colors">
|
||||
{open ? <ChevronUp className="w-3.5 h-3.5" /> : <ChevronDown className="w-3.5 h-3.5" />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{open && (<>
|
||||
{bulkErr && <p style={{ fontSize: 12, color: 'var(--color-red, #ef4444)', marginBottom: 6 }}>{bulkErr}</p>}
|
||||
{bulkErr && <p className="mb-2 text-xs text-red-500 dark:text-red-400">{bulkErr}</p>}
|
||||
{stems.length === 0 ? (
|
||||
<p style={{ fontSize: 12, opacity: 0.45, fontStyle: 'italic' }}>No stems available.</p>
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic">No stems available.</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{stems.map((stem) => {
|
||||
@@ -1506,7 +1454,7 @@ function AbcFileViewer({
|
||||
return (
|
||||
<div className="rounded-lg border border-slate-200 dark:border-gray-700 overflow-hidden">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between px-3 py-2" style={{ background: 'var(--background)' }}>
|
||||
<div className="flex items-center justify-between px-3 py-2 bg-white dark:bg-gray-900">
|
||||
<button
|
||||
onClick={load}
|
||||
className="flex items-center gap-1.5 text-xs font-medium text-slate-700 dark:text-gray-300 hover:text-emerald-600 dark:hover:text-emerald-400 transition-colors"
|
||||
@@ -1521,13 +1469,11 @@ function AbcFileViewer({
|
||||
<div className="flex rounded overflow-hidden border border-slate-200 dark:border-gray-700 text-[10px] font-medium">
|
||||
<button
|
||||
onClick={() => setView('sheet')}
|
||||
className="px-2 py-0.5 transition-colors"
|
||||
style={view === 'sheet' ? { background: '#10b981', color: '#fff' } : { background: 'var(--background)', color: 'var(--foreground-muted)' }}
|
||||
className={`px-2 py-0.5 transition-colors ${view === 'sheet' ? 'bg-emerald-500 text-white' : 'bg-white dark:bg-gray-900 text-slate-500 dark:text-gray-400 hover:bg-slate-50 dark:hover:bg-gray-800'}`}
|
||||
>Sheet</button>
|
||||
<button
|
||||
onClick={() => setView('text')}
|
||||
className="px-2 py-0.5 transition-colors"
|
||||
style={view === 'text' ? { background: '#10b981', color: '#fff' } : { background: 'var(--background)', color: 'var(--foreground-muted)' }}
|
||||
className={`px-2 py-0.5 transition-colors ${view === 'text' ? 'bg-emerald-500 text-white' : 'bg-white dark:bg-gray-900 text-slate-500 dark:text-gray-400 hover:bg-slate-50 dark:hover:bg-gray-800'}`}
|
||||
>Text</button>
|
||||
</div>
|
||||
)}
|
||||
@@ -1689,7 +1635,7 @@ function TranscribeLog({ progress }: { progress: string }) {
|
||||
<Loader2 className="w-3 h-3 text-slate-400 dark:text-gray-500 animate-spin" />
|
||||
</div>
|
||||
{/* log body */}
|
||||
<div className="px-2.5 py-2 max-h-40 overflow-y-auto space-y-0.5" style={{ background: 'var(--body-background)', color: 'var(--foreground)' }}>
|
||||
<div className="px-2.5 py-2 max-h-40 overflow-y-auto space-y-0.5 bg-white dark:bg-gray-950">
|
||||
{lines.length === 0
|
||||
? <span className="text-xs text-slate-400 dark:text-gray-500">Waiting for output…</span>
|
||||
: lines.map((line, i) => (
|
||||
@@ -1935,7 +1881,6 @@ function StemLyricsRow({
|
||||
value={source}
|
||||
onChange={(e) => setSource(e.target.value)}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-sky-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
<option value="text">Paste lyrics</option>
|
||||
<option value="auto">Auto (from file tags / LRC)</option>
|
||||
@@ -1966,7 +1911,6 @@ function StemLyricsRow({
|
||||
placeholder="Paste plain lyrics here, one line per lyric line…"
|
||||
rows={5}
|
||||
className="w-full rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-2 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-sky-400 resize-y font-mono"
|
||||
style={fieldStyle}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -1979,7 +1923,6 @@ function StemLyricsRow({
|
||||
value={whisperModel}
|
||||
onChange={(e) => setWhisperModel(e.target.value)}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-violet-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
{WHISPER_MODELS.map((m) => (
|
||||
<option key={m.id} value={m.id}>{m.label}</option>
|
||||
@@ -1989,7 +1932,6 @@ function StemLyricsRow({
|
||||
value={whisperLang}
|
||||
onChange={(e) => setWhisperLang(e.target.value)}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-violet-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
{WHISPER_LANGS.map((l) => (
|
||||
<option key={l.id} value={l.id}>{l.label}</option>
|
||||
@@ -1999,7 +1941,6 @@ function StemLyricsRow({
|
||||
value={whisperTask}
|
||||
onChange={(e) => setWhisperTask(e.target.value as 'transcribe' | 'translate')}
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-violet-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
<option value="transcribe">Transcribe</option>
|
||||
<option value="translate">Translate → English</option>
|
||||
@@ -2009,7 +1950,6 @@ function StemLyricsRow({
|
||||
onChange={(e) => setVocalStyle(e.target.value as 'general' | 'hiphop')}
|
||||
title="Vocal style — tunes VAD thresholds and ASR priors for the genre"
|
||||
className="rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-2.5 py-1.5 text-xs text-slate-900 dark:text-gray-100 focus:outline-none focus:border-violet-400"
|
||||
style={fieldStyle}
|
||||
>
|
||||
<option value="general">General</option>
|
||||
<option value="hiphop">Hip-hop / Rap</option>
|
||||
@@ -2121,7 +2061,6 @@ function StemLyricsRow({
|
||||
onChange={(e) => setSpeakerNames((prev) => ({ ...prev, [id]: e.target.value }))}
|
||||
placeholder="Name…"
|
||||
className="w-20 text-xs bg-white dark:bg-gray-800 border border-slate-300 dark:border-gray-700 rounded px-1.5 py-0.5 text-slate-700 dark:text-gray-200 focus:outline-none focus:border-violet-400"
|
||||
style={fieldStyle}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
@@ -2130,7 +2069,7 @@ function StemLyricsRow({
|
||||
|
||||
{/* Transcript body */}
|
||||
{hasSpeakers && transcriptSegs ? (
|
||||
<div className="px-2.5 py-2 space-y-0.5 max-h-48 overflow-y-auto" style={{ background: 'var(--body-background)', color: 'var(--foreground)' }}>
|
||||
<div className="px-2.5 py-2 space-y-0.5 max-h-48 overflow-y-auto bg-white dark:bg-gray-950">
|
||||
{(() => {
|
||||
// Group consecutive segments by speaker
|
||||
const groups: Array<{ speaker?: string; lines: string[] }> = []
|
||||
@@ -2154,7 +2093,7 @@ function StemLyricsRow({
|
||||
})()}
|
||||
</div>
|
||||
) : (
|
||||
<pre className="px-2.5 py-2 text-xs whitespace-pre-wrap leading-relaxed max-h-48 overflow-y-auto select-text" style={{ background: 'var(--body-background)', color: 'var(--foreground)' }}>
|
||||
<pre className="px-2.5 py-2 text-xs text-slate-700 dark:text-gray-200 whitespace-pre-wrap leading-relaxed max-h-48 overflow-y-auto bg-white dark:bg-gray-950 select-text">
|
||||
{transcriptText}
|
||||
</pre>
|
||||
)}
|
||||
@@ -2211,22 +2150,19 @@ function LyricsSection({
|
||||
|
||||
const [open, setOpen] = useState(true)
|
||||
|
||||
const skyColor = 'var(--color-blue, #0ea5e9)'
|
||||
return (
|
||||
<section>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
style={{ display: 'flex', alignItems: 'center', gap: 8, background: 'none', border: 'none', cursor: 'pointer', fontSize: 13, fontWeight: 600, color: skyColor }}
|
||||
>
|
||||
<FileText size={15} style={{ color: skyColor }} /> Lyrics Sync
|
||||
</button>
|
||||
<button onClick={() => setOpen((v) => !v)} className="button cycle flat" style={{ padding: 3 }}>
|
||||
{open ? <ChevronUp size={13} /> : <ChevronDown size={13} />}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
className="w-full flex items-center justify-between mb-3 text-left group"
|
||||
>
|
||||
<h3 className="text-sm font-semibold text-slate-700 dark:text-gray-200 flex items-center gap-2 group-hover:text-brand-500 transition-colors">
|
||||
<FileText className="w-4 h-4 text-sky-500" /> Lyrics Sync
|
||||
</h3>
|
||||
{open ? <ChevronUp className="w-3.5 h-3.5 text-slate-400" /> : <ChevronDown className="w-3.5 h-3.5 text-slate-400" />}
|
||||
</button>
|
||||
{open && (vocalStems.length === 0 ? (
|
||||
<p style={{ fontSize: 12, opacity: 0.45, fontStyle: 'italic' }}>No vocals stem available.</p>
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 italic">No vocals stem available.</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{vocalStems.map((stem) => {
|
||||
@@ -2291,27 +2227,27 @@ export default function ProjectDetail({ id, onDelete }: Props) {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '48px 0' }}>
|
||||
<Loader2 size={24} style={{ animation: 'spin 1s linear infinite', color: `rgb(var(--brand-500, 59 130 246))` }} />
|
||||
<div className="flex items-center justify-center py-16">
|
||||
<Loader2 className="w-6 h-6 animate-spin text-brand-400" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (error || !project) {
|
||||
return (
|
||||
<p style={{ fontSize: 13, color: 'var(--color-red, #ef4444)' }}>Failed to load project.</p>
|
||||
<div className="space-y-4">
|
||||
<p className="text-sm text-red-500">Failed to load project.</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 0 }}>
|
||||
<div className="space-y-6">
|
||||
{/* Header */}
|
||||
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 12, marginBottom: 20 }}>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<h2 style={{ fontSize: 15, fontWeight: 700, margin: '0 0 2px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{project.name}
|
||||
</h2>
|
||||
<p style={{ fontSize: 11, opacity: 0.45, margin: 0 }}>
|
||||
<div className="flex items-start gap-3">
|
||||
<div className="flex-1 min-w-0">
|
||||
<h2 className="text-base font-bold text-slate-900 dark:text-white leading-tight truncate">{project.name}</h2>
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 mt-0.5">
|
||||
{project.created_at ? new Date(project.created_at).toLocaleDateString() : ''}
|
||||
</p>
|
||||
</div>
|
||||
@@ -2319,23 +2255,19 @@ export default function ProjectDetail({ id, onDelete }: Props) {
|
||||
<button
|
||||
onClick={onDelete}
|
||||
title="Delete project"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 6, flexShrink: 0, color: 'var(--color-red, #ef4444)' }}
|
||||
className="shrink-0 p-1.5 rounded-lg text-slate-300 dark:text-gray-600 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-950/30 transition-colors"
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Sections */}
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 0 }}>
|
||||
<div className="divide-y divide-slate-100 dark:divide-gray-800 space-y-6">
|
||||
{/* 1 — Stems */}
|
||||
<div style={{ padding: '16px 0', borderTop: '1px solid var(--border-color)' }}>
|
||||
<StemsSection project={project} sepJob={project.sep_job} onAction={invalidate} />
|
||||
</div>
|
||||
<StemsSection project={project} sepJob={project.sep_job} onAction={invalidate} />
|
||||
|
||||
{/* 2 — Mixes */}
|
||||
<div style={{ padding: '16px 0', borderTop: '1px solid var(--border-color)' }}>
|
||||
<div className="pt-6">
|
||||
<MixesSection
|
||||
project={project}
|
||||
sepJob={project.sep_job}
|
||||
@@ -2345,7 +2277,7 @@ export default function ProjectDetail({ id, onDelete }: Props) {
|
||||
</div>
|
||||
|
||||
{/* 3 — MIDI */}
|
||||
<div style={{ padding: '16px 0', borderTop: '1px solid var(--border-color)' }}>
|
||||
<div className="pt-6">
|
||||
<MidiSection
|
||||
project={project}
|
||||
sepJob={project.sep_job}
|
||||
@@ -2355,7 +2287,7 @@ export default function ProjectDetail({ id, onDelete }: Props) {
|
||||
</div>
|
||||
|
||||
{/* 4 — ABC */}
|
||||
<div style={{ padding: '16px 0', borderTop: '1px solid var(--border-color)' }}>
|
||||
<div className="pt-6">
|
||||
<AbcSection
|
||||
project={project}
|
||||
sepJob={project.sep_job}
|
||||
@@ -2366,7 +2298,7 @@ export default function ProjectDetail({ id, onDelete }: Props) {
|
||||
</div>
|
||||
|
||||
{/* 5 — Lyrics Sync */}
|
||||
<div style={{ padding: '16px 0', borderTop: '1px solid var(--border-color)' }}>
|
||||
<div className="pt-6">
|
||||
<LyricsSection
|
||||
project={project}
|
||||
sepJob={project.sep_job}
|
||||
|
||||
+120
-230
@@ -1,11 +1,4 @@
|
||||
/**
|
||||
* Separator.tsx — Phase 3 MetroUI migration
|
||||
*
|
||||
* All business logic (state, queries, handlers, effects) unchanged.
|
||||
* Tailwind classes replaced with MetroUI CSS + inline styles.
|
||||
* Sub-components JobStatus, ResultFiles are not yet migrated (Phase 4+).
|
||||
*/
|
||||
import { useState, useEffect, useRef, type CSSProperties } from 'react'
|
||||
import { useState, useEffect, useRef } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { RefreshCw, Radio, Zap } from 'lucide-react'
|
||||
import FileUpload from '../components/FileUpload'
|
||||
@@ -18,28 +11,9 @@ import {
|
||||
} from '../api/client'
|
||||
import type { Job, ModelOption, PresetsResponse, DynamicLevels, ImportedFile } from '../types'
|
||||
|
||||
// ── Shared style helpers ────────────────────────────────────────────────────
|
||||
|
||||
const fieldLabel: CSSProperties = {
|
||||
display: 'block', fontSize: 11, fontWeight: 700,
|
||||
letterSpacing: '0.08em', textTransform: 'uppercase',
|
||||
opacity: 0.5, marginBottom: 5,
|
||||
}
|
||||
|
||||
const ctrl: CSSProperties = {
|
||||
width: '100%', padding: '6px 10px', fontSize: 13, borderRadius: 4,
|
||||
border: '1px solid var(--border-color)',
|
||||
background: 'var(--background)',
|
||||
color: 'var(--foreground)', outline: 'none', boxSizing: 'border-box',
|
||||
colorScheme: 'inherit',
|
||||
}
|
||||
|
||||
const card: CSSProperties = {
|
||||
borderRadius: 6, border: '1px solid var(--border-color)',
|
||||
background: 'var(--background)', padding: '12px 14px',
|
||||
}
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────────────────────
|
||||
const SELECT_CLS = 'w-full rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-3 py-2 text-sm text-slate-900 dark:text-gray-100 focus:border-brand-500 focus:outline-none'
|
||||
const INPUT_CLS = 'w-full rounded-lg bg-white dark:bg-gray-900 border border-slate-300 dark:border-gray-700 px-3 py-2 text-sm text-slate-900 dark:text-gray-100 focus:border-brand-500 focus:outline-none'
|
||||
const SLIDER_CLS = 'w-full h-2 bg-slate-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer accent-brand-600'
|
||||
|
||||
function groupModels(models: ModelOption[]) {
|
||||
const groups: Record<string, ModelOption[]> = {}
|
||||
@@ -92,6 +66,7 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
|
||||
const grouped = groupModels(models)
|
||||
|
||||
// Read layout preferences saved in Settings → Model Settings
|
||||
const hiddenGroups = new Set<string>((() => {
|
||||
try { return JSON.parse(localStorage.getItem('se-model-hidden-groups') || '[]') as string[] }
|
||||
catch { return [] }
|
||||
@@ -109,6 +84,7 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
catch { return {} }
|
||||
})()
|
||||
|
||||
// Build visible + ordered groups (mirrors Settings ModelDownloader logic)
|
||||
const allGroupNames = Object.keys(grouped)
|
||||
const orderedGroupNames = [
|
||||
...groupOrder.filter(g => allGroupNames.includes(g)),
|
||||
@@ -139,6 +115,7 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
if (first) setModel(first.id)
|
||||
}
|
||||
|
||||
// Reset selected model when it becomes hidden/invisible
|
||||
useEffect(() => {
|
||||
if (!models.length) return
|
||||
const foundGroup = models.find(m => m.id === model)?.group
|
||||
@@ -151,6 +128,7 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [models])
|
||||
|
||||
// Fire callback when a separation job completes
|
||||
const firedRef = useRef<string | null>(null)
|
||||
useEffect(() => {
|
||||
if (
|
||||
@@ -169,13 +147,17 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
}
|
||||
}, [result, onSeparationComplete])
|
||||
|
||||
// Extract metadata when file changes
|
||||
useEffect(() => {
|
||||
if (!file) {
|
||||
setMetadata({})
|
||||
setProjectName('')
|
||||
return
|
||||
}
|
||||
|
||||
// Try to extract metadata from the file
|
||||
extractLyrics(file).then(() => {
|
||||
// Use filename as fallback
|
||||
const filename = file.name.replace(/\.[^/.]+$/, '')
|
||||
setMetadata({ artist: '', title: filename })
|
||||
}).catch(() => {
|
||||
@@ -184,6 +166,7 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
})
|
||||
}, [file])
|
||||
|
||||
// Auto-generate project name from metadata
|
||||
useEffect(() => {
|
||||
if (metadata.artist && metadata.title) {
|
||||
setProjectName(`${metadata.artist} - ${metadata.title}`)
|
||||
@@ -207,6 +190,7 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
dynamicLevels: presetType === 'dynamic' ? dynamicLevels : undefined,
|
||||
sepPowerPreset,
|
||||
}
|
||||
|
||||
let job_id: string
|
||||
if (inputMode === 'imported' && importedFile) {
|
||||
const res = await submitSeparateFromPath(importedFile.path, model, format, opts)
|
||||
@@ -227,51 +211,41 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
setDynamicLevels(prev => ({ ...prev, [stem]: value }))
|
||||
}
|
||||
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
const hasInput = inputMode === 'upload' ? !!file : !!importedFile
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 20 }}>
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────────── */}
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h2 style={{ fontSize: 20, fontWeight: 600, margin: '0 0 4px' }}>Stem Separator</h2>
|
||||
<p style={{ fontSize: 13, opacity: 0.55, margin: 0, lineHeight: 1.5 }}>
|
||||
<h2 className="text-xl font-semibold text-slate-900 dark:text-white mb-1">Stem Separator</h2>
|
||||
<p className="text-sm text-slate-500 dark:text-gray-400">
|
||||
Separate an audio track into individual stems using Demucs, BS-RoFormer, MelBand, or MDX-Net.
|
||||
Create presets like Instrumental, Static mixes, or Dynamic volume-adjusted mixes.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* ── Input mode toggle ─────────────────────────────────────────────────── */}
|
||||
<div style={{ display: 'flex', borderRadius: 5, overflow: 'hidden', border: '1px solid var(--border-color)' }}>
|
||||
{/* Input mode toggle */}
|
||||
<div className="flex rounded-lg border border-slate-200 dark:border-gray-700 overflow-hidden">
|
||||
<button
|
||||
onClick={() => setInputMode('upload')}
|
||||
style={{
|
||||
flex: 1, padding: '7px 12px', fontSize: 12, fontWeight: 600,
|
||||
border: 'none', cursor: 'pointer', transition: 'background 0.15s, color 0.15s',
|
||||
background: inputMode === 'upload' ? accentColor : 'transparent',
|
||||
color: inputMode === 'upload' ? '#fff' : 'inherit',
|
||||
}}
|
||||
className={`flex-1 py-2 text-xs font-medium transition-colors ${
|
||||
inputMode === 'upload'
|
||||
? 'bg-brand-600 text-white'
|
||||
: 'bg-white dark:bg-gray-900 text-slate-600 dark:text-gray-400 hover:bg-slate-50 dark:hover:bg-gray-800'
|
||||
}`}
|
||||
>
|
||||
Upload File
|
||||
</button>
|
||||
<button
|
||||
onClick={() => { setInputMode('imported'); refetchImports() }}
|
||||
style={{
|
||||
flex: 1, padding: '7px 12px', fontSize: 12, fontWeight: 600,
|
||||
border: 'none', borderLeft: '1px solid var(--border-color)', cursor: 'pointer',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6,
|
||||
transition: 'background 0.15s, color 0.15s',
|
||||
background: inputMode === 'imported' ? 'var(--color-blue, #0ea5e9)' : 'transparent',
|
||||
color: inputMode === 'imported' ? '#fff' : 'inherit',
|
||||
}}
|
||||
className={`flex-1 py-2 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${
|
||||
inputMode === 'imported'
|
||||
? 'bg-sky-600 text-white'
|
||||
: 'bg-white dark:bg-gray-900 text-slate-600 dark:text-gray-400 hover:bg-slate-50 dark:hover:bg-gray-800'
|
||||
}`}
|
||||
>
|
||||
<Radio size={12} />
|
||||
<Radio className="w-3 h-3" />
|
||||
Imported Files
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* ── Upload mode ───────────────────────────────────────────────────────── */}
|
||||
{inputMode === 'upload' && (
|
||||
<>
|
||||
<FileUpload
|
||||
@@ -280,106 +254,95 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
onFiles={([f]) => { setFile(f); setJobId(null); setResult(null) }}
|
||||
/>
|
||||
{file && (
|
||||
<div style={{ ...card, borderColor: `rgba(var(--brand-500, 59 130 246), 0.35)` }}>
|
||||
<span style={{ fontSize: 13, fontWeight: 500 }}>Selected: </span>
|
||||
<span style={{ fontSize: 13, opacity: 0.7 }}>{file.name}</span>
|
||||
<div className="rounded-lg border border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-800/50 px-4 py-3">
|
||||
<p className="text-sm font-medium text-slate-700 dark:text-gray-300">
|
||||
Selected: {file.name}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* ── Imported mode ─────────────────────────────────────────────────────── */}
|
||||
{inputMode === 'imported' && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<span style={{ fontSize: 11, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', opacity: 0.5 }}>
|
||||
Select imported file
|
||||
</span>
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Select imported file</span>
|
||||
<button
|
||||
onClick={() => refetchImports()}
|
||||
title="Refresh"
|
||||
className="button cycle flat"
|
||||
style={{ padding: 4, marginLeft: 'auto' }}
|
||||
className="p-1 rounded text-slate-400 hover:text-brand-500 transition-colors"
|
||||
>
|
||||
<RefreshCw size={13} />
|
||||
<RefreshCw className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{imports.length === 0 ? (
|
||||
<div style={{
|
||||
borderRadius: 6, border: '2px dashed var(--border-color)',
|
||||
padding: '24px 16px', textAlign: 'center',
|
||||
}}>
|
||||
<Radio size={22} style={{ opacity: 0.25, margin: '0 auto 8px', display: 'block' }} />
|
||||
<p style={{ fontSize: 13, opacity: 0.45, margin: '0 0 4px' }}>No imported files yet.</p>
|
||||
<p style={{ fontSize: 11, opacity: 0.35, margin: 0 }}>
|
||||
Use the Subsonic panel in the sidebar to import songs.
|
||||
</p>
|
||||
<div className="rounded-lg border border-dashed border-slate-200 dark:border-gray-700 px-4 py-6 text-center">
|
||||
<Radio className="w-6 h-6 text-slate-300 dark:text-gray-600 mx-auto mb-2" />
|
||||
<p className="text-sm text-slate-400 dark:text-gray-600">No imported files yet.</p>
|
||||
<p className="text-xs text-slate-400 dark:text-gray-600 mt-1">Use the Subsonic panel in the sidebar to import songs.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div style={{
|
||||
maxHeight: 192, overflowY: 'auto',
|
||||
borderRadius: 6, border: '1px solid var(--border-color)',
|
||||
}}>
|
||||
<div className="space-y-1 max-h-48 overflow-y-auto rounded-lg border border-slate-200 dark:border-gray-700">
|
||||
{imports.map((f) => (
|
||||
<ImportedFileButton
|
||||
<button
|
||||
key={f.path}
|
||||
file={f}
|
||||
selected={importedFile?.path === f.path}
|
||||
onSelect={() => {
|
||||
onClick={() => {
|
||||
setImportedFile(f)
|
||||
setProjectName(f.filename.replace(/\.[^/.]+$/, ''))
|
||||
setJobId(null); setResult(null)
|
||||
}}
|
||||
/>
|
||||
className={`w-full flex items-start gap-2 px-3 py-2 text-left transition-colors ${
|
||||
importedFile?.path === f.path
|
||||
? 'bg-sky-50 dark:bg-sky-950/30 border-l-2 border-sky-500'
|
||||
: 'hover:bg-slate-50 dark:hover:bg-gray-800/50'
|
||||
}`}
|
||||
>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-xs font-medium text-slate-700 dark:text-gray-200 truncate">{f.filename}</p>
|
||||
<p className="text-[10px] text-slate-400 dark:text-gray-500">
|
||||
{(f.size / 1024 / 1024).toFixed(1)} MB
|
||||
</p>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Model + Format selectors ─────────────────────────────────────────── */}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 12 }}>
|
||||
<label>
|
||||
<span style={fieldLabel}>Model Family</span>
|
||||
<select value={selectedGroup} onChange={(e) => handleGroupChange(e.target.value)} style={ctrl}>
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Model Family</span>
|
||||
<select value={selectedGroup} onChange={(e) => handleGroupChange(e.target.value)} className={SELECT_CLS}>
|
||||
{Object.keys(visibleGrouped).map((g) => (
|
||||
<option key={g} value={g}>{g}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span style={fieldLabel}>Model</span>
|
||||
<select value={model} onChange={(e) => setModel(e.target.value)} style={ctrl}>
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Model</span>
|
||||
<select value={model} onChange={(e) => setModel(e.target.value)} className={SELECT_CLS}>
|
||||
{(visibleGrouped[selectedGroup] ?? []).map((m) => (
|
||||
<option key={m.id} value={m.id}>{m.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span style={fieldLabel}>Output Format</span>
|
||||
<select value={format} onChange={(e) => setFormat(e.target.value)} style={ctrl}>
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Output Format</span>
|
||||
<select value={format} onChange={(e) => setFormat(e.target.value)} className={SELECT_CLS}>
|
||||
{formats.map((f) => <option key={f.id} value={f.id}>{f.label}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* ── BS-RoFormer info ─────────────────────────────────────────────────── */}
|
||||
{isBSR && (
|
||||
<div style={{
|
||||
borderRadius: 6,
|
||||
border: '1px solid rgba(139, 92, 246, 0.45)',
|
||||
background: 'rgba(139, 92, 246, 0.07)',
|
||||
padding: '10px 14px', fontSize: 12,
|
||||
color: 'var(--color-violet, #8b5cf6)',
|
||||
}}>
|
||||
<p style={{ fontWeight: 700, margin: '0 0 4px' }}>BS-RoFormer selected</p>
|
||||
<p style={{ opacity: 0.8, margin: '0 0 6px' }}>
|
||||
State-of-the-art transformer model. Runs in-process — may take longer on CPU.
|
||||
</p>
|
||||
<ul style={{ margin: 0, paddingLeft: 18, opacity: 0.75, lineHeight: 1.7 }}>
|
||||
<div className="rounded-lg border border-purple-300 dark:border-purple-800 bg-purple-50 dark:bg-purple-950/30 px-4 py-3 text-xs text-purple-700 dark:text-purple-300 space-y-1">
|
||||
<p className="font-semibold">BS-RoFormer selected</p>
|
||||
<p>State-of-the-art transformer model. Runs in-process — may take longer on CPU.</p>
|
||||
<ul className="list-disc list-inside mt-1 space-y-0.5 text-purple-600 dark:text-purple-400">
|
||||
<li><strong>4-stem</strong> — vocals · drums · bass · other</li>
|
||||
<li><strong>5-stem (guitar)</strong> — + guitar as separate stem</li>
|
||||
<li><strong>5-stem (piano)</strong> — + piano as separate stem</li>
|
||||
@@ -388,67 +351,66 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Project name ─────────────────────────────────────────────────────── */}
|
||||
<div>
|
||||
<label>
|
||||
<span style={fieldLabel}>Project Name</span>
|
||||
{/* Project Name */}
|
||||
<div className="space-y-2">
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Project Name</span>
|
||||
<input
|
||||
type="text"
|
||||
value={projectName}
|
||||
onChange={(e) => setProjectName(e.target.value)}
|
||||
placeholder="Artist - Title"
|
||||
style={ctrl}
|
||||
className={INPUT_CLS}
|
||||
/>
|
||||
</label>
|
||||
<p style={{ fontSize: 11, opacity: 0.45, margin: '5px 0 0' }}>
|
||||
<p className="text-xs text-slate-500 dark:text-gray-500">
|
||||
Used for folder naming. Auto-generated from metadata if available.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* ── Output preset ────────────────────────────────────────────────────── */}
|
||||
<div>
|
||||
<label>
|
||||
<span style={fieldLabel}>Output Preset</span>
|
||||
<select value={presetType} onChange={(e) => setPresetType(e.target.value)} style={ctrl}>
|
||||
{/* Preset Type */}
|
||||
<div className="space-y-3">
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Output Preset</span>
|
||||
<select value={presetType} onChange={(e) => setPresetType(e.target.value)} className={SELECT_CLS}>
|
||||
{presets?.preset_types.map((p) => (
|
||||
<option key={p.id} value={p.id}>{p.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p style={{ fontSize: 12, opacity: 0.5, margin: '6px 0 0', lineHeight: 1.4 }}>
|
||||
<p className="text-xs text-slate-500 dark:text-gray-500">
|
||||
{presets?.preset_types.find(p => p.id === presetType)?.description}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* ── Static options ───────────────────────────────────────────────────── */}
|
||||
{/* Static Options */}
|
||||
{presetType === 'static' && (
|
||||
<div style={card}>
|
||||
<label>
|
||||
<span style={fieldLabel}>Remove Elements</span>
|
||||
<select value={staticOption} onChange={(e) => setStaticOption(e.target.value)} style={ctrl}>
|
||||
<div className="space-y-3 rounded-lg border border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-800/50 p-4">
|
||||
<label className="space-y-1">
|
||||
<span className="text-xs text-slate-500 dark:text-gray-400 uppercase tracking-wider">Remove Elements</span>
|
||||
<select value={staticOption} onChange={(e) => setStaticOption(e.target.value)} className={SELECT_CLS}>
|
||||
{presets?.static_options.map((o) => (
|
||||
<option key={o.id} value={o.id}>{o.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p style={{ fontSize: 12, opacity: 0.5, margin: '6px 0 0', lineHeight: 1.4 }}>
|
||||
<p className="text-xs text-slate-500 dark:text-gray-500">
|
||||
{presets?.static_options.find(o => o.id === staticOption)?.description}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Dynamic options ──────────────────────────────────────────────────── */}
|
||||
{/* Dynamic Options */}
|
||||
{presetType === 'dynamic' && (
|
||||
<div style={card}>
|
||||
<p style={{ fontSize: 13, fontWeight: 600, margin: '0 0 4px' }}>Volume Levels</p>
|
||||
<p style={{ fontSize: 12, opacity: 0.5, margin: '0 0 14px' }}>
|
||||
Adjust the volume of each stem (0 = mute, 1 = original, 2 = double)
|
||||
</p>
|
||||
<div className="space-y-4 rounded-lg border border-slate-200 dark:border-gray-700 bg-slate-50 dark:bg-gray-800/50 p-4">
|
||||
<p className="text-sm font-medium text-slate-700 dark:text-gray-300">Volume Levels</p>
|
||||
<p className="text-xs text-slate-500 dark:text-gray-500">Adjust the volume of each stem (0 = mute, 1 = original, 2 = double)</p>
|
||||
|
||||
{Object.entries(dynamicLevels).map(([stem, value]) => (
|
||||
<div key={stem} style={{ marginBottom: 12 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 4 }}>
|
||||
<label style={{ fontSize: 13, textTransform: 'capitalize' }}>{stem}</label>
|
||||
<span style={{ fontSize: 13, opacity: 0.55 }}>{Math.round(value * 100)}%</span>
|
||||
<div key={stem} className="space-y-1">
|
||||
<div className="flex justify-between items-center">
|
||||
<label className="text-sm capitalize text-slate-700 dark:text-gray-300">{stem}</label>
|
||||
<span className="text-sm text-slate-500 dark:text-gray-400">{Math.round(value * 100)}%</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
@@ -457,73 +419,46 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
step="0.1"
|
||||
value={value}
|
||||
onChange={(e) => handleDynamicChange(stem as keyof DynamicLevels, parseFloat(e.target.value))}
|
||||
style={{ width: '100%' }}
|
||||
className={SLIDER_CLS}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Preset output preview ────────────────────────────────────────────── */}
|
||||
{/* Preset Preview */}
|
||||
{presetType !== 'stems_only' && (
|
||||
<div style={{
|
||||
borderRadius: 6,
|
||||
border: `1px solid rgba(var(--brand-500, 59 130 246), 0.35)`,
|
||||
background: `rgba(var(--brand-500, 59 130 246), 0.06)`,
|
||||
padding: '10px 14px', fontSize: 13,
|
||||
}}>
|
||||
<p style={{ fontWeight: 600, margin: '0 0 6px', color: accentColor }}>Output Structure Preview:</p>
|
||||
<code style={{
|
||||
display: 'block', fontSize: 11, whiteSpace: 'pre',
|
||||
color: accentColor, opacity: 0.85, fontFamily: 'monospace', lineHeight: 1.7,
|
||||
}}>
|
||||
{projectName || 'Project Name'}/{'\n'}
|
||||
{' Stems/ (always created)'}
|
||||
{presetType === 'instrumental' && '\n Instrumental/ (vocals removed)'}
|
||||
<div className="rounded-lg border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-950/30 px-4 py-3 text-sm text-blue-700 dark:text-blue-300">
|
||||
<p className="font-medium">Output Structure Preview:</p>
|
||||
<code className="block mt-2 text-xs whitespace-pre text-blue-600 dark:text-blue-400">
|
||||
{projectName || 'Project Name'}/
|
||||
{'\n'} Stems/ (always created)
|
||||
{presetType === 'instrumental' && "\n Instrumental/ (vocals removed)"}
|
||||
{presetType === 'static' && `\n Static/ (${presets?.static_options.find(o => o.id === staticOption)?.label})`}
|
||||
{presetType === 'dynamic' && '\n Dynamic/ (volume adjusted mix)'}
|
||||
{presetType === 'dynamic' && "\n Dynamic/ (volume adjusted mix)"}
|
||||
</code>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── Error message ────────────────────────────────────────────────────── */}
|
||||
{error && (
|
||||
<p style={{ fontSize: 13, color: 'var(--color-red, #ef4444)', margin: 0 }}>{error}</p>
|
||||
)}
|
||||
{error && <p className="text-sm text-red-500 dark:text-red-400">{error}</p>}
|
||||
|
||||
{/* ── Submit button ────────────────────────────────────────────────────── */}
|
||||
<button
|
||||
onClick={submit}
|
||||
disabled={!hasInput || loading}
|
||||
className="button primary"
|
||||
style={{ width: '100%', padding: '10px 16px', fontSize: 14, fontWeight: 600 }}
|
||||
disabled={(inputMode === 'upload' ? !file : !importedFile) || loading}
|
||||
className="w-full rounded-lg bg-brand-600 hover:bg-brand-500 disabled:bg-slate-200 disabled:text-slate-400 dark:disabled:bg-gray-800 dark:disabled:text-gray-500 px-4 py-2.5 text-sm font-semibold text-white disabled:cursor-not-allowed transition-colors"
|
||||
>
|
||||
{loading
|
||||
? 'Submitting…'
|
||||
: presetType === 'stems_only'
|
||||
? 'Separate Stems'
|
||||
: `Separate & Create ${presets?.preset_types.find(p => p.id === presetType)?.label}`}
|
||||
{loading ? 'Submitting…' : presetType === 'stems_only' ? 'Separate Stems' : `Separate & Create ${presets?.preset_types.find(p => p.id === presetType)?.label}`}
|
||||
</button>
|
||||
|
||||
{/* ── Auto pipeline button ─────────────────────────────────────────────── */}
|
||||
<button
|
||||
onClick={() => setShowAuto(true)}
|
||||
disabled={!hasInput}
|
||||
style={{
|
||||
width: '100%', padding: '9px 16px', fontSize: 13, fontWeight: 600,
|
||||
borderRadius: 4, cursor: hasInput ? 'pointer' : 'not-allowed',
|
||||
border: '1px solid var(--color-amber, #f59e0b)',
|
||||
background: 'rgba(245, 158, 11, 0.07)',
|
||||
color: 'var(--color-amber, #f59e0b)',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
|
||||
opacity: hasInput ? 1 : 0.4, transition: 'opacity 0.15s',
|
||||
}}
|
||||
disabled={(inputMode === 'upload' ? !file : !importedFile)}
|
||||
className="w-full rounded-lg border border-amber-400 dark:border-amber-600 bg-amber-50 dark:bg-amber-950/30 hover:bg-amber-100 dark:hover:bg-amber-900/40 disabled:opacity-40 disabled:cursor-not-allowed px-4 py-2.5 text-sm font-semibold text-amber-700 dark:text-amber-400 transition-colors flex items-center justify-center gap-2"
|
||||
>
|
||||
<Zap size={15} />
|
||||
<Zap className="w-4 h-4" />
|
||||
Auto Pipeline
|
||||
</button>
|
||||
|
||||
{/* ── Dialogs / job status / results ───────────────────────────────────── */}
|
||||
{showAuto && (
|
||||
<AutoPipelineDialog
|
||||
target={{
|
||||
@@ -546,18 +481,14 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
)}
|
||||
|
||||
{jobId && <JobStatus jobId={jobId} onDone={setResult} />}
|
||||
|
||||
{result && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
<div className="space-y-4">
|
||||
{result.result?.project_name && (
|
||||
<div style={{
|
||||
borderRadius: 6, border: '1px solid rgba(16, 185, 129, 0.4)',
|
||||
background: 'rgba(16, 185, 129, 0.07)', padding: '10px 14px',
|
||||
}}>
|
||||
<p style={{ fontSize: 13, fontWeight: 600, color: 'var(--color-green, #10b981)', margin: '0 0 3px' }}>
|
||||
<div className="rounded-lg border border-green-200 dark:border-green-800 bg-green-50 dark:bg-green-950/30 px-4 py-3">
|
||||
<p className="text-sm font-medium text-green-800 dark:text-green-300">
|
||||
Project: {result.result.project_name}
|
||||
</p>
|
||||
<p style={{ fontSize: 11, color: 'var(--color-green, #10b981)', opacity: 0.7, margin: 0 }}>
|
||||
<p className="text-xs text-green-600 dark:text-green-400 mt-1">
|
||||
Location: {result.result.project_path}
|
||||
</p>
|
||||
</div>
|
||||
@@ -565,47 +496,6 @@ export default function Separator({ onSeparationComplete, onOpenSettings }: Prop
|
||||
<ResultFiles jobId={result.id} files={result.files} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ── Imported file selector row ───────────────────────────────────────────────
|
||||
|
||||
function ImportedFileButton({
|
||||
file, selected, onSelect,
|
||||
}: {
|
||||
file: ImportedFile
|
||||
selected: boolean
|
||||
onSelect: () => void
|
||||
}) {
|
||||
const [hovered, setHovered] = useState(false)
|
||||
const accentColor = `rgb(var(--brand-500, 59 130 246))`
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={onSelect}
|
||||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'flex-start', gap: 10,
|
||||
width: '100%', padding: '8px 12px', textAlign: 'left',
|
||||
border: 'none', borderLeft: `3px solid ${selected ? accentColor : 'transparent'}`,
|
||||
background: selected
|
||||
? `rgba(var(--brand-500, 59 130 246), 0.08)`
|
||||
: hovered ? 'var(--background)' : 'transparent',
|
||||
cursor: 'pointer', transition: 'background 0.12s, border-color 0.12s',
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<p style={{ fontSize: 12, fontWeight: 500, margin: '0 0 2px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{file.filename}
|
||||
</p>
|
||||
<p style={{ fontSize: 10, opacity: 0.45, margin: 0 }}>
|
||||
{(file.size / 1024 / 1024).toFixed(1)} MB
|
||||
</p>
|
||||
</div>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
+629
-571
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user