@@ -400,6 +400,7 @@ function MessageForms({
400400 const deleteSafeDelayMs = 150
401401 const [ confirmDelete , setConfirmDelete ] = useState ( false )
402402 const [ canDelete , setCanDelete ] = useState ( false )
403+ const [ currentContent , setCurrentContent ] = useState ( message . content )
403404 const formRef = useRef < HTMLFormElement | null > ( null )
404405 const textareaRef = useRef < HTMLTextAreaElement | null > ( null )
405406 const [ updateContentForm , updateContentFields ] = useForm ( {
@@ -425,6 +426,8 @@ function MessageForms({
425426 const sendIsPending = sendNowFetcher . state !== 'idle'
426427 const deleteIsPending = deleteFetcher . state !== 'idle'
427428 const textareaProps = getTextareaProps ( updateContentFields . content )
429+ const hasEdits = currentContent !== message . content
430+ const showSaveButton = hasEdits || updateIsPending
428431
429432 useEffect ( ( ) => {
430433 if ( confirmDelete ) {
@@ -478,19 +481,21 @@ function MessageForms({
478481 < span > { headerText } </ span >
479482 </ div >
480483 < div className = "flex items-center gap-2" >
481- < StatusButton
482- form = { updateContentForm . id }
483- status = { updateIsPending ? 'pending' : 'idle' }
484- className = "h-11 w-11 gap-0 text-[hsl(var(--palette-cream))] hover:bg-[hsl(var(--palette-cream))/0.15] sm:h-10 sm:w-10"
485- size = "icon"
486- variant = "ghost"
487- type = "submit"
488- name = "intent"
489- value = { updateMessageContentActionIntent }
490- >
491- < Icon name = "check" size = "sm" />
492- < span className = "sr-only" > Save</ span >
493- </ StatusButton >
484+ { showSaveButton ? (
485+ < StatusButton
486+ form = { updateContentForm . id }
487+ status = { updateIsPending ? 'pending' : 'idle' }
488+ className = "h-11 w-11 gap-0 text-[hsl(var(--palette-cream))] hover:bg-[hsl(var(--palette-cream))/0.15] sm:h-10 sm:w-10"
489+ size = "icon"
490+ variant = "ghost"
491+ type = "submit"
492+ name = "intent"
493+ value = { updateMessageContentActionIntent }
494+ >
495+ < Icon name = "check" size = "sm" />
496+ < span className = "sr-only" > Save</ span >
497+ </ StatusButton >
498+ ) : null }
494499 < DropdownMenu
495500 onOpenChange = { ( open ) => {
496501 if ( ! open ) setConfirmDelete ( false )
@@ -549,6 +554,9 @@ function MessageForms({
549554 </ label >
550555 < textarea
551556 { ...textareaProps }
557+ onInput = { ( event ) => {
558+ setCurrentContent ( event . currentTarget . value )
559+ } }
552560 ref = { textareaRef }
553561 className = "mt-4 w-full resize-none bg-transparent text-sm leading-relaxed text-[hsl(var(--palette-cream))] placeholder:text-[hsl(var(--palette-cream))]/80 focus-visible:outline-none"
554562 rows = { 4 }
0 commit comments