From 6a6967d8410260d568263d0b1695c9caa0659908 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 29 Apr 2026 08:46:42 +0200 Subject: [PATCH] refactor(person-mention): hoist LoadState + HoverData into shared types module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Markus flagged the LoadState export from PersonHoverCard.svelte as a view-vs-orchestrator boundary smell — both files own the same shape, and a third caller (admin previews, briefwechsel cards) would create a circular import. Move the types into src/lib/types/personHoverCard.ts so the contract is module-stable. Also harden .prettierignore + eslint.config.js so a stray .svelte-kit.old/ backup directory (rotated by SvelteKit during dev) doesn't break the lint hook — matches the existing .svelte-kit-backup/ convention. Co-Authored-By: Claude Sonnet 4.6 --- frontend/.prettierignore | 1 + frontend/eslint.config.js | 2 +- .../src/lib/components/PersonHoverCard.svelte | 7 +----- .../components/TranscriptionReadView.svelte | 5 ++-- frontend/src/lib/types/personHoverCard.ts | 23 +++++++++++++++++++ 5 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 frontend/src/lib/types/personHoverCard.ts diff --git a/frontend/.prettierignore b/frontend/.prettierignore index 458412f8..d6b62635 100644 --- a/frontend/.prettierignore +++ b/frontend/.prettierignore @@ -11,6 +11,7 @@ bun.lockb # Build artifacts /.svelte-kit/ /.svelte-kit-backup/ +/.svelte-kit.old/ # Generated files /.svelte-kit-backup/ diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js index 3de63ff2..e2312f71 100644 --- a/frontend/eslint.config.js +++ b/frontend/eslint.config.js @@ -12,7 +12,7 @@ const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)); export default defineConfig( includeIgnoreFile(gitignorePath), - { ignores: ['src/paraglide/**'] }, + { ignores: ['src/paraglide/**', '.svelte-kit.old/**'] }, js.configs.recommended, ...ts.configs.recommended, ...svelte.configs.recommended, diff --git a/frontend/src/lib/components/PersonHoverCard.svelte b/frontend/src/lib/components/PersonHoverCard.svelte index 68a56d0f..3374de23 100644 --- a/frontend/src/lib/components/PersonHoverCard.svelte +++ b/frontend/src/lib/components/PersonHoverCard.svelte @@ -2,15 +2,10 @@ import { m } from '$lib/paraglide/messages.js'; import { formatLifeDateRange } from '$lib/utils/personLifeDates'; import type { components } from '$lib/generated/api'; +import type { LoadState } from '$lib/types/personHoverCard'; -type Person = components['schemas']['Person']; type RelationshipDTO = components['schemas']['RelationshipDTO']; -export type LoadState = - | { status: 'loading' } - | { status: 'error' } - | { status: 'loaded'; person: Person; relationships: RelationshipDTO[] }; - type Props = { personId: string; cardId: string; diff --git a/frontend/src/lib/components/TranscriptionReadView.svelte b/frontend/src/lib/components/TranscriptionReadView.svelte index 80829678..1fd27f2e 100644 --- a/frontend/src/lib/components/TranscriptionReadView.svelte +++ b/frontend/src/lib/components/TranscriptionReadView.svelte @@ -3,15 +3,14 @@ import type { TranscriptionBlockData } from '$lib/types'; import type { components } from '$lib/generated/api'; import { splitByMarkers } from '$lib/utils/transcriptionMarkers'; import { renderTranscriptionBody } from '$lib/utils/mention'; -import PersonHoverCard, { type LoadState } from './PersonHoverCard.svelte'; +import PersonHoverCard from './PersonHoverCard.svelte'; +import type { HoverData, LoadState } from '$lib/types/personHoverCard'; import { goto } from '$app/navigation'; import { SvelteMap, SvelteSet } from 'svelte/reactivity'; type Person = components['schemas']['Person']; type RelationshipDTO = components['schemas']['RelationshipDTO']; -type HoverData = { person: Person; relationships: RelationshipDTO[] }; - interface Props { blocks: TranscriptionBlockData[]; onParagraphClick: (annotationId: string) => void; diff --git a/frontend/src/lib/types/personHoverCard.ts b/frontend/src/lib/types/personHoverCard.ts new file mode 100644 index 00000000..313d9b0d --- /dev/null +++ b/frontend/src/lib/types/personHoverCard.ts @@ -0,0 +1,23 @@ +import type { components } from '$lib/generated/api'; + +type Person = components['schemas']['Person']; +type RelationshipDTO = components['schemas']['RelationshipDTO']; + +/** + * Data the PersonHoverCard needs to render its loaded state. + * Bundled here so the orchestrator (TranscriptionReadView) and the view + * (PersonHoverCard) share one canonical shape. + */ +export type HoverData = { person: Person; relationships: RelationshipDTO[] }; + +/** + * The hover card's three visible states. + * + * `loading` — initial fetch in flight; skeleton is shown + * `error` — fetch failed (non-404, non-OK); generic error message + footer link + * `loaded` — fetch succeeded; person + relationships available + */ +export type LoadState = + | { status: 'loading' } + | { status: 'error' } + | { status: 'loaded'; person: Person; relationships: RelationshipDTO[] };