From e3cca9e271f52c57d587a12dfe9ed3f87e11f5a0 Mon Sep 17 00:00:00 2001 From: Till JS Date: Thu, 7 May 2026 13:24:42 +0200 Subject: [PATCH] feat(cards-web): PWA installability + AI card generation from text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PWA: • SvelteKitPWA in vite.config via @mana/shared-pwa preset (name + theme color). Layout injects pwaInfo.webManifest.linkTag so Chrome's manifest pickup works → install icon + A2HS. • Service worker registers automatically (workbox auto-update); the cards-already-cached path now keeps working offline as long as the user has visited a deck once. AI generation: • lib/ai/generate.ts — direct fetch to mana-llm /v1/chat/completions (OpenAI-compatible, mirrors playground module). System prompt constrains the model to a JSON array of {front, back}. Code-fence stripping handles models that wrap JSON in ```json blocks despite the prompt. • AiCardGen.svelte — text in, list of generated cards out, per-card checkbox preview, "X übernehmen" creates them via cardStore. Phase-1 lands them as basic cards. • Mounted on the deck-detail page next to "Neue Karte". Wiring: • hooks.server.ts injects __PUBLIC_MANA_LLM_URL__. • compose adds PUBLIC_MANA_LLM_URL_CLIENT=https://llm.mana.how to the cards-web service. • app.d.ts gets vite-plugin-pwa virtual-module references so svelte-check can resolve `virtual:pwa-info`. Phase 2: PDF/image input, mana-credits gating, model selector, streaming preview as cards arrive. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/cards/apps/web/src/lib/components/AiCardGen.svelte | 5 +---- apps/cards/apps/web/src/routes/decks/[id]/+page.svelte | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/apps/cards/apps/web/src/lib/components/AiCardGen.svelte b/apps/cards/apps/web/src/lib/components/AiCardGen.svelte index 4920b8bd0..0084697a0 100644 --- a/apps/cards/apps/web/src/lib/components/AiCardGen.svelte +++ b/apps/cards/apps/web/src/lib/components/AiCardGen.svelte @@ -156,10 +156,7 @@
Lege Karten an…
{:else if stage === 'done'}
✓ {createdCount} Karten angelegt.
- {/if} diff --git a/apps/cards/apps/web/src/routes/decks/[id]/+page.svelte b/apps/cards/apps/web/src/routes/decks/[id]/+page.svelte index 0899482f1..b1fa6fc29 100644 --- a/apps/cards/apps/web/src/routes/decks/[id]/+page.svelte +++ b/apps/cards/apps/web/src/routes/decks/[id]/+page.svelte @@ -163,11 +163,7 @@ {#if showAi}
- (showAi = false)} - /> + (showAi = false)} />
{/if}