feat: load Atlas discovery history into CooChat sidebar

Eliminates the two-chat experience on the overview page:

- CooChat now pre-loads Atlas conversation history on mount, showing
  the full discovery conversation in the left panel. Atlas messages
  render with a blue "A" avatar; COO messages use the dark "◈" icon.
  A "Discovery · COO" divider separates historical from new messages.
- FreshIdeaMain detects when a PRD already exists and replaces the
  duplicate AtlasChat with a clean completion view ("Discovery complete")
  that links to the PRD and Build pages. Atlas chat only shows when
  discovery is still in progress.

Made-with: Cursor
This commit is contained in:
2026-03-10 16:28:44 -07:00
parent 8f95270b12
commit 99c1a83b9f
2 changed files with 218 additions and 58 deletions

View File

@@ -3,6 +3,7 @@
import { useEffect, useState } from "react";
import { AtlasChat } from "@/components/AtlasChat";
import { useRouter, useParams } from "next/navigation";
import Link from "next/link";
const DISCOVERY_PHASES = [
"big_picture",
@@ -27,8 +28,15 @@ export function FreshIdeaMain({ projectId, projectName }: FreshIdeaMainProps) {
const [allDone, setAllDone] = useState(false);
const [prdLoading, setPrdLoading] = useState(false);
const [dismissed, setDismissed] = useState(false);
const [hasPrd, setHasPrd] = useState(false);
useEffect(() => {
// Check if PRD already exists on the project
fetch(`/api/projects/${projectId}`)
.then(r => r.json())
.then(d => { if (d.project?.prd) setHasPrd(true); })
.catch(() => {});
const poll = () => {
fetch(`/api/projects/${projectId}/save-phase`)
.then(r => r.json())
@@ -59,6 +67,62 @@ export function FreshIdeaMain({ projectId, projectName }: FreshIdeaMainProps) {
router.push(`/${workspace}/project/${projectId}/build`);
};
// Once the PRD exists, show a clean "done" state in the main panel.
// The Atlas conversation history lives in the left CooChat sidebar.
if (hasPrd) {
return (
<div style={{
height: "100%", display: "flex", flexDirection: "column",
alignItems: "center", justifyContent: "center",
fontFamily: "Outfit, sans-serif", padding: "32px",
}}>
<div style={{
maxWidth: 420, textAlign: "center",
display: "flex", flexDirection: "column", alignItems: "center", gap: 20,
}}>
<div style={{
width: 48, height: 48, borderRadius: 14, background: "#1a1a1a",
display: "flex", alignItems: "center", justifyContent: "center",
fontSize: "1.2rem", color: "#fff",
}}></div>
<div>
<div style={{ fontSize: "1.05rem", fontWeight: 700, color: "#1a1a1a", marginBottom: 6 }}>
Discovery complete
</div>
<div style={{ fontSize: "0.82rem", color: "#6b6560", lineHeight: 1.65 }}>
Your PRD is saved. The full discovery conversation is in the left panel talk to your COO to plan what to build next.
</div>
</div>
<div style={{ display: "flex", gap: 10 }}>
<Link
href={`/${workspace}/project/${projectId}/prd`}
style={{
padding: "10px 20px", borderRadius: 8, border: "none",
background: "#1a1a1a", color: "#fff",
fontSize: "0.82rem", fontWeight: 600,
textDecoration: "none", display: "inline-block",
}}
>
View PRD
</Link>
<Link
href={`/${workspace}/project/${projectId}/build`}
style={{
padding: "10px 20px", borderRadius: 8,
border: "1px solid #e8e4dc",
background: "#fff", color: "#1a1a1a",
fontSize: "0.82rem", fontWeight: 500,
textDecoration: "none", display: "inline-block",
}}
>
Go to Build
</Link>
</div>
</div>
</div>
);
}
return (
<div style={{ height: "100%", display: "flex", flexDirection: "column", position: "relative" }}>
{/* Decision banner — shown when all 6 phases are saved */}