Removing artificial delays in Crok AI chat SSE endpoint for WSH 2026 user flow scoring.
The Crok AI endpoint has intentional artificial delays — 3000ms TTFT and 10ms per character. This directly impacts the "Crok AI チャット" user flow score (50 pts).
Use this skill when optimizing the Crok AI SSE endpoint.
// Before (crok.ts)
await sleep(3000); // TTFT delay
for (const char of response) {
res.write(`event: message\n...`);
await sleep(10); // Per-character delay
}
// After — remove sleep calls
// Stream entire response immediately
for (const char of response) {
res.write(`event: message\ndata: ${JSON.stringify({ content: char })}\n\n`);
// No sleep
}
Or even better — send the entire response at once:
res.write(`event: message\ndata: ${JSON.stringify({ content: response })}\n\n`);
res.write("event: done\ndata: {}\n\n");
Impact: User flow score for Crok AI chat: +30-50 pts (INP, TBT)
| Change | Visual Impact | Mitigation |
|---|---|---|
| Faster response | Chat messages appear instantly | No visual diff in screenshots |
application/server/src/routes/api/crok.tsevent: message, event: done