Enhance PlanningAgent with Markdown rendering and Tailwind Typography

This commit is contained in:
Ding Shuo
2026-03-13 10:52:06 +08:00
parent c8c687cf60
commit cca1b8d046
13 changed files with 2700 additions and 228 deletions

134
src/pages/Home.tsx Normal file
View File

@@ -0,0 +1,134 @@
import React from 'react';
import { Link } from 'react-router-dom';
export default function Home() {
return (
<div className="p-8 max-w-7xl mx-auto w-full">
{/* 欢迎与 AI 提示 */}
<div className="bg-gradient-to-r from-blue-600 to-indigo-700 rounded-2xl p-8 text-white mb-8 shadow-lg flex justify-between items-center">
<div>
<h2 className="text-3xl font-bold mb-2">, SAFe OS 👋</h2>
<p className="text-blue-100 mb-4 text-lg">AI Agent </p>
<div className="flex items-center text-sm bg-black/20 inline-block px-4 py-2 rounded-lg backdrop-blur-sm">
<i className="fa-solid fa-robot mr-2 text-blue-300"></i> AI : <span className="text-green-300 ml-1 font-semibold"> ()</span>
</div>
</div>
<div className="hidden md:block text-right">
<div className="text-5xl font-bold opacity-20"><i className="fa-brands fa-hubspot"></i></div>
</div>
</div>
{/* 数据概览精要 */}
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div className="bg-white p-5 rounded-xl text-center border border-gray-100 shadow-sm">
<p className="text-sm text-gray-500 mb-1"></p>
<p className="text-2xl font-bold text-gray-800">24 <span className="text-xs text-green-500 font-normal"><i className="fa-solid fa-arrow-up"></i> 3</span></p>
</div>
<div className="bg-white p-5 rounded-xl text-center border border-gray-100 shadow-sm">
<p className="text-sm text-gray-500 mb-1"> (PRs)</p>
<p className="text-2xl font-bold text-gray-800">12 <span className="text-xs text-red-500 font-normal"><i className="fa-solid fa-arrow-down"></i> 2</span></p>
</div>
<div className="bg-white p-5 rounded-xl text-center border border-gray-100 shadow-sm">
<p className="text-sm text-gray-500 mb-1"></p>
<p className="text-2xl font-bold text-gray-800 focus-text">92% <span className="text-xs text-green-500 font-normal"></span></p>
</div>
</div>
{/* 三大核心模块入口卡片 */}
<h3 className="text-lg font-bold text-gray-800 mb-4"></h3>
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
{/* 模块 1: 战略规划 (Planning) */}
<div className="module-card bg-white rounded-2xl overflow-hidden border border-gray-100 shadow-sm relative group flex flex-col hover:-translate-y-1 hover:shadow-xl transition-all duration-300">
<div className="h-2 bg-[#0EA5E9]"></div>
<div className="p-6 flex-1">
<div className="w-12 h-12 bg-blue-50 text-[#0EA5E9] rounded-xl flex items-center justify-center text-2xl mb-4 group-hover:bg-[#0EA5E9] group-hover:text-white transition-colors">
<i className="fa-solid fa-chess-knight"></i>
</div>
<h4 className="text-xl font-bold text-gray-800 mb-2"></h4>
<p className="text-gray-500 mb-4 text-sm min-h-[60px]">AI帮助您生成验收标准</p>
<div className="space-y-3 mb-6">
<div className="flex items-center text-sm text-gray-600 bg-gray-50 p-2 rounded">
<i className="fa-solid fa-check text-[#0EA5E9] mr-2 w-4"></i>
</div>
<div className="flex items-center text-sm text-gray-600 bg-gray-50 p-2 rounded">
<i className="fa-solid fa-check text-[#0EA5E9] mr-2 w-4"></i>
</div>
</div>
</div>
<div className="px-6 py-4 bg-gray-50 border-t border-gray-100">
<Link to="/planning" className="block text-center w-full py-2 bg-white border border-gray-200 text-[#0EA5E9] font-semibold rounded-lg hover:border-[#0EA5E9] hover:bg-blue-50 transition-colors">
&rarr;
</Link>
</div>
</div>
{/* 模块 2: 开发运维 (DevOps) */}
<div className="module-card bg-white rounded-2xl overflow-hidden border border-gray-100 shadow-sm relative group flex flex-col hover:-translate-y-1 hover:shadow-xl transition-all duration-300">
<div className="h-2 bg-[#10B981]"></div>
<div className="p-6 flex-1">
<div className="w-12 h-12 bg-green-50 text-[#10B981] rounded-xl flex items-center justify-center text-2xl mb-4 group-hover:bg-[#10B981] group-hover:text-white transition-colors">
<i className="fa-solid fa-code-branch"></i>
</div>
<h4 className="text-xl font-bold text-gray-800 mb-2"></h4>
<p className="text-gray-500 mb-4 text-sm min-h-[60px]">线</p>
<div className="space-y-3 mb-6">
<div className="flex items-center text-sm text-gray-600 bg-gray-50 p-2 rounded">
<i className="fa-solid fa-check text-[#10B981] mr-2 w-4"></i> AI
</div>
<div className="flex items-center text-sm text-gray-600 bg-gray-50 p-2 rounded">
<i className="fa-solid fa-check text-[#10B981] mr-2 w-4"></i>
</div>
</div>
</div>
<div className="px-6 py-4 bg-gray-50 border-t border-gray-100">
<Link to="/devops" className="block text-center w-full py-2 bg-white border border-gray-200 text-[#10B981] font-semibold rounded-lg hover:border-[#10B981] hover:bg-green-50 transition-colors">
线 &rarr;
</Link>
</div>
</div>
{/* 模块 3: 质量门控 (Quality Gate) */}
<div className="module-card bg-white rounded-2xl overflow-hidden border border-gray-100 shadow-sm relative group flex flex-col hover:-translate-y-1 hover:shadow-xl transition-all duration-300">
<div className="h-2 bg-[#8B5CF6]"></div>
<div className="p-6 flex-1">
<div className="w-12 h-12 bg-purple-50 text-[#8B5CF6] rounded-xl flex items-center justify-center text-2xl mb-4 group-hover:bg-[#8B5CF6] group-hover:text-white transition-colors">
<i className="fa-solid fa-shield-halved"></i>
</div>
<h4 className="text-xl font-bold text-gray-800 mb-2"></h4>
<p className="text-gray-500 mb-4 text-sm min-h-[60px]">Dashboard概览 PR </p>
<div className="space-y-3 mb-6">
<div className="flex items-center text-sm text-gray-600 bg-gray-50 p-2 rounded">
<i className="fa-solid fa-check text-[#8B5CF6] mr-2 w-4"></i> PR
</div>
<div className="flex items-center text-sm text-gray-600 bg-gray-50 p-2 rounded">
<i className="fa-solid fa-check text-[#8B5CF6] mr-2 w-4"></i>
</div>
</div>
</div>
<div className="px-6 py-4 bg-gray-50 border-t border-gray-100">
<Link to="/quality" className="block text-center w-full py-2 bg-white border border-gray-200 text-[#8B5CF6] font-semibold rounded-lg hover:border-[#8B5CF6] hover:bg-purple-50 transition-colors">
&rarr;
</Link>
</div>
</div>
</div>
{/* 全局悬浮 AI Agent 助手入口(占位) */}
<div className="fixed bottom-10 right-10 flex flex-col items-end z-50">
<div className="bg-white px-4 py-3 rounded-2xl shadow-lg border border-gray-100 mb-4 relative animate-fade-in-up">
<p className="text-sm text-gray-600">PR</p>
<div className="absolute -bottom-2 right-6 w-4 h-4 bg-white border-b border-r border-gray-100 transform rotate-45"></div>
</div>
<button className="w-16 h-16 bg-[#2563EB] text-white rounded-full shadow-2xl flex items-center justify-center text-3xl hover:bg-blue-700 transition-colors ai-pulse">
<i className="fa-brands fa-hubspot"></i>
</button>
</div>
</div>
);
}

View File

@@ -1,4 +1,7 @@
import { useCallback, useEffect, useReducer, useRef, useState } from "react";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import rehypeRaw from "rehype-raw";
import { API } from "../config";
/* ─── Types ─── */
@@ -294,7 +297,18 @@ export default function PlanningAgent() {
{msg.role === "assistant" && (
<span className="badge mb-3 block w-fit">SYSTEM / RE-ACT LOOP</span>
)}
{msg.content || "Thinking..."}
{msg.role === "assistant" ? (
<div className="prose prose-sm max-w-none prose-p:my-1 prose-pre:bg-gray-800 prose-pre:text-gray-100 prose-code:text-magenta prose-code:bg-magenta/10 prose-code:px-1 prose-code:rounded prose-li:my-0">
<ReactMarkdown
remarkPlugins={[remarkGfm]}
rehypePlugins={[rehypeRaw]}
>
{msg.content || "Thinking..."}
</ReactMarkdown>
</div>
) : (
msg.content || "Thinking..."
)}
{msg.status === "failed" && (
<span className="text-red-500 text-xs block mt-2">Failed to send</span>
)}