From 9def97c3a523dea7b5c0c52605f7370346786118 Mon Sep 17 00:00:00 2001 From: mawkone Date: Thu, 4 Jun 2026 11:16:21 -0700 Subject: [PATCH] fix(frontend): add X-Accel-Buffering to sse stream and optimize textarea input height resize --- .../app/api/projects/[projectId]/stream/route.ts | 1 + vibn-frontend/components/vibn-chat/chat-panel.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/vibn-frontend/app/api/projects/[projectId]/stream/route.ts b/vibn-frontend/app/api/projects/[projectId]/stream/route.ts index 0c32175..5d3ba16 100644 --- a/vibn-frontend/app/api/projects/[projectId]/stream/route.ts +++ b/vibn-frontend/app/api/projects/[projectId]/stream/route.ts @@ -72,6 +72,7 @@ export async function GET( "Content-Type": "text/event-stream", "Cache-Control": "no-cache, no-transform", Connection: "keep-alive", + "X-Accel-Buffering": "no", }, }); } diff --git a/vibn-frontend/components/vibn-chat/chat-panel.tsx b/vibn-frontend/components/vibn-chat/chat-panel.tsx index f050821..0024d79 100644 --- a/vibn-frontend/components/vibn-chat/chat-panel.tsx +++ b/vibn-frontend/components/vibn-chat/chat-panel.tsx @@ -2025,8 +2025,13 @@ export function ChatPanel({ }} onInput={(e) => { const el = e.currentTarget; - el.style.height = "auto"; - el.style.height = Math.min(el.scrollHeight, 120) + "px"; + const newlines = (el.value.match(/\n/g) || []).length; + // Cache lastNewlines on the DOM element to avoid state re-render lag + if ((el as any).lastNewlines !== newlines) { + (el as any).lastNewlines = newlines; + el.style.height = "auto"; + el.style.height = Math.min(el.scrollHeight, 120) + "px"; + } }} /> {selectToggle}