From 111382203a40f77d9b2aed7d1b52cc6802fea5ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?=
<80620802+burakboduroglu@users.noreply.github.com>
Date: Wed, 23 Sep 2026 07:41:18 +0300
Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20study=20chat=20follows=20Mi?=
=?UTF-8?q?stral=20Vibe,=20chats=20open=20at=20their=20own=20URL=20-=20/ai?=
=?UTF-8?q?/study=20is=20a=20persistent=20parent=20route=20with=20the=20op?=
=?UTF-8?q?en=20chat=20as=20a=20child,=20=20=20/ai/study/$threadId;=20open?=
=?UTF-8?q?ing,=20creating=20and=20deleting=20a=20chat=20move=20the=20URL?=
=?UTF-8?q?=20=20=20without=20remounting=20the=20sidebar=20or=20cutting=20?=
=?UTF-8?q?a=20streaming=20answer=20-=20full-bleed=20layout:=20a=20flush?=
=?UTF-8?q?=20history=20sidebar=20(title,=20fold-away=20control,=20=20=20"?=
=?UTF-8?q?Yeni=20sohbet"=20row,=20plain=20"Son=20sohbetler"=20rows=20with?=
=?UTF-8?q?=20a=20hover=20=E2=8B=AE=20menu,=20=20=20"Daha=20fazla=20g?=
=?UTF-8?q?=C3=B6ster"=20instead=20of=20numbered=20pages),=20remembered=20?=
=?UTF-8?q?collapse=20-=20desktop=20top=20bar:=20the=20chat=20title=20with?=
=?UTF-8?q?=20a=20=E2=96=BE=20menu=20for=20rename=20and=20delete=20-=20lan?=
=?UTF-8?q?ding:=20brand=20mark=20and=20a=20time-of-day=20greeting=20with?=
=?UTF-8?q?=20the=20user's=20name,=20=20=20left-aligned=20on=20the=20compo?=
=?UTF-8?q?ser=20column=20-=20turns:=20the=20question=20is=20a=20right-ali?=
=?UTF-8?q?gned=20pill,=20the=20answer=20sits=20beside=20a=20=20=20small?=
=?UTF-8?q?=20brand=20mark=20with=20an=20icon=20row=20(copy,=20retry)=20an?=
=?UTF-8?q?d=20its=20time=20-=20composer:=20hairline=20rounded=20box=20wit?=
=?UTF-8?q?h=20a=20dark=20square=20send=20button=20and=20the=20=20=20cours?=
=?UTF-8?q?e-material=20disclaimer=20under=20it?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/rag/rag-composer.tsx | 11 +-
src/components/rag/rag-copy.ts | 14 ++
src/components/rag/rag-message-row.tsx | 114 +++++++------
src/components/rag/rag-study-panel.tsx | 200 ++++++++++++++++++-----
src/components/rag/rag-study-welcome.tsx | 19 +--
src/components/rag/rag-thread-list.tsx | 170 +++++++++----------
src/lib/format.ts | 6 +
src/routes/router.tsx | 16 +-
8 files changed, 350 insertions(+), 200 deletions(-)
diff --git a/src/components/rag/rag-composer.tsx b/src/components/rag/rag-composer.tsx
index 52770b0..adf6257 100644
--- a/src/components/rag/rag-composer.tsx
+++ b/src/components/rag/rag-composer.tsx
@@ -1,6 +1,6 @@
import { createEffect, onMount } from "solid-js";
import { Button } from "@/components/ui/button";
-import { IconSend } from "@/components/ui/icons";
+import { IconArrowUp } from "@/components/ui/icons";
import { Textarea } from "@/components/ui/textarea";
import { cn } from "@/lib/cn";
@@ -44,7 +44,7 @@ export function RagComposer(props: {
if (!props.disabled) props.onSubmit();
}}
>
-
+
- {/* Enter / Shift+Enter means nothing on a touch keyboard. */}
-
{props.hint}
+
{props.hint}
);
}
diff --git a/src/components/rag/rag-copy.ts b/src/components/rag/rag-copy.ts
index 8b58eeb..9a1b365 100644
--- a/src/components/rag/rag-copy.ts
+++ b/src/components/rag/rag-copy.ts
@@ -19,6 +19,13 @@ const copy = {
title: "Ask your notes",
newThread: "New chat",
history: "Chat history",
+ recents: "Recents",
+ collapseHistory: "Hide chat history",
+ expandHistory: "Show chat history",
+ loadMore: "Show more",
+ greetingMorning: "Good morning",
+ greetingAfternoon: "Good afternoon",
+ greetingEvening: "Good evening",
openHistory: "Open chat history",
closeHistory: "Close chat history",
untitled: "Untitled chat",
@@ -80,6 +87,13 @@ const copy = {
title: "Notlarına sor",
newThread: "Yeni sohbet",
history: "Sohbet geçmişi",
+ recents: "Son sohbetler",
+ collapseHistory: "Sohbet geçmişini gizle",
+ expandHistory: "Sohbet geçmişini göster",
+ loadMore: "Daha fazla göster",
+ greetingMorning: "Günaydın",
+ greetingAfternoon: "İyi günler",
+ greetingEvening: "İyi akşamlar",
openHistory: "Sohbet geçmişini aç",
closeHistory: "Sohbet geçmişini kapat",
untitled: "Başlıksız sohbet",
diff --git a/src/components/rag/rag-message-row.tsx b/src/components/rag/rag-message-row.tsx
index 2a1ac61..b1e645d 100644
--- a/src/components/rag/rag-message-row.tsx
+++ b/src/components/rag/rag-message-row.tsx
@@ -4,7 +4,9 @@ import { CelebiMarkdown } from "@/components/layout/celebi-markdown";
import { IconAlert, IconCopy, IconRefresh } from "@/components/ui/icons";
import { RagCitations } from "@/components/rag/rag-citations";
import { RagThinkingLabel } from "@/components/rag/rag-thinking-label";
-import { cn } from "@/lib/cn";
+import { LogoMark } from "@/components/brand/logo-mark";
+import { formatTime } from "@/lib/format";
+import { currentLocale } from "@/api/client";
export function RagMessageRow(props: {
message: RagMessage;
@@ -48,74 +50,88 @@ export function RagMessageRow(props: {
window.setTimeout(() => setCopied(false), 1_500);
};
+ const iconButton =
+ "inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring";
+
return (
- // The user's turn is a bubble; the answer is not. An answer is the page's
- // content, not a message in a thread, so it runs the full reading column
- // with no frame and no avatar competing with the first line of text.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{props.message.content || props.labels.abstained}
-
- {props.labels.abstainedReason(props.message.reason)}
-
-
-
-
-
-
-
-
+ // Vibe's turns: the question is a pill on the right; the answer runs the
+ // reading column beside a small brand mark, with no frame, and its
+ // actions sit on one quiet icon row under it with the time at the end.
+
+
+ {props.message.content}
+
+
+ }
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{props.message.content || props.labels.abstained}
+
+ {props.labels.abstainedReason(props.message.reason)}
+
+
+
+
+
+
+
{props.footer}
-
-
+
+
void copy()}
>
-
- {copied() ? props.labels.copied : props.labels.copy}
+
{(retry) => (
retry()()}
>
-
- {props.labels.retry}
+
)}
+
+ {props.labels.copied}
+
+ {formatTime(props.message.created_at, currentLocale())}
-
-
-
+
+
+
);
}
diff --git a/src/components/rag/rag-study-panel.tsx b/src/components/rag/rag-study-panel.tsx
index d7a6273..9a21c01 100644
--- a/src/components/rag/rag-study-panel.tsx
+++ b/src/components/rag/rag-study-panel.tsx
@@ -1,4 +1,5 @@
import { For, Show, createEffect, createSignal, on, onCleanup } from "solid-js";
+import { useNavigate, useParams } from "@tanstack/solid-router";
import { formatApiError } from "@/api/client";
import type { RagMessage, RagThread } from "@/api/client";
import {
@@ -17,15 +18,17 @@ import { RagStudyActions } from "@/components/rag/rag-study-actions";
import { RagStudyWelcome } from "@/components/rag/rag-study-welcome";
import { RagThreadList } from "@/components/rag/rag-thread-list";
import { Alert } from "@/components/ui/alert";
-import { Button } from "@/components/ui/button";
import { ConfirmDialog } from "@/components/ui/confirm-dialog";
-import { IconChevronDown, IconMenu, IconPlus, IconX } from "@/components/ui/icons";
+import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
+import { IconChevronDown, IconEdit, IconMenu, IconPanelLeft, IconPlus, IconTrash, IconX } from "@/components/ui/icons";
import { cn } from "@/lib/cn";
import { scopeFromCitations } from "@/lib/rag-study-scope";
+import { useAuth } from "@/stores/auth-context";
import { usePreferences } from "@/stores/preferences-context";
import { suppressQuickActions } from "@/stores/quick-actions";
const POLL_INTERVAL_MS = 2000;
+const COLLAPSED_KEY = "hezarfen.study.historyCollapsed";
/**
* The AI hub's Study tab: chat over the course material the account may
@@ -53,6 +56,30 @@ export function RagStudyPanel() {
// on a phone keeps its conversations one tap away without spending the
// screen on them. From lg it is the fixed column beside the transcript.
const [historyOpen, setHistoryOpen] = createSignal(false);
+ // From lg the history is a sidebar the reader can fold away, remembered on
+ // this device the way a chat app remembers its sidebar.
+ const [historyCollapsed, setHistoryCollapsed] = createSignal(
+ typeof localStorage !== "undefined" && localStorage.getItem(COLLAPSED_KEY) === "1",
+ );
+ createEffect(() => {
+ if (typeof localStorage !== "undefined") localStorage.setItem(COLLAPSED_KEY, historyCollapsed() ? "1" : "0");
+ });
+ const auth = useAuth();
+ // A chat lives at /ai/study/$threadId, the way Vibe opens one at
+ // /chat/. This panel is the persistent parent of that route, so moving
+ // between chats never remounts the sidebar or cuts a streaming answer.
+ const navigate = useNavigate();
+ const params = useParams({ strict: false });
+ const routeThreadId = () => (params() as { threadId?: string }).threadId;
+ // The API has no single-thread read; titles come from the sidebar's list.
+ const [knownThreads, setKnownThreads] = createSignal([]);
+ const greeting = () => {
+ const hour = new Date().getHours();
+ const base = hour < 12 ? copy().greetingMorning : hour < 18 ? copy().greetingAfternoon : copy().greetingEvening;
+ const user = auth.user();
+ const name = user?.display_name?.trim() || user?.name?.trim();
+ return name ? `${base}, ${name}` : base;
+ };
createEffect(() => {
if (!historyOpen()) return;
const onKey = (event: KeyboardEvent) => {
@@ -126,19 +153,21 @@ export function RagStudyPanel() {
};
};
- const openThread = async (thread: RagThread) => {
+ const loadThread = async (id: string) => {
stopPolling();
stopStream();
setError("");
- setThreadId(thread.id);
- setActiveThread(thread);
+ setThreadId(id);
+ setActiveThread(knownThreads().find((thread) => thread.id === id));
+ setMessages([]);
try {
- setMessages((await getRagThreadMessages(thread.id, { limit: 500 })).items);
+ const page = await getRagThreadMessages(id, { limit: 500 });
+ if (threadId() === id) setMessages(page.items);
} catch (err) {
- setError(formatApiError(err));
+ if (threadId() === id) setError(formatApiError(err));
}
};
- const newThread = () => {
+ const resetThread = () => {
stopPolling();
stopStream();
setError("");
@@ -146,6 +175,28 @@ export function RagStudyPanel() {
setActiveThread(undefined);
setMessages([]);
};
+ // The URL is the source of truth for which chat is open. A chat this panel
+ // just created is already open when its URL lands, so it is not reloaded.
+ createEffect(
+ on(routeThreadId, (id) => {
+ if (id === threadId()) return;
+ if (id) void loadThread(id);
+ else resetThread();
+ }),
+ );
+ createEffect(() => {
+ const id = threadId();
+ if (!id || activeThread()?.id === id) return;
+ const known = knownThreads().find((thread) => thread.id === id);
+ if (known) setActiveThread(known);
+ });
+ const openThread = (thread: RagThread) => {
+ setActiveThread(thread);
+ void navigate({ to: "/ai/study/$threadId", params: { threadId: thread.id } });
+ };
+ const newThread = () => {
+ void navigate({ to: "/ai/study" });
+ };
const send = async () => {
const content = draft().trim();
@@ -164,6 +215,7 @@ export function RagStudyPanel() {
const resolvedThreadId = currentThread ?? createdThread!.id;
if (createdThread) setActiveThread(createdThread);
setThreadId(resolvedThreadId);
+ if (createdThread) void navigate({ to: "/ai/study/$threadId", params: { threadId: resolvedThreadId }, replace: true });
const accepted = await postRagMessage(resolvedThreadId, content);
setMessages((items) => [
...items,
@@ -241,7 +293,15 @@ export function RagStudyPanel() {
return (
// Phones: one screen-tall column — top bar, transcript, composer — so the
// composer sits above the tab bar instead of scrolling away with the page.
-
+ // From lg the page fills the content column edge to edge, below the shell
+ // header: a flush history sidebar and the conversation beside it.
+
-
-
{copy().history}
-
- {
- setHistoryOpen(false);
- newThread();
- }}
- >
-
- {copy().newThread}
-
- setHistoryOpen(false)}
- >
-
-
-
+ {/* Vibe's sidebar head: the page's name, then its fold-away control. */}
+
+
{copy().title}
+ setHistoryCollapsed(true)}
+ >
+
+
+ setHistoryOpen(false)}
+ >
+
+
+ {/* "New chat" is a nav row, filled while the new-chat screen is open. */}
+
{
+ setHistoryOpen(false);
+ newThread();
+ }}
+ >
+
+ {copy().newThread}
+
+
{copy().recents}
{
setHistoryOpen(false);
- void openThread(thread);
+ openThread(thread);
}}
onRename={setRenaming}
onRemove={setRemoving}
@@ -332,6 +405,53 @@ export function RagStudyPanel() {
+ {/* Desktop top bar: the open chat's title and its menu; with the
+ sidebar folded away, the way back to it and a fresh chat. */}
+
+
+ setHistoryCollapsed(false)}
+ >
+
+
+
+
+
+
+
+ {(thread) => (
+
+
+
+ {thread().title || copy().untitled}
+
+
+
+ setRenaming(thread())}>
+
+ {copy().rename}
+
+
+ setRemoving(thread())}>
+
+ {copy().delete}
+
+
+
+
+ )}
+
+
{error()}
@@ -345,13 +465,13 @@ export function RagStudyPanel() {
fallback={
// The landing screen centres the mark and the composer instead of
// stranding the composer at the bottom of an empty page.
-
-
+
+
-
-
-
- {props.title}
- {props.hint}
+
+
+
{props.title}
);
}
diff --git a/src/components/rag/rag-thread-list.tsx b/src/components/rag/rag-thread-list.tsx
index a9dcbd0..bf0568c 100644
--- a/src/components/rag/rag-thread-list.tsx
+++ b/src/components/rag/rag-thread-list.tsx
@@ -1,31 +1,18 @@
-import { For, Show, createEffect, createSignal, on } from "solid-js";
+import { For, Show, createEffect, createSignal } from "solid-js";
import { createResource } from "@/lib/create-resource";
import { getRagThreads } from "@/api/rag";
import type { RagThread } from "@/api/client";
import { EmptyInline } from "@/components/ui/empty-inline";
import { IconEdit, IconTrash } from "@/components/ui/icons";
import { PageSpinner } from "@/components/ui/page-spinner";
-import { TablePagination } from "@/components/ui/table-pagination";
import { TableRowActions } from "@/components/ui/table-row-actions";
import { cn } from "@/lib/cn";
-import { formatDateTime } from "@/lib/format";
import type { Locale } from "@/i18n/messages";
-const THREAD_PAGE_SIZE = 12;
-const DAY_MS = 86_400_000;
-
-type Bucket = "today" | "yesterday" | "week" | "earlier";
-const BUCKET_ORDER: Bucket[] = ["today", "yesterday", "week", "earlier"];
-
-/** Which recency bucket a thread falls in, by local calendar day rather than a
- * rolling 24 hours — "dün" has to mean yesterday's date, not 25 hours ago. */
-function bucketOf(updatedAt: number, now: Date): Bucket {
- const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
- if (updatedAt >= startOfToday) return "today";
- if (updatedAt >= startOfToday - DAY_MS) return "yesterday";
- if (updatedAt >= startOfToday - 6 * DAY_MS) return "week";
- return "earlier";
-}
+// One growing page instead of numbered pages: a chat sidebar scrolls, it does
+// not paginate. The API caps a page at 500 rows.
+const THREAD_PAGE_SIZE = 40;
+const THREAD_PAGE_MAX = 500;
export function RagThreadList(props: {
activeId?: string;
@@ -38,96 +25,95 @@ export function RagThreadList(props: {
rename: string;
actions: string;
delete: string;
+ loadMore: string;
groupToday: string;
groupYesterday: string;
groupThisWeek: string;
groupEarlier: string;
};
+ /** Every thread the list holds, for callers that need a title by id. */
+ onThreads?: (threads: RagThread[]) => void;
onOpen: (thread: RagThread) => void;
onRename: (thread: RagThread) => void;
onRemove: (thread: RagThread) => void;
}) {
- const [page, setPage] = createSignal(0);
+ const [limit, setLimit] = createSignal(THREAD_PAGE_SIZE);
const [threads] = createResource(
- () => ({ page: page(), version: props.version }),
- ({ page }) => getRagThreads({ limit: THREAD_PAGE_SIZE, offset: page * THREAD_PAGE_SIZE }),
+ () => ({ limit: limit(), version: props.version }),
+ ({ limit }) => getRagThreads({ limit, offset: 0 }),
);
- const totalPages = () => Math.max(1, Math.ceil((threads.latest?.total ?? 0) / THREAD_PAGE_SIZE));
- const bucketLabel = (bucket: Bucket) =>
- bucket === "today" ? props.labels.groupToday
- : bucket === "yesterday" ? props.labels.groupYesterday
- : bucket === "week" ? props.labels.groupThisWeek
- : props.labels.groupEarlier;
- // Grouping is presentational only — the page still comes from the server in
- // its own order, so an empty bucket simply does not get a heading.
- const groups = (items: RagThread[]) => {
- const now = new Date();
- return BUCKET_ORDER.flatMap((bucket) => {
- const rows = items.filter((thread) => bucketOf(thread.updated_at, now) === bucket);
- return rows.length > 0 ? [{ bucket, rows }] : [];
- });
+ createEffect(() => {
+ const result = threads.latest;
+ if (result) props.onThreads?.(result.items);
+ });
+ const hasMore = () => {
+ const result = threads.latest;
+ return !!result && result.total > result.items.length && limit() < THREAD_PAGE_MAX;
};
-
- createEffect(on(() => threads.latest, (result) => {
- if (result && result.items.length === 0 && page() > 0) setPage(Math.min(page() - 1, totalPages() - 1));
- }));
-
return (
-
-
);
diff --git a/src/lib/format.ts b/src/lib/format.ts
index 72dfa50..94536a6 100644
--- a/src/lib/format.ts
+++ b/src/lib/format.ts
@@ -8,6 +8,12 @@ export function formatDateTime(ms: number | null | undefined, locale: Locale = "
}).format(new Date(ms));
}
+/** Time only (e.g. "07:33") — for a chat turn's stamp. */
+export function formatTime(ms: number | null | undefined, locale: Locale = "en"): string {
+ if (ms == null) return "—";
+ return new Intl.DateTimeFormat(locale === "tr" ? "tr-TR" : "en-US", { timeStyle: "short" }).format(new Date(ms));
+}
+
/** Date only, no time — for stacked date/time cells. */
export function formatDate(ms: number | null | undefined, locale: Locale = "en"): string {
if (ms == null) return "—";
diff --git a/src/routes/router.tsx b/src/routes/router.tsx
index 3e505a9..186f429 100644
--- a/src/routes/router.tsx
+++ b/src/routes/router.tsx
@@ -488,12 +488,26 @@ const aiStudioNoteRoute = createRoute({
component: AiStudioNotePage,
});
+// The study chat is one persistent parent (sidebar + transcript) with the
+// open chat as a child in the URL, so switching chats never remounts it.
const aiStudyRoute = createRoute({
getParentRoute: () => rootRoute,
path: "/ai/study",
component: AiStudyPage,
});
+const aiStudyIndexRoute = createRoute({
+ getParentRoute: () => aiStudyRoute,
+ path: "/",
+ component: () => null,
+});
+
+const aiStudyThreadRoute = createRoute({
+ getParentRoute: () => aiStudyRoute,
+ path: "$threadId",
+ component: () => null,
+});
+
const aiInsightsRoute = createRoute({
getParentRoute: () => rootRoute,
path: "/ai/insights",
@@ -636,7 +650,7 @@ const routeTree = rootRoute.addChildren([
aiRoute,
aiStudioRoute,
aiStudioNoteRoute,
- aiStudyRoute,
+ aiStudyRoute.addChildren([aiStudyIndexRoute, aiStudyThreadRoute]),
aiInsightsRoute,
aiInsightStudentRoute,
questionGenerationRoute,