We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc9310c commit bc45ddbCopy full SHA for bc45ddb
app/lib/hooks/usePromptEnhancer.ts
@@ -51,18 +51,35 @@ export function usePromptEnhancer() {
51
try {
52
setInput('');
53
54
+ let rafId: number | null = null;
55
+ let pendingUpdate = false;
56
+
57
+ const updateInput = () => {
58
+ setInput(_input);
59
+ pendingUpdate = false;
60
+ rafId = null;
61
+ };
62
63
while (true) {
64
const { value, done } = await reader.read();
65
66
if (done) {
67
+ if (rafId) {
68
+ cancelAnimationFrame(rafId);
69
+ }
70
71
72
break;
73
}
74
75
_input += decoder.decode(value);
76
77
logger.trace('Set input', _input);
78
- setInput(_input);
79
+ if (!pendingUpdate) {
80
+ pendingUpdate = true;
81
+ rafId = requestAnimationFrame(updateInput);
82
83
84
} catch (error) {
85
_error = error;
0 commit comments