mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #213] [CLOSED] fix(client): Author's Notes edits lost on outside-click #4508
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4508
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/213
Author: @Trade-Mottoes
Created: 4/24/2026
Status: ❌ Closed
Base:
main← Head:refactor/author-notes-dialog📝 Commits (1)
b71f15afix(client): Author's Notes edits lost on outside-click📊 Changes
2 files changed (+184 additions, -58 deletions)
View changed files
📝
packages/client/src/components/chat/ChatRoleplayPanels.tsx(+136 -38)📝
packages/client/src/components/chat/ChatRoleplaySurface.tsx(+48 -20)📄 Description
The bug
Open Author's Notes, type content, click outside the popover. The typed content is lost — sometimes. Whether the save takes is, in the current implementation, in the lap of the gods. :)
Repro: Open Author's Notes on any chat. Type a paragraph. Click anywhere outside the popover. Re-open. Roughly half the time the content is gone.
Root cause
The outside-click handler fires on
mousedownand unmounts the textarea before itsonBlur(which triggered the save) can run. No reliable fix is possible within the popover-plus-blur-save architecture — the container is trying to be both a transient peek surface (dismiss on mousedown) and a live editor (persist on blur), and those contracts race by construction.Fix
Split viewing and editing into their proper containers.
AuthorNotesPeek— read-only popover. Transient dismissal is safe because no mutation is in flight. Usesclickrather thanmousedownfor predictable close semantics.AuthorNotesPanel— committed editing in the sharedModalprimitive (same one used byEditAgentModal,LorebookMakerModal, etc.) with explicit Save / Cancel.isDirtygates prop-sync so external refetches don't clobber pending edits.AuthorNotesButton— three-state machine (closed / peek / edit) owning all transitions; the two child components are unaware of each other.Why peek/edit rather than just "use Modal for everything"
Viewing and editing have different optimal containers. Peeking is by far the more common action ("what did I put in here again?") and is cheap, frequent, and safe. Editing wants a committed feel — backdrop, focus trap, Escape. The one-container-fits-both compromise is precisely what caused the save race: the popover was trying to serve both contracts at once.
User-visible result
All four close paths (X / backdrop / Escape / Cancel) are race-proof by construction. Desktop and mobile now render as a single consistent dialog (previously desktop was a popover, mobile a full-screen portal). Also picks up
role=dialog,aria-modal, Escape handling and focus trap from the sharedModal.Testing
pnpm lint && pnpm buildpass.Screenshots
Peek with discrete edit button:

Edit:

Summary by CodeRabbit
Release Notes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.