xonecas.io
53129
Pa

PAT / commit 09f8835

feat: thread list in sidebar

xonecas2025-12-16 09f8835274fba94103d96cf6db22c22b48f2c20a parent 14df8af

2 files changed

app/page.tsx+2−2
@@ -68,7 +68,7 @@ export default function Home() {
6868
6969 const createNewThread = async (titleOverride?: string, firstMessage?: string): Promise<number | null> => {
7070 try {
71- const title = titleOverride || (firstMessage ? firstMessage.substring(0, 20) : "New Thread");
71+ const title = titleOverride || (firstMessage ? firstMessage.substring(0, 100) : "New Thread");
7272 const res = await fetch("/api/threads", {
7373 method: "POST",
7474 headers: { "Content-Type": "application/json" },
@@ -108,7 +108,7 @@ export default function Home() {
108108 let threadId = currentThreadId;
109109 if (!threadId) {
110110 // Create a new thread if none exists
111- threadId = await createNewThread(message.substring(0, 20), message);
111+ threadId = await createNewThread(message.substring(0, 100), message);
112112 if (!threadId) {
113113 setIsLoading(false);
114114 return;
src/components/Sidebar.tsx+23−17
@@ -30,23 +30,29 @@ export default function Sidebar({
3030 </button>
3131 <div className="flex flex-col gap-2">
3232 <label className="text-sm font-semibold">Threads</label>
33- <select
34- value={currentThreadId || ""}
35- onChange={(e) => {
36- const threadId = e.target.value ? parseInt(e.target.value) : null;
37- if (threadId) {
38- onThreadSelect(threadId);
39- }
40- }}
41- className="bg-neutral-100 px-3 py-1 text-neutral-800 focus:outline-none dark:bg-neutral-950 dark:text-neutral-200"
42- >
43- <option value="">Select a thread...</option>
44- {threads.map((thread) => (
45- <option key={thread.id} value={thread.id}>
46- {thread.title || `Thread ${thread.id}`}
47- </option>
48- ))}
49- </select>
33+ <div className="flex flex-col gap-1">
34+ {threads.length === 0 ? (
35+ <div className="px-3 py-2 text-sm text-neutral-600 dark:text-neutral-400">
36+ No threads yet
37+ </div>
38+ ) : (
39+ threads.map((thread) => (
40+ <button
41+ key={thread.id}
42+ onClick={() => onThreadSelect(thread.id)}
43+ className={`px-3 py-2 text-left text-sm border-2 hover:bg-neutral-300 dark:hover:bg-neutral-800 ${
44+ currentThreadId === thread.id
45+ ? "bg-neutral-300 dark:bg-neutral-800 border-green-900 dark:border-green-500"
46+ : "bg-neutral-100 dark:bg-neutral-950 border-transparent"
47+ }`}
48+ >
49+ <div className="line-clamp-2 break-words">
50+ {thread.title || `Thread ${thread.id}`}
51+ </div>
52+ </button>
53+ ))
54+ )}
55+ </div>
5056 </div>
5157 <div className="flex flex-col gap-2">
5258 <label className="text-sm font-semibold">Theme</label>