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

address review (agy): drop a stray NUL from the hook, and hide the override outside edit mode

[._.]/ Adam Eivy8ae419c07fb2
diff --git a/client/src/components/brain/tabs/NotesTab.jsx b/client/src/components/brain/tabs/NotesTab.jsx
index 9a7e17609e..16a22183f9 100644
--- a/client/src/components/brain/tabs/NotesTab.jsx
+++ b/client/src/components/brain/tabs/NotesTab.jsx
@@ -527,8 +527,11 @@ export default function NotesTab() {
/>
)}
+ {/* Editor-only: outside edit mode there is no buffer the user meant to
+ write, and a stray "Save anyway" click would still issue the risky
+ forced write. */}
<ForceSaveNoteRow
- offered={forceOffered}
+ offered={editing && forceOffered}
onConfirm={() => handleSaveNote({ force: true })}
onCancel={dismissForce}
/>
diff --git a/client/src/components/brain/tabs/NotesTab.test.jsx b/client/src/components/brain/tabs/NotesTab.test.jsx
index ba4bc076c8..1dd06811f8 100644
--- a/client/src/components/brain/tabs/NotesTab.test.jsx
+++ b/client/src/components/brain/tabs/NotesTab.test.jsx
@@ -202,6 +202,21 @@ describe('NotesTab iCloud force save', () => {
expect(api.updateNote).toHaveBeenLastCalledWith('vault-1', 'a.md', 'body', { force: true });
});
+ it('hides the override once the user leaves edit mode', async () => {
+ // Outside edit mode there is no buffer the user meant to write, so a stray
+ // "Save anyway" click would issue the risky forced write for nothing.
+ api.updateNote.mockRejectedValue(evicted());
+ await openEditor();
+
+ await clickSave();
+ await clickSave();
+ expect(screen.getByRole('button', { name: 'Save anyway' })).toBeInTheDocument();
+
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Close editor' })); });
+
+ expect(screen.queryByRole('button', { name: 'Save anyway' })).toBeNull();
+ });
+
it('does not arm on an unrelated failure', async () => {
api.updateNote.mockRejectedValue(Object.assign(new Error('nope'), { code: 'INVALID_PATH' }));
await openEditor();
diff --git a/client/src/components/wiki/tabs/BrowseTab.jsx b/client/src/components/wiki/tabs/BrowseTab.jsx
index 5398bac608..7e0ef4537e 100644
--- a/client/src/components/wiki/tabs/BrowseTab.jsx
+++ b/client/src/components/wiki/tabs/BrowseTab.jsx
@@ -287,8 +287,11 @@ export default function BrowseTab({ vaultId, notes, rawNotes, allNotes, onRefres
/>
)}
+ {/* Editor-only: outside edit mode there is no buffer the user meant to
+ write, and a stray "Save anyway" click would still issue the risky
+ forced write. */}
<ForceSaveNoteRow
- offered={forceOffered}
+ offered={editing && forceOffered}
onConfirm={() => handleSaveNote({ force: true })}
onCancel={dismissForce}
/>
diff --git a/client/src/components/wiki/tabs/BrowseTab.test.jsx b/client/src/components/wiki/tabs/BrowseTab.test.jsx
index e576c95b63..7823956c1e 100644
--- a/client/src/components/wiki/tabs/BrowseTab.test.jsx
+++ b/client/src/components/wiki/tabs/BrowseTab.test.jsx
@@ -117,6 +117,19 @@ describe('BrowseTab iCloud force save', () => {
));
});
+ it('hides the override once the user leaves edit mode', async () => {
+ api.updateNote.mockRejectedValue(evicted());
+ await openEditor();
+
+ await clickSave();
+ await clickSave();
+ expect(await screen.findByRole('button', { name: 'Save anyway' })).toBeInTheDocument();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
+
+ await waitFor(() => expect(screen.queryByRole('button', { name: 'Save anyway' })).toBeNull());
+ });
+
it('does not arm on an unrelated save failure', async () => {
api.updateNote.mockRejectedValue(Object.assign(new Error('nope'), { code: 'INVALID_PATH' }));
await openEditor();
diff --git a/client/src/hooks/useNoteSave.js b/client/src/hooks/useNoteSave.js
index 00f6ddeaef..de905b4bb3 100644
Binary files a/client/src/hooks/useNoteSave.js and b/client/src/hooks/useNoteSave.js differ
diff --git a/server/services/obsidian.js b/server/services/obsidian.js
index 6eb75b9734..db0f19c9c0 100644
--- a/server/services/obsidian.js
+++ b/server/services/obsidian.js
@@ -338,14 +338,20 @@ export async function updateNote(vaultId, notePath, content, { force = false } =
const moved = !before || !after
|| before.blocks !== after.blocks
|| before.mtimeMs !== after.mtimeMs;
- // Only "brctl succeeded AND nothing changed" proves retrying is futile —
- // that is the signature of a download with nothing to fetch. A `false`
- // here means the heal did NOT succeed (timed out against a wedged iCloud,
- // exited non-zero, `brctl` missing, or a non-iCloud File Provider path
- // brctl can't speak to), and every one of those also leaves blocks/mtime
- // untouched. Reporting those as stalled would arm the force-save override
- // on a genuinely evicted note and hand the user the uninterruptible write
- // this guard exists to prevent — so they stay retryable.
+ // "brctl succeeded AND nothing changed" is the signature of a download with
+ // nothing to fetch. A `false` here means the heal did NOT succeed (timed out
+ // against a wedged iCloud, exited non-zero, `brctl` missing, or a non-iCloud
+ // File Provider path brctl can't speak to), and every one of those also
+ // leaves blocks/mtime untouched. Reporting those as stalled would arm the
+ // force-save override on a genuinely evicted note and hand the user the
+ // uninterruptible write this guard exists to prevent — so they stay retryable.
+ //
+ // This narrows the false-positive window; it does not close it. `brctl` can
+ // exit 0 while a real download is still in flight (see the return contract
+ // on `materializeAndWait`), so a note whose bytes land after this check
+ // still reports stalled once. That is why `stalled` only ever *offers* the
+ // override — after a second round, behind a click that names the risk — and
+ // never bypasses anything on its own.
const stalled = materialized && !moved;
return {
error: 'NOTE_EVICTED',