Summary
Rework the plant identification view (/pflanzen/identifikation) so that the identification history/overview makes it visible when a plant instance was created from an identification result, and exposes that instance as a clickable linked element leading to its detail page.
Today the link between an identification result and the plant instance it produced is purely ephemeral in the frontend: after a suggestion is selected, PlantInstanceCreateDialog creates the instance and handlePlantCreated navigates to /pflanzen/plant-instances/{key}. Nothing is persisted back onto the identification record, so the history list cannot show whether an entry led to an instance, nor link to it.
Current state
- Route + page:
src/frontend/src/routes/AppRoutes.tsx:555 → src/frontend/src/pages/ki-recognition/PlantIdentificationPage.tsx
- History/overview list is implemented inline in the page:
PlantIdentificationPage.tsx:126-176 (identification-history-list / identification-history-item)
- Data flow: Redux
identificationSlice.ts (fetchIdentificationHistory) → API src/frontend/src/api/endpoints/identification.ts:96 → GET /t/{slug}/identification/history
- Instance detail route pattern:
/pflanzen/plant-instances/:key (AppRoutes.tsx:538)
- No link field exists yet on the identification record:
- Backend model
src/backend/app/domain/models/identification.py:36-54 (IdentificationRequest) — no plant_instance_key
- Response DTO
src/backend/app/api/v1/recognition/schemas.py:87-97 (HistoryEntryResponse) — no instance field
- Frontend type
src/frontend/src/api/types.ts:4776-4785 (IdentificationHistoryEntry) — no instance field
- (Note:
plant_instance_key at types.ts:4812 belongs to PestDetectionResult, unrelated to identification.)
Proposed changes
Backend
- Add a nullable
plant_instance_key (reference to the created plant instance) to the IdentificationRequest model and HistoryEntryResponse DTO.
- Persist this reference when a plant instance is created from an identification result (link the identification record to the newly created instance). Provide a migration for existing records (backfill left null).
- Ensure tenant scoping / authorization is respected for the linked instance.
Frontend
- Extend
IdentificationHistoryEntry with the optional plant_instance_key.
- In the history/overview list (
PlantIdentificationPage.tsx:126-176), when an entry has a linked instance:
- Visually indicate that an instance was created from this identification (e.g. status chip / icon).
- Render the instance as a clickable linked element navigating to
/pflanzen/plant-instances/{key}.
- When no instance was created, keep the existing behaviour (offer to create one).
i18n
- Add DE/EN keys under
pages.plantIdentification (.../de/translation.json:810, .../en/translation.json:810), e.g. historyInstanceCreated, historyOpenInstance. DE is canonical, EN mirrored.
Acceptance criteria
Notes
- Follow the 5-layer backend architecture (NFR-001) and the versioned migration framework for the new field.
- Frontend: custom hooks returning objects/arrays must be memoised; enum/i18n conventions apply.
Summary
Rework the plant identification view (
/pflanzen/identifikation) so that the identification history/overview makes it visible when a plant instance was created from an identification result, and exposes that instance as a clickable linked element leading to its detail page.Today the link between an identification result and the plant instance it produced is purely ephemeral in the frontend: after a suggestion is selected,
PlantInstanceCreateDialogcreates the instance andhandlePlantCreatednavigates to/pflanzen/plant-instances/{key}. Nothing is persisted back onto the identification record, so the history list cannot show whether an entry led to an instance, nor link to it.Current state
src/frontend/src/routes/AppRoutes.tsx:555→src/frontend/src/pages/ki-recognition/PlantIdentificationPage.tsxPlantIdentificationPage.tsx:126-176(identification-history-list/identification-history-item)identificationSlice.ts(fetchIdentificationHistory) → APIsrc/frontend/src/api/endpoints/identification.ts:96→GET /t/{slug}/identification/history/pflanzen/plant-instances/:key(AppRoutes.tsx:538)src/backend/app/domain/models/identification.py:36-54(IdentificationRequest) — noplant_instance_keysrc/backend/app/api/v1/recognition/schemas.py:87-97(HistoryEntryResponse) — no instance fieldsrc/frontend/src/api/types.ts:4776-4785(IdentificationHistoryEntry) — no instance fieldplant_instance_keyattypes.ts:4812belongs toPestDetectionResult, unrelated to identification.)Proposed changes
Backend
plant_instance_key(reference to the created plant instance) to theIdentificationRequestmodel andHistoryEntryResponseDTO.Frontend
IdentificationHistoryEntrywith the optionalplant_instance_key.PlantIdentificationPage.tsx:126-176), when an entry has a linked instance:/pflanzen/plant-instances/{key}.i18n
pages.plantIdentification(.../de/translation.json:810,.../en/translation.json:810), e.g.historyInstanceCreated,historyOpenInstance. DE is canonical, EN mirrored.Acceptance criteria
/pflanzen/plant-instances/{key}).Notes