Skip to content

Open source alternative to Semrush and Ahrefs

Port the SAM chat page and sidebar Chat tab to shadcn (EVE-317) (#761)

Carter Smithfba48fc9eb14
diff --git a/src/client/components/PortalMenu.tsx b/src/client/components/PortalMenu.tsx
deleted file mode 100644
index 7a689b8c..00000000
--- a/src/client/components/PortalMenu.tsx
+++ /dev/null
@@ -1,96 +0,0 @@
-import type { ReactNode } from "react";
-import { useEffect, useRef, useState } from "react";
-import { createPortal } from "react-dom";
-import { MoreHorizontal } from "lucide-react";
-
-/**
- * Kebab actions menu rendered through a portal in fixed position, so it can't
- * be clipped by overflow containers (scrollable tables, overflow-hidden
- * cards). Opens below the trigger, right-aligned. Closes on outside click,
- * Escape, scroll, and resize.
- */
-export function PortalMenu({
- ariaLabel,
- triggerClassName = "btn btn-ghost btn-xs btn-square",
- triggerContent = <MoreHorizontal className="size-3.5" />,
- menuClassName = "w-40",
- children,
-}: {
- ariaLabel: string;
- triggerClassName?: string;
- triggerContent?: ReactNode;
- menuClassName?: string;
- /** Menu <li> items; call `close` before running an item's action. */
- children: (close: () => void) => ReactNode;
-}) {
- const [isOpen, setIsOpen] = useState(false);
- const buttonRef = useRef<HTMLButtonElement | null>(null);
- const menuRef = useRef<HTMLUListElement | null>(null);
- const [position, setPosition] = useState({ top: 0, left: 0 });
-
- useEffect(() => {
- if (!isOpen) return;
- const closeOnOutsideClick = (event: MouseEvent) => {
- const target = event.target;
- if (
- target instanceof Node &&
- (buttonRef.current?.contains(target) ||
- menuRef.current?.contains(target))
- ) {
- return;
- }
- setIsOpen(false);
- };
- const close = () => setIsOpen(false);
- const closeOnScroll = (event: Event) => {
- // Scrolling inside the menu itself shouldn't dismiss it.
- const target = event.target;
- if (target instanceof Node && menuRef.current?.contains(target)) return;
- setIsOpen(false);
- };
- const closeOnEscape = (event: KeyboardEvent) => {
- if (event.key === "Escape") setIsOpen(false);
- };
- document.addEventListener("mousedown", closeOnOutsideClick);
- document.addEventListener("keydown", closeOnEscape);
- window.addEventListener("scroll", closeOnScroll, true);
- window.addEventListener("resize", close);
- return () => {
- document.removeEventListener("mousedown", closeOnOutsideClick);
- document.removeEventListener("keydown", closeOnEscape);
- window.removeEventListener("scroll", closeOnScroll, true);
- window.removeEventListener("resize", close);
- };
- }, [isOpen]);
-
- return (
- <>
- <button
- ref={buttonRef}
- type="button"
- className={triggerClassName}
- aria-label={ariaLabel}
- aria-expanded={isOpen}
- onClick={() => {
- const rect = buttonRef.current?.getBoundingClientRect();
- if (rect) setPosition({ top: rect.bottom + 4, left: rect.right });
- setIsOpen((open) => !open);
- }}
- >
- {triggerContent}
- </button>
- {isOpen && typeof document !== "undefined"
- ? createPortal(
- <ul
- ref={menuRef}
- className={`menu fixed z-[1000] -translate-x-full rounded-box border border-base-300 bg-base-100 p-2 shadow-lg ${menuClassName}`}
- style={{ top: position.top, left: position.left }}
- >
- {children(() => setIsOpen(false))}
- </ul>,
- document.body,
- )
- : null}
- </>
- );
-}
diff --git a/src/client/components/chat/ChatMessage.tsx b/src/client/components/chat/ChatMessage.tsx
index 1afd36fb..fefcf580 100644
--- a/src/client/components/chat/ChatMessage.tsx
+++ b/src/client/components/chat/ChatMessage.tsx
@@ -4,12 +4,20 @@ import {
AlertTriangle,
Check,
ChevronRight,
- Copy,
- Loader2,
Pencil,
Undo2,
} from "lucide-react";
+import { CopyButton } from "@/client/components/CopyButton";
import { Markdown } from "@/client/components/Markdown";
+import { Badge } from "@/client/components/ui/badge";
+import { Button } from "@/client/components/ui/button";
+import {
+ Collapsible,
+ CollapsibleContent,
+ CollapsibleTrigger,
+} from "@/client/components/ui/collapsible";
+import { Spinner } from "@/client/components/ui/spinner";
+import { Textarea } from "@/client/components/ui/textarea";
// Turn a tool part type ("tool-get_serp_results") into a readable label
// ("Get serp results"). SAM exposes the full MCP tool surface, too many tools
@@ -59,25 +67,6 @@ function messageText(message: UIMessage): string {
.trim();
}
-function CopyButton({ message }: { message: UIMessage }) {
- const [copied, setCopied] = useState(false);
- return (
- <button
- type="button"
- aria-label="Copy message"
- title="Copy"
- className="btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content"
- onClick={() => {
- void navigator.clipboard.writeText(messageText(message));
- setCopied(true);
- setTimeout(() => setCopied(false), 1500);
- }}
- >
- {copied ? <Check className="size-3.5" /> : <Copy className="size-3.5" />}
- </button>
- );
-}
-
// Hover action bar under a message: copy for every message, undo/edit for user
// messages when the chat wires up the handlers (rewinding needs server support,
// so chats opt in per handler).
@@ -92,32 +81,38 @@ function MessageActions({
}) {
return (
<div
- className={`flex gap-0.5 reveal-on-hover ${
+ className={`flex gap-0.5 text-muted-foreground reveal-on-hover ${
message.role === "user" ? "justify-end" : ""
}`}
>
- <CopyButton message={message} />
+ <CopyButton
+ value={messageText(message)}
+ successMessage="Message copied"
+ label="Copy message"
+ variant="ghost"
+ size="icon-xs"
+ />
{onStartEdit ? (
- <button
- type="button"
+ <Button
+ variant="ghost"
+ size="icon-xs"
aria-label="Edit message"
title="Edit and resend"
- className="btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content"
onClick={onStartEdit}
>
- <Pencil className="size-3.5" />
- </button>
+ <Pencil />
+ </Button>
) : null}
{onUndo ? (
- <button
- type="button"
+ <Button
+ variant="ghost"
+ size="icon-xs"
aria-label="Undo from this message"
title="Undo — remove this message and everything after it"
- className="btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content"
onClick={onUndo}
>
- <Undo2 className="size-3.5" />
- </button>
+ <Undo2 />
+ </Button>
) : null}
</div>
);
@@ -133,33 +128,24 @@ function ReasoningBlock({
part: Extract<UIMessage["parts"][number], { type: "reasoning" }>;
live: boolean;
}) {
- const [expanded, setExpanded] = useState(false);
// Persisted parts can keep a stale state:"streaming" (interrupted or
// multi-segment turns), so only trust it while the message is actually
// being generated — otherwise finished replies show hanging spinners.
const isStreaming = live && part.state === "streaming";
return (
- <div className="text-base-content/60">
- <button
- type="button"
- onClick={() => setExpanded((open) => !open)}
- className="inline-flex items-center gap-1.5 text-xs hover:text-base-content/80"
- >
+ <Collapsible className="text-muted-foreground">
+ <CollapsibleTrigger className="group inline-flex items-center gap-1.5 rounded-sm text-xs outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50">
{isStreaming ? (
- <Loader2 className="size-3 animate-spin" />
+ <Spinner className="size-3" />
) : (
- <ChevronRight
- className={`size-3 transition-transform ${expanded ? "rotate-90" : ""}`}
- />
+ <ChevronRight className="size-3 transition-transform group-data-panel-open:rotate-90" />
)}
<span>{isStreaming ? "Thinking…" : "Thought process"}</span>
- </button>
- {expanded ? (
- <div className="mt-1.5 whitespace-pre-wrap border-l-2 border-base-300 pl-3 text-xs text-base-content/50">
- {part.text}
- </div>
- ) : null}
- </div>
+ </CollapsibleTrigger>
+ <CollapsibleContent className="mt-1.5 whitespace-pre-wrap border-l-2 border-border pl-3 text-xs">
+ {part.text}
+ </CollapsibleContent>
+ </Collapsible>
);
}
@@ -183,20 +169,13 @@ function ToolBadge({
const isError = state === "output-error" || (!isDone && !live);
const isRunning = !isError && !isDone;
return (
- <span
- className={`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs ${
- isError ? "bg-error/10 text-error" : "bg-base-200 text-base-content/70"
- }`}
+ <Badge
+ variant={isError ? "destructive" : "secondary"}
+ className="h-6 px-2.5 font-normal"
>
- {isRunning ? (
- <Loader2 className="size-3 animate-spin" />
- ) : isError ? (
- <AlertTriangle className="size-3" />
- ) : (
- <Check className="size-3" />
- )}
- <span>{isRunning ? `${runningText}…` : doneText}</span>
- </span>
+ {isRunning ? <Spinner /> : isError ? <AlertTriangle /> : <Check />}
+ {isRunning ? `${runningText}…` : doneText}
+ </Badge>
);
}
@@ -235,8 +214,9 @@ export function ChatMessage({
};
return (
<div className="flex flex-col items-end gap-1.5 pl-8 sm:pl-16">
- <textarea
- className="textarea textarea-bordered w-full max-w-xl text-sm"
+ <Textarea
+ className="max-h-36 max-w-xl"
+ // Browsers without CSS field-sizing size the box from `rows`.
rows={Math.min(6, Math.max(2, draft.split("\n").length))}
value={draft}
autoFocus
@@ -250,20 +230,12 @@ export function ChatMessage({
}}
/>
<div className="flex gap-1.5">
- <button
- type="button"
- className="btn btn-ghost btn-xs"
- onClick={() => setEditing(false)}
- >
+ <Button variant="ghost" size="xs" onClick={() => setEditing(false)}>
Cancel
- </button>
- <button
- type="button"
- className="btn btn-primary btn-xs"
- onClick={submit}
- >
+ </Button>
+ <Button size="xs" onClick={submit}>
Save & resend
- </button>
+ </Button>
</div>
</div>
);
@@ -271,7 +243,7 @@ export function ChatMessage({
return (
<div className="group flex flex-col gap-1">
<div className="flex justify-end pl-8 sm:pl-16">
- <div className="rounded-box rounded-br-sm bg-primary px-4 py-2.5 text-sm text-primary-content">
+ <div className="rounded-xl rounded-br-sm bg-primary px-4 py-2.5 text-sm text-primary-foreground">
{message.parts.map((part, index) =>
part.type === "text" ? (
<span key={index} className="whitespace-pre-wrap">
diff --git a/src/client/components/table/AppDataTable.tsx b/src/client/components/table/AppDataTable.tsx
deleted file mode 100644
index bdc31be7..00000000
--- a/src/client/components/table/AppDataTable.tsx
+++ /dev/null
@@ -1,129 +0,0 @@
-import {
- flexRender,
- type Header,
- type Row,
- type Table,
-} from "@tanstack/react-table";
-import type { MouseEvent, ReactNode } from "react";
-
-// The DaisyUI table, for pages that have not moved to `DataTable` yet. Each
-// page port moves its tables to `DataTable`. The last port deletes this file.
-
-export function AppDataTable<TData>({
- table,
- className = "table table-sm",
- wrapperClassName = "overflow-x-auto",
- empty,
- getRowClassName,
- getRowProps,
- getCellClassName,
- fixedLayout,
- stickyHeader,
-}: {
- table: Table<TData>;
- className?: string;
- wrapperClassName?: string;
- empty?: ReactNode;
- getRowClassName?: (row: Row<TData>) => string | undefined;
- getRowProps?: (row: Row<TData>) => {
- onClick?: (event: MouseEvent<HTMLTableRowElement>) => void;
- className?: string;
- };
- getCellClassName?: (row: Row<TData>, columnId: string) => string | undefined;
- fixedLayout?: boolean;
- stickyHeader?: boolean;
-}) {
- if (table.getRowModel().rows.length === 0 && empty) return <>{empty}</>;
-
- return (
- <div className={wrapperClassName}>
- <table
- className={className}
- style={fixedLayout ? { tableLayout: "fixed" } : undefined}
- >
- {fixedLayout ? (
- <colgroup>
- {table.getVisibleLeafColumns().map((column) => (
- <col key={column.id} style={{ width: column.getSize() }} />
- ))}
- </colgroup>
- ) : null}
- <thead>
- {table.getHeaderGroups().map((headerGroup) => (
- <tr key={headerGroup.id}>
- {headerGroup.headers.map((header) => (
- <HeaderCell
- key={header.id}
- header={header}
- fixedLayout={fixedLayout}
- stickyHeader={stickyHeader}
- />
- ))}
- </tr>
- ))}
- </thead>
- <tbody>
- {table.getRowModel().rows.map((row) => {
- const rowProps = getRowProps?.(row);
- return (
- <tr
- key={row.id}
- onClick={rowProps?.onClick}
- className={[getRowClassName?.(row), rowProps?.className]
- .filter(Boolean)
- .join(" ")}
- >
- {row.getVisibleCells().map((cell) => {
- const metaClass = cell.column.columnDef.meta?.cellClassName;
- return (
- <td
- key={cell.id}
- className={[
- typeof metaClass === "function"
- ? metaClass(row)
- : metaClass,
- getCellClassName?.(row, cell.column.id),
- ]
- .filter(Boolean)
- .join(" ")}
- >
- {flexRender(
- cell.column.columnDef.cell,
- cell.getContext(),
- )}
- </td>
- );
- })}
- </tr>
- );
- })}
- </tbody>
- </table>
- </div>
- );
-}
-
-function HeaderCell<TData>({
- header,
- fixedLayout,
- stickyHeader,
-}: {
- header: Header<TData, unknown>;
- fixedLayout?: boolean;
- stickyHeader?: boolean;
-}) {
- const meta = header.column.columnDef.meta;
- return (
- <th
- className={[
- stickyHeader ? "bg-base-200" : undefined,
- meta?.headerClassName,
- ]
- .filter(Boolean)
- .join(" ")}
- style={fixedLayout ? { width: header.getSize() } : undefined}
- >
- {flexRender(header.column.columnDef.header, header.getContext())}
- </th>
- );
-}
diff --git a/src/client/components/table/TableBulkActionBar.tsx b/src/client/components/table/TableBulkActionBar.tsx
index b16dac97..df2dd73d 100644
--- a/src/client/components/table/TableBulkActionBar.tsx
+++ b/src/client/components/table/TableBulkActionBar.tsx
@@ -1,4 +1,4 @@
-import { ChevronDown, Download, X } from "lucide-react";
+import { Download, X } from "lucide-react";
import type { ReactNode } from "react";
import { Button } from "@/client/components/ui/button";
import {
@@ -113,50 +113,3 @@ export function TableBulkExportMenu({
</DropdownMenu>
);
}
-
-export function TableExportMenu({
- actions,
- buttonClassName = "btn btn-sm gap-1",
- labelClassName,
- menuClassName = "dropdown-content z-10 menu p-2 shadow-lg bg-base-100 border border-base-300 rounded-box w-56",
-}: {
- actions: Array<{
- label: ReactNode;
- icon?: ReactNode;
- onClick: () => void;
- disabled?: boolean;
- }>;
- buttonClassName?: string;
- /** Lets narrow toolbars hide the text and keep the icon. */
- labelClassName?: string;
- menuClassName?: string;
-}) {
- return (
- <div className="dropdown dropdown-end">
- <div
- tabIndex={0}
- role="button"
- aria-label="Export"
- className={buttonClassName}
- >
- <Download className="size-4" />
- <span className={labelClassName}>Export</span>
- <ChevronDown className="size-3 opacity-60" />
- </div>
- <ul tabIndex={0} className={menuClassName}>
- {actions.map((action, index) => (
- <li key={index}>
- <button
- type="button"
- onClick={action.onClick}
- disabled={action.disabled}
- >
- {action.icon}
- {action.label}
- </button>
- </li>
- ))}
- </ul>
- </div>
- );
-}
diff --git a/src/client/features/sam/ChatComposer.tsx b/src/client/features/sam/ChatComposer.tsx
index 479252ac..5acdf1ea 100644
--- a/src/client/features/sam/ChatComposer.tsx
+++ b/src/client/features/sam/ChatComposer.tsx
@@ -1,11 +1,11 @@
-import {
- useLayoutEffect,
- useRef,
- useState,
- type FormEvent,
- type KeyboardEvent,
-} from "react";
+import { useState, type FormEvent, type KeyboardEvent } from "react";
import { ArrowUp, Square } from "lucide-react";
+import {
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupTextarea,
+} from "@/client/components/ui/input-group";
export function ChatComposer({
busy,
@@ -18,16 +18,6 @@ export function ChatComposer({
onStop: () => void;
}) {
const [value, setValue] = useState("");
- const textareaRef = useRef<HTMLTextAreaElement>(null);
-
- // Auto-grow the textarea up to a few lines, then scroll. Resetting height to
- // `auto` first lets it shrink as well as grow.
- useLayoutEffect(() => {
- const ta = textareaRef.current;
- if (!ta) return;
- ta.style.height = "auto";
- ta.style.height = `${Math.min(ta.scrollHeight, 160)}px`;
- }, [value]);
function submit() {
const text = value.trim();
@@ -49,38 +39,43 @@ export function ChatComposer({
}
return (
- <form
- onSubmit={handleSubmit}
- className="flex items-end gap-2 rounded-box border border-base-300 bg-base-100 px-3 py-2 focus-within:border-primary"
- >
- <textarea
- ref={textareaRef}
- value={value}
- onChange={(event) => setValue(event.target.value)}
- onKeyDown={handleKey}
- rows={1}
- placeholder="Ask SAM to research, analyze, or track anything…"
- className="max-h-40 flex-1 resize-none border-0 bg-transparent px-1 py-1 text-sm leading-relaxed outline-none placeholder:text-base-content/50 focus:outline-none"
- />
- {busy ? (
- <button
- type="button"
- aria-label="Stop"
- onClick={onStop}
- className="btn btn-neutral btn-circle btn-sm"
- >
- <Square className="size-3.5 fill-current" />
- </button>
- ) : (
- <button
- type="submit"
- aria-label="Send message"
- disabled={!value.trim()}
- className="btn btn-primary btn-circle btn-sm"
- >
- <ArrowUp className="size-4" />
- </button>
- )}
+ <form onSubmit={handleSubmit}>
+ {/* InputGroup dims itself when it holds a disabled control. The empty
+ composer disables only Send, so keep the field at full strength. */}
+ <InputGroup className="items-end rounded-xl bg-card has-disabled:bg-card has-disabled:opacity-100 dark:has-disabled:bg-input/30">
+ <InputGroupTextarea
+ value={value}
+ onChange={(event) => setValue(event.target.value)}
+ onKeyDown={handleKey}
+ rows={1}
+ placeholder="Ask SAM to research, analyze, or track anything…"
+ className="max-h-40 min-h-0 px-3 leading-relaxed"
+ />
+ <InputGroupAddon align="inline-end">
+ {busy ? (
+ <InputGroupButton
+ variant="secondary"
+ size="icon-sm"
+ className="rounded-full"
+ aria-label="Stop"
+ onClick={onStop}
+ >
+ <Square className="size-3.5 fill-current" />
+ </InputGroupButton>
+ ) : (
+ <InputGroupButton
+ type="submit"
+ variant="default"
+ size="icon-sm"
+ className="rounded-full"
+ aria-label="Send message"
+ disabled={!value.trim()}
+ >
+ <ArrowUp />
+ </InputGroupButton>
+ )}
+ </InputGroupAddon>
+ </InputGroup>
</form>
);
}
diff --git a/src/client/features/sam/SamChat.tsx b/src/client/features/sam/SamChat.tsx
index 7a31822f..dd935308 100644
--- a/src/client/features/sam/SamChat.tsx
+++ b/src/client/features/sam/SamChat.tsx
@@ -186,14 +186,14 @@ export function SamChat({
<div className="flex h-full min-h-0 flex-col">
{/* Session title + the shortest path to inspect or correct the shared
memory SAM reads and writes during the conversation. */}
- <div className="flex items-center justify-between gap-3 border-b border-base-300 px-5 py-3.5">
- <span className="truncate text-sm font-medium text-base-content/80">
+ <div className="flex items-center justify-between gap-3 border-b border-border px-5 py-3.5">
+ <span className="truncate text-sm font-medium text-foreground/80">
{activeSession.title}
</span>
<Link
to="/p/$projectId/context"
params={{ projectId }}
- className="flex shrink-0 items-center gap-1.5 text-xs text-base-content/60 transition-colors hover:text-base-content"
+ className="flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground"
>
<Brain className="size-3.5" />
Project memory
diff --git a/src/client/features/sam/SamConversation.tsx b/src/client/features/sam/SamConversation.tsx
index 3e20122e..73866067 100644
--- a/src/client/features/sam/SamConversation.tsx
+++ b/src/client/features/sam/SamConversation.tsx
@@ -3,12 +3,13 @@ import { useAgent } from "agents/react";
// variant skips the client->server transcript sync Think doesn't support.
import { useAgentChat } from "@cloudflare/think/react";
import { useEffect, useRef, useState } from "react";
-import { RotateCcw } from "lucide-react";
import { findLast } from "remeda";
import { toast } from "sonner";
import { ChatComposer } from "@/client/features/sam/ChatComposer";
import { invalidateSamSessions } from "@/client/features/sam/samQueries";
import { captureClientEvent } from "@/client/lib/posthog";
+import { ErrorState } from "@/client/components/ErrorState";
+import { Button } from "@/client/components/ui/button";
import {
ChatMessage,
messageHasVisibleContent,
@@ -165,13 +166,14 @@ export function SamConversation({
// Dev-only escape hatch: wipes this session's persisted transcript on
// the server (Think's cf_agent_chat_clear), for testing fresh-session
// behavior without creating a new chat.
- <button
- type="button"
- className="btn btn-ghost btn-xs absolute right-3 top-2 z-10 text-base-content/40"
+ <Button
+ variant="ghost"
+ size="xs"
+ className="absolute top-2 right-3 z-10 text-muted-foreground"
onClick={() => clearHistory()}
>
Clear history (dev)
- </button>
+ </Button>
) : null}
<div
ref={scrollRef}
@@ -180,7 +182,7 @@ export function SamConversation({
>
<div className="mx-auto max-w-2xl space-y-6">
{messages.length === 0 ? (
- <div className="space-y-2 text-sm text-base-content/80">
+ <div className="space-y-2 text-sm text-foreground/80">
<p>
Hey, I’m SAM — your in-app SEO agent. I can research keywords,
size up competitors, read your SERPs, backlinks, rank tracking
@@ -214,7 +216,7 @@ export function SamConversation({
))}
{showTyping ? (
- <div className="flex items-center gap-2 pt-1 text-base-content/40">
+ <div className="flex items-center gap-2 pt-1 text-muted-foreground">
<span className="flex items-center gap-1.5">
<span className="size-1.5 animate-bounce rounded-full bg-current [animation-delay:-0.3s]" />
<span className="size-1.5 animate-bounce rounded-full bg-current [animation-delay:-0.15s]" />
@@ -224,60 +226,58 @@ export function SamConversation({
) : null}
{isRecovering ? (
- <p className="text-xs text-base-content/50">
+ <p className="text-xs text-muted-foreground">
Saving the reply that got cut off…
</p>
) : null}
{status === "error" ? (
- <div className="flex flex-wrap items-center gap-3 text-sm text-error">
- <span>SAM stopped before finishing this reply.</span>
- {lastUserMessage ? (
- <button
- type="button"
- className="btn btn-outline btn-error btn-xs gap-1"
- disabled={isBusy}
- onClick={retryLast}
- >
- <RotateCcw className="size-3" />
- Retry
- </button>
- ) : null}
- </div>
+ <ErrorState
+ variant="inline"
+ message="SAM stopped before finishing this reply."
+ onRetry={lastUserMessage ? retryLast : undefined}
+ isRetrying={isBusy}
+ />
) : null}
{showSuggestions ? (
<div className="flex flex-wrap gap-2">
{SUGGESTIONS.map((question) => (
- <button
+ <Button
key={question}
- type="button"
- className="rounded-full border border-base-300 bg-base-100 px-3 py-1.5 text-xs font-medium text-base-content/70 transition-colors hover:border-primary/50 hover:text-base-content"
+ variant="outline"
+ size="sm"
+ className="rounded-full text-xs text-muted-foreground"
onClick={() => sendText(question, "suggestion")}
>
{question}
- </button>
+ </Button>
))}
</div>
) : null}
</div>
</div>
- <div className="flex-shrink-0 border-t border-base-300 px-5 py-3">
+ <div className="flex-shrink-0 border-t border-border px-5 py-3">
<div className="mx-auto w-full max-w-2xl">
{connectionError ? (
- <div className="mb-2 flex flex-wrap items-center gap-3 text-sm text-error">
- <span>Lost the connection to SAM.</span>
- <button
- type="button"
- className="btn btn-outline btn-error btn-xs"
- onClick={() => agent.reconnect()}
- >
- Reconnect
- </button>
+ <div className="mb-2">
+ <ErrorState
+ variant="inline"
+ message="Lost the connection to SAM."
+ action={
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => agent.reconnect()}
+ >
+ Reconnect
+ </Button>
+ }
+ />
</div>
) : isReconnecting ? (
- <p className="mb-2 text-xs text-base-content/60">Reconnecting…</p>
+ <p className="mb-2 text-xs text-muted-foreground">Reconnecting…</p>
) : null}
<ChatComposer
busy={isBusy}
diff --git a/src/client/features/sam/SamSidebarPanel.tsx b/src/client/features/sam/SamSidebarPanel.tsx
index 736bc49d..a9ef9a47 100644
--- a/src/client/features/sam/SamSidebarPanel.tsx
+++ b/src/client/features/sam/SamSidebarPanel.tsx
@@ -1,13 +1,16 @@
import { Link, useLocation } from "@tanstack/react-router";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useEffect, useState } from "react";
-import { Archive, Loader2, Plus, X } from "lucide-react";
+import { Archive, Plus, X } from "lucide-react";
import { archiveSamSession } from "@/serverFunctions/sam";
import {
invalidateSamSessions,
samSessionsQueryOptions,
} from "@/client/features/sam/samQueries";
import { QueryState } from "@/client/components/QueryState";
+import { Badge } from "@/client/components/ui/badge";
+import { Button } from "@/client/components/ui/button";
+import { Spinner } from "@/client/components/ui/spinner";
import { useSamBetaOptIn } from "./samBetaOptIn";
import { useSamSessions } from "./useSamSessions";
@@ -25,26 +28,30 @@ function BetaNotice() {
if (dismissed) return null;
return (
- <div className="mx-2 mb-2 rounded-lg border border-base-300 bg-base-100 p-3">
+ <div className="mx-2 mb-2 rounded-lg border border-border bg-card p-3">
<div className="flex items-center justify-between">
- <span className="badge badge-primary badge-sm">Beta</span>
- <button
- type="button"
+ <Badge>Beta</Badge>
+ <Button
+ variant="ghost"
+ size="icon-xs"
aria-label="Dismiss"
- className="btn btn-ghost btn-xs btn-square text-base-content/40"
+ className="text-muted-foreground"
onClick={() => {
localStorage.setItem(BETA_NOTICE_DISMISSED_KEY, "1");
setDismissed(true);
}}
>
- <X className="size-3.5" />
- </button>
+ <X />
+ </Button>
</div>
- <p className="mt-1.5 text-xs text-base-content/70">
+ <p className="mt-1.5 text-xs text-muted-foreground">
For more powerful AI workflows, use the OpenSEO MCP with your own agent
like Claude Code or Hermes.
</p>
- <Link to="/ai" className="link link-primary mt-1.5 inline-block text-xs">
+ <Link
+ to="/ai"
+ className="mt-1.5 inline-block text-xs text-primary underline-offset-4 hover:underline"
+ >
Set up the MCP →
</Link>
</div>
@@ -105,7 +112,7 @@ export function SamSidebarPanel({
// points there instead of offering a chat list that can't be used yet.
if (!optedIn) {
return (
- <p className="px-4 py-6 text-center text-xs text-base-content/50">
+ <p className="px-4 py-6 text-center text-xs text-muted-foreground">
Sam is in beta and opt-in. Open Chat to read more and decide.
</p>
);
@@ -116,19 +123,16 @@ export function SamSidebarPanel({
<div className="px-2 pb-1">
{/* Ghost row styled like a list item so the sidebar header doesn't
stack three heavy full-width controls. */}
- <button
- type="button"
- className="btn btn-ghost btn-sm btn-block justify-start gap-2 font-normal text-base-content/70 hover:text-base-content"
- disabled={createSession.isPending}
+ <Button
+ variant="ghost"
+ size="sm"
+ className="w-full justify-start gap-2 font-normal text-muted-foreground"
+ pending={createSession.isPending}
onClick={() => createSession.mutate()}
>
- {createSession.isPending ? (
- <Loader2 className="size-4 animate-spin" />
- ) : (
- <Plus className="size-4" />
- )}
+ {createSession.isPending ? null : <Plus />}
New chat
- </button>
+ </Button>
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-2 py-1">
@@ -136,14 +140,14 @@ export function SamSidebarPanel({
query={sessionsQuery}
errorFallback="Failed to load chats."
loading={
- <div className="flex justify-center py-6 text-base-content/50">
- <Loader2 className="size-4 animate-spin" />
+ <div className="flex justify-center py-6 text-muted-foreground">
+ <Spinner />
</div>
}
>
{(loadedSessions) =>
loadedSessions.length === 0 ? (
- <p className="px-2 py-6 text-center text-xs text-base-content/50">
+ <p className="px-2 py-6 text-center text-xs text-muted-foreground">
No chats yet. Start a new one.
</p>
) : (
@@ -161,25 +165,26 @@ export function SamSidebarPanel({
<button
type="button"
onClick={() => goToSession(session.id)}
- className="min-w-0 flex-1 truncate px-2 py-1.5 text-left text-sm text-base-content/80"
+ className="min-w-0 flex-1 truncate px-2 py-1.5 text-left text-sm text-sidebar-foreground/80"
>
{session.title}
</button>
{/* The age and the Archive button share one grid cell, so the
button takes the place of the age when it shows. */}
<div className="grid shrink-0 place-items-center *:col-start-1 *:row-start-1">
- <span className="text-xs text-base-content/40 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0 pointer-coarse:opacity-0">
+ <span className="pointer-events-none text-xs text-muted-foreground/75 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0 pointer-coarse:opacity-0">
{ageLabel(session.updatedAt)}
</span>
- <button
- type="button"
+ <Button
+ variant="ghost"
+ size="icon-xs"
aria-label="Archive chat"
- className="btn btn-ghost btn-xs btn-square reveal-on-hover"
+ className="text-muted-foreground reveal-on-hover"
disabled={archiveSession.isPending}
onClick={() => archiveSession.mutate(session.id)}
>
- <Archive className="size-3.5 text-base-content/50" />
- </button>
+ <Archive />
+ </Button>
</div>
</div>
);