fix(skill-editor): compare content with original to determine dirty state

Previously, any edit would mark the file as dirty even if the content
was restored to its original state. Now we compare against the original
content and clear the dirty flag when they match.
This commit is contained in:
yyh 2026-01-17 17:52:00 +08:00
parent b82b73ef94
commit bbf1247f80
No known key found for this signature in database

View File

@ -99,9 +99,16 @@ const SkillDocEditor: FC = () => {
const handleEditorChange = useCallback((value: string | undefined) => {
if (!activeTabId || !isEditable)
return
storeApi.getState().setDraftContent(activeTabId, value ?? '')
const newValue = value ?? ''
const originalContent = fileContent?.content ?? ''
if (newValue === originalContent)
storeApi.getState().clearDraftContent(activeTabId)
else
storeApi.getState().setDraftContent(activeTabId, newValue)
storeApi.getState().pinTab(activeTabId)
}, [activeTabId, isEditable, storeApi])
}, [activeTabId, isEditable, storeApi, fileContent?.content])
const handleSave = useCallback(async () => {
if (!activeTabId || !appId || !isEditable)