|
9 | 9 | } from "@copilotkitnext/react"; |
10 | 10 | import type { ToolsMenuItem } from "@copilotkitnext/react"; |
11 | 11 | import { z } from "zod"; |
12 | | -import { useMemo } from "react"; |
| 12 | +import { useMemo, useState } from "react"; |
13 | 13 |
|
14 | 14 | // Disable static optimization for this page |
15 | 15 | export const dynamic = "force-dynamic"; |
@@ -61,6 +61,13 @@ export default function Home() { |
61 | 61 | } |
62 | 62 |
|
63 | 63 | function Chat() { |
| 64 | + const [selectedThreadId, setSelectedThreadId] = useState<"thread---a" | "thread---b" | "thread---c">("thread---a"); |
| 65 | + const threadOptions: Array<{ id: typeof selectedThreadId; label: string }> = [ |
| 66 | + { id: "thread---a", label: "Thread A" }, |
| 67 | + { id: "thread---b", label: "Thread B" }, |
| 68 | + { id: "thread---c", label: "Thread C" }, |
| 69 | + ]; |
| 70 | + |
64 | 71 | //useConfigureSuggestions({ |
65 | 72 | // instructions: "Suggest helpful next actions", |
66 | 73 | //}); |
@@ -120,5 +127,37 @@ function Chat() { |
120 | 127 | [], |
121 | 128 | ); |
122 | 129 |
|
123 | | - return <CopilotChat inputProps={{ toolsMenu }} threadId="xyz" />; |
| 130 | + return ( |
| 131 | + <div style={{ display: "flex", flexDirection: "column", height: "100%", padding: "16px", gap: "16px" }}> |
| 132 | + <div style={{ display: "flex", gap: "10px", justifyContent: "center" }}> |
| 133 | + {threadOptions.map(({ id, label }) => { |
| 134 | + const isActive = id === selectedThreadId; |
| 135 | + return ( |
| 136 | + <button |
| 137 | + key={id} |
| 138 | + type="button" |
| 139 | + onClick={() => setSelectedThreadId(id)} |
| 140 | + aria-pressed={isActive} |
| 141 | + style={{ |
| 142 | + padding: "6px 14px", |
| 143 | + borderRadius: "20px", |
| 144 | + border: isActive ? "2px solid #111827" : "1px solid #d1d5db", |
| 145 | + backgroundColor: isActive ? "#111827" : "#ffffff", |
| 146 | + color: isActive ? "#ffffff" : "#111827", |
| 147 | + fontWeight: 600, |
| 148 | + fontSize: "0.85rem", |
| 149 | + cursor: "pointer", |
| 150 | + transition: "all 0.15s ease-in-out", |
| 151 | + }} |
| 152 | + > |
| 153 | + {label} |
| 154 | + </button> |
| 155 | + ); |
| 156 | + })} |
| 157 | + </div> |
| 158 | + <div style={{ flex: 1, minHeight: 0 }}> |
| 159 | + <CopilotChat inputProps={{ toolsMenu }} threadId={selectedThreadId} /> |
| 160 | + </div> |
| 161 | + </div> |
| 162 | + ); |
124 | 163 | } |
0 commit comments