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-1080]): address codex iter-2 — reactivate resurrected memories + silence double toast

Adam Eivy89bd638b74fa
diff --git a/client/src/components/brain/tabs/BrainGraph.jsx b/client/src/components/brain/tabs/BrainGraph.jsx
index 0d0ce93f0a..3af5f369a7 100644
--- a/client/src/components/brain/tabs/BrainGraph.jsx
+++ b/client/src/components/brain/tabs/BrainGraph.jsx
@@ -215,7 +215,9 @@ export default function BrainGraph() {
// automatically (issue #1080). The default sync only embeds new records.
const handleSync = async ({ refresh = false } = {}) => {
setSyncing(true);
- const stats = await api.syncBrainData({ refresh }).catch(err => {
+ // silent:true — this catch owns the error toast, so suppress the helper's
+ // own toast to avoid a duplicate (CLAUDE.md: custom catch ⇒ silent).
+ const stats = await api.syncBrainData({ refresh }, { silent: true }).catch(err => {
toast.error(err.message || 'Sync failed');
return null;
});
diff --git a/client/src/services/apiBrain.js b/client/src/services/apiBrain.js
index 9b6a4b219f..437556caa5 100644
--- a/client/src/services/apiBrain.js
+++ b/client/src/services/apiBrain.js
@@ -200,8 +200,10 @@ export const getBrainGraph = () => request('/brain/graph');
// Brain - Bridge Sync (brain data to CoS memory system).
// refresh:true re-embeds already-mapped records to heal memory entries that
// went stale before the per-record sync signal existed (issue #1080).
-export const syncBrainData = ({ refresh = false } = {}) =>
- request('/brain/bridge-sync', { method: 'POST', body: JSON.stringify({ refresh }) });
+// `options` (e.g. { silent: true }) passes through to the request helper so a
+// caller with its own error toast doesn't get a duplicate from the helper.
+export const syncBrainData = ({ refresh = false } = {}, options = {}) =>
+ request('/brain/bridge-sync', { method: 'POST', body: JSON.stringify({ refresh }), ...options });
// Brain - Daily Log
export const listDailyLogs = (options = {}) => {
diff --git a/server/services/brainMemoryBridge.js b/server/services/brainMemoryBridge.js
index d7ecaf750c..aeb09d9ef0 100644
--- a/server/services/brainMemoryBridge.js
+++ b/server/services/brainMemoryBridge.js
@@ -188,8 +188,12 @@ export async function syncBrainRecord(brainType, record) {
const embedding = await embeddings.generateMemoryEmbedding(memoryData).catch(() => null);
if (existingMemoryId) {
- // Update existing memory
- const updated = await memory.updateMemory(existingMemoryId, memoryData);
+ // Update existing memory. Force status:'active' so a record that was
+ // archived for a synced-in delete/archive and later came back live
+ // (un-deleted on a peer, or un-archived) is searchable again — memory
+ // search filters out archived rows, so without this the resurrected
+ // record would stay invisible (issue #1080 review finding).
+ const updated = await memory.updateMemory(existingMemoryId, { ...memoryData, status: 'active' });
if (updated && embedding) {
await memory.updateMemoryEmbedding(existingMemoryId, embedding);
}
diff --git a/server/services/brainMemoryBridge.test.js b/server/services/brainMemoryBridge.test.js
index 04a8224cfe..6f4269a7f9 100644
--- a/server/services/brainMemoryBridge.test.js
+++ b/server/services/brainMemoryBridge.test.js
@@ -110,6 +110,20 @@ describe('brainMemoryBridge — resyncBrainRecord (issue #1080)', () => {
expect(updateMemory).not.toHaveBeenCalled();
expect(createMemory).not.toHaveBeenCalled();
});
+
+ it('reactivates an archived memory when its record comes back live (status:active)', async () => {
+ const bridge = await loadBridge();
+ // p1 is already mapped (memory was archived for a prior synced-in delete);
+ // now the record resolves live again. The re-embed must reset status:active
+ // or memory search (which filters status='active') keeps hiding it.
+ bridgeFileContents = JSON.stringify({ [bridge.bridgeKey('people', 'p1')]: 'mem-resurrect' });
+ getById.mockResolvedValue({ id: 'p1', name: 'Alice', context: 'back again' });
+
+ await bridge.resyncBrainRecord('people', 'p1');
+
+ expect(updateMemory).toHaveBeenCalledWith('mem-resurrect', expect.objectContaining({ status: 'active' }));
+ expect(createMemory).not.toHaveBeenCalled();
+ });
});
describe('brainMemoryBridge — queueResync debounce + dedup', () => {