From e3e5ad7fe066008b1060bb9ea5528df8f858cbbd Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Thu, 15 Oct 2026 08:09:25 +0000 Subject: [PATCH] feat(recordings): edit an entity from a recording's Entities tab Editors get a pencil next to each entity the index knows; it opens the same side panel as the Entities page, to rename, retype, hide or merge without leaving the recording. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01EzVhJCpwskyo5NhHEtS822 --- CHANGELOG.md | 3 + docs/processing.md | 2 + .../recording-entities-edit.test.tsx | 61 +++++++++++++++++++ .../components/recording/entities-tab.tsx | 20 +++++- 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 nextjs-frontend/__tests__/recording-entities-edit.test.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index bac839d46..cf9fe676b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,9 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version topic's drawer has a find box to merge another topic in, and topics merge on the graph canvas too. The API answers a merge or delete with an `undo` id (`POST /api/v1/topics/changes/{id}/undo`) and lists recent ones ([Topics](docs/topics.md)). +- **Edit entities from a recording.** In a recording's **Entities** tab, the pencil next to an entity opens its side + panel, so editors rename, retype, hide or merge it without leaving the recording + ([Entities](docs/processing.md#entities-and-the-graph-explorer)). ## 0.9.0 October 15, 2026 {id="0.9.0"} diff --git a/docs/processing.md b/docs/processing.md index 765418de1..adbfa7260 100644 --- a/docs/processing.md +++ b/docs/processing.md @@ -119,6 +119,8 @@ and opens each in a side panel where editors rename, retype, describe, merge and - **Merge or retype many:** editors tick rows (or the whole page) and the bar at the bottom merges them into one (the one on the fixed list, else the most mentioned; the arrow picks another) or gives them all one type. - Every merge and bulk type change happens at once and has **Undo** on its notice, so nothing asks to confirm. +- **From a recording:** in a recording's **Entities** tab, the pencil next to an entity opens the same side panel, so + editors rename, retype, hide or merge it without leaving the recording. - **Index** (`GET /api/v1/entities`): - Search forgives misspellings and covers aliases. diff --git a/nextjs-frontend/__tests__/recording-entities-edit.test.tsx b/nextjs-frontend/__tests__/recording-entities-edit.test.tsx new file mode 100644 index 000000000..02c6344d5 --- /dev/null +++ b/nextjs-frontend/__tests__/recording-entities-edit.test.tsx @@ -0,0 +1,61 @@ +import { fireEvent, render, screen } from "@testing-library/react"; +import "@testing-library/jest-dom"; + +import { useRec } from "@/components/recording/context"; +import { EntitiesTab } from "@/components/recording/entities-tab"; + +jest.mock("@/components/recording/context", () => ({ useRec: jest.fn() })); +jest.mock("@/components/player/media", () => ({ usePlayerApi: () => ({ seek: jest.fn() }) })); +jest.mock("@/components/recording/hooks", () => ({ + useRecordingEntities: () => ({ + data: { items: [{ id: 7, name: "Acme", key: "acme", type: "ORG", aliases: ["Acme Inc"] }] }, + isLoading: false, + }), +})); +jest.mock("@/components/topics/recording-topics", () => ({ RecordingTopics: () => null })); +jest.mock("@/components/entities/entity-drawer", () => ({ + EntityDrawer: ({ id, ns, onClose }: { id: number; ns: string; onClose: () => void }) => ( +
+ +
+ ), +})); + +const rec = (canEditNamespace: boolean) => + (useRec as jest.Mock).mockReturnValue({ + model: { + entities: [ + { name: "Acme Inc", type: "ORG", segs: [0] }, + { name: "Mystery", type: "ORG", segs: [0] }, + ], + keywords: [], + segments: [{ t0: 0 }], + }, + id: 1, + entity: { selected: null, select: jest.fn() }, + where: () => "0:00", + ns: "pods", + canEditNamespace, + }); + +describe("editing entities from a recording", () => { + it("opens an entity the editor picks, without leaving the recording", () => { + rec(true); + render(); + // only entities the index knows can be edited + expect(screen.queryByRole("button", { name: "Edit Mystery" })).not.toBeInTheDocument(); + fireEvent.click(screen.getByRole("button", { name: "Edit Acme Inc" })); + expect(screen.getByRole("dialog", { name: "Entity 7 in pods" })).toBeInTheDocument(); + fireEvent.click(screen.getByRole("button", { name: "Close" })); + expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); + }); + + it("offers viewers no pencil", () => { + rec(false); + render(); + expect(screen.queryByRole("button", { name: /^Edit / })).not.toBeInTheDocument(); + expect(screen.getByRole("link", { name: "Open Acme Inc in the graph" })).toBeInTheDocument(); + }); +}); diff --git a/nextjs-frontend/components/recording/entities-tab.tsx b/nextjs-frontend/components/recording/entities-tab.tsx index dc5f9c182..ea8fb472d 100644 --- a/nextjs-frontend/components/recording/entities-tab.tsx +++ b/nextjs-frontend/components/recording/entities-tab.tsx @@ -8,13 +8,15 @@ import { ChevronRight, Hash, MapPin, + Pencil, Tag, User, type LucideIcon, } from "lucide-react"; import Link from "next/link"; -import { useMemo } from "react"; +import { useMemo, useState } from "react"; +import { EntityDrawer } from "@/components/entities/entity-drawer"; import { usePlayerApi } from "@/components/player/media"; import { useRec } from "@/components/recording/context"; import { useRecordingEntities } from "@/components/recording/hooks"; @@ -64,12 +66,14 @@ export function groupEntities( /** * Entities tab: the topics it is about, the keyword cloud, then entities by type with mentions in this recording. Choosing one marks its - * mentions ● on the waveform and jumps to the first; the chevron opens it in the graph. + * mentions ● on the waveform and jumps to the first; the chevron opens it in the graph, and for editors the pencil + * opens it to rename, retype, hide or merge without leaving the recording. */ export function EntitiesTab() { const { model, id, entity, where, ns, canEditNamespace } = useRec(); const api = usePlayerApi(); const list = useRecordingEntities(id, model.entities.length > 0); + const [editing, setEditing] = useState(null); const groups = useMemo(() => groupEntities(model.entities), [model.entities]); // The player's entities carry no ids; match them to the entity index by name, key or alias to link to the graph. const ids = useMemo(() => { @@ -165,6 +169,17 @@ export function EntitiesTab() { {e.segs.length} {e.segs.length === 1 ? "mention" : "mentions"} + {eid && canEditNamespace && ( + + )} {eid ? ( ))} + {editing && ns && setEditing(null)} onOpen={setEditing} />} ); }