Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(memory): retire the quarantine notice on a non-empty store; route its CTA to Sources\n\nReview follow-ups on #5823 (Codex + CodeRabbit):\n\n- `resynced` compared chunk *content* time (a mail's sent_at, a file's\n modified_at) to the quarantine time, so restored history never retired the\n notice. It now means "the rebuilt, initially empty store holds a chunk\n again" (`total_chunks > 0`), read from the same store observation as the\n chunk tile.\n- The "Re-sync memory" action landed on Brain's Sync tab, which only shows\n status and history; the per-source Sync and All In controls are on the\n Sources tab, so it routes there.\n- The app-wide poll ignores responses that are not from its latest request,\n so a delayed `resynced: false` cannot re-open a notice a newer response\n retired.\n- The NoticeCenter tests mock the poll, which needs CoreStateProvider.\n

Shanufe2a37ffa71f
diff --git a/app/src/components/notices/__tests__/NoticeCenter.test.tsx b/app/src/components/notices/__tests__/NoticeCenter.test.tsx
index e38998e580..fe2bc694f4 100644
--- a/app/src/components/notices/__tests__/NoticeCenter.test.tsx
+++ b/app/src/components/notices/__tests__/NoticeCenter.test.tsx
@@ -27,6 +27,8 @@ vi.mock('../../../hooks/useEmbeddingBudgetState', () => ({
useEmbeddingBudgetState: () => budgetState,
}));
vi.mock('../../../hooks/useUsageState', () => ({ useUsageState: () => usageState }));
+// openhuman#5820: the quarantine poll needs CoreStateProvider; not under test here.
+vi.mock('../useMemoryQuarantinePoll', () => ({ useMemoryQuarantinePoll: () => undefined }));
vi.mock('../../../lib/nativeNotifications/tauriBridge', () => ({ showNativeNotification }));
vi.mock('../../../utils/openUrl', () => ({ openUrl: vi.fn() }));
vi.mock('../../../services/api/openrouterFreeModels', () => ({ applyOpenRouterFreeModels }));
diff --git a/app/src/components/notices/useAppNotices.ts b/app/src/components/notices/useAppNotices.ts
index f823de7981..94b0e99333 100644
--- a/app/src/components/notices/useAppNotices.ts
+++ b/app/src/components/notices/useAppNotices.ts
@@ -73,8 +73,9 @@ const ACTION_ROUTE: Record<Exclude<UserErrorAction, 'dismiss'>, string> = {
// both the explanation and the retry.
open_connections: '/connections?tab=skills',
// openhuman#5820: after a corrupt-store quarantine the rebuilt tree is
- // empty; re-syncing sources from Brain's sync tab is the remediation.
- open_memory_sync: '/brain?tab=sync',
+ // empty; the per-source Sync and All In controls that repopulate it live on
+ // Brain's Sources tab (the Sync tab only shows status and history).
+ open_memory_sync: '/brain?tab=sources',
};
const ACTION_LABEL_KEY: Record<Exclude<UserErrorAction, 'dismiss'>, string> = {
diff --git a/app/src/components/notices/useMemoryQuarantinePoll.ts b/app/src/components/notices/useMemoryQuarantinePoll.ts
index 13628141c6..b43dd3b832 100644
--- a/app/src/components/notices/useMemoryQuarantinePoll.ts
+++ b/app/src/components/notices/useMemoryQuarantinePoll.ts
@@ -31,10 +31,17 @@ export function useMemoryQuarantinePoll(): void {
useEffect(() => {
if (!isAuthenticated) return;
let cancelled = false;
+ // A slow response must not overwrite a newer one: a delayed
+ // `resynced: false` landing after a fresh `resynced: true` would re-open
+ // a notice the user has already earned the retirement of.
+ let latestRequest = 0;
const tick = async () => {
+ const request = ++latestRequest;
try {
const status = await memoryTreePipelineStatus();
- if (!cancelled) reportMemoryQuarantine(dispatch, status.quarantine);
+ if (!cancelled && request === latestRequest) {
+ reportMemoryQuarantine(dispatch, status.quarantine);
+ }
} catch (err) {
// Signed out mid-poll, core restarting: nothing to report, try again
// next tick.
diff --git a/app/src/utils/tauriCommands/memoryTree.ts b/app/src/utils/tauriCommands/memoryTree.ts
index f5a37f9184..2bb47aa2ab 100644
--- a/app/src/utils/tauriCommands/memoryTree.ts
+++ b/app/src/utils/tauriCommands/memoryTree.ts
@@ -894,7 +894,7 @@ export interface MemoryTreeQuarantine {
quarantined_at_ms: number;
/** Local path of the preserved damaged database. */
quarantined_path: string;
- /** A chunk landed after the quarantine: the rebuilt store is repopulating. */
+ /** The rebuilt (initially empty) store holds a chunk again: the user re-synced. */
resynced: boolean;
}
diff --git a/src/openhuman/memory/tree/tree/rpc.rs b/src/openhuman/memory/tree/tree/rpc.rs
index ae88b5eb76..9ebfb7fd4c 100644
--- a/src/openhuman/memory/tree/tree/rpc.rs
+++ b/src/openhuman/memory/tree/tree/rpc.rs
@@ -902,8 +902,7 @@ pub struct PipelineStatusResponse {
/// workspace, derived from disk (`memory_tree/chunks.db.corrupt-<ts>`),
/// so it survives restarts and reaches a renderer that was not connected
/// when the quarantine happened. `None` when nothing was ever quarantined.
- /// Reported until a sync lands after the quarantine (`resynced`), which
- /// is when the rebuilt store stops being empty.
+ /// Reported until the rebuilt store holds a chunk again (`resynced`).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub quarantine: Option<QuarantineStatus>,
}
@@ -919,8 +918,11 @@ pub struct QuarantineStatus {
/// The preserved copy of the damaged database. Local to this machine and
/// shown only to its own user, so the user can hand it to recovery tooling.
pub quarantined_path: String,
- /// Whether a chunk has been written since the quarantine — the rebuilt
- /// store is being repopulated, so the notice can retire.
+ /// Whether the rebuilt store holds any chunk again. The quarantine leaves
+ /// an empty schema, so a non-empty store means the user has re-synced
+ /// and the notice can retire. Deliberately not a timestamp comparison:
+ /// chunk timestamps are *content* time (a mail's `sent_at`, a file's
+ /// `modified_at`), so restored history predates the quarantine forever.
pub resynced: bool,
}
@@ -932,7 +934,7 @@ pub struct QuarantineStatus {
/// Side-file quarantines (`chunks.db-wal.corrupt-…`) do not match the prefix.
fn latest_quarantine(
workspace_dir: &std::path::Path,
- most_recent_chunk_ms: i64,
+ total_chunks: u64,
) -> Option<QuarantineStatus> {
const PREFIX: &str = "chunks.db.corrupt-";
let dir = workspace_dir.join("memory_tree");
@@ -950,7 +952,7 @@ fn latest_quarantine(
Some(QuarantineStatus {
quarantined_at_ms,
quarantined_path: path.display().to_string(),
- resynced: most_recent_chunk_ms > quarantined_at_ms,
+ resynced: total_chunks > 0,
})
}
@@ -1077,10 +1079,9 @@ pub async fn pipeline_status_rpc(
// back to the active degradation cause, then `None` when healthy.
let first_blocking_cause = latest_failure.or_else(|| degraded.cause.clone());
- // openhuman#5820: disk-derived so it is durable and replayable; computed
- // from the same `store` observation as `last_sync_ms` so "resynced" and
- // the tile agree.
- let quarantine = latest_quarantine(config.workspace_dir.as_path(), last_sync_ms);
+ // openhuman#5820: disk-derived so it is durable and replayable; "resynced"
+ // reads the same `store` observation as the chunk tile, so the two agree.
+ let quarantine = latest_quarantine(config.workspace_dir.as_path(), total_chunks);
if let Some(q) = &quarantine {
log::debug!(
"[memory-tree][rpc] pipeline_status: quarantine at={} resynced={} path={}",
@@ -2191,16 +2192,18 @@ mod tests {
.and_utc()
.timestamp_millis();
- // A chunk written before the quarantine: the rebuilt store is still empty.
- let pending = latest_quarantine(tmp.path(), at - 1).expect("newest quarantine");
+ // The rebuilt store is still empty: the notice stands.
+ let pending = latest_quarantine(tmp.path(), 0).expect("newest quarantine");
assert_eq!(pending.quarantined_at_ms, at);
assert!(pending
.quarantined_path
.ends_with("chunks.db.corrupt-20260827T070304Z"));
assert!(!pending.resynced);
- // A chunk written after it: the user re-synced, the notice can retire.
- let done = latest_quarantine(tmp.path(), at + 1).expect("newest quarantine");
+ // Any chunk in the rebuilt store: the user re-synced, the notice retires.
+ // Chunk *content* time is irrelevant here: restored history predates the
+ // quarantine forever, which is exactly why this is not a timestamp test.
+ let done = latest_quarantine(tmp.path(), 1).expect("newest quarantine");
assert!(done.resynced);
}