xonecas.io
53129
Pa

PAT / commit 7e540c4

fix: small bugfixes

xonecas2025-12-16 7e540c4463fd2d0b5121ebc9c65c8ff880492fcb parent 0b50b14

3 files changed

app/api/threads/route.ts+1−1
@@ -39,7 +39,7 @@ export async function GET(request: Request) {
3939 const totalCount = totalCountResult[0]?.count || 0;
4040 const hasMore = offset + limit < totalCount;
4141
42- return NextResponse.json({ threads: threadsList, hasMore });
42+ return NextResponse.json({ threads: threadsList, hasMore, totalCount });
4343 } catch (error) {
4444 console.error("Get threads error", error);
4545 return NextResponse.json({ error: "Failed to get threads" }, { status: 500 });
app/page.tsx+6−2
@@ -15,6 +15,7 @@ export default function Home() {
1515 const { themeMode, handleThemeChange } = useTheme();
1616 const [currentThreadId, setCurrentThreadId] = useState<number | null>(null);
1717 const [threads, setThreads] = useState<Thread[]>([]);
18+ const [totalThreadCount, setTotalThreadCount] = useState<number>(0);
1819 const [isLoading, setIsLoading] = useState(false);
1920 const [hasMoreThreads, setHasMoreThreads] = useState(true);
2021 const messagesContainerRef = useRef<HTMLDivElement>(null);
@@ -31,6 +32,7 @@ export default function Home() {
3132 const threadsList = data.threads || [];
3233 setThreads(threadsList);
3334 setHasMoreThreads(data.hasMore || false);
35+ setTotalThreadCount(data.totalCount || 0);
3436 } catch (error) {
3537 console.error("Failed to load threads", error);
3638 }
@@ -90,6 +92,7 @@ export default function Home() {
9092 const threadsList = threadsData.threads || [];
9193 setThreads(threadsList);
9294 setHasMoreThreads(threadsData.hasMore || false);
95+ setTotalThreadCount(threadsData.totalCount || 0);
9396 return newThread.id;
9497 } catch (error) {
9598 console.error("Failed to create thread", error);
@@ -181,6 +184,7 @@ export default function Home() {
181184 const threadsList = threadsData.threads || [];
182185 setThreads(threadsList);
183186 setHasMoreThreads(threadsData.hasMore || false);
187+ setTotalThreadCount(threadsData.totalCount || 0);
184188 } catch (error) {
185189 console.error("Failed to send message", error);
186190 } finally {
@@ -206,9 +210,9 @@ export default function Home() {
206210 ref={messagesContainerRef}
207211 className="text-sm p-4 flex-1 overflow-y-auto overflow-x-hidden bg-neutral-100 dark:bg-neutral-950"
208212 >
209- <div className="flex min-h-full flex-col justify-end gap-8 max-w-4xl mx-auto">
213+ <div className="flex min-h-full flex-col justify-end gap-8 max-w-5xl mx-auto">
210214 {currentThreadId === null ? (
211- <NoThreadSelected threadCount={threads.length} />
215+ <NoThreadSelected threadCount={totalThreadCount} />
212216 ) : (
213217 messages.map((msg) => (
214218 <div
src/components/NoThreadSelected.tsx+2−2
@@ -29,8 +29,8 @@ export default function NoThreadSelected({ threadCount }: NoThreadSelectedProps)
2929 const timeDisplay = currentTime ? formatTime(currentTime) : "";
3030
3131 return (
32- <div className="min-w-0 max-w-4xl mx-auto">
33- <div className="p-8 bg-neutral-200 dark:bg-neutral-900 prose prose-neutral dark:prose-invert">
32+ <div className="min-w-0 max-w-5xl mx-auto">
33+ <div className="p-8 bg-neutral-200 dark:bg-neutral-900 prose prose-neutral dark:prose-invert max-w-none">
3434 <ReactMarkdown remarkPlugins={[remarkGfm]} rehypePlugins={[rehypeHighlight]}>
3535 {`# Welcome to PAT 👋