diff --git a/.claude/audits/2026-11-06-v1-2-6-u1-label-proposals.md b/.claude/audits/2026-11-06-v1-2-6-u1-label-proposals.md
index 34d3f079..49841d31 100644
--- a/.claude/audits/2026-11-06-v1-2-6-u1-label-proposals.md
+++ b/.claude/audits/2026-11-06-v1-2-6-u1-label-proposals.md
@@ -33,3 +33,14 @@ Reworded prose (no new key): `admin.failure.view.asset.unknown`, `editor.annotat
`editor.annotations.no_category`, `editor.annotations.no_child_view`, `editor.views.frame.newly_invalid`
(they named the removed tabs). Removed keys: `editor.tab.views`, `editor.tab.references`,
`editor.tab.vertebrae` (renamed to `editor.place.*`), `editor.annotations.select_hint` (the overview replaces it).
+
+## Lot C (annotation card, side column from 1 024 px)
+
+| Key | FR | EN | Where | Status |
+|---|---|---|---|---|
+| `editor.overview.filter` | Filtrer par nom | Filter by name | Card field (name and placeholder) | board text |
+| `editor.overview.uncategorised` | Sans catégorie | No category | Group title, only if a document holds such an annotation | plan wording |
+| `editor.overview.no_match` | Aucune annotation ne correspond. | No annotation matches. | Card, filter without result | proposal |
+| `editor.annotations.show_all` | Toutes les annotations | All annotations | Properties panel, back to the card | plan wording |
+
+Reused: `editor.annotations.list` (« Annotations de la vue », card title and list name), `editor.annotations.list_empty`.
diff --git a/apps/app/e2e/shell/editor-annotations.spec.ts b/apps/app/e2e/shell/editor-annotations.spec.ts
index 36a52eb9..223eff7e 100644
--- a/apps/app/e2e/shell/editor-annotations.spec.ts
+++ b/apps/app/e2e/shell/editor-annotations.spec.ts
@@ -8,8 +8,10 @@ import {
editorActor,
geometryField,
openEditor,
+ pickAnnotation,
saveDraft,
seedDraft,
+ selectionTag,
selectTab,
serverDocument,
standardShape,
@@ -92,7 +94,7 @@ test.describe('editor annotations (A3)', () => {
.getByLabel(dict['editor.annotations.zone'])
.selectOption('zone-a')
await createFromPanel(page)
- await expect(list(page).getByText('Point un')).toBeVisible()
+ await expect(selectionTag(page)).toContainText('Point un')
await expect(properties(page)).toBeVisible()
const placed = await geometryField(page, dict, 'cx').inputValue()
expect(Math.abs(Number(placed) - 300)).toBeLessThan(1)
@@ -110,7 +112,7 @@ test.describe('editor annotations (A3)', () => {
.click()
await fillCreation(page, { fr: 'Zone une', en: 'Zone one' })
await createFromPanel(page)
- await expect(list(page).getByText('Zone une')).toBeVisible()
+ await expect(selectionTag(page)).toContainText('Zone une')
// A link to the detail view: the same tracing, the opened view chosen.
await tool(page, 'link').click()
@@ -125,7 +127,7 @@ test.describe('editor annotations (A3)', () => {
.click()
await fillCreation(page, { fr: 'Accès un', en: 'Access one' }, 'detail-a')
await createFromPanel(page)
- await expect(list(page).getByText('Accès un')).toBeVisible()
+ await expect(selectionTag(page)).toContainText('Accès un')
await expect(
page.getByRole('button', {
name: dict['editor.annotations.undo'],
@@ -134,9 +136,7 @@ test.describe('editor annotations (A3)', () => {
).toBeEnabled()
// A numeric edit of the point, then undo and redo.
- await list(page)
- .getByRole('button', { name: /Point un/ })
- .click()
+ await pickAnnotation(page, dict, /Point un/)
const cx = geometryField(page, dict, 'cx')
await cx.fill('420')
await cx.press('Enter')
@@ -234,7 +234,7 @@ test.describe('editor annotations (A3)', () => {
.focus()
await page.keyboard.press('Enter')
await expect(creation(page)).toHaveCount(0)
- await expect(list(page).getByText('Clavier')).toBeVisible()
+ await expect(selectionTag(page)).toContainText('Clavier')
await expect(geometryField(page, dict, 'cx')).toHaveValue('250')
const cy = geometryField(page, dict, 'cy')
@@ -252,7 +252,7 @@ test.describe('editor annotations (A3)', () => {
.getByRole('button', { name: dict['editor.annotations.create'] })
.focus()
await page.keyboard.press('Enter')
- await expect(list(page).getByText('Zone clavier')).toBeVisible()
+ await expect(selectionTag(page)).toContainText('Zone clavier')
const vertexX = page.getByLabel(
dict['editor.annotations.geometry.vertex_x'].replace('{n}', '1'),
)
diff --git a/apps/app/e2e/shell/editor-geometry.spec.ts b/apps/app/e2e/shell/editor-geometry.spec.ts
index ce24bf10..1354aa11 100644
--- a/apps/app/e2e/shell/editor-geometry.spec.ts
+++ b/apps/app/e2e/shell/editor-geometry.spec.ts
@@ -10,9 +10,11 @@ import {
geometryField,
openEditor,
openSection,
+ pickAnnotation,
pointOf,
saveDraft,
seedDraft,
+ selectionTag,
selectTab,
serverDocument,
shapeWith,
@@ -30,8 +32,6 @@ const dict = fr
const isPhone = (info: TestInfo) => info.project.name === 'chromium-375'
const creation = (page: Page) => page.getByTestId('annotation-creation')
const notice = (page: Page) => page.getByTestId('correction-notice')
-const list = (page: Page) =>
- page.getByRole('list', { name: dict['editor.annotations.list'] })
const tool = (page: Page, id: string) =>
page.getByRole('button', {
@@ -93,7 +93,7 @@ test.describe('editor geometry (adversarial)', () => {
await expect(notice(page)).toBeVisible()
await expect(page.getByTestId('overlay-click-cross')).toBeAttached()
const shown = await proposed(page)
- await expect(list(page)).toHaveCount(0)
+ await expect(selectionTag(page)).toHaveCount(0) // an insertion selects it
// Cancelled: the notice goes, nothing was inserted.
await notice(page)
@@ -102,7 +102,7 @@ test.describe('editor geometry (adversarial)', () => {
})
.click()
await expect(notice(page)).toHaveCount(0)
- await expect(list(page)).toHaveCount(0)
+ await expect(selectionTag(page)).toHaveCount(0) // an insertion selects it
// Confirmed: the same attempt again, the corrected position inserted.
await creation(page)
@@ -114,7 +114,7 @@ test.describe('editor geometry (adversarial)', () => {
.getByRole('button', { name: dict['editor.annotations.correction_use'] })
.click()
await expect(creation(page)).toHaveCount(0)
- await expect(list(page).getByText('Bord')).toBeVisible()
+ await expect(selectionTag(page)).toContainText('Bord')
await expect(geometryField(page, dict, 'cx')).toHaveValue(shown.x)
await expect(geometryField(page, dict, 'cy')).toHaveValue(shown.y)
})
@@ -143,7 +143,7 @@ test.describe('editor geometry (adversarial)', () => {
})
.click()
await expect(notice(page)).toHaveCount(0)
- await expect(list(page)).toHaveCount(0)
+ await expect(selectionTag(page)).toHaveCount(0) // an insertion selects it
// Then confirmed: the same attempt again inserts the corrected position.
await creation(page)
.getByRole('button', { name: dict['editor.annotations.create'] })
@@ -152,7 +152,7 @@ test.describe('editor geometry (adversarial)', () => {
await notice(page)
.getByRole('button', { name: dict['editor.annotations.correction_use'] })
.click()
- await expect(list(page).getByText('Bord détail')).toBeVisible()
+ await expect(selectionTag(page)).toContainText('Bord détail')
})
test('a point inherited out of its frame is repaired through the geometry group', async ({
@@ -165,9 +165,7 @@ test.describe('editor geometry (adversarial)', () => {
)
requests.forbid(actor.account.email, actor.account.password)
await viewChip(page, 'Détail A').click()
- await list(page)
- .getByRole('button', { name: /Hors cadre/ })
- .click()
+ await pickAnnotation(page, dict, /Hors cadre/)
const issues = page.getByTestId('annotation-geometry-issues')
await expect(issues).toBeVisible()
const verification = page.getByRole('tab', {
@@ -454,9 +452,7 @@ test.describe('editor touch path (real browser)', () => {
// A movable selection needs the touch itself: the browser reads touch-action at
// touchstart, so a drag of the selected marker must not be left to the pan.
- await list(page)
- .getByRole('button', { name: /Tactile/ })
- .click()
+ await pickAnnotation(page, dict, /Tactile/)
await expect.poll(touchAction).toBe('none')
const cx = geometryField(page, dict, 'cx')
await expect(cx).toHaveValue('500')
diff --git a/apps/app/e2e/shell/editor-journey.spec.ts b/apps/app/e2e/shell/editor-journey.spec.ts
index 1cb15739..c31a929e 100644
--- a/apps/app/e2e/shell/editor-journey.spec.ts
+++ b/apps/app/e2e/shell/editor-journey.spec.ts
@@ -5,7 +5,8 @@ import { stepUpAdmin } from '../support/admin'
import { expect, expectAccessible, test } from '../support/browser'
import { dropLateReplays, routeToSandbox } from '../support/sandbox'
import {
- annotationList,
+ pickAnnotation,
+ selectionTag,
clickDrawing,
createFromPanel,
creationPanel,
@@ -175,20 +176,19 @@ const MODIFIED = { point: 3, vertex: 4 }
/** Applies (not only refuses) changes to a point, a zone and a link; read back at the save. */
async function modifyAnnotations(page: Page) {
- const list = annotationList(page, dict)
- await list.getByRole('button', { name: /Point essai/ }).click()
+ await pickAnnotation(page, dict, /Point essai/)
const cx = geometryField(page, dict, 'cx')
const before = Number(await cx.inputValue())
await commitText(cx, String(before + MODIFIED.point))
await expect(cx).toHaveValue(String(before + MODIFIED.point))
- await list.getByRole('button', { name: /Zone dessinée/ }).click()
+ await pickAnnotation(page, dict, /Zone dessinée/)
const vertex = page.getByLabel(
dict['editor.annotations.geometry.vertex_x'].replace('{n}', '1'),
)
const start = Number(await vertex.inputValue())
await commitText(vertex, String(start + MODIFIED.vertex))
await expect(vertex).toHaveValue(String(start + MODIFIED.vertex))
- await list.getByRole('button', { name: /Accès essai/ }).click()
+ await pickAnnotation(page, dict, /Accès essai/)
await commitText(page.locator('#annotation-name-fr'), 'Accès modifié')
await page.locator('#annotation-laterality').selectOption('bilateral')
await expect(page.locator('#annotation-name-fr')).toHaveValue('Accès modifié')
@@ -204,9 +204,7 @@ async function repairGeometry(page: Page) {
await clickDrawing(page, 1, 1)
await fillCreation(page, dict, { fr: 'Point de bord', en: 'Edge point' })
await createFromPanel(page, dict)
- await expect(
- annotationList(page, dict).getByText('Point de bord'),
- ).toBeVisible()
+ await expect(selectionTag(page)).toContainText('Point de bord')
const cx = geometryField(page, dict, 'cx')
await cx.fill('9999')
await cx.press('Enter')
diff --git a/apps/app/e2e/shell/editor-structures.spec.ts b/apps/app/e2e/shell/editor-structures.spec.ts
index 1c1cae47..69e3f8c9 100644
--- a/apps/app/e2e/shell/editor-structures.spec.ts
+++ b/apps/app/e2e/shell/editor-structures.spec.ts
@@ -9,6 +9,7 @@ import {
openEditor,
openReferences,
openSection,
+ pickAnnotation,
pointOf,
saveDraft,
seedDraft,
@@ -289,10 +290,7 @@ test.describe('editor structures (A4)', () => {
// The point goes first; the zone then deletes with its descendants named.
await showDrawing(page, dict)
- await page
- .getByRole('list', { name: dict['editor.annotations.list'] })
- .getByRole('button', { name: /Point lié/ })
- .click()
+ await pickAnnotation(page, dict, /Point lié/)
await page
.getByTestId('annotation-properties')
.getByRole('button', { name: dict['editor.action.delete'] })
diff --git a/apps/app/e2e/support/editor.ts b/apps/app/e2e/support/editor.ts
index fce3c63b..4271a835 100644
--- a/apps/app/e2e/support/editor.ts
+++ b/apps/app/e2e/support/editor.ts
@@ -488,6 +488,24 @@ export const creationPanel = (page: Page) =>
export const annotationList = (page: Page, dict: Dict) =>
page.getByRole('list', { name: dict['editor.annotations.list'] })
+/** The tag over the drawing while an annotation is selected (the card is then hidden). */
+export const selectionTag = (page: Page) =>
+ page.getByTestId('annotation-selection-tag')
+
+/** Selects an annotation from the overview card, leaving a selection first when there is one. */
+export async function pickAnnotation(
+ page: Page,
+ dict: Dict,
+ name: RegExp | string,
+) {
+ const all = page.getByRole('button', {
+ name: dict['editor.annotations.show_all'],
+ exact: true,
+ })
+ if (await all.isVisible()) await all.click()
+ await annotationList(page, dict).getByRole('button', { name }).click()
+}
+
export const toolButton = (page: Page, dict: Dict, id: string) =>
page.getByRole('button', {
name: dict[`editor.annotations.tool.${id}`],
diff --git a/apps/app/src/catalogue/useCatalogue.ts b/apps/app/src/catalogue/useCatalogue.ts
index 0c799174..b32d9798 100644
--- a/apps/app/src/catalogue/useCatalogue.ts
+++ b/apps/app/src/catalogue/useCatalogue.ts
@@ -50,7 +50,7 @@ export function useCatalogue() {
}
/** Lower case without accents, so « epaule » finds « Épaule ». */
-function folded(text: string): string {
+export function folded(text: string): string {
return text.normalize('NFD').replace(/\p{Diacritic}/gu, '').toLowerCase()
}
diff --git a/apps/app/src/components/editor/annotations/AnnotationList.tsx b/apps/app/src/components/editor/annotations/AnnotationList.tsx
index 3acf75e0..49b116b2 100644
--- a/apps/app/src/components/editor/annotations/AnnotationList.tsx
+++ b/apps/app/src/components/editor/annotations/AnnotationList.tsx
@@ -1,11 +1,10 @@
import type { Annotation, SheetView } from '@faunosteo/core-wasm/types'
+import type { AnnotationGroup } from '@/editor/annotations/overview'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import ReviewBadge from './ReviewBadge'
-const LIST =
- 'max-h-64 divide-y divide-[var(--color-border)] overflow-y-auto rounded-lg ' +
- 'border border-[var(--color-border)]'
+const LIST = 'max-h-96 space-y-2 overflow-y-auto'
const ROW =
'flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-sm ' +
@@ -24,52 +23,91 @@ export function annotationName(
return opened?.name[locale] ?? annotation.id
}
-/**
- * The annotations of the view: name, kind, review badge; each row a button, reachable
- * from the keyboard. Selection works in every mode, so a read-only draft is browsable.
- */
-export default function AnnotationList({
- annotations,
+function Row({
+ annotation,
views,
- selectedId,
onSelect,
}: {
- annotations: readonly Annotation[]
+ annotation: Annotation
views: readonly SheetView[]
- selectedId: string | null
onSelect: (id: string) => void
}) {
const t = useT()
const locale = useLocaleStore((s) => s.locale)
- if (annotations.length === 0) {
- return (
-
- {t('editor.annotations.list_empty')}
-
- )
- }
+ return (
+
+ onSelect(annotation.id)}
+ className={ROW}
+ >
+
+
+ {t(`editor.annotations.kind.${annotation.kind}`)}
+ {' '}
+ {annotationName(annotation, views, locale)}
+
+
+
+
+ )
+}
+
+/** « Sans catégorie » or the category: swatch, name and the count of rows shown. */
+function GroupTitle({ group }: { group: AnnotationGroup }) {
+ const t = useT()
+ const locale = useLocaleStore((s) => s.locale)
+ const { category } = group
+ return (
+
+
+
+ {category ? category.name[locale] : t('editor.overview.uncategorised')}
+
+
+ {group.annotations.length}
+
+
+ )
+}
+
+/**
+ * The annotations of the view by category, each row a button reachable from the keyboard.
+ * Selection works in every mode, so a read-only draft is browsable.
+ */
+export default function AnnotationList({
+ groups,
+ views,
+ onSelect,
+}: {
+ groups: readonly AnnotationGroup[]
+ views: readonly SheetView[]
+ onSelect: (id: string) => void
+}) {
+ const t = useT()
return (
- {annotations.map((annotation) => (
-
- onSelect(annotation.id)}
- className={`${ROW} ${
- annotation.id === selectedId
- ? 'bg-[var(--color-surface-strong)]'
- : ''
- }`}
- >
-
-
- {t(`editor.annotations.kind.${annotation.kind}`)}
- {' '}
- {annotationName(annotation, views, locale)}
-
-
-
+ {groups.map((group) => (
+
+
+
+ {group.annotations.map((annotation) => (
+
+ ))}
+
))}
diff --git a/apps/app/src/components/editor/annotations/EditableAnnotations.tsx b/apps/app/src/components/editor/annotations/EditableAnnotations.tsx
index 95fb7c98..acb956e6 100644
--- a/apps/app/src/components/editor/annotations/EditableAnnotations.tsx
+++ b/apps/app/src/components/editor/annotations/EditableAnnotations.tsx
@@ -28,7 +28,7 @@ import type { EditorPlaceProps } from '@/editor/tabs'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import AnnotationCanvas from './AnnotationCanvas'
-import AnnotationList, { annotationName } from './AnnotationList'
+import { annotationName } from './AnnotationList'
import CreationPanel from './CreationPanel'
import KeyboardAdd from './KeyboardAdd'
import OverviewPanel from './OverviewPanel'
@@ -131,7 +131,7 @@ export default function EditableAnnotations(props: Props) {
const context = useCommitContext()
const placement = usePlacement({ ...scene, context })
return (
-
+
@@ -180,12 +180,6 @@ function CanvasColumn({
linkDisabled={model.children.length === 0}
onAdd={(kind) => addAtCentre(kind, scene.frame, dispatch)}
/>
- dispatch({ type: 'select', id })}
- />
)
}
@@ -281,6 +275,7 @@ function SidePanel({
viewId={scene.viewId}
readOnly={false}
onSelectView={(id) => dispatch({ type: 'view', viewId: id })}
+ onSelectAnnotation={(id) => dispatch({ type: 'select', id })}
onOpenSection={scene.onOpenSection}
/>
)
@@ -295,6 +290,7 @@ function SidePanel({
dispatch={dispatch}
context={context}
navigate={scene.navigate}
+ onShowAll={() => dispatch({ type: 'select', id: null })}
/>
)
}
diff --git a/apps/app/src/components/editor/annotations/OverviewPanel.tsx b/apps/app/src/components/editor/annotations/OverviewPanel.tsx
index f211cc1b..e4995f76 100644
--- a/apps/app/src/components/editor/annotations/OverviewPanel.tsx
+++ b/apps/app/src/components/editor/annotations/OverviewPanel.tsx
@@ -1,12 +1,18 @@
+import { useMemo, useState } from 'react'
import type {
AnatomicalSheetDocument,
SheetView,
} from '@faunosteo/core-wasm/types'
-import { useOverviewCounts } from '@/editor/annotations/overview'
+import Input from '@/components/ui/Input'
+import {
+ groupAnnotations,
+ useOverviewCounts,
+} from '@/editor/annotations/overview'
import type { AnnotationSection } from '@/editor/navigation'
import { usePlural } from '@/editor/plural'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
+import AnnotationList, { annotationName } from './AnnotationList'
const CARD = 'space-y-2 rounded-xl border border-[var(--color-border)] p-4'
const TITLE = 'text-sm font-semibold'
@@ -24,6 +30,7 @@ export interface OverviewPanelProps {
/** Put before every id (the read-only twin beside the kept edit panel). */
idPrefix?: string
onSelectView: (viewId: string) => void
+ onSelectAnnotation: (annotationId: string) => void
onOpenSection: (section: AnnotationSection, opener: HTMLElement) => void
}
@@ -183,7 +190,59 @@ function CategoriesCard(props: OverviewPanelProps) {
)
}
-/** Board 01's overview: the views and the categories, with the entries to their sections. */
+function AnnotationsCard(props: OverviewPanelProps) {
+ const t = useT()
+ const locale = useLocaleStore((s) => s.locale)
+ const { doc, viewId, onSelectAnnotation } = props
+ const [term, setTerm] = useState('')
+ const prefix = props.idPrefix ?? ''
+ const total = useOverviewCounts(doc).annotationsByView.get(viewId) ?? 0
+ const groups = useMemo(
+ () =>
+ groupAnnotations(doc, viewId, term, (a) =>
+ annotationName(a, doc.views, locale),
+ ),
+ [doc, viewId, term, locale],
+ )
+ return (
+
+ )
+}
+
+/** Board 01's overview: the views, the categories, then the annotations of the shown view. */
export default function OverviewPanel(props: OverviewPanelProps) {
const t = useT()
return (
@@ -195,6 +254,7 @@ export default function OverviewPanel(props: OverviewPanelProps) {
>
+
)
}
diff --git a/apps/app/src/components/editor/annotations/PropertiesPanel.tsx b/apps/app/src/components/editor/annotations/PropertiesPanel.tsx
index 5f4118bd..3205dc51 100644
--- a/apps/app/src/components/editor/annotations/PropertiesPanel.tsx
+++ b/apps/app/src/components/editor/annotations/PropertiesPanel.tsx
@@ -1,4 +1,5 @@
import { useState, type Dispatch } from 'react'
+import { flushSync } from 'react-dom'
import type {
AnatomicalSheetDocument,
Annotation,
@@ -15,6 +16,7 @@ import {
import { isEditable } from '@/editor/annotations/geometryEdit'
import type { UiAction } from '@/editor/annotations/uiState'
import { geometryErrorsById } from '@/editor/issues'
+import { focusRow } from '@/editor/focusRequest'
import { targetOfKey } from '@/editor/navigation'
import type { EditorPlaceProps } from '@/editor/tabs'
import { useEditCommand } from '@/editor/useEditCommand'
@@ -37,6 +39,8 @@ export interface PropertiesPanelProps {
dispatch: Dispatch
context: CommitContext
navigate: EditorPlaceProps['navigate']
+ /** Clears the selection: the overview shows again. */
+ onShowAll: () => void
/** Put before every id, for a twin of the panel that lives beside another one. */
idPrefix?: string
}
@@ -60,6 +64,7 @@ export default function PropertiesPanel(props: PropertiesPanelProps) {
data-testid="annotation-properties"
className="space-y-4 rounded-xl border border-[var(--color-border)] p-4"
>
+
void }) {
+ const t = useT()
+ return (
+ {
+ flushSync(onShowAll)
+ focusRow({ kind: 'annotation', id })
+ }}
+ >
+ {t('editor.annotations.show_all')}
+
+ )
+}
+
function GeometrySection(props: PropertiesPanelProps) {
const t = useT()
const { annotation, readOnly, geometryLocked } = props
diff --git a/apps/app/src/components/editor/tabs/AnnotationsTab.tsx b/apps/app/src/components/editor/tabs/AnnotationsTab.tsx
index a68c8772..ccdd8851 100644
--- a/apps/app/src/components/editor/tabs/AnnotationsTab.tsx
+++ b/apps/app/src/components/editor/tabs/AnnotationsTab.tsx
@@ -1,9 +1,7 @@
import { useEffect, useState } from 'react'
import type { AnatomicalSheetDocument } from '@faunosteo/core-wasm/types'
import CatalogueCanvas from '@/components/catalogue/CatalogueCanvas'
-import AnnotationList, {
- annotationName,
-} from '@/components/editor/annotations/AnnotationList'
+import { annotationName } from '@/components/editor/annotations/AnnotationList'
import EditableAnnotations from '@/components/editor/annotations/EditableAnnotations'
import OverviewPanel from '@/components/editor/annotations/OverviewPanel'
import PropertiesPanel from '@/components/editor/annotations/PropertiesPanel'
@@ -166,7 +164,7 @@ function ReadOnlyAnnotations({
const selected = model.annotations.find((a) => a.id === selectedId)
if (!preview || !view) return null
return (
-
+
{selected ? (
undefined}
context={{ t: (key) => key, locale }}
navigate={navigate}
+ onShowAll={() => setSelectedId(null)}
/>
) : (
)}
diff --git a/apps/app/src/editor/annotations/overview.ts b/apps/app/src/editor/annotations/overview.ts
index 5a8a5d9e..ef1823db 100644
--- a/apps/app/src/editor/annotations/overview.ts
+++ b/apps/app/src/editor/annotations/overview.ts
@@ -1,5 +1,10 @@
import { useMemo } from 'react'
-import type { AnatomicalSheetDocument } from '@faunosteo/core-wasm/types'
+import type {
+ AnatomicalSheetDocument,
+ Annotation,
+ AnnotationCategory,
+} from '@faunosteo/core-wasm/types'
+import { folded } from '@/catalogue/useCatalogue'
/**
* What the overview panel counts, read once per parsed document: the annotations of each
@@ -24,3 +29,36 @@ export function useOverviewCounts(
): OverviewCounts {
return useMemo(() => overviewCounts(doc), [doc])
}
+
+/** The annotations of one category in the shown view; `category` is null for strays. */
+export interface AnnotationGroup {
+ category: AnnotationCategory | null
+ annotations: Annotation[]
+}
+
+/**
+ * The annotations of a view grouped by category in document order, keeping those whose
+ * displayed name contains `term` (case and accents ignored). A group « Sans catégorie »
+ * exists only when an annotation names a category the document does not hold.
+ */
+export function groupAnnotations(
+ doc: AnatomicalSheetDocument,
+ viewId: string,
+ term: string,
+ nameOf: (annotation: Annotation) => string,
+): AnnotationGroup[] {
+ const wanted = folded(term.trim())
+ const shown = doc.annotations.filter(
+ (a) => a.view_id === viewId && folded(nameOf(a)).includes(wanted),
+ )
+ const known = new Set(doc.categories.map((category) => category.id))
+ const groups: AnnotationGroup[] = doc.categories.map((category) => ({
+ category,
+ annotations: shown.filter((a) => a.category_id === category.id),
+ }))
+ groups.push({
+ category: null,
+ annotations: shown.filter((a) => !known.has(a.category_id)),
+ })
+ return groups.filter((group) => group.annotations.length > 0)
+}
diff --git a/apps/app/src/i18n/en.ts b/apps/app/src/i18n/en.ts
index 9703cab3..ffbd4364 100644
--- a/apps/app/src/i18n/en.ts
+++ b/apps/app/src/i18n/en.ts
@@ -1221,6 +1221,10 @@ export const en: Dict = {
'editor.overview.see_categories': 'See the categories',
'editor.overview.regions_one': 'Vertebral regions ({count} region)',
'editor.overview.regions_other': 'Vertebral regions ({count} regions)',
+ 'editor.overview.filter': 'Filter by name',
+ 'editor.overview.uncategorised': 'No category',
+ 'editor.overview.no_match': 'No annotation matches.',
+ 'editor.annotations.show_all': 'All annotations',
'editor.references.open': 'References',
'editor.references.close': 'Close the references',
'editor.draft.loading': 'Loading the draft…',
diff --git a/apps/app/src/i18n/fr.ts b/apps/app/src/i18n/fr.ts
index 0b62d610..6849e8bc 100644
--- a/apps/app/src/i18n/fr.ts
+++ b/apps/app/src/i18n/fr.ts
@@ -1252,6 +1252,10 @@ export const fr: Dict = {
'editor.overview.see_categories': 'Voir les catégories',
'editor.overview.regions_one': 'Régions vertébrales ({count} région)',
'editor.overview.regions_other': 'Régions vertébrales ({count} régions)',
+ 'editor.overview.filter': 'Filtrer par nom',
+ 'editor.overview.uncategorised': 'Sans catégorie',
+ 'editor.overview.no_match': 'Aucune annotation ne correspond.',
+ 'editor.annotations.show_all': 'Toutes les annotations',
'editor.references.open': 'Références',
'editor.references.close': 'Fermer les références',
'editor.draft.loading': 'Chargement du brouillon…',
diff --git a/apps/app/tests/unit/editor-overview.test.tsx b/apps/app/tests/unit/editor-overview.test.tsx
new file mode 100644
index 00000000..cab04c3f
--- /dev/null
+++ b/apps/app/tests/unit/editor-overview.test.tsx
@@ -0,0 +1,132 @@
+/** V1-2.6 U1 Lot C: board 01's « Annotations de la vue » card, in edit and read-only. */
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, render, screen, waitFor, within } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import type { Annotation } from '@faunosteo/core-wasm/types'
+import AnnotationsTab from '@/components/editor/tabs/AnnotationsTab'
+import { useLocaleStore } from '@/state/localeStore'
+import { drawnText, insert, point } from '../helpers/editorFixtures'
+import { openReady, resetStore } from '../helpers/editorHarness'
+
+vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
+vi.mock('@faunosteo/supabase', async (orig) => ({
+ ...(await orig()),
+ getSheetVersion: vi.fn(),
+ downloadSheetDrawing: vi.fn(),
+ saveSheetDraft: vi.fn(),
+ getOfficialSheetAdmin: vi.fn(),
+ submitSheetReview: vi.fn(),
+}))
+
+const props = {
+ readOnly: false,
+ navigate: vi.fn(),
+ reloadSheet: vi.fn(),
+ section: 'drawing' as const,
+ visited: ['drawing'] as const,
+ onOpenSection: vi.fn(),
+ onBack: vi.fn(),
+}
+
+const named = (id: string, fr: string, category: string, view = 'view-main') => {
+ const base = point(id, 50, 50, 5, view).value as Annotation
+ return {
+ kind: 'annotation',
+ value: { ...base, category_id: category, name: { fr, en: fr } },
+ } as const
+}
+
+/** Two categories (b declared after a); the first annotation sits in b. */
+function sheet(): string {
+ let text = insert(drawnText(), {
+ kind: 'category',
+ value: { id: 'cat-b', name: { fr: 'Os', en: 'Bone' }, color: '#aa0000' },
+ })
+ text = insert(text, named('a1', 'Épaule', 'cat-b'))
+ text = insert(text, named('a2', 'Genou', 'cat-a'))
+ return insert(text, {
+ kind: 'view',
+ value: {
+ kind: 'detail',
+ id: 'view-det',
+ name: { fr: 'Tête', en: 'Head' },
+ svg_asset_id: null,
+ view_box: { min_x: 10, min_y: 10, width: 80, height: 80 },
+ parent_view_id: 'view-main',
+ },
+ })
+}
+
+beforeEach(() => useLocaleStore.setState({ locale: 'fr' }))
+afterEach(() => {
+ cleanup()
+ resetStore()
+})
+
+async function mount(readOnly = false) {
+ await openReady({ text: sheet() })
+ render( )
+ await screen.findByRole('list', { name: 'Annotations de la vue' })
+}
+
+const card = () => screen.getByRole('list', { name: 'Annotations de la vue' })
+const rows = () => within(card()).getAllByRole('button')
+
+describe.each([
+ ['edit', false],
+ ['read-only', true],
+])('the annotation card (%s)', (_mode, readOnly) => {
+ it('groups the rows by category in document order, with a count per group', async () => {
+ await mount(readOnly)
+ const titles = within(card())
+ .getAllByRole('listitem')
+ .filter((item) => item.querySelector('ul'))
+ .map((item) => item.querySelector('p')?.textContent)
+ expect(titles).toEqual(['N1', 'Os1'])
+ expect(rows().map((b) => b.textContent)).toEqual([
+ expect.stringContaining('Genou'),
+ expect.stringContaining('Épaule'),
+ ])
+ })
+
+ it('filters on the displayed name, ignoring case and accents', async () => {
+ await mount(readOnly)
+ const user = userEvent.setup()
+ await user.type(screen.getByRole('searchbox', { name: 'Filtrer par nom' }), 'EPAULE')
+ expect(rows()).toHaveLength(1)
+ expect(rows()[0]).toHaveTextContent('Épaule')
+ await user.type(screen.getByRole('searchbox'), 'zzz')
+ expect(screen.getByText('Aucune annotation ne correspond.')).toBeInTheDocument()
+ })
+
+ it('a row selects the annotation; « Toutes les annotations » returns with focus on its row', async () => {
+ await mount(readOnly)
+ const user = userEvent.setup()
+ await user.click(rows()[1])
+ expect(await screen.findByTestId('annotation-properties')).toBeVisible()
+ await user.click(screen.getByRole('button', { name: 'Toutes les annotations' }))
+ expect(screen.getByTestId('annotation-overview')).toBeVisible()
+ await waitFor(() => expect(document.activeElement).toBe(rows()[1]))
+ })
+
+ it('a view row switches the canvas view', async () => {
+ await mount(readOnly)
+ const user = userEvent.setup()
+ const views = screen.getByRole('region', { name: 'Aperçu de la fiche' })
+ await user.click(within(views).getByRole('button', { name: /^Tête/ }))
+ expect(within(views).getByRole('button', { name: /^Tête/ })).toHaveAttribute(
+ 'aria-current',
+ 'true',
+ )
+ expect(screen.getByText('Aucune annotation dans cette vue.')).toBeInTheDocument()
+ })
+})
+
+describe('the side column', () => {
+ it('sits beside the canvas from lg (1 024 px), not xl', async () => {
+ await mount()
+ const grid = screen.getByTestId('annotation-overview').closest('.grid')
+ expect(grid?.className).toContain('lg:grid-cols-[minmax(0,1fr)_22rem]')
+ expect(grid?.className).not.toContain('xl:')
+ })
+})