Skip to content

Commit 46b7488

Browse files
claudegary149
authored andcommitted
Add streaming haptic burst on first token arrival
Adds a multi-vibration "machine starting up" haptic pattern that fires once when the first token of a response starts streaming in, similar to ChatGPT's behavior. Uses navigator.vibrate([50, 30, 50, 30, 80]) for three quick pulses that feel fun and responsive. https://claude.ai/code/session_01Ewm55pEVHLfFzPHxmMyecw
1 parent d806f98 commit 46b7488

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/lib/utils/haptics.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ export function error() {
6262
export function selection() {
6363
fire("selection");
6464
}
65+
66+
/** Stream start burst — multiple short vibrations for a "machine starting up" feel. */
67+
export function streamStart(): void {
68+
if (!enabled || !browser) return;
69+
if (typeof navigator.vibrate !== "function") return;
70+
// Three quick pulses: two short taps + a slightly longer finish
71+
navigator.vibrate([50, 30, 50, 30, 80]);
72+
}

src/routes/conversation/[id]/+page.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import { updateDebouncer } from "$lib/utils/updates.js";
2929
import SubscribeModal from "$lib/components/SubscribeModal.svelte";
3030
import { loading } from "$lib/stores/loading.js";
31+
import { streamStart } from "$lib/utils/haptics";
3132
import { requireAuthUser } from "$lib/utils/auth.js";
3233
import { isConversationGenerationActive } from "$lib/utils/generationState";
3334
@@ -320,6 +321,9 @@
320321
) {
321322
flushBuffer(currentTime);
322323
}
324+
if (pending) {
325+
streamStart();
326+
}
323327
pending = false;
324328
} else if (update.type === MessageUpdateType.FinalAnswer) {
325329
// Mirror server-side merge behavior so the UI reflects the

0 commit comments

Comments
 (0)