From ffd269344d100a67d64b838e47dfc09faed4c135 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 25 Mar 2026 11:06:36 +0000 Subject: [PATCH] fix(chat): only reset artifact editor on tab switch, not content updates Remove active?.content from the useEffect dependency array so that store-side content updates (e.g. from streaming) do not overwrite the user's unsaved in-progress edits in the textarea. --- .../src/features/chat/components/artifact-panel.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/studio/frontend/src/features/chat/components/artifact-panel.tsx b/studio/frontend/src/features/chat/components/artifact-panel.tsx index c2a08bbbe8..4f90ed9cf6 100644 --- a/studio/frontend/src/features/chat/components/artifact-panel.tsx +++ b/studio/frontend/src/features/chat/components/artifact-panel.tsx @@ -69,10 +69,12 @@ export const ArtifactPanel: FC = () => { const active = artifacts.find((a) => a.id === activeId) ?? artifacts[0]; - // Sync local editor value when active artifact changes + // Sync local editor value when switching between artifacts useEffect(() => { if (active) setLocalValue(active.content); - }, [active?.id, active?.content]); + // Only reset on tab switch, not on content updates (which would clobber edits) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [active?.id]); if (!panelOpen || artifacts.length === 0 || !active) return null;