From 740cb3e1e66f44563f22080c41a9deb82d5fdf5b Mon Sep 17 00:00:00 2001 From: robin Date: Sun, 5 Oct 2025 17:00:46 +0000 Subject: [PATCH] optimized webchat --- .../lib/components/chatbotDemo/Chatbot.svelte | 67 ++++++++- .../components/chatbotDemo/InputRow.svelte | 133 ++++++++++++++-- .../components/chatbotDemo/Messages.svelte | 142 ++++++++++++++++-- .../staticPageRows/VoicebotPreview.svelte | 61 +++----- .../voicebotDemo/voicebotPreviewController.ts | 2 +- .../src/lib/components/widgets/Label.svelte | 66 ++++++++ 6 files changed, 397 insertions(+), 74 deletions(-) create mode 100644 frontend/src/lib/components/widgets/Label.svelte diff --git a/frontend/src/lib/components/chatbotDemo/Chatbot.svelte b/frontend/src/lib/components/chatbotDemo/Chatbot.svelte index abe0af4..6445109 100644 --- a/frontend/src/lib/components/chatbotDemo/Chatbot.svelte +++ b/frontend/src/lib/components/chatbotDemo/Chatbot.svelte @@ -1,23 +1,80 @@
- - + +
diff --git a/frontend/src/lib/components/chatbotDemo/Messages.svelte b/frontend/src/lib/components/chatbotDemo/Messages.svelte index 64ed28f..5b1f13a 100644 --- a/frontend/src/lib/components/chatbotDemo/Messages.svelte +++ b/frontend/src/lib/components/chatbotDemo/Messages.svelte @@ -1,23 +1,141 @@ -
- {#each chat.messages as message, idx (idx)} -
- {@html message.content} -
+
+ {#each messages as message, idx (idx)} + {#if message.role === "assistant"} +
+
+ {@html message.content || ""} +
+
+ {:else if message.role === "user"} +
+
+ {@html message.content} +
+
+ {:else} +
+
+ {@html message.content} +
+
+ {/if} {/each} + {#if streaming} +
+
+ + + +
+
+ {/if}
diff --git a/frontend/src/lib/components/staticPageRows/VoicebotPreview.svelte b/frontend/src/lib/components/staticPageRows/VoicebotPreview.svelte index 8cdc3bc..6b7d1e4 100644 --- a/frontend/src/lib/components/staticPageRows/VoicebotPreview.svelte +++ b/frontend/src/lib/components/staticPageRows/VoicebotPreview.svelte @@ -4,6 +4,7 @@ import ProductCategoryFrame from "../widgets/ProductCategoryFrame.svelte" import CrinkledSection from "../CrinkledSection.svelte" import { createVoicebotPreviewController } from "../voicebotDemo/voicebotPreviewController" + import Label from "../widgets/Label.svelte" const voiceProperties: Array<{ title: string; icon: string; color: string }> = [ { @@ -65,22 +66,23 @@ aria-pressed={$status === "connected"} aria-busy={$status === "connecting"} aria-label="Voicebot Demo starten" - on:click={() => void toggle()} - on:keydown={handleKeydown} + onclick={() => void toggle()} + onkeydown={handleKeydown} > Kontextwerk is calling
-
- {$statusHint} -
+ {/snippet} {/snippet} @@ -111,40 +113,6 @@ user-select: none; } - .voice-overlay { - position: absolute; - bottom: 1.2rem; - left: 50%; - transform: translateX(-50%); - padding: 0.45rem 1.1rem; - border-radius: 999px; - background: rgba(13, 12, 12, 0.8); - color: white; - font-size: 0.8rem; - font-weight: 500; - letter-spacing: 0.01em; - display: flex; - align-items: center; - gap: 0.4rem; - pointer-events: none; - white-space: nowrap; - transition: - background 0.2s ease, - color 0.2s ease; - } - - .voice-overlay[data-status="connected"] { - background: rgba(76, 175, 80, 0.85); - } - - .voice-overlay[data-status="connecting"] { - background: rgba(255, 152, 0, 0.85); - } - - .voice-overlay[data-status="error"] { - background: rgba(235, 87, 87, 0.9); - } - &:hover { transform: translateY(-4px); } @@ -154,4 +122,11 @@ outline-offset: 4px; } } + .voice-status { + width: 100%; + display: flex; + align-items: center; + justify-content: center; + margin-top: 1.2rem; + } diff --git a/frontend/src/lib/components/voicebotDemo/voicebotPreviewController.ts b/frontend/src/lib/components/voicebotDemo/voicebotPreviewController.ts index 068ff1e..acc0733 100644 --- a/frontend/src/lib/components/voicebotDemo/voicebotPreviewController.ts +++ b/frontend/src/lib/components/voicebotDemo/voicebotPreviewController.ts @@ -37,7 +37,7 @@ export const createVoicebotPreviewController = (): VoicebotPreviewController => const statusHint = derived([statusStore, errorStore], ([$status, $error]) => { switch ($status) { case "idle": - return "Tippen, um die Voice-Demo zu starten" + return "Tippen, um die Demo zu starten" case "connecting": return "Verbindung wird aufgebaut …" case "connected": diff --git a/frontend/src/lib/components/widgets/Label.svelte b/frontend/src/lib/components/widgets/Label.svelte new file mode 100644 index 0000000..39d1e71 --- /dev/null +++ b/frontend/src/lib/components/widgets/Label.svelte @@ -0,0 +1,66 @@ + + + + crinkle + + {label} + + crinkle + + +