- The chat UI becomes increasingly sluggish and eventually appears to freeze while a deep research run is in progress.
- The slowdown correlates with long-running research sessions that emit hundreds of Server-Sent Events (SSE) chunks.
- Browser developer tools show a flood of
console.debugstatements emitted for every streaming chunk and for each rerender of complex components such asPlanCard.
- High-frequency debug logging on the critical render path overwhelms the browser:
web/src/core/store/store.tslogs each SSE event inside thesendMessageasync iterator (console.debug("[store.sendMessage] received", …)), as well as a second log each time a message object is updated.web/src/core/api/chat.tsechoes every raw SSE event withconsole.debug("[chatStream] event", event.event).web/src/app/chat/components/message-list-view.tsxlogs render state for everyPlanCardrender, capturing large message snapshots.
- During deep research the backend pushes dozens of message chunks per second; each chunk triggers multiple
console.debugcalls. Logging large payloads (chat messages, tool call metadata) is especially expensive because the console serialises these objects. - The accumulated logging work blocks the main thread, which manifests as UI freezes even though React state updates are throttled to 50 ms.
- Remove or gate the streaming
console.debugstatements behind an explicit development flag (e.g.if (process.env.NEXT_PUBLIC_DEBUG_STREAM === "true")). - Replace per-chunk logging with coarse-grained sampling (e.g. log once per message or when the stream finishes) to avoid O(N) logs for chunk counts.
- Avoid logging full message objects from React render functions; if logging is still needed, log lightweight identifiers (message id, agent, status) and only in development mode.
- After trimming the logs, validate in the browser profiler (React Profiler or Chrome Performance) to ensure the render thread remains responsive during long research runs.
- Optionally add a feature flag so verbose diagnostics can be re-enabled when troubleshooting without shipping them to production builds.
Implementing the logging guard is typically sufficient to eliminate the freeze, because it removes thousands of synchronous console operations emitted during a single research session.