https://arxiv.org/abs/2606.28344. The end of web parsing. The beginning of scalable pixel-native search. link: https://pixelrag.ai/
feat(web): show the user's recent questions in the ask UI (#7)
Zhifei Lia8f4ee68eb8c
diff --git a/web/app/chat/page.tsx b/web/app/chat/page.tsxindex c16161b..65fc1c1 100644--- a/web/app/chat/page.tsx+++ b/web/app/chat/page.tsx@@ -14,8 +14,10 @@ import {ChevronRight,ImagePlus,X,+ Clock,} from "lucide-react"import { tileUrl } from "@/lib/api"+import { getHistory, addHistory, clearHistory } from "@/lib/history"import { motion, AnimatePresence } from "framer-motion"import Markdown from "react-markdown"import remarkGfm from "remark-gfm"@@ -113,6 +115,7 @@ function ChatPageInner() {const query = (text ?? input).trim()const img = imageOverride ?? imageif ((!query && !img) || isStreaming) return+ if (query) addHistory(query, "ask")const userMsg: ChatMessage = { id: crypto.randomUUID(), role: "user", content: query, image: img }const assistantMsg: ChatMessage = { id: crypto.randomUUID(), role: "assistant", content: "", searches: [] }setMessages((prev) => [...prev, userMsg, assistantMsg])@@ -300,6 +303,8 @@ export default function ChatPage() {/* ─── Empty State ─── */function EmptyState({ onExample, onSearchMode }: { onExample: (q: string) => void; onSearchMode: () => void }) {+ const [recent, setRecent] = React.useState<string[]>([])+ React.useEffect(() => setRecent(getHistory("ask")), [])return (<div className="relative flex h-full flex-col items-center justify-center px-6">{/* Background mesh */}@@ -353,6 +358,35 @@ function EmptyState({ onExample, onSearchMode }: { onExample: (q: string) => voi</button>))}</motion.div>++ {/* Your recent questions (saved locally on this device) */}+ {recent.length > 0 && (+ <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ delay: 0.5 }} className="relative z-10 mt-7 w-full max-w-lg">+ <div className="mb-2.5 flex items-center justify-between px-1">+ <span className="flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[0.12em] text-[var(--chat-muted)]">+ <Clock className="h-3 w-3" /> Recent+ </span>+ <button+ onClick={() => { clearHistory("ask"); setRecent([]) }}+ className="text-[11px] text-[var(--chat-muted)] transition-colors hover:text-[var(--chat-secondary)]"+ >+ Clear+ </button>+ </div>+ <div className="flex flex-wrap gap-2">+ {recent.map((q) => (+ <button+ key={q}+ onClick={() => onExample(q)}+ title={q}+ className="max-w-[15rem] truncate rounded-full border border-[var(--chat-border)] bg-[var(--chat-card)] px-3 py-1.5 text-[12px] text-[var(--chat-secondary)] transition-all hover:border-[var(--chat-accent-dim)] hover:text-[var(--chat-fg)]"+ >+ {q}+ </button>+ ))}+ </div>+ </motion.div>+ )}</div>)}diff --git a/web/lib/history.ts b/web/lib/history.tsindex 4d2fd9a..5b98f81 100644--- a/web/lib/history.ts+++ b/web/lib/history.ts@@ -1,10 +1,14 @@-const KEY = "pixelrag-search-history"+// Per-user, client-side query history kept in localStorage. Two independent+// namespaces: "search" (the visual search box) and "ask" (the agent chat).+type Kind = "search" | "ask"+const MAX = 10+const keyFor = (kind: Kind) => `pixelrag-${kind}-history`-export function getHistory(): string[] {+export function getHistory(kind: Kind = "search"): string[] {if (typeof window === "undefined") return []try {- const raw = localStorage.getItem(KEY)+ const raw = localStorage.getItem(keyFor(kind))if (!raw) return []const parsed = JSON.parse(raw)if (!Array.isArray(parsed)) return []@@ -14,24 +18,24 @@ export function getHistory(): string[] {}}-export function addHistory(query: string): void {+export function addHistory(query: string, kind: Kind = "search"): void {if (typeof window === "undefined") returnconst trimmed = query.trim()if (!trimmed) returntry {- const prev = getHistory()+ const prev = getHistory(kind)const deduped = prev.filter((s) => s !== trimmed)const next = [trimmed, ...deduped].slice(0, MAX)- localStorage.setItem(KEY, JSON.stringify(next))+ localStorage.setItem(keyFor(kind), JSON.stringify(next))} catch {// localStorage unavailable — silently ignore}}-export function clearHistory(): void {+export function clearHistory(kind: Kind = "search"): void {if (typeof window === "undefined") returntry {- localStorage.removeItem(KEY)+ localStorage.removeItem(keyFor(kind))} catch {// silently ignore}