Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions desktop/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
import type { CSSProperties, KeyboardEvent, PointerEvent as ReactPointerEvent } from "react";
import {
SquarePen,
Expand Down Expand Up @@ -257,6 +257,12 @@ export default function App() {
todos.length > 0 &&
todos.some((t) => t.status !== "completed");

// useDeferredValue lets React prioritise Composer input (high-priority) over
// Transcript re-renders (low-priority) during streaming. When a keystroke
// and a transcript update collide, the keystroke is processed immediately
// and the transcript re-render is deferred to idle time.
const deferredItems = useDeferredValue(state.items);

useEffect(() => {
if (!pendingPlanRevision || state.running) return;
const text = pendingPlanRevision;
Expand Down Expand Up @@ -927,7 +933,7 @@ export default function App() {
<span className="loading-screen__text">{t("common.loading")}</span>
</div>
) : (
<Transcript items={state.items} live={state.live} footerHeight={footerHeight} onPrompt={send} onRewind={rewind} />
<Transcript items={deferredItems} live={state.live} footerHeight={footerHeight} onPrompt={send} onRewind={rewind} />
)}
</main>

Expand Down
Loading