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.
This commit is contained in:
parent
2ea8217727
commit
ffd269344d
1 changed files with 4 additions and 2 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue