diff --git a/src/components/notes/rag-output-document.ts b/src/components/notes/rag-output-document.ts
new file mode 100644
index 0000000..4f812df
--- /dev/null
+++ b/src/components/notes/rag-output-document.ts
@@ -0,0 +1,196 @@
+import type { RagOutput } from "@/api/client";
+
+const SUMMARY_KEYS = ["summary", "ozet", "özet", "content", "text", "answer"];
+const POINT_KEYS = ["keywords", "key_points", "topics", "questions", "highlights"];
+/** Payload entries the drawer renders on their own; the rest land in `fields`. */
+const RENDERED_KEYS: Record
= {
+ summary: true,
+ ozet: true,
+ "özet": true,
+ content: true,
+ text: true,
+ answer: true,
+ keywords: true,
+ key_points: true,
+ topics: true,
+ questions: true,
+ highlights: true,
+ files: true,
+ failed: true,
+ course_note: true,
+};
+
+function asRecord(value: unknown): Record | null {
+ return value != null && typeof value === "object" && !Array.isArray(value)
+ ? value as Record
+ : null;
+}
+
+/** The payload's own prose, whatever key the service used for it. */
+export function payloadText(payload: unknown): string {
+ if (typeof payload === "string") return payload.trim();
+ const record = asRecord(payload);
+ if (!record) return "";
+ for (const key of SUMMARY_KEYS) {
+ const value = record[key];
+ if (typeof value === "string" && value.trim()) return value.trim();
+ }
+ return "";
+}
+
+/** The payload's list-shaped highlights, whatever key the service used. */
+export function payloadPoints(payload: unknown): string[] {
+ const record = asRecord(payload);
+ if (!record) return [];
+ for (const key of POINT_KEYS) {
+ const value = record[key];
+ if (Array.isArray(value)) {
+ const rows = value.filter((item): item is string => typeof item === "string" && !!item.trim());
+ if (rows.length > 0) return rows;
+ }
+ }
+ return [];
+}
+
+/** Attachment id → name, for the ids the service recorded in `payload.files`. */
+export function payloadFileNames(payload: unknown): Map {
+ const names = new Map();
+ const files = asRecord(payload)?.files;
+ if (!Array.isArray(files)) return names;
+ for (const entry of files) {
+ const file = asRecord(entry);
+ const name = typeof file?.name === "string" && file.name.trim() ? file.name.trim() : null;
+ if (!name) continue;
+ for (const idKey of ["id", "doc_id"]) {
+ const id = file?.[idKey];
+ if (typeof id === "string" && id && !names.has(id)) names.set(id, name);
+ }
+ }
+ return names;
+}
+
+export type RagOutputDocument = {
+ /** The produced prose — the summary the service wrote. */
+ summary: string;
+ points: string[];
+ /** Attachment names in the order the output listed them; never raw ids. */
+ sourceNames: string[];
+ /** Stored attachment ids whose name the payload does not carry. */
+ unnamedSources: number;
+ failed: string[];
+ /** Payload entries with no dedicated rendering, in payload order. */
+ fields: Array<{ key: string; value: unknown }>;
+ raw: unknown;
+};
+
+/**
+ * Read one stored AI output into everything the drawer shows. The payload is
+ * the service's own object served unread, so every read here is defensive: a
+ * shape the service did not send degrades to an empty value, never a crash.
+ */
+export function readRagOutputDocument(output: RagOutput): RagOutputDocument {
+ const raw = output.payload;
+ const record = asRecord(raw);
+ const names = payloadFileNames(raw);
+ const storedSources = Array.isArray(output.sources) ? output.sources : [];
+
+ const sourceNames: string[] = [];
+ let unnamedSources = 0;
+ if (storedSources.length > 0) {
+ for (const id of storedSources) {
+ const name = names.get(id);
+ if (name) {
+ if (!sourceNames.includes(name)) sourceNames.push(name);
+ } else {
+ unnamedSources += 1;
+ }
+ }
+ } else {
+ // No stored id list — fall back to the names the payload itself recorded.
+ for (const name of new Set(names.values())) sourceNames.push(name);
+ }
+
+ const failed = Array.isArray(record?.failed)
+ ? record.failed.filter((item): item is string => typeof item === "string" && !!item.trim()).map((item) => item.trim())
+ : [];
+
+ return {
+ summary: payloadText(raw),
+ points: payloadPoints(raw),
+ sourceNames,
+ unnamedSources,
+ failed,
+ fields: record
+ ? Object.entries(record)
+ .filter(([key]) => !RENDERED_KEYS[key])
+ .map(([key, value]) => ({ key, value }))
+ : [],
+ raw,
+ };
+}
+
+export type RagOutputMarkdownLabels = {
+ date: string;
+ note: string;
+ sources: string;
+ failed: string;
+ otherFields: string;
+};
+
+/**
+ * The downloadable document: title, date, note, sources, body — built from the
+ * same view the drawer renders, in plain Markdown a teacher can open anywhere.
+ */
+export function buildRagOutputMarkdown(input: {
+ title: string;
+ date: string;
+ noteTitle?: string;
+ document: RagOutputDocument;
+ labels: RagOutputMarkdownLabels;
+}): string {
+ const { document: doc, labels } = input;
+ const lines: string[] = [`# ${input.title}`, ""];
+ lines.push(`- **${labels.date}:** ${input.date}`);
+ if (input.noteTitle?.trim()) lines.push(`- **${labels.note}:** ${input.noteTitle.trim()}`);
+ if (doc.sourceNames.length > 0 || doc.unnamedSources > 0) {
+ const named = [...doc.sourceNames];
+ if (doc.unnamedSources > 0) named.push(`(${doc.unnamedSources})`);
+ lines.push(`- **${labels.sources}:** ${named.join(", ")}`);
+ }
+ lines.push("");
+ if (doc.summary) {
+ lines.push(doc.summary, "");
+ }
+ if (doc.points.length > 0) {
+ for (const point of doc.points) lines.push(`- ${point}`);
+ lines.push("");
+ }
+ if (doc.failed.length > 0) {
+ lines.push(`## ${labels.failed}`, "");
+ for (const name of doc.failed) lines.push(`- ${name}`);
+ lines.push("");
+ }
+ if (doc.fields.length > 0) {
+ lines.push(`## ${labels.otherFields}`, "");
+ for (const field of doc.fields) lines.push(`- **${field.key}:** ${fieldValueText(field.value)}`);
+ lines.push("");
+ }
+ return lines.join("\n");
+}
+
+/**
+ * One value → one line of text. Exported so the drawer's field list and the
+ * Markdown export render unknown payload values identically.
+ */
+export function fieldValueText(value: unknown): string {
+ if (typeof value === "string") return value;
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
+ return JSON.stringify(value) ?? String(value);
+}
+
+/** Deterministic download name: `yz-cikti-YYYYMMDD-HHmm.md`. */
+export function ragOutputFileName(generatedAt: number): string {
+ const d = new Date(generatedAt);
+ const pad = (n: number) => String(n).padStart(2, "0");
+ return `yz-cikti-${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}.md`;
+}
diff --git a/src/components/notes/rag-output-drawer.test.tsx b/src/components/notes/rag-output-drawer.test.tsx
new file mode 100644
index 0000000..df60b02
--- /dev/null
+++ b/src/components/notes/rag-output-drawer.test.tsx
@@ -0,0 +1,192 @@
+import { cleanup, fireEvent, render, screen, waitFor } from "@solidjs/testing-library";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import type { RagOutput } from "@/api/client";
+import { RagOutputDrawer } from "@/components/notes/rag-output-drawer";
+import { buildRagOutputMarkdown, readRagOutputDocument } from "@/components/notes/rag-output-document";
+import { ragOutputMessage } from "@/components/notes/rag-output-messages";
+import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel";
+import { formatDateTime } from "@/lib/format";
+import type { NoteFileSource } from "@/lib/note-source";
+import { PreferencesProvider } from "@/stores/preferences-context";
+
+const aiApi = vi.hoisted(() => ({ getAiCapabilities: vi.fn() }));
+const toastApi = vi.hoisted(() => ({ showToast: vi.fn() }));
+
+vi.mock("@/api/ai", () => aiApi);
+vi.mock("@/components/ui/toast", () => ({ showToast: toastApi.showToast, Toaster: () => null }));
+
+const CAPABILITIES_WITH_RAG = {
+ enabled: true,
+ protocol: "hab/2",
+ capabilities: [{ capability: "rag.index", workers: 1, inflight: 0 }],
+};
+
+const NOTE_TITLE = "Hücre ve Canlılar";
+const SUMMARY = "Hücre konusu 18 parçaya bölünerek indekslendi.";
+const GENERATED_AT = Date.UTC(2026, 8, 18, 11, 30);
+
+const HEALTHY: RagOutput = {
+ id: "output-1",
+ course_note: "note-1",
+ course: "course-1",
+ sources: ["file-aaa1", "file-bbb2"],
+ generated_at: GENERATED_AT,
+ payload: {
+ course_note: "note-1",
+ chunks: 18,
+ summary: SUMMARY,
+ keywords: ["hücre zarı", "organel"],
+ files: [
+ { id: "file-aaa1", doc_id: "doc-ccc3", name: "hücre-notu.pdf" },
+ { id: "file-bbb2", doc_id: "doc-ddd4", name: "organeller.pdf" },
+ ],
+ failed: [],
+ },
+};
+
+const LABELS = {
+ date: ragOutputMessage("en", "date"),
+ note: ragOutputMessage("en", "note"),
+ sources: ragOutputMessage("en", "sources"),
+ failed: ragOutputMessage("en", "failedTitle"),
+ otherFields: ragOutputMessage("en", "otherFields"),
+};
+
+function expectedMarkdown(output: RagOutput) {
+ return buildRagOutputMarkdown({
+ title: NOTE_TITLE,
+ date: formatDateTime(output.generated_at, "en"),
+ noteTitle: NOTE_TITLE,
+ document: readRagOutputDocument(output),
+ labels: LABELS,
+ });
+}
+
+function stubSource(output: RagOutput): NoteFileSource {
+ return {
+ maxFiles: 10,
+ listFiles: async () => ({ items: [], total: 0, limit: 10, offset: 0 }),
+ uploadFile: async () => {
+ throw new Error("not used by this panel");
+ },
+ deleteFile: async () => {},
+ fileUrl: () => "",
+ fileBlob: async () => new Blob(),
+ listRagOutputs: async () => ({ items: [output], total: 1, limit: 10, offset: 0 }),
+ deleteRagOutput: async () => {},
+ reindexRag: async () => {},
+ };
+}
+
+function renderPanel(output: RagOutput) {
+ render(() => (
+
+
+
+ ));
+}
+
+function renderDrawer(output: RagOutput) {
+ render(() => (
+
+ {}} />
+
+ ));
+}
+
+const writeText = vi.fn<(text: string) => Promise>();
+const createObjectURL = vi.fn<(blob: Blob) => string>(() => "blob:test");
+const clickSpy = vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => {});
+
+describe("RagOutputDrawer", () => {
+ beforeEach(() => {
+ aiApi.getAiCapabilities.mockResolvedValue(CAPABILITIES_WITH_RAG);
+ writeText.mockResolvedValue();
+ writeText.mockClear();
+ createObjectURL.mockClear();
+ clickSpy.mockClear();
+ Object.defineProperty(navigator, "clipboard", { value: { writeText }, configurable: true });
+ Object.defineProperty(URL, "createObjectURL", { value: createObjectURL, configurable: true });
+ Object.defineProperty(URL, "revokeObjectURL", { value: () => {}, configurable: true });
+ });
+
+ afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+ });
+
+ it("opens the drawer from the card body and shows the stored output", async () => {
+ renderPanel(HEALTHY);
+ await waitFor(() => expect(screen.getByText(SUMMARY)).toBeTruthy());
+
+ fireEvent.click(screen.getByRole("button", { name: "View" }));
+
+ await waitFor(() => expect(screen.getByText("Source attachments")).toBeTruthy());
+ // Attachments by name, and the prose — now on screen twice: card and drawer.
+ expect(screen.getByText("hücre-notu.pdf")).toBeTruthy();
+ expect(screen.getByText("organeller.pdf")).toBeTruthy();
+ expect(screen.getAllByText(SUMMARY).length).toBeGreaterThanOrEqual(2);
+ expect(screen.getAllByText(NOTE_TITLE).length).toBeGreaterThanOrEqual(1);
+ // Every payload field stays reachable: the lesser ones in the open, the raw
+ // object behind the disclosure.
+ expect(screen.getByText("Text chunks")).toBeTruthy();
+ expect(screen.getByText("18")).toBeTruthy();
+ expect(screen.getByText("Technical details")).toBeTruthy();
+ expect(screen.getByRole("button", { name: "Copy" })).toBeTruthy();
+ expect(screen.getByRole("button", { name: "Download (.md)" })).toBeTruthy();
+ expect(screen.getByRole("button", { name: "Print / PDF" })).toBeTruthy();
+ });
+
+ it("builds a Markdown document with title, date, source names and body — and no raw ids", () => {
+ const markdown = expectedMarkdown(HEALTHY);
+
+ expect(markdown).toContain(`# ${NOTE_TITLE}`);
+ expect(markdown).toContain(formatDateTime(GENERATED_AT, "en"));
+ expect(markdown).toContain("2026");
+ expect(markdown).toContain("hücre-notu.pdf");
+ expect(markdown).toContain("organeller.pdf");
+ expect(markdown).toContain(SUMMARY);
+ expect(markdown).toContain("- hücre zarı");
+ expect(markdown).toContain("18");
+ expect(markdown).not.toContain("file-aaa1");
+ expect(markdown).not.toContain("doc-ccc3");
+ expect(markdown).not.toContain("course_note");
+ });
+
+ it("copies exactly the built Markdown and confirms it visibly", async () => {
+ renderDrawer(HEALTHY);
+
+ fireEvent.click(screen.getByRole("button", { name: "Copy" }));
+
+ await waitFor(() => expect(writeText).toHaveBeenCalledTimes(1));
+ expect(writeText).toHaveBeenCalledWith(expectedMarkdown(HEALTHY));
+ await waitFor(() => expect(screen.getByText("Copied to the clipboard")).toBeTruthy());
+ });
+
+ it("downloads the Markdown under a dated .md file name", async () => {
+ renderDrawer(HEALTHY);
+
+ fireEvent.click(screen.getByRole("button", { name: "Download (.md)" }));
+
+ expect(createObjectURL).toHaveBeenCalledTimes(1);
+ const blob = createObjectURL.mock.calls[0][0];
+ await expect(blob.text()).resolves.toBe(expectedMarkdown(HEALTHY));
+ expect(clickSpy).toHaveBeenCalledTimes(1);
+ });
+
+ it("renders an honest sentence for a degraded output instead of a blank drawer", async () => {
+ const degraded: RagOutput = {
+ ...HEALTHY,
+ sources: ["file-zzz9"],
+ payload: { course_note: "note-1", files: [], failed: ["bozuk.pdf"], summary: "" },
+ };
+ renderDrawer(degraded);
+
+ await waitFor(() => expect(screen.getByText("Some attachments could not be processed")).toBeTruthy());
+ expect(screen.getByText("Not processed: bozuk.pdf")).toBeTruthy();
+ expect(screen.getByText("This output has no readable text. The raw record is below.")).toBeTruthy();
+ // The stored attachment id has no name to show, so it never leaks raw.
+ expect(screen.getByText("Unnamed attachment")).toBeTruthy();
+ expect(screen.queryByText(/file-zzz9/)).toBeNull();
+ });
+});
diff --git a/src/components/notes/rag-output-drawer.tsx b/src/components/notes/rag-output-drawer.tsx
new file mode 100644
index 0000000..6078b94
--- /dev/null
+++ b/src/components/notes/rag-output-drawer.tsx
@@ -0,0 +1,236 @@
+import { For, Show, createSignal, onCleanup } from "solid-js";
+import type { RagOutput } from "@/api/client";
+import { Alert } from "@/components/ui/alert";
+import { Button } from "@/components/ui/button";
+import { SidePanel } from "@/components/ui/side-panel";
+import { IconCopy, IconDownload, IconFileText } from "@/components/ui/icons";
+import {
+ buildRagOutputMarkdown,
+ fieldValueText,
+ ragOutputFileName,
+ readRagOutputDocument,
+} from "@/components/notes/rag-output-document";
+import { ragOutputMessage, type RagOutputMessageKey } from "@/components/notes/rag-output-messages";
+import { formatDateTime } from "@/lib/format";
+import { usePreferences } from "@/stores/preferences-context";
+
+/**
+ * Print isolation: the SidePanel portals into the app's document, so a bare
+ * `window.print()` would capture the whole page. These rules hide every
+ * element except the document body, flatten the panel out of its fixed,
+ * scroll-clipped layout, and pull the document to the page origin. The action
+ * row and the technical disclosure opt out with `print:hidden`.
+ */
+const PRINT_STYLES = `
+@media print {
+ body * { visibility: hidden; }
+ .rag-output-print, .rag-output-print * { overflow: visible !important; }
+ .rag-output-print { position: static !important; max-width: none !important; height: auto !important; box-shadow: none !important; }
+ .rag-output-print [data-rag-print-doc], .rag-output-print [data-rag-print-doc] * { visibility: visible; }
+ .rag-output-print [data-rag-print-doc] { position: absolute; left: 0; top: 0; width: 100%; color: #000; }
+}
+`;
+
+/** Payload keys with a Turkish label; anything else is labelled by its key. */
+const FIELD_LABELS: Partial> = {
+ chunks: "chunks",
+};
+
+/**
+ * One stored AI output, readable and exportable: the note it belongs to, the
+ * attachments by name, the produced prose, the lesser payload fields, and the
+ * raw record behind a disclosure. Copy / download / print all build their
+ * output from this same document.
+ */
+export function RagOutputDrawer(props: {
+ output: RagOutput | null;
+ /** The note the output belongs to — shown by title, never by id. */
+ noteTitle?: string;
+ onOpenChange: (open: boolean) => void;
+}) {
+ const { locale } = usePreferences();
+ const rt = (key: RagOutputMessageKey, vars?: Record) =>
+ ragOutputMessage(locale(), key, vars);
+ const [copied, setCopied] = createSignal(false);
+ const [copyError, setCopyError] = createSignal("");
+ let copiedTimer: ReturnType | undefined;
+ onCleanup(() => copiedTimer && clearTimeout(copiedTimer));
+
+ const doc = () => (props.output ? readRagOutputDocument(props.output) : null);
+ const noteTitle = () => props.noteTitle?.trim() ?? "";
+ const markdown = () => {
+ const output = props.output;
+ const read = doc();
+ if (!output || !read) return "";
+ return buildRagOutputMarkdown({
+ title: noteTitle() || rt("drawerTitle"),
+ date: formatDateTime(output.generated_at, locale()),
+ noteTitle: noteTitle(),
+ document: read,
+ labels: {
+ date: rt("date"),
+ note: rt("note"),
+ sources: rt("sources"),
+ failed: rt("failedTitle"),
+ otherFields: rt("otherFields"),
+ },
+ });
+ };
+
+ const copy = async () => {
+ setCopyError("");
+ if (!navigator.clipboard?.writeText) {
+ setCopyError(rt("copyFailed"));
+ return;
+ }
+ try {
+ await navigator.clipboard.writeText(markdown());
+ setCopied(true);
+ copiedTimer = setTimeout(() => setCopied(false), 2500);
+ } catch {
+ setCopied(false);
+ setCopyError(rt("copyFailed"));
+ }
+ };
+
+ const download = () => {
+ const output = props.output;
+ if (!output) return;
+ const blob = new Blob([markdown()], { type: "text/markdown;charset=utf-8" });
+ const url = URL.createObjectURL(blob);
+ const link = document.createElement("a");
+ link.href = url;
+ link.download = ragOutputFileName(output.generated_at);
+ document.body.appendChild(link);
+ link.click();
+ link.remove();
+ URL.revokeObjectURL(url);
+ };
+
+ return (
+
+
+
+ {(output) => (
+
+ {(read) => (
+
+
+
+
+
+
+
+
+
+ {rt("copied")}
+
+
+ {copyError()}
+
+
+
+ - {rt("date")}
+ - {formatDateTime(output().generated_at, locale())}
+
+ - {rt("note")}
+ - {noteTitle()}
+
+
+
+
+
{rt("sources")}
+
0 || read().unnamedSources > 0}
+ fallback={{rt("noSources")}
}
+ >
+
+ {(name) => - {name}
}
+ 0}>
+ -
+ {rt("unnamedSource")}
+ {read().unnamedSources > 1 ? ` × ${read().unnamedSources}` : ""}
+
+
+
+
+
+
+ 0}>
+
+ {/* One flex item: Alert lays its children out in a row. */}
+
+
{rt("failedTitle")}
+
{rt("failedLine", { names: read().failed.join(", ") })}
+
+
+
+
+ 0}
+ fallback={{rt("emptyText")}}
+ >
+
+ {read().summary}
+
+ 0}>
+
+
+
+
+ 0}>
+
+
+ {rt("otherFields")}
+
+
+
+ {(field) => (
+
+
-
+ {FIELD_LABELS[field.key] ? rt(FIELD_LABELS[field.key]!) : field.key}
+
+ - {fieldValueText(field.value)}
+
+ )}
+
+
+
+
+
+
+ {rt("technical")}
+
+ {JSON.stringify(read().raw, null, 2)}
+
+
+
+ )}
+
+ )}
+
+
+ );
+}
diff --git a/src/components/notes/rag-output-messages.ts b/src/components/notes/rag-output-messages.ts
new file mode 100644
index 0000000..4ec3f9a
--- /dev/null
+++ b/src/components/notes/rag-output-messages.ts
@@ -0,0 +1,81 @@
+import { formatMessage, type Locale } from "@/i18n/messages";
+
+/**
+ * Copy for the AI output drawer and its export actions.
+ *
+ * These strings deliberately live in their own module instead of the shared
+ * `src/i18n/messages.ts` table: that file is being edited by sibling lanes on
+ * the same day this drawer was built. The shape mirrors the shared table — a
+ * typed key union, one dict per locale, `{var}` interpolation through
+ * `formatMessage` — so the entries can be folded into the shared table later
+ * without touching a call site.
+ */
+export type RagOutputMessageKey =
+ | "view"
+ | "drawerTitle"
+ | "date"
+ | "note"
+ | "sources"
+ | "noSources"
+ | "unnamedSource"
+ | "emptyText"
+ | "failedTitle"
+ | "failedLine"
+ | "otherFields"
+ | "chunks"
+ | "technical"
+ | "copy"
+ | "copied"
+ | "copyFailed"
+ | "download"
+ | "print";
+
+const en: Record = {
+ "view": "View",
+ "drawerTitle": "AI output",
+ "date": "Date",
+ "note": "Note",
+ "sources": "Source attachments",
+ "noSources": "No attachments — built from the note text.",
+ "unnamedSource": "Unnamed attachment",
+ "emptyText": "This output has no readable text. The raw record is below.",
+ "failedTitle": "Some attachments could not be processed",
+ "failedLine": "Not processed: {names}",
+ "otherFields": "Other fields",
+ "chunks": "Text chunks",
+ "technical": "Technical details",
+ "copy": "Copy",
+ "copied": "Copied to the clipboard",
+ "copyFailed": "Could not copy to the clipboard.",
+ "download": "Download (.md)",
+ "print": "Print / PDF",
+};
+
+const tr: Record = {
+ "view": "Görüntüle",
+ "drawerTitle": "YZ çıktısı",
+ "date": "Tarih",
+ "note": "Not",
+ "sources": "Kaynak ekler",
+ "noSources": "Ek yok — not metninden oluşturuldu.",
+ "unnamedSource": "Adı bilinmeyen ek",
+ "emptyText": "Bu çıktıda okunabilir bir metin yok. Ham kayıt aşağıdadır.",
+ "failedTitle": "Bazı ekler işlenemedi",
+ "failedLine": "İşlenemeyenler: {names}",
+ "otherFields": "Diğer alanlar",
+ "chunks": "Metin parçaları",
+ "technical": "Teknik ayrıntı",
+ "copy": "Kopyala",
+ "copied": "Panoya kopyalandı",
+ "copyFailed": "Panoya kopyalanamadı.",
+ "download": "İndir (.md)",
+ "print": "Yazdır / PDF",
+};
+
+export function ragOutputMessage(
+ locale: Locale,
+ key: RagOutputMessageKey,
+ vars?: Record,
+): string {
+ return formatMessage((locale === "tr" ? tr : en)[key], vars);
+}
diff --git a/src/components/notes/rag-outputs-panel.tsx b/src/components/notes/rag-outputs-panel.tsx
index f28671c..0c0aca9 100644
--- a/src/components/notes/rag-outputs-panel.tsx
+++ b/src/components/notes/rag-outputs-panel.tsx
@@ -12,8 +12,10 @@ import { TableRowActions } from "@/components/ui/table-row-actions";
import { createFlash } from "@/lib/flash";
import { formatDateTime } from "@/lib/format";
import { usePreferences, useT } from "@/stores/preferences-context";
-import { IconSparkles, IconTrash } from "@/components/ui/icons";
+import { IconEye, IconSparkles, IconTrash } from "@/components/ui/icons";
import { RagOutputContent } from "@/components/notes/rag-output-content";
+import { RagOutputDrawer } from "@/components/notes/rag-output-drawer";
+import { ragOutputMessage } from "@/components/notes/rag-output-messages";
const RAG_PAGE_SIZE = 10;
@@ -28,6 +30,8 @@ export function RagOutputsPanel(props: {
noteId: string;
active: boolean;
source: NoteFileSource;
+ /** The note's title, shown by name in the output drawer. */
+ noteTitle?: string;
/** Delete control is teacher-only; readers see the list. Defaults to true. */
canManage?: boolean;
}) {
@@ -36,6 +40,7 @@ export function RagOutputsPanel(props: {
const [error, setError] = createSignal("");
const [flash, setFlash] = createFlash();
const [deleteTarget, setDeleteTarget] = createSignal(null);
+ const [viewTarget, setViewTarget] = createSignal(null);
const [generating, setGenerating] = createSignal(false);
/** Set when a reindex attempt ended without a new output — the truthful state. */
const [missed, setMissed] = createSignal("");
@@ -160,28 +165,45 @@ export function RagOutputsPanel(props: {
{formatDateTime(output.generated_at, locale())}
-
- ,
+ onSelect: () => setViewTarget(output),
+ },
+ ...(props.canManage !== false && props.source.deleteRagOutput
+ ? [{
label: t("common.delete"),
icon: ,
destructive: true,
onSelect: () => setDeleteTarget(output),
- },
- ]}
- />
-
+ }]
+ : []),
+ ]}
+ />
-