Skip to content

Commit 488bf65

Browse files
tmmampagent
andauthored
fix(zbugs-gpui): mark an issue viewed after the server confirms its changes (#186)
The zbugs GPUI end-to-end job failed once on #185 at the viewState check: `e2e online: passed`, then Postgres had the issue's viewed time before its modified time. zbugs' issue trigger stamps `modified` with the time the server's transaction for a change starts, after the client showed the change. The one-second view timer took its viewed time from the client's state, so when it fired before the server had applied the close, the server's stamp came later. The app marked the issue viewed again a second after the server confirmed it, but the run had already exited. The timer now waits until the server has confirmed the pending mutations before it takes the viewed time, as `max(now, modified)` of the confirmed issue. Amp-Thread-ID: https://ampcode.com/threads/T-5a01d9bf-e8fb-479a-8866-c293f3e230d5 Co-authored-by: Amp <amp@ampcode.com>
1 parent 2c829ea commit 488bf65

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎apps/zbugs-gpui/src/app.rs‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::live::Live;
99
use crate::picker::{self, Choice};
1010
use crate::session::{Session, app_dir, now_ms, save_setting};
1111
use futures::StreamExt;
12-
use futures::channel::mpsc;
12+
use futures::channel::{mpsc, oneshot};
1313
use gpui_kit::assets::IconName as Lucide;
1414
use gpui_kit::base::actions::Confirm;
1515
use gpui_kit::component::button::*;
@@ -1407,9 +1407,21 @@ impl ZbugsApp {
14071407
cx.background_executor()
14081408
.timer(std::time::Duration::from_secs(1))
14091409
.await;
1410+
// Then once the server has confirmed what's pending: it stamps
1411+
// an issue's `modified` itself as it applies a change, after the
1412+
// client showed it, so a viewed time taken before that would
1413+
// leave the issue unread.
1414+
let (done, settled) = oneshot::channel();
1415+
let waiting = this.update(cx, |this, _| {
1416+
this.session.zero.when_pending_settled(move || {
1417+
let _ = done.send(());
1418+
})
1419+
});
1420+
if waiting.is_err() || settled.await.is_err() {
1421+
return;
1422+
}
14101423
let _ = this.update(cx, |this, cx| {
1411-
// Done: a change the server confirms after this one, such
1412-
// as its own `modified` for a close, starts another.
1424+
// Done: a change after this one starts another.
14131425
this.view_timer = None;
14141426
let modified = this
14151427
.detail

0 commit comments

Comments
 (0)