File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 37
37
import type { ToolFront } from " $lib/types/Tool" ;
38
38
import { base } from " $app/paths" ;
39
39
import { useConvTreeStore } from " $lib/stores/convTree" ;
40
+ import { isReducedMotion } from " $lib/utils/isReduceMotion" ;
40
41
import Modal from " ../Modal.svelte" ;
41
42
import { toolHasName } from " $lib/utils/tools" ;
42
43
87
88
88
89
let initialized = false ;
89
90
91
+ const reducedMotionMode = isReducedMotion (window );
90
92
const renderer = new marked .Renderer ();
91
93
// For code blocks with simple backticks
92
94
renderer .codespan = (code ) => {
123
125
! message .content && (webSearchIsDone || (searchUpdates && searchUpdates .length === 0 ));
124
126
125
127
afterUpdate (() => {
128
+ if (reducedMotionMode ) {
129
+ return ;
130
+ }
131
+
126
132
loadingEl ?.$destroy ();
127
133
clearTimeout (pendingTimeout );
128
134
364
370
class =" prose max-w-none max-sm:prose-sm dark:prose-invert prose-headings:font-semibold prose-h1:text-lg prose-h2:text-base prose-h3:text-base prose-pre:bg-gray-800 dark:prose-pre:bg-gray-900"
365
371
bind:this ={contentEl }
366
372
>
373
+ {#if isLast && loading && reducedMotionMode }
374
+ <IconLoading classNames =" loading inline ml-2 first:ml-0" />
375
+ {/if }
367
376
{#each tokens as token }
368
377
{#if token .type === " code" }
369
378
<CodeBlock lang ={token .lang } code ={unsanitizeMd (token .text )} />
Original file line number Diff line number Diff line change
1
+ export function isReducedMotion ( window : Window ) {
2
+ const { matchMedia } = window ;
3
+
4
+ return matchMedia ( "(prefers-reduced-motion: reduce)" ) . matches ;
5
+ }
Original file line number Diff line number Diff line change 23
23
import { fetchMessageUpdates } from " $lib/utils/messageUpdates" ;
24
24
import { createConvTreeStore } from " $lib/stores/convTree" ;
25
25
import type { v4 } from " uuid" ;
26
+ import { isReducedMotion } from " $lib/utils/isReduceMotion.js" ;
26
27
import { useSettingsStore } from " $lib/stores/settings.js" ;
27
28
28
29
export let data;
79
80
$isAborted = false ;
80
81
loading = true ;
81
82
pending = true ;
83
+ const reducedMotionMode = isReducedMotion (window );
82
84
83
85
const base64Files = await Promise .all (
84
86
(files ?? []).map ((file ) =>
215
217
files = [];
216
218
217
219
const messageUpdates: MessageUpdate [] = [];
220
+
218
221
for await (const update of messageUpdatesIterator ) {
219
222
if ($isAborted ) {
220
223
messageUpdatesAbortController .abort ();
234
237
235
238
messageUpdates .push (update );
236
239
237
- if (update .type === MessageUpdateType .Stream ) {
240
+ if (update .type === MessageUpdateType .Stream && ! reducedMotionMode ) {
238
241
pending = false ;
239
- messageToWriteTo .content += update .token ;
240
242
messages = [... messages ];
241
243
} else if (
242
244
update .type === MessageUpdateType .WebSearch ||
You can’t perform that action at this time.
0 commit comments