c39fab70c1
The #274 page_changed marker lived only in the ephemeral system prompt, so the diff the agent saw was invisible in the chat export/history, and the note was too weak — the agent still overwrote the user's manual edits with a full-page replace. - Persist the diff the agent saw as metadata.pageChanged on the assistant row (flushAssistant), threaded into all five flush call sites in stream(). Model replay (rowToUiMessage/rowParts) reads only metadata.parts, so the sibling never re-injects the note into the model context on later turns. - Render the persisted diff as a labelled block (en/ru) before the message body in the server-side Markdown export (chat-markdown.util.ts). - Strengthen PAGE_CHANGED_NOTE: mandate a fresh getPage re-read and targeted edits (editPageText/patchNode/insertNode/deleteNode) instead of a whole-page replace, and never revert or overwrite the user's edits. Tests: prompt, export and service specs updated; 114 pass, tsc clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>