From db871cf12b2f38e9e21e55560a1e246188e32253 Mon Sep 17 00:00:00 2001 From: bizfix Date: Sat, 5 Dec 2026 21:12:51 +0800 Subject: [PATCH 1/8] feat(director-v2): add live production flow graph with step outputs, prompts, and invocation telemetry --- client/src/api/directorNext.ts | 7 + .../en/features/directorNext/messages.ts | 54 ++ .../zh-CN/features/directorNext/messages.ts | 54 ++ .../directorNext/workspace/NovelWorkspace.tsx | 4 +- .../workspace/ResourceDirectory.tsx | 7 +- .../src/pages/directorNext/workspace/model.ts | 4 +- .../workspace/visualizations/index.ts | 1 + .../productionFlow/ProductionFlowCanvas.tsx | 309 ++++++ .../ProductionFlowInspector.tsx | 480 +++++++++ .../ProductionFlowOutputTab.tsx | 370 +++++++ .../productionFlow/ProductionFlowView.tsx | 360 +++++++ .../visualizations/productionFlow/index.ts | 1 + .../visualizations/productionFlow/layout.ts | 383 ++++++++ .../productionFlow/productionFlow.css | 76 ++ .../promptWorkbench/PromptWorkbenchPage.tsx | 16 +- .../director-asset-visualizations.md | 8 + server/src/app/director/services.ts | 2 + server/src/app/director/workspace/index.ts | 1 + .../app/director/workspace/productionFlow.ts | 909 ++++++++++++++++++ server/src/modules/director/http/routes.ts | 11 + .../tests/directorNext/productionFlow.test.js | 240 +++++ shared/types/director/productionFlow.ts | 91 ++ 22 files changed, 3380 insertions(+), 8 deletions(-) create mode 100644 client/src/pages/directorNext/workspace/visualizations/productionFlow/ProductionFlowCanvas.tsx create mode 100644 client/src/pages/directorNext/workspace/visualizations/productionFlow/ProductionFlowInspector.tsx create mode 100644 client/src/pages/directorNext/workspace/visualizations/productionFlow/ProductionFlowOutputTab.tsx create mode 100644 client/src/pages/directorNext/workspace/visualizations/productionFlow/ProductionFlowView.tsx create mode 100644 client/src/pages/directorNext/workspace/visualizations/productionFlow/index.ts create mode 100644 client/src/pages/directorNext/workspace/visualizations/productionFlow/layout.ts create mode 100644 client/src/pages/directorNext/workspace/visualizations/productionFlow/productionFlow.css create mode 100644 server/src/app/director/workspace/productionFlow.ts create mode 100644 server/tests/directorNext/productionFlow.test.js create mode 100644 shared/types/director/productionFlow.ts diff --git a/client/src/api/directorNext.ts b/client/src/api/directorNext.ts index 65f2185059..278025fbed 100644 --- a/client/src/api/directorNext.ts +++ b/client/src/api/directorNext.ts @@ -47,6 +47,13 @@ export async function getDirectorLedgers(novelId:string):Promise>(`/director-next/novels/${encodeURIComponent(novelId)}/ledgers`)).data; } +export async function getDirectorProductionFlow(novelId: string, chapterId?: string): Promise> { + return (await apiClient.get>( + `/director-next/novels/${encodeURIComponent(novelId)}/production-flow`, + { params: chapterId ? { chapterId } : undefined, errorPresentation: "inline" }, + )).data; +} + export async function annotateVolumeSummaries(novelId: string, volumeIds: string[]) { const { data } = await apiClient.post>( `/director-next/novels/${encodeURIComponent(novelId)}/volume-summary-emphasis`, {volumeIds}, {errorPresentation:"inline"}, diff --git a/client/src/i18n/locales/en/features/directorNext/messages.ts b/client/src/i18n/locales/en/features/directorNext/messages.ts index 0353a22cc3..395f5a328a 100644 --- a/client/src/i18n/locales/en/features/directorNext/messages.ts +++ b/client/src/i18n/locales/en/features/directorNext/messages.ts @@ -1179,4 +1179,58 @@ export default { "worldMapEnrichMissingHint": "Some locations do not yet have saved coordinates or connecting routes. Let AI arrange relative positions and key routes from your saved world settings.", "worldMapEnrichDone": "Updated coordinates for {{locations}} locations and added {{connections}} routes.", "worldMapEnrichDoneWithForces": "Updated coordinates for {{locations}} locations, added {{connections}} routes and {{relations}} organization relations.", + "loadingProductionFlow": "Loading production flow graph…", + "productionFlowTitle": "Production Flow", + "productionFlowDescription": "Track live novel progress across all stages, inspect each step's saved output, linked prompts, and real model invocations. Click any node for details or a stage header to focus its branches.", + "productionFlowLocateActive": "Locate active step", + "productionFlowRefresh": "Refresh flow graph", + "productionFlowLoadFailed": "The production flow graph could not be loaded.", + "productionFlowRetry": "Reload", + "productionFlowSummarySteps": "Core steps", + "productionFlowSummaryChapters": "Completed chapters", + "productionFlowSummaryCalls": "Model calls", + "productionFlowSummaryQualityDebts": "{{count}} chapters need review", + "productionFlowStageFilterAria": "Filter production flow by stage", + "productionFlowOverviewTab": "Full book", + "productionFlowToggleBranches": "Show branches", + "productionFlowChapterScopeLabel": "Inspect chapter", + "productionFlowStatusCompleted": "Done", + "productionFlowStatusRunning": "Running", + "productionFlowStatusWaitingGate": "Awaiting confirmation", + "productionFlowStatusAttention": "Needs review", + "productionFlowStatusPaused": "Paused", + "productionFlowStatusSkipped": "Skipped", + "productionFlowStatusPending": "Pending", + "productionFlowStageProgress": "{{done}} / {{total}} done", + "productionFlowFocusStage": "Focus", + "productionFlowHasPromptHint": "This step uses a prompt template", + "productionFlowSelectNodeHint": "Select any step node on the flow graph to inspect its saved output, linked prompt templates, and model execution history.", + "productionFlowInspectorAria": "Step inspector", + "productionFlowProtectedBadge": "Protected edit", + "productionFlowOpenReviewGate": "Review & confirm stage", + "productionFlowTabOutput": "Output", + "productionFlowTabPrompts": "Prompts", + "productionFlowTabInvocations": "Executions", + "productionFlowNoPromptForStep": "This step is completed by the author or system orchestration and does not use a standalone model prompt.", + "productionFlowPreviewPromptHint": "Live templates are omitted in preview mode. Linked template key: {{key}}.", + "productionFlowOpenPromptWorkbench": "Open in Prompt Workbench", + "productionFlowLoadingInvocationDetail": "Loading prompt messages and response…", + "productionFlowLoadInvocationFailed": "Failed to load invocation details.", + "productionFlowNoPayloadSaved": "No prompt/response snapshot was saved for this call.", + "productionFlowActualPromptMessages": "Sent prompt messages ({{count}})", + "productionFlowActualModelOutput": "Model response", + "productionFlowNoInvocationsYet": "No model invocations have been recorded for this step yet.", + "productionFlowOpenFullUsagePage": "Open full AI usage log", + "productionFlowMetricCalls": "Calls", + "productionFlowMetricTokens": "Tokens", + "productionFlowMetricDuration": "Total time", + "productionFlowBookTitle": "Title", + "productionFlowNoOutputYet": "No saved output for this step yet.", + "productionFlowOpenStoryAsset": "Open full story plan", + "productionFlowOpenWorldAsset": "Open full world settings", + "productionFlowOpenCastAsset": "Open full character cast", + "productionFlowOpenVolumesAsset": "Open full volume plan", + "productionFlowOpenChapterReader": "Open chapter reader", + "productionFlowOpenChapterPlan": "Open chapter plan", + "productionFlowNoChapterProseYet": "No manuscript prose has been generated for the selected chapter yet.", } as const; diff --git a/client/src/i18n/locales/zh-CN/features/directorNext/messages.ts b/client/src/i18n/locales/zh-CN/features/directorNext/messages.ts index 31a77aa2d4..f539ce7c66 100644 --- a/client/src/i18n/locales/zh-CN/features/directorNext/messages.ts +++ b/client/src/i18n/locales/zh-CN/features/directorNext/messages.ts @@ -1179,4 +1179,58 @@ export default { "worldMapEnrichMissingHint": "部分地点尚未保存空间方位或路线连接,可由 AI 根据已保存设定补齐相对坐标与关键通道。", "worldMapEnrichDone": "已更新 {{locations}} 个地点的地图方位,新增 {{connections}} 条路线。", "worldMapEnrichDoneWithForces": "已更新 {{locations}} 个地点的地图方位,新增 {{connections}} 条路线与 {{relations}} 条势力关系。", + "loadingProductionFlow": "正在读取创作流程图…", + "productionFlowTitle": "创作流程图", + "productionFlowDescription": "按创作阶段查看本书实时进度、每步产出、关联提示词与真实模型调用记录。点击任意节点展开详情,点击阶段标题可聚焦该阶段分支。", + "productionFlowLocateActive": "定位当前步骤", + "productionFlowRefresh": "刷新流程图", + "productionFlowLoadFailed": "创作流程图暂时无法读取。", + "productionFlowRetry": "重新加载", + "productionFlowSummarySteps": "核心进度", + "productionFlowSummaryChapters": "已完成章节", + "productionFlowSummaryCalls": "模型调用", + "productionFlowSummaryQualityDebts": "{{count}} 章待复核", + "productionFlowStageFilterAria": "按创作阶段筛选流程图", + "productionFlowOverviewTab": "全书总览", + "productionFlowToggleBranches": "显示分支步骤", + "productionFlowChapterScopeLabel": "查看章节", + "productionFlowStatusCompleted": "已完成", + "productionFlowStatusRunning": "进行中", + "productionFlowStatusWaitingGate": "待确认", + "productionFlowStatusAttention": "待复核", + "productionFlowStatusPaused": "已暂停", + "productionFlowStatusSkipped": "已跳过", + "productionFlowStatusPending": "未开始", + "productionFlowStageProgress": "已完成 {{done}} / {{total}}", + "productionFlowFocusStage": "聚焦", + "productionFlowHasPromptHint": "此步骤关联提示词模板", + "productionFlowSelectNodeHint": "点击左侧流程图中的任意步骤节点,查看对应的实际产出、提示词模板与执行记录。", + "productionFlowInspectorAria": "步骤详情", + "productionFlowProtectedBadge": "已保护手改", + "productionFlowOpenReviewGate": "前往确认本阶段", + "productionFlowTabOutput": "本步产出", + "productionFlowTabPrompts": "提示词", + "productionFlowTabInvocations": "执行记录", + "productionFlowNoPromptForStep": "此步骤由作者操作或系统编排完成,不需要独立的模型提示词。", + "productionFlowPreviewPromptHint": "示例预览模式下不请求真实模板,绑定模板键:{{key}}。", + "productionFlowOpenPromptWorkbench": "去提示词工作台", + "productionFlowLoadingInvocationDetail": "正在读取本次调用的输入与输出…", + "productionFlowLoadInvocationFailed": "本次调用详情读取失败。", + "productionFlowNoPayloadSaved": "本次调用未保存详细提示词快照。", + "productionFlowActualPromptMessages": "实际发送的提示词消息({{count}} 条)", + "productionFlowActualModelOutput": "模型实际返回内容", + "productionFlowNoInvocationsYet": "本书在该步骤暂无模型调用记录。", + "productionFlowOpenFullUsagePage": "查看本书完整 AI 用量", + "productionFlowMetricCalls": "调用次数", + "productionFlowMetricTokens": "Token 用量", + "productionFlowMetricDuration": "累计耗时", + "productionFlowBookTitle": "书名", + "productionFlowNoOutputYet": "这一步还没有保存的产出内容。", + "productionFlowOpenStoryAsset": "查看完整故事规划", + "productionFlowOpenWorldAsset": "查看完整世界设定", + "productionFlowOpenCastAsset": "查看完整角色阵容", + "productionFlowOpenVolumesAsset": "查看完整分卷规划", + "productionFlowOpenChapterReader": "打开本章阅读", + "productionFlowOpenChapterPlan": "查看本章规划", + "productionFlowNoChapterProseYet": "所选章节还没有生成正文。", } as const; diff --git a/client/src/pages/directorNext/workspace/NovelWorkspace.tsx b/client/src/pages/directorNext/workspace/NovelWorkspace.tsx index 8d1b409493..cff051dca8 100644 --- a/client/src/pages/directorNext/workspace/NovelWorkspace.tsx +++ b/client/src/pages/directorNext/workspace/NovelWorkspace.tsx @@ -28,6 +28,7 @@ import type { CharacterForwardPreview } from "@ai-novel/shared/types/characterFo import type { CharacterProfileImpactSuggestion } from "@ai-novel/shared/types/director/characterProfileImpact"; const WorldMapView = lazy(()=>import("./visualizations").then(module=>({default:module.WorldMapView}))); const CharacterGraphView = lazy(()=>import("./visualizations").then(module=>({default:module.CharacterGraphView}))); +const ProductionFlowView = lazy(()=>import("./visualizations").then(module=>({default:module.ProductionFlowView}))); const CHAPTER_REFERENCE_DOCK_MIN_WIDTH = 896; export function NovelWorkspace({ book, preview = false, review, onLeaveReview, onOpenChapterReview, followGeneration = false, generation = null, activity, onEditChapter, editedChapter, onInlineChapterSaved, onInlineEditingChange, onAdjustingCharacter, onOpenProseReview }: { book: WorkspaceBook; preview?: boolean; review?:URLSearchParams; onLeaveReview?:()=>void; onOpenChapterReview?:()=>void; followGeneration?:boolean; generation?:DirectorGenerationSnapshot|null; activity?:DirectorWorkspaceActivity; onEditChapter?:(chapterId:string)=>void; editedChapter?:{id:string;revision:number}|null; onInlineChapterSaved?:(chapterId:string)=>Promise|void; onInlineEditingChange?:(active:boolean)=>void; onAdjustingCharacter?:(active:boolean)=>void; onOpenProseReview?:(suggestions:CharacterProfileImpactSuggestion[])=>void }) { @@ -193,7 +194,8 @@ export function NovelWorkspace({ book, preview = false, review, onLeaveReview, o :
{followTarget && sameSelection(selected, followTarget.selection) && selected.kind !== "chapter" && activity?.focus ?

: null} - {selected.kind === "world_map" ? {uiI18n.t("loadingWorldMap", {ns: "directorNext"})}

}>select({kind:"world"})}/>
+ {selected.kind === "production_flow" ? {uiI18n.t("loadingProductionFlow", {ns: "directorNext"})}

}>
+ : selected.kind === "world_map" ? {uiI18n.t("loadingWorldMap", {ns: "directorNext"})}

}>select({kind:"world"})}/>
: selected.kind === "character_graph" ? {uiI18n.t("loadingCharacterGraph", {ns: "directorNext"})}

}>select({kind:"character",id})}/>
: selected.kind === "character_timeline" ? : selected.kind === "foreshadowing" || selected.kind === "resources" || selected.kind === "character_resources" ? diff --git a/client/src/pages/directorNext/workspace/ResourceDirectory.tsx b/client/src/pages/directorNext/workspace/ResourceDirectory.tsx index 26958b3987..5ebf34213e 100644 --- a/client/src/pages/directorNext/workspace/ResourceDirectory.tsx +++ b/client/src/pages/directorNext/workspace/ResourceDirectory.tsx @@ -3,7 +3,7 @@ import UiText from "@/components/i18n/LocalizedText"; import { i18n as uiI18n, useTranslation as useUiTranslation, toUiText as uiTextValue } from "@/i18n"; import { BookMarked, BookOpen, CalendarDays, FileText, Globe2, Layers, ListChecks, - Lock, Map, Network, Package, Route, Users, type LucideIcon, + Lock, Map, Network, Package, Route, Users, Workflow, type LucideIcon, } from "lucide-react"; import type { Selection, WorkspaceBook } from "./model"; import { buildStoryDirectory, beatSelection, chapterSelection, sameSelection, type PlannedChapter } from "./planning"; @@ -72,7 +72,10 @@ export function ResourceDirectory({ book, selected, onSelect }: { book: Workspac return - {/* Legend + Controls Row */} + {/* Minimal Controls & Proof Legend */}
-
+
-
@@ -436,6 +401,7 @@ export function ProductionFlowView({ focusStepRequest={focusRequest} onSelectStep={setSelectedStepId} onFocusStage={stageId => setScope(stageId)} + onBackToOverview={() => setScope("overview")} /> { hasWaitingGate: boolean; hasAttention: boolean; allDone: boolean; + direction: "ltr" | "rtl"; onFocusStage: (stageId: ProductionFlowStageId) => void; } @@ -26,11 +27,16 @@ export interface LiveStepNodeData extends Record { order: number; branchLabel?: string; isBranch: boolean; + illustrated: boolean; state: ProductionFlowNodeState; selected: boolean; onSelect: (stepId: string) => void; } +export interface SerpentineEdgeData extends Record { + turn?: "right" | "left"; +} + export type StageHeaderNode = Node; export type LiveStepNode = Node; export type ProductionFlowGraphNode = StageHeaderNode | LiveStepNode; @@ -62,36 +68,61 @@ function isStepActive(state: ProductionFlowNodeState | undefined): boolean { return state?.status === "running" || state?.status === "waiting_gate"; } +const STAGE_MARKER_HEX: Record = { + opening: "#265e62", + foundation: "#765064", + volumes: "#855931", + preparation: "#44617f", + writing: "#516742", +}; + function resolveEdgeAppearance( + stageId: string, sourceState: ProductionFlowNodeState | undefined, targetState: ProductionFlowNodeState | undefined, branch: boolean, ): { className: string; animated: boolean; markerColor: string } { - if (isStepActive(targetState)) { + const stageClass = `pf-stage-${stageId}`; + const stageHex = STAGE_MARKER_HEX[stageId] ?? "#265e62"; + if (targetState?.status === "running") { + return { + className: `pf-edge pf-edge-active ${stageClass}`, + animated: true, + markerColor: "#c0442a", + }; + } + if (targetState?.status === "waiting_gate") { return { - className: targetState?.status === "waiting_gate" ? "pf-edge pf-edge-gate" : "pf-edge pf-edge-active", + className: `pf-edge pf-edge-gate ${stageClass}`, animated: true, - markerColor: targetState?.status === "waiting_gate" ? "var(--pf-gate)" : "var(--pf-active)", + markerColor: "#c47a16", + }; + } + if (targetState?.status === "attention") { + return { + className: `pf-edge pf-edge-attention ${stageClass}`, + animated: false, + markerColor: "#c0442a", }; } if (isStepDone(sourceState) && isStepDone(targetState)) { return { - className: branch ? "pf-edge pf-edge-done pf-edge-branch" : "pf-edge pf-edge-done", + className: branch ? `pf-edge pf-edge-done pf-edge-branch ${stageClass}` : `pf-edge pf-edge-done ${stageClass}`, animated: false, - markerColor: "var(--pf-done)", + markerColor: stageHex, }; } if (isStepDone(sourceState) && !branch) { return { - className: "pf-edge pf-edge-frontier", + className: `pf-edge pf-edge-frontier ${stageClass}`, animated: false, - markerColor: "var(--pf-active)", + markerColor: stageHex, }; } return { - className: branch ? "pf-edge pf-edge-pending pf-edge-branch" : "pf-edge pf-edge-pending", + className: branch ? `pf-edge pf-edge-pending pf-edge-branch ${stageClass}` : `pf-edge pf-edge-pending ${stageClass}`, animated: false, - markerColor: "var(--pf-pending-stroke)", + markerColor: "#9ca3af", }; } @@ -109,22 +140,24 @@ export function buildProductionFlowGraph(params: { const edges: Edge[] = []; if (scope === "overview") { - // Horizontal stage-by-stage production tracks (left -> right progression per stage, top -> bottom stages). - const stageBadgeWidth = 176; - const stageBadgeGap = 28; - const stepWidth = 216; - const stepHeight = 86; - const stepGapX = 42; - const branchWidth = 198; - const branchHeight = 72; - const branchGapY = 26; - const baseRowGapY = 44; - const trackStartX = stageBadgeWidth + stageBadgeGap; + // True continuous serpentine river: 5 alternating LTR / RTL stage tracks with sweeping semicircular U-turns. + const coverWidth = 176; + const coverHeight = 92; + const stationWidth = 176; + const stationHeight = 96; + const branchWidth = 172; + const branchHeight = 76; + const totalRowSpan = 1140; // Right edge of rightmost node across all 5 rows + const baseRowPitch = 154; - let cursorY = 0; + let cursorY = 12; + let prevRowEndId: string | null = null; + let prevRowEndState: ProductionFlowNodeState | undefined; + let prevRowDirection: "ltr" | "rtl" = "ltr"; stages.forEach((stage, stageIndex) => { const stageId = stage.id as ProductionFlowStageId; + const direction: "ltr" | "rtl" = stageIndex % 2 === 0 ? "ltr" : "rtl"; const mainStates = stage.main.map(step => nodeMap[step.id] ?? fallbackNodeState(step.id, stageId)); const doneCount = mainStates.filter(isStepDone).length; const hasActive = mainStates.some(s => s.status === "running"); @@ -132,12 +165,24 @@ export function buildProductionFlowGraph(params: { const hasAttention = mainStates.some(s => s.status === "attention" || s.status === "paused"); const allDone = doneCount === stage.main.length; + // Distribute cover + main steps evenly across totalRowSpan so 4-step and 5-step rows stagger organically. + const slotCount = stage.main.length + 1; + const maxStart = totalRowSpan - stationWidth; + const stepPitch = slotCount > 1 ? maxStart / (slotCount - 1) : 0; + const slotX = (slotIndex: number) => + direction === "ltr" + ? Math.round(slotIndex * stepPitch) + : Math.round(maxStart - slotIndex * stepPitch); + + const coverId = `stage-cover-${stage.id}`; + const coverY = cursorY + Math.round((stationHeight - coverHeight) / 2); + nodes.push({ - id: `stage-header-${stage.id}`, + id: coverId, type: "stageHeader", - position: { x: 0, y: cursorY }, - width: stageBadgeWidth, - height: stepHeight, + position: { x: slotX(0), y: coverY }, + width: coverWidth, + height: coverHeight, selectable: false, draggable: false, focusable: false, @@ -150,22 +195,41 @@ export function buildProductionFlowGraph(params: { hasWaitingGate, hasAttention, allDone, + direction, onFocusStage, }, }); + // Sweeping semicircular U-turn from previous row's last step into this row's stage cover + if (prevRowEndId) { + const turn: "right" | "left" = prevRowDirection === "ltr" ? "right" : "left"; + const appearance = resolveEdgeAppearance(stage.id, prevRowEndState, mainStates[0], false); + edges.push({ + id: `e-uturn-${prevRowEndId}-${coverId}`, + source: prevRowEndId, + target: coverId, + sourceHandle: turn === "right" ? "right-out" : "left-out", + targetHandle: turn === "right" ? "right-in" : "left-in", + type: "serpentine", + animated: appearance.animated, + className: `${appearance.className} pf-edge-uturn`, + data: { turn } satisfies SerpentineEdgeData, + markerEnd: { type: MarkerType.ArrowClosed, width: 12, height: 12, color: appearance.markerColor }, + }); + } + const stepXById = new Map(); stage.main.forEach((step, idx) => { - const x = trackStartX + idx * (stepWidth + stepGapX); + const x = slotX(idx + 1); stepXById.set(step.id, x); const state = mainStates[idx]; nodes.push({ id: step.id, type: "liveStep", position: { x, y: cursorY }, - width: stepWidth, - height: stepHeight, + width: stationWidth, + height: stationHeight, draggable: false, focusable: false, data: { @@ -173,58 +237,42 @@ export function buildProductionFlowGraph(params: { stage, order: idx, isBranch: false, + illustrated: false, state, selected: selectedStepId === step.id, onSelect: onSelectStep, }, }); - if (idx > 0) { - const prev = stage.main[idx - 1]; - const prevState = mainStates[idx - 1]; - const appearance = resolveEdgeAppearance(prevState, state, false); - edges.push({ - id: `e-main-${prev.id}-${step.id}`, - source: prev.id, - target: step.id, - sourceHandle: "right-out", - targetHandle: "left-in", - type: "straight", - animated: appearance.animated, - className: appearance.className, - markerEnd: { type: MarkerType.ArrowClosed, width: 13, height: 13, color: appearance.markerColor }, - }); - } - }); - // Vertical stage-to-stage spine link on the stage badges - if (stageIndex > 0) { - const prevStage = stages[stageIndex - 1]; - const prevLastState = nodeMap[prevStage.main[prevStage.main.length - 1].id]; - const firstState = mainStates[0]; - const appearance = resolveEdgeAppearance(prevLastState, firstState, false); + const sourceId = idx === 0 ? coverId : stage.main[idx - 1].id; + const sourceState = idx === 0 + ? (allDone || doneCount > 0 || isStepActive(state) ? state : prevRowEndState) + : mainStates[idx - 1]; + const appearance = resolveEdgeAppearance(stage.id, sourceState, state, false); edges.push({ - id: `e-stage-handoff-${prevStage.id}-${stage.id}`, - source: `stage-header-${prevStage.id}`, - target: `stage-header-${stage.id}`, - sourceHandle: "stage-bottom", - targetHandle: "stage-top", + id: `e-main-${sourceId}-${step.id}`, + source: sourceId, + target: step.id, + sourceHandle: direction === "ltr" ? "right-out" : "left-out", + targetHandle: direction === "ltr" ? "left-in" : "right-in", type: "straight", animated: appearance.animated, - className: `${appearance.className} pf-edge-stage-rail`, - markerEnd: { type: MarkerType.ArrowClosed, width: 12, height: 12, color: appearance.markerColor }, + className: appearance.className, + markerEnd: { type: MarkerType.ArrowClosed, width: 11, height: 11, color: appearance.markerColor }, }); - } + }); - let rowBottom = cursorY + stepHeight; + let rowBottom = cursorY + stationHeight; if (showBranches && stage.branches?.length) { const laneBottomByX = new Map(); for (const branch of stage.branches) { - const fromX = stepXById.get(branch.from) ?? trackStartX; - const branchY = laneBottomByX.get(fromX) ?? (cursorY + stepHeight + branchGapY); + const fromX = stepXById.get(branch.from) ?? slotX(1); + const branchY = laneBottomByX.get(fromX) ?? (cursorY + stationHeight + 24); const parentState = nodeMap[branch.from]; branch.steps.forEach((step, idx) => { - const x = fromX + idx * (branchWidth + 28); + const delta = idx * (branchWidth + 24) * (direction === "ltr" ? 1 : -1); + const x = Math.max(0, Math.min(totalRowSpan - branchWidth, fromX + delta)); const state = nodeMap[step.id] ?? fallbackNodeState(step.id, stageId); nodes.push({ id: step.id, @@ -240,13 +288,14 @@ export function buildProductionFlowGraph(params: { order: idx, branchLabel: idx === 0 ? branch.label : undefined, isBranch: true, + illustrated: false, state, selected: selectedStepId === step.id, onSelect: onSelectStep, }, }); if (idx === 0) { - const appearance = resolveEdgeAppearance(parentState, state, true); + const appearance = resolveEdgeAppearance(stage.id, parentState, state, true); edges.push({ id: `e-branch-${branch.from}-${step.id}`, source: branch.from, @@ -260,43 +309,46 @@ export function buildProductionFlowGraph(params: { }); } else { const prev = branch.steps[idx - 1]; - const appearance = resolveEdgeAppearance(nodeMap[prev.id], state, true); + const appearance = resolveEdgeAppearance(stage.id, nodeMap[prev.id], state, true); edges.push({ id: `e-branch-${prev.id}-${step.id}`, source: prev.id, target: step.id, - sourceHandle: "right-out", - targetHandle: "left-in", + sourceHandle: direction === "ltr" ? "right-out" : "left-out", + targetHandle: direction === "ltr" ? "left-in" : "right-in", type: "straight", animated: appearance.animated, className: appearance.className, markerEnd: { type: MarkerType.ArrowClosed, width: 10, height: 10, color: appearance.markerColor }, }); } - const nextY = branchY + branchHeight + 16; + const nextY = branchY + branchHeight + 14; laneBottomByX.set(x, Math.max(laneBottomByX.get(x) ?? nextY, nextY)); rowBottom = Math.max(rowBottom, branchY + branchHeight); }); - laneBottomByX.set(fromX, branchY + branchHeight + 16); + laneBottomByX.set(fromX, branchY + branchHeight + 14); } } - cursorY = rowBottom + baseRowGapY; + prevRowEndId = stage.main[stage.main.length - 1].id; + prevRowEndState = mainStates[mainStates.length - 1]; + prevRowDirection = direction; + cursorY = Math.max(cursorY + baseRowPitch, rowBottom + 56); }); return { nodes, edges }; } - // Focused single-stage view: spacious horizontal main production spine + branches directly below + // Focused single-stage illustrated craft board: bespoke ManuscriptFigure cards + graceful branch arcs const stage = stages.find(item => item.id === scope) ?? stages[0]; const stageId = stage.id as ProductionFlowStageId; - const mainWidth = 236; - const mainHeight = 96; - const mainGapX = 54; - const branchWidth = 220; - const branchHeight = 80; - const branchOffsetY = mainHeight + 60; - const branchRowGap = 20; + const mainWidth = 204; + const mainHeight = 176; + const mainGapX = 48; + const branchWidth = 200; + const branchHeight = 76; + const branchOffsetY = mainHeight + 58; + const branchRowGap = 18; const mainXById = new Map(); @@ -317,6 +369,7 @@ export function buildProductionFlowGraph(params: { stage, order: idx, isBranch: false, + illustrated: true, state, selected: selectedStepId === step.id, onSelect: onSelectStep, @@ -324,7 +377,7 @@ export function buildProductionFlowGraph(params: { }); if (idx > 0) { const prev = stage.main[idx - 1]; - const appearance = resolveEdgeAppearance(nodeMap[prev.id], state, false); + const appearance = resolveEdgeAppearance(stage.id, nodeMap[prev.id], state, false); edges.push({ id: `e-stage-main-${prev.id}-${step.id}`, source: prev.id, @@ -334,7 +387,7 @@ export function buildProductionFlowGraph(params: { type: "straight", animated: appearance.animated, className: appearance.className, - markerEnd: { type: MarkerType.ArrowClosed, width: 14, height: 14, color: appearance.markerColor }, + markerEnd: { type: MarkerType.ArrowClosed, width: 13, height: 13, color: appearance.markerColor }, }); } }); @@ -363,13 +416,14 @@ export function buildProductionFlowGraph(params: { order: idx, branchLabel: idx === 0 ? branch.label : undefined, isBranch: true, + illustrated: false, state, selected: selectedStepId === step.id, onSelect: onSelectStep, }, }); if (idx === 0) { - const appearance = resolveEdgeAppearance(parentState, state, true); + const appearance = resolveEdgeAppearance(stage.id, parentState, state, true); edges.push({ id: `e-stage-branch-${branch.from}-${step.id}`, source: branch.from, @@ -379,11 +433,11 @@ export function buildProductionFlowGraph(params: { type: "smoothstep", animated: appearance.animated, className: appearance.className, - markerEnd: { type: MarkerType.ArrowClosed, width: 11, height: 11, color: appearance.markerColor }, + markerEnd: { type: MarkerType.ArrowClosed, width: 10, height: 10, color: appearance.markerColor }, }); } else { const prev = branch.steps[idx - 1]; - const appearance = resolveEdgeAppearance(nodeMap[prev.id], state, true); + const appearance = resolveEdgeAppearance(stage.id, nodeMap[prev.id], state, true); edges.push({ id: `e-stage-branch-${prev.id}-${step.id}`, source: prev.id, @@ -393,15 +447,15 @@ export function buildProductionFlowGraph(params: { type: "straight", animated: appearance.animated, className: appearance.className, - markerEnd: { type: MarkerType.ArrowClosed, width: 11, height: 11, color: appearance.markerColor }, + markerEnd: { type: MarkerType.ArrowClosed, width: 10, height: 10, color: appearance.markerColor }, }); } const nextLaneY = y + branchHeight + branchRowGap; - laneBottomByColumn.set(x, Math.max(laneBottomByColumn.get(x) ?? branchOffsetY, nextLaneY)); + laneBottomByColumn.set(x, Math.max(laneBottomByColumn.get(x) ?? nextLaneY, nextLaneY)); }); if (branch.join && mainXById.has(branch.join)) { const last = branch.steps[branch.steps.length - 1]; - const appearance = resolveEdgeAppearance(nodeMap[last.id], nodeMap[branch.join], true); + const appearance = resolveEdgeAppearance(stage.id, nodeMap[last.id], nodeMap[branch.join], true); edges.push({ id: `e-stage-join-${last.id}-${branch.join}`, source: last.id, @@ -410,7 +464,7 @@ export function buildProductionFlowGraph(params: { targetHandle: "bottom-in", type: "smoothstep", className: appearance.className, - markerEnd: { type: MarkerType.ArrowClosed, width: 11, height: 11, color: appearance.markerColor }, + markerEnd: { type: MarkerType.ArrowClosed, width: 10, height: 10, color: appearance.markerColor }, }); } laneBottomByColumn.set(fromX, y + branchHeight + branchRowGap); diff --git a/client/src/pages/directorNext/workspace/visualizations/productionFlow/productionFlow.css b/client/src/pages/directorNext/workspace/visualizations/productionFlow/productionFlow.css index 14a142be32..a49d699336 100644 --- a/client/src/pages/directorNext/workspace/visualizations/productionFlow/productionFlow.css +++ b/client/src/pages/directorNext/workspace/visualizations/productionFlow/productionFlow.css @@ -1,47 +1,97 @@ +/* Editorial Print-Studio Serpentine Production Flow (Design 1 + 2) */ .pf-canvas-shell { - --pf-done: #15803d; - --pf-done-bg: color-mix(in srgb, #16a34a 9%, var(--background)); - --pf-done-border: color-mix(in srgb, #16a34a 32%, var(--border)); - --pf-active: var(--primary); - --pf-active-bg: color-mix(in srgb, var(--primary) 11%, var(--background)); - --pf-gate: #d97706; - --pf-gate-bg: color-mix(in srgb, #f59e0b 12%, var(--background)); - --pf-attention: #ea580c; - --pf-attention-bg: color-mix(in srgb, #f97316 12%, var(--background)); - --pf-pending-stroke: color-mix(in srgb, var(--foreground) 18%, transparent); + --atlas-stock: color-mix(in srgb, var(--background) 93%, #dcc799); + --atlas-pigment: #265e62; + --atlas-ink: color-mix(in srgb, var(--atlas-pigment) 84%, var(--foreground)); + --atlas-tint: color-mix(in srgb, var(--atlas-ink) 14%, var(--atlas-stock)); + --atlas-proof: #b84228; + --atlas-display: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif; + + --pf-paper: color-mix(in srgb, var(--background) 92%, #d7c08e); + --pf-surface: color-mix(in srgb, var(--background) 97%, #e9d9b4); + --pf-hair: color-mix(in srgb, var(--foreground) 13%, var(--pf-paper)); + --pf-pending-stroke: color-mix(in srgb, var(--foreground) 20%, transparent); + --pf-proof: #c0442a; + --pf-proof-bg: color-mix(in srgb, #c0442a 10%, var(--pf-surface)); + --pf-gate: #c47a16; + --pf-gate-bg: color-mix(in srgb, #d98218 11%, var(--pf-surface)); + --pf-stage-ink: #265e62; + position: relative; width: 100%; - min-height: 500px; - height: clamp(500px, 64dvh, 760px); + min-height: 540px; + height: clamp(540px, 68dvh, 780px); border-radius: 0.875rem; background: - radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--primary) 5%, transparent), transparent 48%), - color-mix(in srgb, var(--muted) 32%, var(--background)); + radial-gradient(ellipse at 12% 8%, color-mix(in srgb, #e8d2a0 26%, transparent), transparent 52%), + radial-gradient(ellipse at 88% 92%, color-mix(in srgb, #265e62 6%, transparent), transparent 50%), + var(--pf-paper); overflow: hidden; } .dark .pf-canvas-shell { - --pf-done: #4ade80; - --pf-done-bg: color-mix(in srgb, #22c55e 12%, var(--background)); - --pf-done-border: color-mix(in srgb, #22c55e 36%, var(--border)); - --pf-gate: #fbbf24; - --pf-gate-bg: color-mix(in srgb, #f59e0b 14%, var(--background)); - --pf-attention: #fb923c; - --pf-attention-bg: color-mix(in srgb, #f97316 14%, var(--background)); - --pf-pending-stroke: color-mix(in srgb, var(--foreground) 22%, transparent); -} - -.pf-stage-ribbon[data-stage="opening"] { --pf-stage-color: #265e62; } -.pf-stage-ribbon[data-stage="foundation"] { --pf-stage-color: #765064; } -.pf-stage-ribbon[data-stage="volumes"] { --pf-stage-color: #8f5b28; } -.pf-stage-ribbon[data-stage="preparation"] { --pf-stage-color: #3d6389; } -.pf-stage-ribbon[data-stage="writing"] { --pf-stage-color: #4b7040; } - -.dark .pf-stage-ribbon[data-stage="opening"] { --pf-stage-color: #5eead4; } -.dark .pf-stage-ribbon[data-stage="foundation"] { --pf-stage-color: #f0abfc; } -.dark .pf-stage-ribbon[data-stage="volumes"] { --pf-stage-color: #fbbf24; } -.dark .pf-stage-ribbon[data-stage="preparation"] { --pf-stage-color: #7dd3fc; } -.dark .pf-stage-ribbon[data-stage="writing"] { --pf-stage-color: #86efac; } + --atlas-stock: color-mix(in srgb, var(--background) 94%, #2f261b); + --atlas-ink: color-mix(in srgb, var(--atlas-pigment) 46%, var(--foreground)); + --atlas-tint: color-mix(in srgb, var(--atlas-pigment) 24%, var(--atlas-stock)); + --atlas-proof: #f29678; + + --pf-paper: color-mix(in srgb, var(--background) 95%, #2a2218); + --pf-surface: color-mix(in srgb, var(--background) 92%, #352b1e); + --pf-hair: color-mix(in srgb, var(--foreground) 14%, transparent); + --pf-pending-stroke: color-mix(in srgb, var(--foreground) 24%, transparent); + --pf-proof: #f28b6e; + --pf-proof-bg: color-mix(in srgb, #e26d50 16%, var(--pf-surface)); + --pf-gate: #f5b942; + --pf-gate-bg: color-mix(in srgb, #e69d22 16%, var(--pf-surface)); + --pf-stage-ink: #6ec4c7; + + background: + radial-gradient(ellipse at 12% 8%, color-mix(in srgb, #7a5d34 14%, transparent), transparent 55%), + var(--pf-paper); +} + +/* Stage pigment palette (aligned with Prompt Workbench Book Atlas) */ +.pf-stage-opening, [data-stage="opening"] { + --atlas-pigment: #265e62; + --pf-stage-ink: #265e62; + --print-cut: #183d40; + --print-paper: #fff2d3; + --print-accent: #f1aa79; +} +.pf-stage-foundation, [data-stage="foundation"] { + --atlas-pigment: #765064; + --pf-stage-ink: #765064; + --print-cut: #4b3240; + --print-paper: #fff2d3; + --print-accent: #edb7b2; +} +.pf-stage-volumes, [data-stage="volumes"] { + --atlas-pigment: #855931; + --pf-stage-ink: #855931; + --print-cut: #55381e; + --print-paper: #fff2d3; + --print-accent: #f7b152; +} +.pf-stage-preparation, [data-stage="preparation"] { + --atlas-pigment: #44617f; + --pf-stage-ink: #44617f; + --print-cut: #2b3e52; + --print-paper: #fff2d3; + --print-accent: #9ad1d7; +} +.pf-stage-writing, [data-stage="writing"] { + --atlas-pigment: #516742; + --pf-stage-ink: #516742; + --print-cut: #334229; + --print-paper: #fff2d3; + --print-accent: #e8bd71; +} + +.dark .pf-stage-opening, .dark [data-stage="opening"] { --pf-stage-ink: #6ec6c9; } +.dark .pf-stage-foundation, .dark [data-stage="foundation"] { --pf-stage-ink: #d4a3bc; } +.dark .pf-stage-volumes, .dark [data-stage="volumes"] { --pf-stage-ink: #e5b37c; } +.dark .pf-stage-preparation, .dark [data-stage="preparation"] { --pf-stage-ink: #8db9e6; } +.dark .pf-stage-writing, .dark [data-stage="writing"] { --pf-stage-ink: #a2ca86; } .pf-canvas-shell .react-flow__handle { width: 6px; @@ -53,139 +103,338 @@ .pf-canvas-shell .react-flow__controls { border-radius: 0.5rem; overflow: hidden; - border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); - box-shadow: 0 2px 10px rgb(0 0 0 / 0.08); - background: var(--popover); + border: 1px solid var(--pf-hair); + box-shadow: none; + background: var(--pf-surface); } .pf-canvas-shell .react-flow__controls-button { - background: var(--popover); + background: var(--pf-surface); color: var(--foreground); - border-bottom-color: color-mix(in srgb, var(--border) 60%, transparent); + border-bottom-color: var(--pf-hair); } .pf-canvas-shell .react-flow__controls-button:hover { - background: var(--muted); + background: var(--atlas-tint); } -/* Progress-aware edge rails */ +/* Flowing editorial river rails */ .pf-edge path { + fill: none; stroke-linecap: round; transition: stroke 180ms ease, stroke-width 180ms ease; } .pf-edge-done path { - stroke: var(--pf-done); - stroke-width: 2.75; + stroke: var(--pf-stage-ink); + stroke-width: 3; +} + +.pf-edge-uturn.pf-edge-done path { + stroke-width: 3.25; } .pf-edge-frontier path { - stroke: var(--pf-active); + stroke: var(--pf-stage-ink); stroke-width: 2.25; - stroke-dasharray: 6 4; + stroke-dasharray: 6 5; } .pf-edge-active path { - stroke: var(--pf-active); - stroke-width: 3.25; + stroke: var(--pf-proof); + stroke-width: 3.5; } .pf-edge-gate path { stroke: var(--pf-gate); + stroke-width: 3.25; +} + +.pf-edge-attention path { + stroke: var(--pf-proof); stroke-width: 3; } .pf-edge-pending path { stroke: var(--pf-pending-stroke); - stroke-width: 1.5; + stroke-width: 1.6; stroke-dasharray: 4 5; } .pf-edge-branch path { - stroke-dasharray: 4 4; + stroke-dasharray: 3 4; + stroke-width: 1.75; } -.pf-edge-stage-rail path { - stroke-width: 2.5; +/* Stage Woodblock Cover Plate (Design 2) */ +.pf-cover-plate { + position: relative; + display: flex; + flex-direction: column; + justify-content: space-between; + width: 100%; + height: 100%; + overflow: hidden; + border-radius: 3px 10px 4px 3px; + padding: 10px 12px 9px; + text-align: left; + color: var(--print-paper); + background: var(--print-cut); + box-shadow: 0 6px 16px -10px rgb(0 0 0 / 0.45); + transition: transform 160ms ease, box-shadow 160ms ease; } -/* Distinct node status cards */ -.pf-step-card { +.pf-cover-plate::before { + content: ""; + position: absolute; + inset: 0; + background: var(--atlas-pigment); + clip-path: polygon(24% 0, 100% 0, 100% 100%, 60% 100%); + opacity: 0.86; +} + +.pf-cover-plate:hover { + transform: translateY(-2px); + box-shadow: 0 10px 22px -10px rgb(0 0 0 / 0.52); +} + +.pf-cover-plate .stage-imprint { + position: absolute; + right: -6px; + top: -4px; + width: 98px; + height: 68px; + opacity: 0.92; + pointer-events: none; +} + +.pf-cover-folio { + position: relative; + font: italic 22px/1 Georgia, serif; + letter-spacing: -0.04em; + color: var(--print-accent); +} + +.pf-cover-title { position: relative; + font: 650 15.5px/1.2 var(--atlas-display); + color: var(--print-paper); +} + +.pf-cover-bar { + position: relative; + height: 3px; + width: 100%; + border-radius: 9999px; + background: rgb(255 242 211 / 0.22); overflow: hidden; +} + +.pf-cover-bar > span { + display: block; + height: 100%; + border-radius: 9999px; + background: var(--print-accent); + transition: width 300ms ease; +} + +/* Borderless River Station (Design 1 — NO repeated boxes!) */ +.pf-river-station { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; + padding: 2px 6px; border-radius: 0.75rem; - transition: transform 150ms ease, background-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease; + text-align: center; + transition: background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease; +} + +.pf-river-station:hover { + background: color-mix(in srgb, var(--pf-surface) 76%, transparent); +} + +/* Medallion centered right on the 50% horizontal river line */ +.pf-medallion { + position: relative; + z-index: 2; + display: grid; + place-items: center; + width: 28px; + height: 28px; + border-radius: 9999px; + transition: transform 160ms ease, box-shadow 160ms ease; +} + +.pf-river-station:hover .pf-medallion { + transform: scale(1.08); +} + +.pf-river-station[data-status="completed"] .pf-medallion { + background: var(--pf-stage-ink); + color: #fff8ea; + box-shadow: 0 0 0 4px var(--pf-paper); } -.pf-step-card:hover { - transform: translateY(-1px); +.pf-river-station[data-status="pending"] { + opacity: 0.62; +} +.pf-river-station[data-status="pending"]:hover { + opacity: 0.96; +} +.pf-river-station[data-status="pending"] .pf-medallion { + width: 24px; + height: 24px; + background: var(--pf-paper); + border: 1.75px dashed var(--pf-pending-stroke); + color: var(--muted-foreground); + box-shadow: 0 0 0 4px var(--pf-paper); +} + +.pf-river-station[data-status="skipped"] { + opacity: 0.5; +} +.pf-river-station[data-status="skipped"]:hover { + opacity: 0.9; +} +.pf-river-station[data-status="skipped"] .pf-medallion { + width: 22px; + height: 22px; + background: var(--pf-paper); + border: 1.5px dashed var(--pf-pending-stroke); + color: var(--muted-foreground); + box-shadow: 0 0 0 4px var(--pf-paper); } -.pf-step-card[data-status="completed"] { - background: var(--pf-done-bg); - border: 1px solid var(--pf-done-border); - box-shadow: inset 4px 0 0 var(--pf-done); +/* Elevated High-Signal Editorial Cards (ONLY running / waiting_gate / attention / paused / selected) */ +.pf-river-station[data-elevated="true"] { + opacity: 1; + background: var(--pf-surface); + box-shadow: 0 8px 22px -12px rgb(0 0 0 / 0.28); } -.pf-step-card[data-status="running"] { - background: var(--pf-active-bg); - border: 1.5px solid var(--pf-active); - box-shadow: inset 4px 0 0 var(--pf-active), 0 0 0 0 color-mix(in srgb, var(--pf-active) 35%, transparent); - animation: pf-pulse-ring 2s ease-out infinite; +.pf-river-station[data-status="running"] { + background: var(--pf-surface); + border: 1.5px solid var(--pf-proof); + box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--pf-proof) 45%, transparent); +} +.pf-river-station[data-status="running"] .pf-medallion { + background: var(--pf-proof); + color: #fff; + animation: pf-beacon-pulse 1.9s ease-out infinite; } -.pf-step-card[data-status="waiting_gate"] { +.pf-river-station[data-status="waiting_gate"] { background: var(--pf-gate-bg); border: 1.5px solid var(--pf-gate); - box-shadow: inset 4px 0 0 var(--pf-gate), 0 4px 14px -4px color-mix(in srgb, var(--pf-gate) 32%, transparent); + box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--pf-gate) 48%, transparent); +} +.pf-river-station[data-status="waiting_gate"] .pf-medallion { + background: var(--pf-gate); + color: #fff; } -.pf-step-card[data-status="attention"] { - background: var(--pf-attention-bg); - border: 1.5px solid var(--pf-attention); - box-shadow: inset 4px 0 0 var(--pf-attention); +.pf-river-station[data-status="attention"] { + background: var(--pf-proof-bg); + border: 1.5px solid var(--pf-proof); + box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--pf-proof) 42%, transparent); +} +.pf-river-station[data-status="attention"] .pf-medallion { + background: var(--pf-proof); + color: #fff; } -.pf-step-card[data-status="paused"] { +.pf-river-station[data-status="paused"] { background: var(--pf-gate-bg); border: 1.5px dashed var(--pf-gate); - box-shadow: inset 4px 0 0 var(--pf-gate); } - -.pf-step-card[data-status="skipped"] { - background: color-mix(in srgb, var(--muted) 55%, var(--background)); - border: 1px dashed color-mix(in srgb, var(--border) 80%, transparent); - opacity: 0.62; +.pf-river-station[data-status="paused"] .pf-medallion { + background: var(--pf-gate); + color: #fff; } -.pf-step-card[data-status="skipped"]:hover { - opacity: 0.92; +.pf-river-station[data-selected="true"] { + opacity: 1 !important; + background: var(--pf-surface); + outline: 2px solid var(--pf-stage-ink); + outline-offset: 2px; + box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--pf-stage-ink) 45%, transparent); } -.pf-step-card[data-status="pending"] { - background: color-mix(in srgb, var(--background) 70%, var(--muted)); - border: 1px dashed color-mix(in srgb, var(--foreground) 16%, transparent); - opacity: 0.68; +/* Illustrated Craft Card for Focused Single-Stage Mode */ +.pf-craft-card { + position: relative; + display: flex; + flex-direction: column; + width: 100%; + height: 100%; + overflow: hidden; + border-radius: 6px; + background: var(--pf-surface); + text-align: left; + box-shadow: 0 4px 14px -8px rgb(0 0 0 / 0.2); + transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease; } -.pf-step-card[data-status="pending"]:hover { - opacity: 0.95; +.pf-craft-card:hover { + transform: translateY(-2px); + box-shadow: 0 10px 24px -10px rgb(0 0 0 / 0.28); } -.pf-step-card[data-selected="true"] { +.pf-craft-card[data-status="pending"] { + opacity: 0.66; +} +.pf-craft-card[data-status="pending"]:hover { + opacity: 0.96; +} +.pf-craft-card[data-status="running"] { + outline: 2px solid var(--pf-proof); +} +.pf-craft-card[data-status="waiting_gate"] { + outline: 2px solid var(--pf-gate); +} +.pf-craft-card[data-status="attention"] { + outline: 2px solid var(--pf-proof); +} +.pf-craft-card[data-selected="true"] { opacity: 1 !important; - outline: 2.5px solid var(--primary); + outline: 2.5px solid var(--pf-stage-ink); outline-offset: 2px; - box-shadow: 0 8px 22px -8px color-mix(in srgb, var(--primary) 40%, transparent); } -/* Live shimmer bar on running node */ +.pf-craft-figure { + position: relative; + height: 82px; + width: 100%; + background: var(--atlas-tint); + display: grid; + place-items: center; + flex: none; +} + +.pf-craft-figure svg { + width: 100%; + height: 100%; +} + +.pf-craft-card[data-selected="true"] .pf-craft-figure, +.pf-craft-card[data-status="running"] .pf-craft-figure { + --atlas-ink: #fff2d7; + --atlas-stock: var(--atlas-pigment); + --atlas-tint: color-mix(in srgb, var(--atlas-pigment) 76%, #e9d8ae); + --atlas-proof: #ffba91; + background: var(--atlas-pigment); +} + .pf-running-bar { position: absolute; inset-inline: 0; bottom: 0; height: 3px; - background: color-mix(in srgb, var(--primary) 18%, transparent); + background: color-mix(in srgb, var(--pf-proof) 18%, transparent); overflow: hidden; } @@ -194,7 +443,7 @@ position: absolute; inset-block: 0; width: 45%; - background: var(--primary); + background: var(--pf-proof); border-radius: 9999px; animation: pf-shimmer-slide 1.6s ease-in-out infinite; } @@ -204,20 +453,14 @@ 100% { transform: translateX(260%); } } -@keyframes pf-pulse-ring { - 0% { - box-shadow: inset 4px 0 0 var(--pf-active), 0 0 0 0 color-mix(in srgb, var(--primary) 34%, transparent); - } - 70% { - box-shadow: inset 4px 0 0 var(--pf-active), 0 0 0 9px color-mix(in srgb, var(--primary) 0%, transparent); - } - 100% { - box-shadow: inset 4px 0 0 var(--pf-active), 0 0 0 0 color-mix(in srgb, var(--primary) 0%, transparent); - } +@keyframes pf-beacon-pulse { + 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pf-proof) 45%, transparent); } + 70% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--pf-proof) 0%, transparent); } + 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pf-proof) 0%, transparent); } } @media (prefers-reduced-motion: reduce) { - .pf-step-card[data-status="running"], + .pf-river-station[data-status="running"] .pf-medallion, .pf-running-bar::after { animation: none; } From 0e7eebaefe310ffd59cde60b2ab263ad3287cf5a Mon Sep 17 00:00:00 2001 From: bizfix Date: Sat, 5 Dec 2026 22:51:23 +0800 Subject: [PATCH 4/8] polish(director-v2): align production flow graph with Prompt Workbench Book Atlas layout --- .../productionFlow/ProductionFlowCanvas.tsx | 459 ++++++----- .../ProductionFlowInspector.tsx | 25 +- .../productionFlow/ProductionFlowView.tsx | 342 +++------ .../visualizations/productionFlow/layout.ts | 533 +++++-------- .../productionFlow/productionFlow.css | 712 ++++++++++-------- 5 files changed, 938 insertions(+), 1133 deletions(-) diff --git a/client/src/pages/directorNext/workspace/visualizations/productionFlow/ProductionFlowCanvas.tsx b/client/src/pages/directorNext/workspace/visualizations/productionFlow/ProductionFlowCanvas.tsx index 495951e62c..b7f751c667 100644 --- a/client/src/pages/directorNext/workspace/visualizations/productionFlow/ProductionFlowCanvas.tsx +++ b/client/src/pages/directorNext/workspace/visualizations/productionFlow/ProductionFlowCanvas.tsx @@ -1,5 +1,7 @@ -import { useEffect, useMemo } from "react"; +import { useEffect, useMemo, type CSSProperties } from "react"; import { + Background, + BackgroundVariant, BaseEdge, Controls, Handle, @@ -15,13 +17,16 @@ import { AlertTriangle, ArrowLeft, ArrowUpRight, + BookCheck, Check, Clock, - GitBranch, + CornerDownLeft, + Feather, + Hand, + Layers2, Loader2, Pause, SkipForward, - Sparkles, } from "lucide-react"; import type { DirectorProductionFlowProjection, @@ -29,29 +34,29 @@ import type { ProductionFlowStageId, } from "@ai-novel/shared/types/director/productionFlow"; import { useTranslation as useUiTranslation, i18n as uiI18n } from "@/i18n"; -import { flowBranchLabel, flowStageText, flowStepText } from "@/pages/promptWorkbench/creationFlow/presentation"; +import { + flowBranchLabel, + flowRouteLabel, + flowStageText, + flowStepText, +} from "@/pages/promptWorkbench/creationFlow/presentation"; import { StageImprint } from "@/pages/promptWorkbench/creationFlow/overview/StageImprint"; import { ManuscriptFigure } from "@/pages/promptWorkbench/creationFlow/ManuscriptFigure"; import { stages } from "@/pages/promptWorkbench/creationFlow/flowDefinition"; import { buildProductionFlowGraph, - type LiveStepNode, + roundedRoute, + spineX, + type AtlasRouteEdge, + type BookStationNode, type ProductionFlowScope, - type SerpentineEdgeData, - type StageHeaderNode, + type StageCoverNode, } from "./layout"; import "./productionFlow.css"; -function formatCompactTokens(tokens: number): string { - if (tokens >= 1_000) return `${(tokens / 1000).toFixed(1)}k`; - return String(tokens); -} +const defaultMarks = { author: Hand, ai: Feather, system: Layers2, destination: CornerDownLeft }; -function isElevatedStatus(status: ProductionFlowNodeStatus): boolean { - return status === "running" || status === "waiting_gate" || status === "attention" || status === "paused"; -} - -function stampLabel(status: ProductionFlowNodeStatus): string | null { +function statusTagLabel(status: ProductionFlowNodeStatus): string | null { switch (status) { case "running": return uiI18n.t("productionFlowStatusRunning", { ns: "directorNext" }); @@ -66,134 +71,83 @@ function stampLabel(status: ProductionFlowNodeStatus): string | null { } } -function SerpentineEdge({ - id, - sourceX, - sourceY, - targetX, - targetY, - markerEnd, - style, - data, -}: EdgeProps) { - const turn = (data as SerpentineEdgeData | undefined)?.turn; - let path: string; - const dy = targetY - sourceY; - const radius = Math.min(56, Math.max(20, Math.abs(dy) / 2)); - - if (turn === "right") { - const turnX = Math.max(sourceX, targetX) + radius + 16; - path = [ - `M ${sourceX} ${sourceY}`, - `L ${turnX - radius} ${sourceY}`, - `A ${radius} ${radius} 0 0 1 ${turnX} ${sourceY + radius}`, - `L ${turnX} ${targetY - radius}`, - `A ${radius} ${radius} 0 0 1 ${turnX - radius} ${targetY}`, - `L ${targetX} ${targetY}`, - ].join(" "); - } else if (turn === "left") { - const turnX = Math.min(sourceX, targetX) - radius - 16; - path = [ - `M ${sourceX} ${sourceY}`, - `L ${turnX + radius} ${sourceY}`, - `A ${radius} ${radius} 0 0 0 ${turnX} ${sourceY + radius}`, - `L ${turnX} ${targetY - radius}`, - `A ${radius} ${radius} 0 0 0 ${turnX + radius} ${targetY}`, - `L ${targetX} ${targetY}`, - ].join(" "); - } else { - path = `M ${sourceX} ${sourceY} L ${targetX} ${targetY}`; - } - - return ; -} - -function StageCoverNodeView({ data }: NodeProps) { +function CoverNodeView({ data }: NodeProps) { useUiTranslation("directorNext"); useUiTranslation("promptWorkbench"); - const { stage, order, doneCount, totalCount, hasActive, hasWaitingGate, hasAttention, allDone, onFocusStage } = data; + const { cover: { stage, order }, doneCount, totalCount, hasActive, hasWaitingGate, hasAttention, allDone, lit, onFocusStage } = data; const stageId = stage.id as ProductionFlowStageId; const pct = totalCount > 0 ? Math.round((doneCount / totalCount) * 100) : 0; return ( -
- - - - - +
); } -function MedallionIcon({ status, order }: { status: ProductionFlowNodeStatus; order: number }) { - switch (status) { - case "completed": - return