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([issue-718]): address codex review

[._.]/ Adam Eivyb22321d1882c
diff --git a/client/src/hooks/useCanonPatch.js b/client/src/hooks/useCanonPatch.js
index 33d1884c6b..e51334c03e 100644
--- a/client/src/hooks/useCanonPatch.js
+++ b/client/src/hooks/useCanonPatch.js
@@ -30,7 +30,10 @@ export function useCanonPatch({ universe, universeId, apply, mountedRef }) {
e.id === entryId ? { ...e, ...patch } : e
);
apply({ ...universe, [kindKey]: list });
- const updated = await updateUniverse(universeId, { [kindKey]: list })
+ // `{ silent: true }` because the .catch below owns the failure toast —
+ // without it the apiCore request() helper fires a second, duplicate one
+ // (CLAUDE.md "Custom catch ⇒ silent: true").
+ const updated = await updateUniverse(universeId, { [kindKey]: list }, { silent: true })
.catch((err) => { toast.error(`Save failed: ${err.message}`); return null; });
if (updated && mountedRef.current && currentUniverseIdRef.current === capturedId) {
apply(updated);
diff --git a/client/src/hooks/useCanonPatch.test.jsx b/client/src/hooks/useCanonPatch.test.jsx
index 2f0184cf8e..30c8b638be 100644
--- a/client/src/hooks/useCanonPatch.test.jsx
+++ b/client/src/hooks/useCanonPatch.test.jsx
@@ -56,18 +56,18 @@ describe('useCanonPatch', () => {
{ id: 'c2', name: 'Bob' },
],
});
- // PATCH sends the full kind list.
+ // PATCH sends the full kind list, silently (the hook owns the error toast).
expect(updateUniverse).toHaveBeenCalledWith('u1', {
characters: [
{ id: 'c1', name: 'Alice', intExt: 'EXT' },
{ id: 'c2', name: 'Bob' },
],
- });
+ }, { silent: true });
// Server response re-applied.
expect(apply).toHaveBeenNthCalledWith(2, serverCopy);
});
- it('no-ops on a missing universe or a non-object patch', async () => {
+ it('no-ops when the universe is missing', async () => {
const { result, apply } = setup({ universe: null });
await act(async () => {
await result.current.patchEntry(KIND, 'c1', { intExt: 'EXT' });
@@ -76,6 +76,16 @@ describe('useCanonPatch', () => {
expect(updateUniverse).not.toHaveBeenCalled();
});
+ it('no-ops when the patch is missing or not an object', async () => {
+ const { result, apply } = setup();
+ await act(async () => {
+ await result.current.patchEntry(KIND, 'c1', null);
+ await result.current.patchEntry(KIND, 'c1', 'nope');
+ });
+ expect(apply).not.toHaveBeenCalled();
+ expect(updateUniverse).not.toHaveBeenCalled();
+ });
+
it('toasts and skips the re-apply when the PATCH fails', async () => {
updateUniverse.mockRejectedValue(new Error('boom'));
const { result, apply } = setup();