Andrew commited on
Commit
a374d74
·
1 Parent(s): 48df71b

(fix) Introduce ThinkingPlaceholder to smooth streaming UI

Browse files
src/lib/components/chat/ThinkingPlaceholder.svelte ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { onDestroy } from "svelte";
3
+
4
+ let step = $state(0);
5
+
6
+ const interval = setInterval(() => {
7
+ step = (step + 1) % 4;
8
+ }, 450);
9
+
10
+ onDestroy(() => {
11
+ clearInterval(interval);
12
+ });
13
+
14
+ const label = "Thinking";
15
+
16
+ let dots = $derived(".".repeat(step));
17
+ </script>
18
+
19
+ <div class="thinking-placeholder" role="status" aria-live="polite">
20
+ <span class="label">{label}{dots}</span>
21
+ </div>
22
+
23
+ <style>
24
+ .thinking-placeholder {
25
+ display: inline-flex;
26
+ align-items: center;
27
+ gap: 0.5rem;
28
+ border-radius: 0.75rem;
29
+ border: 1px solid rgba(209, 213, 219, 0.7);
30
+ background: linear-gradient(135deg, rgba(249, 250, 251, 0.75), rgba(243, 244, 246, 0.65));
31
+ padding: 0.75rem 1rem;
32
+ color: #6b7280;
33
+ font-size: 0.9rem;
34
+ font-weight: 500;
35
+ letter-spacing: 0.01em;
36
+ min-width: 9rem;
37
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
38
+ }
39
+
40
+ .label {
41
+ font-family: var(--font-sans, inherit);
42
+ }
43
+
44
+ :global(.dark) .thinking-placeholder {
45
+ border-color: rgba(75, 85, 99, 0.7);
46
+ background: rgba(31, 41, 55, 0.55);
47
+ color: #9ca3af;
48
+ box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.1);
49
+ }
50
+ </style>
51
+