Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: never apply a format result over a buffer that was dirty when the pass started (#9738)

[._.]/ Adam Eivy04aa70391430
diff --git a/client/src/components/writers-room/WorkEditor.jsx b/client/src/components/writers-room/WorkEditor.jsx
index 9a4d9ea015..54af650d1f 100644
--- a/client/src/components/writers-room/WorkEditor.jsx
+++ b/client/src/components/writers-room/WorkEditor.jsx
@@ -589,6 +589,8 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseO
if (runningKind) return false;
const startOwner = ownerKeyRef.current;
const startBody = bodyRef.current;
+ // Analysis reads the SAVED draft, so a buffer that was already dirty is not what gets formatted.
+ const startedClean = startBody === savedBodyRef.current;
setRunningKind(kind);
setRunStartedAt(Date.now());
const snapshot = await runWritersRoomAnalysis(work.id, { kind }, { silent: true }).catch((err) => {
@@ -625,7 +627,7 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseO
// text (not just a dirty flag) also catches edit-then-save, where the
// buffer is clean again but no longer the analyzed source. The result
// stays in Analysis history for explicit application.
- if (bodyRef.current !== startBody) {
+ if (!startedClean || bodyRef.current !== startBody) {
toast('Format result not applied — you edited the draft meanwhile. Apply it from Analysis history.', { icon: 'ℹ️' });
} else {
setBody(snapshot.result.formattedBody);