xonecas.io
5414
Sa

sat / commit 56e4f29

fix: remove janky scroll stuff

xonecas2026-01-15 56e4f29921e5afbbc77bd6479f927c7fa69f90db parent 885f3c7

3 files changed

src/components/app-sidebar.tsx+3−3
@@ -4,6 +4,7 @@ import { MessageSquarePlus, Trash2 } from "lucide-react";
44 import Link from "next/link";
55 import { usePathname, useRouter } from "next/navigation";
66 import { useEffect, useState, useTransition } from "react";
7+import { toast } from "sonner";
78 import {
89 deleteConversation,
910 getConversations,
@@ -35,7 +36,6 @@ import {
3536 SidebarMenuButton,
3637 SidebarMenuItem,
3738 } from "@/components/ui/sidebar";
38-import { toast } from "sonner";
3939 import type { Conversation } from "@/db/schema";
4040
4141 export function AppSidebar() {
@@ -93,7 +93,7 @@ export function AppSidebar() {
9393 <Button asChild variant="outline" className="w-full justify-start">
9494 <Link href="/">
9595 <MessageSquarePlus className="size-4" />
96- New Chat
96+ New Conversation
9797 </Link>
9898 </Button>
9999 </SidebarGroupContent>
@@ -120,7 +120,7 @@ export function AppSidebar() {
120120 <AlertDialog>
121121 <AlertDialogTrigger asChild>
122122 <SidebarMenuAction showOnHover>
123- <Trash2 className="size-4" />
123+ <Trash2 className="size-4 cursor-pointer" />
124124 <span className="sr-only">Delete conversation</span>
125125 </SidebarMenuAction>
126126 </AlertDialogTrigger>
src/components/chat.tsx+33−37
@@ -63,14 +63,6 @@ export function Chat({ conversationId }: ChatProps) {
6363 const messagesEndRef = useRef<HTMLDivElement>(null);
6464 const textareaRef = useRef<HTMLTextAreaElement>(null);
6565
66- const scrollToBottom = useCallback(() => {
67- messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
68- }, []);
69-
70- useEffect(() => {
71- scrollToBottom();
72- }, [messages, scrollToBottom]);
73-
7466 // Load existing conversation turns
7567 useEffect(() => {
7668 async function loadConversation() {
@@ -328,7 +320,7 @@ export function Chat({ conversationId }: ChatProps) {
328320 setIsStreaming(false);
329321 // Navigate to new conversation URL after streaming completes
330322 if (shouldNavigate && newConversationId) {
331- router.push(`/conversation/${newConversationId}`);
323+ router.push(`/conversation/${newConversationId}`, { scroll: false });
332324 }
333325 }
334326 },
@@ -464,10 +456,7 @@ function MessageBubble({ message }: { message: Message }) {
464456 </Avatar>
465457
466458 {isUser ? (
467- <Card
468- size="sm"
469- className="bg-primary text-primary-foreground max-w-[80%]"
470- >
459+ <Card size="sm" className="max-w-[80%]">
471460 <CardContent>
472461 <p className="whitespace-pre-wrap">{message.content}</p>
473462 </CardContent>
@@ -477,19 +466,31 @@ function MessageBubble({ message }: { message: Message }) {
477466 {/* Reasoning section */}
478467 {message.reasoning && (
479468 <CardContent>
480- <Collapsible>
481- <div className="border-muted-foreground/20 bg-muted/30 rounded-lg border p-2">
482- <CollapsibleTrigger className="text-muted-foreground hover:text-foreground flex w-full items-center gap-1 text-xs transition-colors [&[data-state=open]>svg:first-child]:rotate-90">
483- <ChevronRight className="size-3 transition-transform" />
484- <span>Thinking...</span>
485- </CollapsibleTrigger>
486- <CollapsibleContent>
487- <p className="text-muted-foreground mt-2 whitespace-pre-wrap text-xs">
488- {message.reasoning}
469+ {(() => {
470+ const lines = message.reasoning.split("\n");
471+ const visibleLines = lines.slice(-5).join("\n");
472+ const hiddenLines = lines.slice(0, -5).join("\n");
473+ const hasHiddenContent = lines.length > 5;
474+
475+ return (
476+ <Collapsible>
477+ <CollapsibleTrigger className="text-muted-foreground hover:text-foreground flex w-full items-center gap-1 text-xs transition-colors [&[data-state=open]>svg:first-child]:rotate-90">
478+ <ChevronRight className="size-3 transition-transform" />
479+ <span>Show more reasoning</span>
480+ </CollapsibleTrigger>
481+ {hasHiddenContent && (
482+ <CollapsibleContent>
483+ <p className="text-muted-foreground whitespace-pre-wrap text-xs mt-2">
484+ {hiddenLines}
485+ </p>
486+ </CollapsibleContent>
487+ )}
488+ <p className="text-muted-foreground whitespace-pre-wrap text-xs">
489+ {visibleLines}
489490 </p>
490- </CollapsibleContent>
491- </div>
492- </Collapsible>
491+ </Collapsible>
492+ );
493+ })()}
493494 </CardContent>
494495 )}
495496
@@ -515,28 +516,23 @@ function MessageBubble({ message }: { message: Message }) {
515516 }
516517
517518 function ToolCallBubble({ toolCall }: { toolCall: ToolCall }) {
518- const isSearch = toolCall.name === "search_web";
519-
520519 return (
521- <Collapsible>
522- <Card size="sm" className="border-blue-500/20 bg-blue-500/5">
520+ <Collapsible className="my-4">
521+ <Card size="sm">
523522 <CardContent>
524523 <div className="flex items-center gap-2">
525524 {toolCall.status === "pending" ? (
526- <Loader2 className="size-3 animate-spin text-blue-500" />
527- ) : isSearch ? (
528- <Search className="size-3 text-blue-500" />
525+ <Loader2 className="size-3 animate-spin" />
529526 ) : (
530- <Wrench className="size-3 text-blue-500" />
527+ <Wrench className="size-3" />
531528 )}
532529 <span className="text-xs font-medium">
533- {isSearch ? "Searching" : toolCall.name}
534- {isSearch &&
535- typeof toolCall.args.query === "string" &&
530+ Calling {toolCall.name}
531+ {typeof toolCall.args.query === "string" &&
536532 toolCall.args.query && (
537533 <span className="text-muted-foreground font-normal">
538534 {" "}
539- for "{toolCall.args.query}"
535+ with "{toolCall.args.query}"
540536 </span>
541537 )}
542538 </span>
src/components/markdown-content.tsx+6−7
@@ -22,9 +22,7 @@ const components: Components = {
2222 {children}
2323 </h4>
2424 ),
25- p: ({ children }) => (
26- <p className="leading-7 not-first:mt-4">{children}</p>
27- ),
25+ p: ({ children }) => <p className="leading-7 not-first:mt-4">{children}</p>,
2826 blockquote: ({ children }) => (
2927 <blockquote className="mt-4 border-l-2 pl-6 italic">{children}</blockquote>
3028 ),
@@ -62,13 +60,14 @@ const components: Components = {
6260 th: ({ children }) => (
6361 <th className="border px-4 py-2 text-left font-bold">{children}</th>
6462 ),
65- td: ({ children }) => (
66- <td className="border px-4 py-2">{children}</td>
67- ),
63+ td: ({ children }) => <td className="border px-4 py-2">{children}</td>,
64+ hr: () => <hr className="my-8 border-t" />,
6865 };
6966
7067 export const MarkdownContent = memo(function MarkdownContent({
7168 content,
72-}: { content: string }) {
69+}: {
70+ content: string;
71+}) {
7372 return <ReactMarkdown components={components}>{content}</ReactMarkdown>;
7473 });