0.12.0-11 Drive Fix
This commit is contained in:
@@ -960,6 +960,19 @@ export default function DashboardPage({
|
||||
const state = String(pipeline?.state || 'IDLE').trim().toUpperCase();
|
||||
const currentPipelineJobId = normalizeJobId(pipeline?.activeJobId || pipeline?.context?.jobId);
|
||||
const isProcessing = processingStates.includes(state);
|
||||
// When the pipeline transitions to METADATA_SELECTION for a new job while another job
|
||||
// is still encoding in the background, isProcessing becomes false and the log clears.
|
||||
// Track the background encoding job so its live log keeps polling.
|
||||
const backgroundProcessingJobId = useMemo(() => {
|
||||
if (isProcessing) return null;
|
||||
const bg = dashboardJobs.find((job) => {
|
||||
const s = normalizeStatus(job?.status);
|
||||
return processingStates.includes(s);
|
||||
});
|
||||
return bg ? normalizeJobId(bg.id) : null;
|
||||
}, [isProcessing, dashboardJobs]);
|
||||
const liveLogJobId = backgroundProcessingJobId || currentPipelineJobId;
|
||||
const liveLogActive = isProcessing || Boolean(backgroundProcessingJobId);
|
||||
const monitoringState = useMemo(
|
||||
() => normalizeHardwareMonitoringPayload(hardwareMonitoring),
|
||||
[hardwareMonitoring]
|
||||
@@ -1295,7 +1308,7 @@ export default function DashboardPage({
|
||||
}, [audiobookUploadPhase]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentPipelineJobId || !isProcessing) {
|
||||
if (!liveLogJobId || !liveLogActive) {
|
||||
setLiveJobLog('');
|
||||
return undefined;
|
||||
}
|
||||
@@ -1303,7 +1316,7 @@ export default function DashboardPage({
|
||||
let cancelled = false;
|
||||
const refreshLiveLog = async () => {
|
||||
try {
|
||||
const response = await api.getJob(currentPipelineJobId, { includeLiveLog: true, lite: true });
|
||||
const response = await api.getJob(liveLogJobId, { includeLiveLog: true, lite: true });
|
||||
if (!cancelled) {
|
||||
setLiveJobLog(response?.job?.log || '');
|
||||
}
|
||||
@@ -1318,7 +1331,7 @@ export default function DashboardPage({
|
||||
cancelled = true;
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, [currentPipelineJobId, isProcessing]);
|
||||
}, [liveLogJobId, liveLogActive]);
|
||||
|
||||
const pipelineByJobId = useMemo(() => {
|
||||
const map = new Map();
|
||||
@@ -1435,7 +1448,7 @@ export default function DashboardPage({
|
||||
await refreshPipeline();
|
||||
await loadDashboardJobs();
|
||||
const analyzedJobId = normalizeJobId(response?.result?.jobId);
|
||||
if (analyzedJobId && state === 'ENCODING') {
|
||||
if (analyzedJobId) {
|
||||
setMetadataDialogContext({
|
||||
jobId: analyzedJobId,
|
||||
detectedTitle: response?.result?.detectedTitle || '',
|
||||
@@ -1465,9 +1478,26 @@ export default function DashboardPage({
|
||||
const handleAnalyzeForDrive = async (devicePath) => {
|
||||
setDriveAnalyzeBusy((prev) => new Set([...prev, devicePath]));
|
||||
try {
|
||||
await api.analyzeDisc(devicePath);
|
||||
const response = await api.analyzeDisc(devicePath);
|
||||
await refreshPipeline();
|
||||
await loadDashboardJobs();
|
||||
const analyzedJobId = normalizeJobId(response?.result?.jobId);
|
||||
if (analyzedJobId) {
|
||||
setMetadataDialogContext({
|
||||
jobId: analyzedJobId,
|
||||
detectedTitle: response?.result?.detectedTitle || '',
|
||||
selectedMetadata: {
|
||||
title: response?.result?.detectedTitle || '',
|
||||
year: null,
|
||||
imdbId: null,
|
||||
poster: null
|
||||
},
|
||||
omdbCandidates: Array.isArray(response?.result?.omdbCandidates)
|
||||
? response.result.omdbCandidates
|
||||
: []
|
||||
});
|
||||
setMetadataDialogVisible(true);
|
||||
}
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
} finally {
|
||||
@@ -2284,7 +2314,10 @@ export default function DashboardPage({
|
||||
}
|
||||
if (device?.path) {
|
||||
const base = driveMap.get(device.path) || { path: device.path, model: device.model };
|
||||
driveMap.set(device.path, { ...base, pipelineDevice: device, pipelineState: state });
|
||||
// When device comes from a recent DISC_DETECTED event, use 'DISC_DETECTED' as the
|
||||
// effective state for that drive even if the global pipeline state is ENCODING etc.
|
||||
const effectivePipelineState = lastNonCdDiscEvent ? 'DISC_DETECTED' : state;
|
||||
driveMap.set(device.path, { ...base, pipelineDevice: device, pipelineState: effectivePipelineState });
|
||||
}
|
||||
// For drives that the detection service found but aren't tracked by cdDrives or the global
|
||||
// state machine (e.g. a second non-CD disc), show DISC_DETECTED using detectedDiscs.
|
||||
@@ -2297,7 +2330,7 @@ export default function DashboardPage({
|
||||
return Array.from(driveMap.values())
|
||||
.filter((drv) => !String(drv.path || '').startsWith('__virtual__'))
|
||||
.sort((a, b) => (a.path || '').localeCompare(b.path || ''));
|
||||
}, [knownDrives, pipeline?.cdDrives, pipeline?.detectedDiscs, device, state]);
|
||||
}, [knownDrives, pipeline?.cdDrives, pipeline?.detectedDiscs, device, state, lastNonCdDiscEvent]);
|
||||
const isDriveActive = driveActiveStates.includes(state);
|
||||
const canRescan = !isDriveActive;
|
||||
const canOpenMetadataModal = Boolean(defaultMetadataDialogContext?.jobId);
|
||||
@@ -2801,7 +2834,7 @@ export default function DashboardPage({
|
||||
const statusBadgeValue = getStatusLabel(job?.status, { queued: isQueued });
|
||||
const statusBadgeSeverity = getStatusSeverity(normalizedStatus, { queued: isQueued });
|
||||
const isExpanded = normalizeJobId(expandedJobId) === jobId;
|
||||
const isCurrentSession = currentPipelineJobId === jobId && state !== 'IDLE';
|
||||
const isCurrentSession = liveLogJobId === jobId && (state !== 'IDLE' || liveLogActive);
|
||||
const reviewConfirmed = Boolean(Number(job?.encode_review_confirmed || 0));
|
||||
const pipelineForJob = pipelineByJobId.get(jobId) || pipeline;
|
||||
const jobTitle = job?.title || job?.detected_title || `Job #${jobId}`;
|
||||
|
||||
Reference in New Issue
Block a user