Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <small>October 15, 2026</small> {id="0.9.0"}

Expand Down
2 changes: 2 additions & 0 deletions docs/processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
61 changes: 61 additions & 0 deletions nextjs-frontend/__tests__/recording-entities-edit.test.tsx
Original file line number Diff line number Diff line change
@@ -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 }) => (
<div role="dialog" aria-label={`Entity ${id} in ${ns}`}>
<button type="button" onClick={onClose}>
Close
</button>
</div>
),
}));

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(<EntitiesTab />);
// 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(<EntitiesTab />);
expect(screen.queryByRole("button", { name: /^Edit / })).not.toBeInTheDocument();
expect(screen.getByRole("link", { name: "Open Acme Inc in the graph" })).toBeInTheDocument();
});
});
20 changes: 18 additions & 2 deletions nextjs-frontend/components/recording/entities-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<number | null>(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(() => {
Expand Down Expand Up @@ -165,6 +169,17 @@ export function EntitiesTab() {
{e.segs.length} {e.segs.length === 1 ? "mention" : "mentions"}
</span>
</button>
{eid && canEditNamespace && (
<button
type="button"
aria-label={`Edit ${e.name}`}
title="Rename, retype, hide or merge it"
onClick={() => setEditing(eid)}
className="grid size-7 shrink-0 place-items-center rounded-full text-fg-muted hover:bg-background hover:text-fg"
>
<Pencil className="size-3.5" />
</button>
)}
{eid ? (
<Link
href={`/graph?focus=e${eid}`}
Expand All @@ -184,6 +199,7 @@ export function EntitiesTab() {
</ul>
</section>
))}
{editing && ns && <EntityDrawer id={editing} ns={ns} onClose={() => setEditing(null)} onOpen={setEditing} />}
</>
);
}
Loading