From 2e9ec76d60ab085e011d97753b33f61f404776bb Mon Sep 17 00:00:00 2001 From: Till JS Date: Sat, 25 Apr 2026 12:31:29 +0200 Subject: [PATCH] feat(writing): token-usage in version history + draft drag-source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two small UX wins. Version-history shows generation cost - VersionHistory takes a generations[] prop (DetailView already pulls one via useGenerationsForDraft) and looks up each AI version's linked Generation by id. When found, renders a monospace cost line under the version's wordcount: "1234 → 567 Tokens · 1.4s · ollama/gemma3:4b". - Skips silently when the generation row isn't there (e.g. older drafts before the field was tracked, or a generation that was reverted). - Lets the user see what each draft cost without digging into the Workbench audit timeline. Drafts as drag source - DraftCard wires `use:dragSource` with type='draft' + a payload carrying id / title / kind / content / wordCount / topic. Cards in the Writing list view are now drag origins for any drop target that declares acceptsDropFrom: ['draft']. - App-registry entry for 'writing' gets the matching collection / paramKey / dragType / getDisplayData fields so the workbench layer treats drafts as full first-class drag-citizens (sibling navigation, display fallbacks). - @mana/shared-ui DragType union extended with 'draft'. No drop-target wiring yet — articles' acceptsDropFrom can pick up 'draft' as a follow-up, but the M10 ExportMenu's "Als Artikel speichern" already covers that flow from the editor side. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../apps/web/src/lib/app-registry/apps.ts | 10 +++++ .../writing/components/DraftCard.svelte | 18 ++++++++- .../writing/components/VersionHistory.svelte | 40 ++++++++++++++++++- .../modules/writing/views/DetailView.svelte | 1 + packages/shared-ui/src/dnd/types.ts | 3 +- 5 files changed, 68 insertions(+), 4 deletions(-) diff --git a/apps/mana/apps/web/src/lib/app-registry/apps.ts b/apps/mana/apps/web/src/lib/app-registry/apps.ts index 35455147e..a43eb7685 100644 --- a/apps/mana/apps/web/src/lib/app-registry/apps.ts +++ b/apps/mana/apps/web/src/lib/app-registry/apps.ts @@ -1354,6 +1354,16 @@ registerApp({ ), }, ], + collection: 'writingDrafts', + paramKey: 'draftId', + dragType: 'draft', + getDisplayData: (item) => ({ + title: (item.title as string) || (item.topic as string) || 'Draft', + subtitle: + typeof item.wordCount === 'number' && item.wordCount > 0 + ? `${item.wordCount} Wörter` + : undefined, + }), }); registerApp({ diff --git a/apps/mana/apps/web/src/lib/modules/writing/components/DraftCard.svelte b/apps/mana/apps/web/src/lib/modules/writing/components/DraftCard.svelte index bf79db267..2d79fa56a 100644 --- a/apps/mana/apps/web/src/lib/modules/writing/components/DraftCard.svelte +++ b/apps/mana/apps/web/src/lib/modules/writing/components/DraftCard.svelte @@ -1,5 +1,6 @@ -