import type { LucideIcon } from "lucide-react"; import { ArrowRight, AlertTriangle, Bot, CheckCircle2, ChevronDown, CircleCheck, Cloud, FlaskConical, GitBranch, GitCommit, GitPullRequest, Loader2, MessageSquareText, RefreshCcw, ShieldAlert, TestTube2, X, } from "lucide-react"; import type { ReactNode } from "react"; import { Button } from "@/components/ui/button"; import type { PMFlowReleaseGateEvidence, PMFlowReleaseValidationDecision, PMFlowReleaseValidationRun, } from "@/api/pmflowOs"; import { usePMFlowOsStore } from "@/features/pmflow-os/store"; import { cn } from "@/lib/utils"; type StatusTone = "success" | "warning" | "danger" | "neutral" | "info"; const gateItems = [ { label: "功能完整性", status: "通过", detail: "核心流程与功能验证完成", tone: "success" as const }, { label: "性能基线", status: "通过", detail: "P95 响应时间 < 800ms", tone: "success" as const }, { label: "安全扫描", status: "通过", detail: "无高危漏洞", tone: "success" as const }, { label: "数据迁移", status: "通过", detail: "迁移脚本执行成功", tone: "success" as const }, { label: "兼容性测试", status: "通过", detail: "主流浏览器验证通过", tone: "success" as const }, { label: "可观测性", status: "通过", detail: "监控与告警已就绪", tone: "success" as const }, { label: "回滚预案", status: "通过", detail: "回滚版本已准备", tone: "success" as const }, { label: "文档与支持", status: "待完善", detail: "帮助文档需补充 2 篇", tone: "warning" as const }, ]; const readinessMetrics = [ { label: "质量", value: "94%", width: "w-[94%]" }, { label: "可观测性", value: "92%", width: "w-[92%]" }, { label: "稳定性", value: "90%", width: "w-[90%]" }, { label: "缺陷度", value: "92%", width: "w-[92%]" }, ]; const feedbackStats = [ { label: "总反馈", value: "1,243", delta: "较上周 +18%" }, { label: "正向反馈", value: "862", delta: "▲ 69%" }, { label: "待处理", value: "214", delta: "▲ 17%" }, { label: "负向反馈", value: "167", delta: "● 13%" }, ]; const feedbackItems = [ { name: "雁仪", source: "付费用户 · 5 分钟前", text: "希望支持上传更多类型的文档进行问答,目前仅支持 PDF 和 Word。", tag: "已处理", tone: "info" as const }, { name: "阿聪", source: "免费用户 · 17 分钟前", text: "在长文本问答时,偶尔会出现答案截断的情况。", tag: "待处理", tone: "warning" as const }, { name: "海峰", source: "企业用户 · 1 小时前", text: "新版的引用来源展示很有帮助,但任感提升 👍", tag: "已处理", tone: "info" as const }, ]; const experiments = [ { status: "进行中", title: "新手引导流程优化", goal: "提升新用户次日留存", metric: "次日留存率", version: "B", lift: "+12.4%", progress: "w-[62%]", remain: "3 天", tone: "success" as const }, { status: "进行中", title: "定价页文案优化", goal: "提升付费转化率", metric: "付费转化率", version: "A", lift: "+6.1%", progress: "w-[48%]", remain: "5 天", tone: "success" as const }, { status: "已完成", title: "推荐入口位置调整", goal: "提升功能使用率", metric: "功能点击率", version: "B vs A", lift: "+8.7%", progress: "w-full", remain: "采用版本 B", tone: "info" as const }, { status: "草案", title: "周报订阅引导文案", goal: "提升周报订阅转化", metric: "订阅转化率", version: "-", lift: "预计开始", progress: "w-[0%]", remain: "2024-05-20", tone: "neutral" as const }, ]; const riskItems = [ { level: "高", title: "第三方模型服务波动", tag: "外部依赖", owner: "程晨", risk: "季度主线存在 5xx 波动", impact: "登录、问答生成", action: "已配置降级策略与超时重试", rollback: "切回 v1.1.8(保留)", }, { level: "中", title: "向量检索召回率下降", tag: "模型效果", owner: "召回年长风", risk: "新版展开下滑明显", impact: "答案相关性", action: "已上线召回扩展实验", rollback: "切回旧召回策略", }, ]; const funnelRows = [ { label: "访问首页", value: "128,420", rate: "100%" }, { label: "注册账号", value: "36,842", rate: "28.7%" }, { label: "创建项目", value: "18,562", rate: "14.5%" }, { label: "核心功能使用", value: "9,124", rate: "7.1%" }, { label: "付费转化", value: "4,118", rate: "3.2%" }, ]; const keyMetrics = [ { label: "新增用户", value: "12,842", delta: "▲ 18%", path: "M2 16 L12 10 L22 12 L32 6 L42 9 L52 5 L62 8 L72 6" }, { label: "付费转化率", value: "3.21%", delta: "▲ 0.42pp", path: "M2 14 L12 13 L22 16 L32 8 L42 11 L52 5 L62 14 L72 7" }, { label: "ARPU", value: "¥98.6", delta: "▲ 6%", path: "M2 15 L12 11 L22 14 L32 12 L42 8 L52 10 L62 6 L72 5" }, { label: "留存率(次日)", value: "48.7%", delta: "▲ 3.6pp", path: "M2 12 L12 14 L22 9 L32 10 L42 7 L52 12 L62 5 L72 9" }, { label: "NPS", value: "62", delta: "▲ 5", path: "M2 16 L12 12 L22 13 L32 9 L42 11 L52 7 L62 10 L72 4" }, ]; const aiActions = [ { title: "优先处理", focus: "长文本截断", suffix: "问题" }, { title: "扩展", focus: "新手引导", suffix: "实验至企业用户" }, { title: "监控", focus: "第三方模型服务", suffix: "稳定性" }, { title: "发布下一版迭代计划", focus: "", suffix: "预计 5 月 20 日" }, ]; const nextSuggestions = [ { title: "迭代优先级建议", body: "基于负向反馈,建议优先优化长文本截断问题,预计影响 13% 的活跃用户。", action: "查看建议详情" }, { title: "实验推荐", body: "建议对「上传更多文档类型」进行需求验证实验,预估提升付费转化 +4~7%。", action: "创建实验" }, { title: "增长机会", body: "新手引导流程优化效果良好,建议扩展至企业用户引导,目标提升次留 +10%。", action: "查看方案" }, { title: "风险关注", body: "模型服务波动风险仍在,建议持续监控并保留回滚策略,保障稳定性。", action: "查看风险方案" }, ]; function Card({ children, className }: { children: ReactNode; className?: string }) { return
{children}
; } function StatusChip({ label, tone = "neutral" }: { label: string; tone?: StatusTone }) { const toneClass: Record = { success: "border-emerald-100 bg-emerald-50 text-emerald-600", warning: "border-orange-100 bg-orange-50 text-orange-500", danger: "border-red-100 bg-red-50 text-red-500", neutral: "border-slate-100 bg-slate-50 text-slate-500", info: "border-blue-100 bg-blue-50 text-[#2463EB]", }; return {label}; } function SectionTitle({ icon: Icon, title, meta, action }: { icon?: LucideIcon; title: string; meta?: string; action?: string }) { return (
{Icon ? : null}

{title}

{meta ? {meta} : null}
{action ? : null}
); } function ProgressLine({ label, value, width }: { label: string; value: string; width: string }) { return (
{label} {value}
); } function MiniSpark({ path }: { path: string }) { return ( ); } function ReadinessRing() { return (
92%
准备就绪
); } function FunnelChart() { return (
{funnelRows.map((item) => (
{item.label} {item.value} {item.rate}
))}
); } function RevenueChart() { return ( ); } function AiCopilot() { return ( ); } type PMFlowOsStoreSnapshot = ReturnType; function gateTone(status?: string): StatusTone { if (status === "ready") return "success"; if (status === "blocked") return "danger"; if (status === "needs_confirmation") return "warning"; return "neutral"; } function gateLabel(status?: string) { if (status === "ready") return "可发布"; if (status === "blocked") return "阻塞"; if (status === "needs_confirmation") return "需要人工确认"; return "缺少执行证据"; } function validationRunLabel(status?: string) { if (status === "ready") return "发布候选"; if (status === "blocked") return "保持阻塞"; if (status === "needs_confirmation") return "需要确认"; return "未记录"; } function validationSummaryText(run?: PMFlowReleaseValidationRun | null) { if (!run) return "尚未创建 release validation run。"; const summary = run.validationSummary || {}; const sourceStatus = typeof summary.releaseGateStatus === "string" ? summary.releaseGateStatus : run.status; return `基于 ${sourceStatus} release gate 固化,部署执行:${summary.deploymentExecuted ? "已执行" : "未执行"}`; } function checkTone(status?: string): StatusTone { if (status === "passed") return "success"; if (status === "failed") return "danger"; return "warning"; } function evidenceIcon(type: string) { if (type.includes("branch")) return GitBranch; if (type.includes("commit")) return GitCommit; if (type.includes("pr") || type.includes("merged")) return GitPullRequest; if (type.includes("test") || type.includes("check")) return TestTube2; if (type.includes("fail") || type.includes("block")) return AlertTriangle; return CheckCircle2; } function EvidenceRow({ item }: { item: PMFlowReleaseGateEvidence }) { const Icon = evidenceIcon(item.type); return (
{item.taskTitle ? {item.taskTitle} : null}

{item.summary}

{item.repo ? {item.repo} : null} {item.branchName ? branch {item.branchName} : null} {item.commitSha ? commit {item.commitSha.slice(0, 12)} : null} {item.prNumber ? PR #{item.prNumber} : null}
{item.occurredAt ? new Date(item.occurredAt).toLocaleString("zh-CN") : "未记录时间"}
); } function RealReleaseGrowthPage({ store }: { store: PMFlowOsStoreSnapshot }) { const { state, dataSourceMode, dataSourceStatus, dataSourceError, executionSummary, executionSummaryStatus, executionSummaryError, projectionWarnings, refetchExecutionSummary, createReleaseValidationRun, } = store; const gate = executionSummary?.releaseGate; const latestValidationRun = gate?.latestValidationRun; const isLoading = dataSourceStatus === "loading" || executionSummaryStatus === "loading"; const warnings = [...projectionWarnings, ...(executionSummary?.warnings || [])]; const emptyMode = dataSourceMode === "empty" || gate?.status === "empty" || !gate; const canCreateValidationRun = Boolean(!emptyMode && gate?.evidence?.length); const handleCreateValidationRun = (decision: PMFlowReleaseValidationDecision) => { const decisionLabel = decision === "enter_release_candidate" ? "进入发布候选" : "保持阻塞"; createReleaseValidationRun({ decision, note: `ReleaseGrowthPage 人工确认:${decisionLabel};PMFlow 仅记录发布前验证,不执行部署。`, }); }; return (
Release Gate

发布 / 增长判断

本页只读取 Execution Bridge 回写的 branch、commit、PR、test、failed 证据生成发布判断;PMFlow 不在这里执行发布命令。

{dataSourceError || executionSummaryError ? (
{dataSourceError || executionSummaryError}
) : null}

{gate?.title || "缺少执行证据"}

{gate?.summary || "URL 缺少 projectId 或后端尚未返回 execution-summary,无法生成发布判断。"}

当前项目
{state.project.name}
执行状态
{executionSummary?.execution.status || state.execution.status}
{emptyMode ? (

没有可用于发布判断的执行证据

需要先从执行桥回写 branch、commit、PR、test 或 failed 事件。当前页面不会用 mock 发布结果补位。

) : null}
{(gate?.checks || []).map((item) => (
{item.label}
{item.detail || "暂无对应证据"}
))} {!gate?.checks?.length ?
暂无门禁检查项。
: null}
{(gate?.evidence || []).map((item) => ( ))} {!gate?.evidence?.length ?
暂无真实 execution evidence。
: null}
); } export default function ReleaseGrowthPage() { const store = usePMFlowOsStore(); if (store.dataSourceMode !== "demo") { return ; } return (
当前项目
AI 智能问答产品
当前阶段
发布状态
已发布 v1.2.0
发布时间
2024-05-12 10:30
当前风险
中等
新增用户
12,842
付费转化率
3.21%
月度经常性收入
¥126,800
{gateItems.map((item) => (
{item.label}
{item.detail}
))}
{readinessMetrics.map((item) => ( ))}
{riskItems.map((item) => (
{item.level} {item.title}
依赖的模型服务在高峰期存在 {item.risk} 影响范围:{item.impact} 应对方案:{item.action} 回滚方案:{item.rollback}
))}
{feedbackStats.map((item) => (
{item.label}
{item.value}
{item.delta}
))}
{feedbackItems.map((item, index) => (
{item.name.slice(0, 1)}
{item.text}
来自 {item.source}
))}
{experiments.map((item) => (
{item.title}
实验目标
{item.goal}
关键指标:{item.metric}
当前版本:{item.version}
提升效果 {item.lift}
运行进度 {item.remain}
{item.status === "已完成" ? ( ) : null} {item.status === "草案" ? : null}
))}
整体转化率 3.2%
收入(元) 新增付费用户(人)
{keyMetrics.map((item) => (
{item.label} {item.value}
{item.delta}
))}

AI 下一步建议

{nextSuggestions.map((item) => (
{item.title}

{item.body}

))}
以上建议由 AI 基于当前数据生成
); }