feat(p2v): 무빙 포스터·롱컷 통합 및 상세·소셜 기능 연결
This commit is contained in:
1 parent
cd71f6d9d3
commit
c06018d88c
42 files changed
+3020
-1610
No files matched your search
@@ -37,8 +37,13 @@ import SsulResultContent from '../Ssulbox/SsulResultContent';
|
||||
import PosterMakingContent from '../Poster/PosterMakingContent';
|
||||
import PosterReviewContent from '../Poster/PosterReviewContent';
|
||||
import PosterResultContent from '../Poster/PosterResultContent';
|
||||
import PlayreelMakingContent from '../P2v/PlayreelMakingContent';
|
||||
import PlayreelGateContent from '../P2v/PlayreelGateContent';
|
||||
import PlayreelResultContent from '../P2v/PlayreelResultContent';
|
||||
import { usePlayreelJob } from '../../hooks/usePlayreelJob';
|
||||
import { GateKey, deletePlayreelJob } from '../../utils/playreelApi';
|
||||
import { useP2vJob } from '../../hooks/useP2vJob';
|
||||
import { deletePosterJob, isPastReview, retryPosterJob } from '../../utils/p2vApi';
|
||||
import { deletePosterJob, isPastReview } from '../../utils/p2vApi';
|
||||
import {
|
||||
K,
|
||||
clearProjectStorage,
|
||||
@@ -83,6 +88,21 @@ const SSUL_STEP_INDEX: Record<SsulStep, number> = {
|
||||
*/
|
||||
type PosterStep = 'entry' | 'making' | 'review' | 'result';
|
||||
|
||||
/** 롱컷(Playreel) 진행 단계. 포스터와 같은 이유로 잡 status 에서 파생한다 */
|
||||
type PlayreelStep = 'entry' | 'making' | 'review' | 'result';
|
||||
|
||||
/**
|
||||
* 롱컷 스텝퍼 라벨. 검수 게이트가 5번이라 게이트마다 칸을 두면 너무 길어진다 —
|
||||
* 승인 전 준비(수집·분석) / 확인 / 승인 후 생성으로 묶는다.
|
||||
*/
|
||||
const PLAYREEL_STEP_LABELS = [
|
||||
'playreel.steps.input',
|
||||
'playreel.steps.prepare',
|
||||
'playreel.steps.review',
|
||||
'playreel.steps.render',
|
||||
'playreel.steps.done',
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* 스텝퍼 라벨. 5단계인 이유는 검수 게이트 **앞뒤가 서로 다른 작업**이기 때문이다 —
|
||||
* 분석(검출·나레이션·모션)과 생성(음성·음악·애니메이션·렌더)을 한 칸에 묶으면
|
||||
@@ -215,8 +235,18 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
() => localStorage.getItem(K.POSTER_JOB_ID),
|
||||
);
|
||||
const [posterBusy, setPosterBusy] = useState(false);
|
||||
|
||||
/** 롱컷(Playreel) 잡. 포스터 영상과 같은 규칙으로 서버 status 에서 단계를 파생한다 */
|
||||
const [playreelJobId, setPlayreelJobId] = useState<string | null>(
|
||||
() => localStorage.getItem(K.PLAYREEL_JOB_ID),
|
||||
);
|
||||
const [playreelBusy, setPlayreelBusy] = useState(false);
|
||||
/** 방금 자동 승인한 게이트. 진행 화면이 안내를 보여주고, 새 잡·검수 화면에서 지운다 */
|
||||
const [playreelAutoGate, setPlayreelAutoGate] = useState<GateKey | null>(null);
|
||||
const { job: playreelJob, notFound: playreelNotFound, refresh: refreshPlayreelJob } =
|
||||
usePlayreelJob(pipeline === 'playreel' ? playreelJobId : null);
|
||||
const { job: posterJob, notFound: posterNotFound, refresh: refreshPosterJob } =
|
||||
useP2vJob('f1', pipeline === 'poster' ? posterJobId : null);
|
||||
useP2vJob(pipeline === 'poster' ? posterJobId : null);
|
||||
|
||||
const changePipeline = (next: Pipeline) => {
|
||||
setPipeline(next);
|
||||
@@ -241,12 +271,40 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
? 4
|
||||
: isPastReview(posterJob) ? 3 : 1;
|
||||
|
||||
const playreelStep: PlayreelStep = !playreelJobId
|
||||
? 'entry'
|
||||
: playreelJob?.status === 'awaiting_review' && playreelJob.gate && playreelJob.review
|
||||
? 'review'
|
||||
: playreelJob?.status === 'done'
|
||||
? 'result'
|
||||
: 'making'; // queued · running · failed · 조회 전(null)
|
||||
|
||||
// 자동 승인 안내는 다음 확인 요청(또는 완성)이 오면 낡은 정보라 지운다
|
||||
useEffect(() => {
|
||||
// 승인 직후에도 한동안 같은 게이트가 검수 대기로 보이므로, 다른 게이트일 때만 지운다
|
||||
if (playreelStep === 'result' || (playreelStep === 'review' && playreelJob?.gate !== playreelAutoGate)) {
|
||||
setPlayreelAutoGate(null);
|
||||
}
|
||||
}, [playreelStep, playreelJob?.gate, playreelAutoGate]);
|
||||
|
||||
/** 첫 게이트(연출 확인)를 승인했으면 이후 대기는 '생성' 구간이다 */
|
||||
const playreelPastApproval = playreelJob?.stages.motion?.status !== undefined
|
||||
&& playreelJob.stages.motion.status !== 'idle';
|
||||
|
||||
const playreelStepIndex = playreelStep === 'entry'
|
||||
? 0
|
||||
: playreelStep === 'review'
|
||||
? 2
|
||||
: playreelStep === 'result'
|
||||
? 4
|
||||
: playreelPastApproval ? 3 : 1;
|
||||
|
||||
/** 진입 화면(탭이 보이는 단계) 여부. 파이프라인마다 진입 조건이 다르다 */
|
||||
const isEntry =
|
||||
pipeline === 'ado2' ? wizardStep === -2
|
||||
: pipeline === 'ssul' ? ssulStep === 'entry'
|
||||
: pipeline === 'poster' ? posterStep === 'entry'
|
||||
// 스타일링은 전 과정이 진입 화면 안에서 끝난다 (위저드 없음)
|
||||
: pipeline === 'playreel' ? playreelStep === 'entry'
|
||||
: true;
|
||||
const [songTaskId, setSongTaskId] = useState<string | null>(savedSongTaskId);
|
||||
const [imageTaskId, setImageTaskId] = useState<string | null>(savedImageTaskId);
|
||||
@@ -623,24 +681,7 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
setPosterJobId(null);
|
||||
};
|
||||
|
||||
/**
|
||||
* 실패한 스테이지부터 다시. 업로드부터 다시 하지 않는다 —
|
||||
* i2v 실패(모델 큐·크레딧)는 같은 입력으로 재시도하면 자주 통과한다.
|
||||
*/
|
||||
const handlePosterRetry = async () => {
|
||||
if (!posterJobId || posterBusy) return;
|
||||
setPosterBusy(true);
|
||||
try {
|
||||
await retryPosterJob(posterJobId);
|
||||
refreshPosterJob();
|
||||
} catch {
|
||||
// 재시도 요청 자체가 실패해도 잡 상태는 그대로다 — 폴링 결과가 계속 화면을 그린다
|
||||
} finally {
|
||||
setPosterBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
/** 실패한 잡과 산출물을 지우고 처음부터. 되돌릴 수 없다 */
|
||||
/** 실패한 잡과 산출물을 지우고 처음부터. 크레딧은 실패 시점에 이미 환불됐다. 되돌릴 수 없다 */
|
||||
const handlePosterDiscard = async () => {
|
||||
if (!posterJobId || posterBusy) return;
|
||||
if (!window.confirm(t('poster.making.discardConfirm'))) return;
|
||||
@@ -655,13 +696,47 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
// ── 롱컷 (Playreel) ──────────────────────────────────────────────────
|
||||
|
||||
const handlePlayreelJobStarted = (jobId: string) => {
|
||||
localStorage.setItem(K.PLAYREEL_JOB_ID, jobId);
|
||||
setPlayreelJobId(jobId);
|
||||
};
|
||||
|
||||
/** 잡을 버리고 주소 입력 화면으로. 서버 잡은 남겨둔다(내 콘텐츠에 쓰인다) */
|
||||
const handlePlayreelNew = () => {
|
||||
localStorage.removeItem(K.PLAYREEL_JOB_ID);
|
||||
setPlayreelJobId(null);
|
||||
setPlayreelAutoGate(null);
|
||||
};
|
||||
|
||||
/** 실패한 잡과 산출물을 지우고 처음부터. 크레딧은 실패 시점에 이미 환불됐다. 되돌릴 수 없다 */
|
||||
const handlePlayreelDiscard = async () => {
|
||||
if (!playreelJobId || playreelBusy) return;
|
||||
if (!window.confirm(t('playreel.making.discardConfirm'))) return;
|
||||
setPlayreelBusy(true);
|
||||
try {
|
||||
await deletePlayreelJob(playreelJobId);
|
||||
} catch {
|
||||
// 서버에서 이미 사라졌어도 화면은 처음으로 돌려보내는 게 맞다
|
||||
} finally {
|
||||
setPlayreelBusy(false);
|
||||
handlePlayreelNew();
|
||||
}
|
||||
};
|
||||
|
||||
/** 사라졌거나 내 것이 아닌 롱컷 잡(404)이면 주소 입력 화면으로 되돌린다 */
|
||||
useEffect(() => {
|
||||
if (playreelNotFound) handlePlayreelNew();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [playreelNotFound]);
|
||||
|
||||
/**
|
||||
* 사라진 잡 정리.
|
||||
*
|
||||
* P2V 에는 "내 활성 잡" 엔드포인트가 없어(단일 팀 키라 사용자 개념이 없다)
|
||||
* localStorage 의 id 가 복구의 유일한 근거다. 그런데 서버를 재시작하거나 다른
|
||||
* 사람이 그 잡을 지우면 id 만 남아 **빈 진행 화면에서 영원히 멈춘다** — 실제로 겪었다.
|
||||
* 404 를 만나면 업로드 화면으로 되돌린다.
|
||||
* 복구의 근거는 localStorage 의 id 다. 그런데 그 잡이 지워졌거나 로그인한 사용자의
|
||||
* 것이 아니면(백엔드는 남의 잡을 404 로 답한다) id 만 남아 **빈 진행 화면에서
|
||||
* 영원히 멈춘다**. 404 를 만나면 업로드 화면으로 되돌린다.
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (posterNotFound) handlePosterNew();
|
||||
@@ -718,6 +793,7 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
setSsulStep('entry');
|
||||
// clearProjectStorage() 가 POSTER_JOB_ID 를 지우므로 state 도 함께 비운다
|
||||
setPosterJobId(null);
|
||||
setPlayreelJobId(null);
|
||||
setSongTaskId(null);
|
||||
setImageTaskId(null);
|
||||
setAnalysisData(null);
|
||||
@@ -745,6 +821,7 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
error={analysisError}
|
||||
onSsulJobStarted={handleSsulJobStarted}
|
||||
onPosterJobStarted={handlePosterJobStarted}
|
||||
onPlayreelJobStarted={handlePlayreelJobStarted}
|
||||
onGoToPayment={handleGoToPayment}
|
||||
/>
|
||||
);
|
||||
@@ -766,6 +843,34 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
}
|
||||
}
|
||||
|
||||
// 롱컷도 자체 축으로 진행한다 (단계는 잡 status 파생)
|
||||
if (pipeline === 'playreel') {
|
||||
switch (playreelStep) {
|
||||
case 'review':
|
||||
return playreelJob ? (
|
||||
<PlayreelGateContent
|
||||
key={playreelJob.gate}
|
||||
job={playreelJob}
|
||||
onChanged={refreshPlayreelJob}
|
||||
onAutoApproved={setPlayreelAutoGate}
|
||||
/>
|
||||
) : null;
|
||||
case 'result':
|
||||
return playreelJob ? (
|
||||
<PlayreelResultContent job={playreelJob} onNew={handlePlayreelNew} />
|
||||
) : null;
|
||||
default:
|
||||
return (
|
||||
<PlayreelMakingContent
|
||||
job={playreelJob}
|
||||
onDiscard={handlePlayreelDiscard}
|
||||
busy={playreelBusy}
|
||||
autoApprovedGate={playreelAutoGate}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 포스터 영상도 자체 축으로 진행한다 (단계는 잡 status 파생)
|
||||
if (pipeline === 'poster') {
|
||||
switch (posterStep) {
|
||||
@@ -781,7 +886,6 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
return (
|
||||
<PosterMakingContent
|
||||
job={posterJob}
|
||||
onRetry={handlePosterRetry}
|
||||
onDiscard={handlePosterDiscard}
|
||||
busy={posterBusy}
|
||||
/>
|
||||
@@ -913,6 +1017,18 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// 롱컷은 검수 게이트 5번을 준비·확인·생성 3구간으로 묶은 5단계
|
||||
if (pipeline === 'playreel') {
|
||||
return (
|
||||
<div className="wizard-page-container">
|
||||
<WizardStepper
|
||||
steps={PLAYREEL_STEP_LABELS.map((key) => t(key))}
|
||||
currentStep={playreelStepIndex}
|
||||
/>
|
||||
{renderWizardContent()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// 브랜드 분석(0)은 전체 화면 스크롤이지만 스텝퍼는 표시
|
||||
if (wizardStep === 0) {
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user