From 84984bee5992ad1e2d2bd3e4e4e59581cb7f83e4 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 1 Apr 2026 13:26:48 -0400 Subject: [PATCH] Correct TOCTOU comment to say it narrows rather than closes the race The re-check reduces the window but doesn't eliminate it, since state can still change at subsequent await points during the commit/archive sequence. --- crates/sidebar/src/sidebar.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index f12fb60edf15d76efccc05559ae69505fecc3140..72099378bdfd3bcf9dc900a210f35fd11e77ba1f 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -3068,9 +3068,11 @@ impl Sidebar { let store = cx.update(|_window, cx| ThreadMetadataStore::global(cx))?; - // Re-check inside the async block to close the TOCTOU window: + // Re-check inside the async block to narrow the TOCTOU window: // another thread on the same worktree may have been un-archived // (or a new one created) between the synchronous check and here. + // Note: this does not fully close the race — state can still change + // at subsequent await points during the commit/archive sequence. let still_last_thread = store.update(cx, |store, _cx| { !store .entries_for_path(&folder_paths)