From e955477da92522886968560aa799f1c39f85606e Mon Sep 17 00:00:00 2001 From: kylekz Date: Tue, 10 Nov 2026 02:08:07 +1300 Subject: [PATCH] Reveal a posted thread whose card the reload drew first Posting a comment sets the pane's pending thread and reveals its card once a change to the rows draws it. The review's reload and the post's answer race: on a loaded machine the reload can draw the card first, so posted() refreshed rows that no longer changed and nothing revealed or cleared the pending thread. It stayed pending until a later listing drew its card again and scrolled the stream to it, e.g. round 2's interdiff in review_rounds, which then opened on http.ts instead of cache.ts (the Windows CI flake at review_rounds.jsonl:85). posted() now reveals the card at once when it is already drawn. Under load on windows-2025 (review_rounds four at a time, 24 runs): main fails 9 to 15 of 24 at that assertion; with this 24 of 24 pass. Co-Authored-By: Claude Opus 5.5 --- crates/dv_ui/src/diff_pane/tests/threads.rs | 29 +++++++++++++++++++++ crates/dv_ui/src/diff_pane/threads.rs | 7 ++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/crates/dv_ui/src/diff_pane/tests/threads.rs b/crates/dv_ui/src/diff_pane/tests/threads.rs index ecf6fd0..5a86ecf 100644 --- a/crates/dv_ui/src/diff_pane/tests/threads.rs +++ b/crates/dv_ui/src/diff_pane/tests/threads.rs @@ -704,3 +704,32 @@ fn a_reply_opened_near_the_bottom_comes_wholly_into_view(cx: &mut TestAppContext "the card ends at {bottom}, past the viewport's {height}" ); } + +/// A post's answer can reach the pane after the review's reload has already drawn the new +/// card (a loaded machine): the card is revealed then, and nothing is left waiting to scroll +/// the stream back to it on a later change. +#[gpui::test] +fn a_post_answered_after_its_card_is_drawn_leaves_nothing_to_reveal_later(cx: &mut TestAppContext) { + let repo = stream_fixture(80); + let (_dir, shell, cx) = open(&repo, cx); + let pane = pane(&shell, cx); + let thread = add_thread(&shell, "b.txt", AnchorSide::New, (2, 2), "Why a digit?", cx); + let target = ComposerTarget { + path: "b.txt".to_string(), + side: AnchorSide::New, + start_line: 2, + end_line: 2, + reply_to: None, + }; + pane.update_in(cx, |pane, window, cx| { + pane.posted(target, Ok(thread.clone()), window, cx); + }); + settle_drawn(cx, &shell, "the answer", |_, _| true); + assert_eq!(focused(&pane, cx), Some(thread)); + + // The reader moves on to c.txt; a later change to the rows (`S`) leaves them there. + press(cx, &shell, "j j"); + pane.read_with(cx, |pane, _| assert_eq!(pane.top_file(), Some("c.txt"))); + press(cx, &shell, "s"); + pane.read_with(cx, |pane, _| assert_eq!(pane.top_file(), Some("c.txt"))); +} diff --git a/crates/dv_ui/src/diff_pane/threads.rs b/crates/dv_ui/src/diff_pane/threads.rs index 1d2c1be..651a78d 100644 --- a/crates/dv_ui/src/diff_pane/threads.rs +++ b/crates/dv_ui/src/diff_pane/threads.rs @@ -802,7 +802,7 @@ impl DiffPane { cx.notify(); } - fn posted( + pub(super) fn posted( &mut self, target: ComposerTarget, result: Result, @@ -824,6 +824,11 @@ impl DiffPane { } self.focused_thread = Some(thread.clone()); self.pending_thread = Some(thread); + // The review's reload can draw the card before this answer comes (a loaded + // machine), leaving no change to its rows to reveal it on: it is revealed now + // if it is there, else once it is drawn. + self.reveal_pending_thread(); + self.viewport_changed(cx); if let Some(path) = self.target_block_path(&target, cx) { self.refresh_path(&path, cx); }