From 292e4e46124b9cfc57c19d8cba8d3e40b6c479fd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 17:57:25 -0800 Subject: [PATCH] Cloud: a page drawn after sign-out does not ask the service again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit File › Open and Save As call `start` on every frame. After a sign-out, `start` asked who is signed in and listed the root folder again. The sign-out has no answer and no order against those requests, so a provider that still held the session could answer with the departed account and its files, and the account answer also reset Share. `sign_out` now sets a flag that stops `start` from asking anything until the next `sign_in`, and the page header reads "Signed out" instead of "Connecting to your cloud account…" while it is set. --- crates/cloud-ui/src/cloud/conflict_tests.rs | 37 +++++++++++++++++++++ crates/cloud-ui/src/cloud/mod.rs | 15 ++++++++- crates/cloud-ui/src/cloud/pages.rs | 5 +++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/crates/cloud-ui/src/cloud/conflict_tests.rs b/crates/cloud-ui/src/cloud/conflict_tests.rs index 1e22e815fe..c1c3d820a7 100644 --- a/crates/cloud-ui/src/cloud/conflict_tests.rs +++ b/crates/cloud-ui/src/cloud/conflict_tests.rs @@ -235,6 +235,43 @@ fn a_late_reply_from_before_sign_out_is_dropped() { ); } +/// File › Open calls `start` on every frame. A sign-out has no answer, so nothing orders it +/// before a request the next frame sends. A provider that still holds the session answers that +/// request with the departed account, and the window must not show that account or its files. +#[test] +fn a_page_drawn_after_sign_out_does_not_bring_the_account_back() { + let (mut app, held, _log) = two_tabs(); + start(&mut app); + let (_, post) = held.take(|j| matches!(j, Job::Account)).unwrap(); + post.send(Event::Account(Ok(account("Previous Person")))); + held.take(|j| matches!(j, Job::List(_))).unwrap(); + drain(&mut app, &egui::Context::default()); + sign_out(&mut app); + start(&mut app); + // Whatever the frame asked is answered as a provider that has not yet ended the session would. + while let Some((job, post)) = held.take(|j| matches!(j, Job::Account | Job::List(_))) { + match job { + Job::Account => post.send(Event::Account(Ok(account("Previous Person")))), + Job::List(path) => post.send(Event::Listed { path, entries: Ok(vec![entry("/Payroll 2026.note", "p1")]) }), + _ => {} + } + } + drain(&mut app, &egui::Context::default()); + let r = report(&app); + assert!( + r["account"].is_null() && r["entries"].as_array().is_some_and(Vec::is_empty), + "signed out, yet account={} entries={}", + r["account"], + r["entries"] + ); + sign_in(&mut app); + let (_, post) = held.take(|j| matches!(j, Job::SignIn)).unwrap(); + post.send(Event::Account(Ok(account("Ada")))); + drain(&mut app, &egui::Context::default()); + start(&mut app); + assert!(held.take(|j| matches!(j, Job::List(_))).is_some(), "the next sign-in lists the root folder again"); +} + /// Save as a copy, then the first click on the Save As page is refused (no name typed yet). The /// second click, with a name, must still copy the conflicted document A, not the active tab B. #[test] diff --git a/crates/cloud-ui/src/cloud/mod.rs b/crates/cloud-ui/src/cloud/mod.rs index d988b3abb6..3f76377f0e 100644 --- a/crates/cloud-ui/src/cloud/mod.rs +++ b/crates/cloud-ui/src/cloud/mod.rs @@ -190,6 +190,11 @@ pub struct CloudFiles { pub account_fault: Option, /// The account is asked for once per run. A frame never asks again. asked_account: bool, + /// Set by [`sign_out`] and cleared by [`sign_in`]. While it is set, the + /// pages ask the service nothing. [`Job::SignOut`] has no answer and no + /// order against a later job, so a provider that still holds the session + /// could answer an account or listing request with the departed account. + signed_out: bool, /// The folder being browsed. Shared by the Open and Save As pages, which /// are never on screen together. pub mine: Folder, @@ -243,6 +248,7 @@ impl CloudFiles { account: None, account_fault: None, asked_account: false, + signed_out: false, mine: Folder::default(), shared: Folder::default(), source: Source::default(), @@ -337,8 +343,10 @@ pub fn submit(app: &A, job: Job) { } /// Asks who is signed in, once per run, and lists the root folder. +/// +/// After [`sign_out`] it asks nothing until the next [`sign_in`]. pub fn start(app: &mut A) { - if !available(app) { + if !available(app) || app.cloud().signed_out { return; } if !app.cloud().asked_account { @@ -368,6 +376,7 @@ pub fn sign_in(app: &mut A) { // would then be swallowed by the guard that stops a frame asking twice. A // button that does nothing the second time reads as a broken button. cloud.asked_account = true; + cloud.signed_out = false; cloud.link = None; cloud.status = Some(working); // A new session. A job the previous one left outstanding may never @@ -389,6 +398,10 @@ pub fn sign_out(app: &mut A) { cloud.account = None; cloud.account_fault = None; cloud.asked_account = false; + // File › Open and Save As call `start` on every frame. Without this, the + // next frame would ask who is signed in and list the root folder while + // the sign-out may still be on its way. + cloud.signed_out = true; cloud.link = None; cloud.mine = Folder::default(); cloud.shared = Folder::default(); diff --git a/crates/cloud-ui/src/cloud/pages.rs b/crates/cloud-ui/src/cloud/pages.rs index 86e71d1c88..e1ce9b1ad4 100644 --- a/crates/cloud-ui/src/cloud/pages.rs +++ b/crates/cloud-ui/src/cloud/pages.rs @@ -42,6 +42,11 @@ fn header(app: &mut A, ui: &mut Ui) { let line = if account.display.is_empty() { app.tr("Signed in") } else { account.display.clone() }; dim(ui, &style, &line); } + // Nothing is asked after a sign-out, so there is nothing to wait for. + (None, None) if app.cloud().signed_out => { + let signed_out = app.tr("Signed out"); + dim(ui, &style, &signed_out); + } (None, None) => { let waiting = app.tr("Connecting to your cloud account…"); dim(ui, &style, &waiting);