DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
feat(notebook): expose direct record editing
XZHb0d3bd9e69b5
diff --git a/web/components/notebook/NotebookRecordActions.tsx b/web/components/notebook/NotebookRecordActions.tsxindex 561803609..c7b3054e7 100644--- a/web/components/notebook/NotebookRecordActions.tsx+++ b/web/components/notebook/NotebookRecordActions.tsx@@ -106,7 +106,7 @@ export default function NotebookRecordActions({<div className="p-1"><MenuItemicon={Pencil}- label={t("Edit")}+ label={t("Edit record")}onClick={() => {close();onEdit();diff --git a/web/components/notebook/NotebookRecordRow.tsx b/web/components/notebook/NotebookRecordRow.tsxindex ce85594cb..7df9d1cf3 100644--- a/web/components/notebook/NotebookRecordRow.tsx+++ b/web/components/notebook/NotebookRecordRow.tsx@@ -14,6 +14,7 @@ import {} from "lucide-react";import { useTranslation } from "react-i18next";import { ConfirmDialog } from "@/components/ui/ConfirmDialog";+import Tooltip from "@/components/common/Tooltip";import NotebookRecordActions from "@/components/notebook/NotebookRecordActions";import { notify } from "@/lib/notifications";import type { NotebookRecordItem, NotebookSummary } from "@/lib/notebook-api";@@ -254,6 +255,21 @@ export default function NotebookRecordRow({{timestamp}</span>+ <Tooltip label={t("Edit record")} side="bottom">+ <button+ type="button"+ disabled={busy}+ aria-label={t("Edit record")}+ onClick={() => {+ if (!expanded) onToggle();+ startEditing();+ }}+ className="inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg text-[var(--muted-foreground)] opacity-60 transition-[background-color,color,opacity,transform] duration-150 active:scale-[0.97] hover:bg-[var(--muted)] hover:text-[var(--foreground)] hover:opacity-100 focus-visible:bg-[var(--muted)] focus-visible:text-[var(--foreground)] focus-visible:opacity-100 focus-visible:outline-none disabled:opacity-30"+ >+ <Pencil size={14} />+ </button>+ </Tooltip>+<NotebookRecordActionstargets={moveTargets}disabled={busy}diff --git a/web/locales/en/app.json b/web/locales/en/app.jsonindex 8a91940f4..33c2c7e67 100644--- a/web/locales/en/app.json+++ b/web/locales/en/app.json@@ -2782,6 +2782,7 @@"Could not load your notebooks": "Could not load your notebooks","Delete notebook": "Delete notebook","Description (optional)": "Description (optional)",+ "Edit record": "Edit record","Edit notebook": "Edit notebook","Filter notebooks": "Filter notebooks","Name your first notebook": "Name your first notebook",diff --git a/web/locales/zh/app.json b/web/locales/zh/app.jsonindex d44038055..c5ddaf75c 100644--- a/web/locales/zh/app.json+++ b/web/locales/zh/app.json@@ -2782,6 +2782,7 @@"Could not load your notebooks": "无法加载你的笔记本","Delete notebook": "删除笔记本","Description (optional)": "描述(可选)",+ "Edit record": "编辑记录","Edit notebook": "编辑笔记本","Filter notebooks": "筛选笔记本","Name your first notebook": "为第一个笔记本起名",diff --git a/web/tests/notebook-record-edit-discoverability.spec.tsx b/web/tests/notebook-record-edit-discoverability.spec.tsxnew file mode 100644index 000000000..efb806d76--- /dev/null+++ b/web/tests/notebook-record-edit-discoverability.spec.tsx@@ -0,0 +1,60 @@+import { fireEvent, render, screen, waitFor } from "@testing-library/react";+import { useState } from "react";+import { expect, it, vi } from "vitest";+import NotebookRecordRow from "@/components/notebook/NotebookRecordRow";+import type { NotebookRecordItem } from "@/lib/notebook-api";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));+vi.mock("@/components/common/MarkdownRenderer", () => ({ default: () => null }));++const record: NotebookRecordItem = {+ id: "record-1",+ type: "chat",+ title: "Stored record",+ user_query: "What changed?",+ output: "The record body.",+};++function renderRow(onEdit = vi.fn().mockResolvedValue(undefined)) {+ function Harness() {+ const [expanded, setExpanded] = useState(false);++ return (+ <NotebookRecordRow+ record={record}+ notebooks={[]}+ currentNotebookId="notebook-1"+ expanded={expanded}+ onToggle={() => setExpanded((value) => !value)}+ onEdit={onEdit}+ onDelete={vi.fn().mockResolvedValue(undefined)}+ onRelocate={vi.fn().mockResolvedValue(undefined)}+ onOpenSession={vi.fn()}+ />+ );+ }++ render(<Harness />);+}++it("opens the record editor directly without opening the row menu", async () => {+ const onEdit = vi.fn().mockResolvedValue(undefined);+ renderRow(onEdit);++ const editButton = screen.getByRole("button", { name: "Edit record" });+ expect(editButton).toBeVisible();+ expect(screen.queryByRole("menu")).not.toBeInTheDocument();++ fireEvent.click(editButton);+ const titleInput = screen.getByLabelText("Record title");+ expect(titleInput).toHaveValue("Stored record");++ fireEvent.change(titleInput, { target: { value: "Updated record" } });+ fireEvent.click(screen.getByRole("button", { name: "Save" }));++ await waitFor(() =>+ expect(onEdit).toHaveBeenCalledWith("record-1", { title: "Updated record" }),+ );+});