fix(chat): a failed refresh retries quietly before showing the error
- after 2, 5 and 15 s; the Could not refresh notice and Not up to date only after the third failure - a network blip on wake no longer leaves an error banner in the open chat Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -111,6 +111,11 @@ pub const MEMBERS_BUTTON: &str = "shell/islands/main/members-button";
111
111
pub const HEADER_DIVIDER: &str = "shell/islands/main/divider-header";
112
112
pub const TIMELINE_TAG: &str = "shell/islands/main/timeline";
113
113
pub const FEED_EDGE_TAG: &str = "shell/islands/main/timeline/divider-feed";
114
const QUIET_RETRY_DELAYS: [Duration; 3] = [
115
Duration::from_secs(2),
116
Duration::from_secs(5),
117
Duration::from_secs(15),
118
];
114
119
const HEADER_HEIGHT: f32 = 60.;
115
120
const HEADER_PADDING: f32 = 20.;
116
121
const HEADER_GAP: f32 = 12.;
@@ -178,6 +183,7 @@ struct Current {
178
183
has_older: bool,
179
184
loading_older: bool,
180
185
older_blocked: bool,
186
quiet_retries: usize,
181
187
fetched: bool,
182
188
first_unread: Option<String>,
183
189
posts_new_after: Option<DateTime<Utc>>,
@@ -929,6 +935,7 @@ impl ConversationView {
929
935
loading_older: false,
930
936
older_blocked: false,
931
937
fetched: false,
938
quiet_retries: 0,
932
939
first_unread,
933
940
posts_new_after,
934
941
sync: SyncProgress::default(),
@@ -1923,15 +1930,38 @@ impl ConversationView {
1923
1930
sync.messages = false;
1924
1931
let (newest_cached, started_at) = (sync.newest_cached, sync.started_at);
1925
1932
match result {
1926
Ok(Ok(_)) => self.mark_fetched_new(newest_cached, started_at, cx),
1927
Ok(Err(error)) => self.fail_sync(generation, short_error(&error)),
1928
Err(error) => self.fail_sync(generation, short_error(&error)),
1933
Ok(Ok(_)) => {
1934
if let Some(current) = self.current.as_mut() {
1935
current.quiet_retries = 0;
1936
}
1937
self.mark_fetched_new(newest_cached, started_at, cx)
1938
}
1939
Ok(Err(error)) => self.fail_sync(generation, short_error(&error), cx),
1940
Err(error) => self.fail_sync(generation, short_error(&error), cx),
1929
1941
}
1930
1942
self.rebuild(false, cx);
1931
1943
self.settle_progress(generation, cx);
1932
1944
}
1933
1945
1934
fn fail_sync(&mut self, generation: u64, error: String) {
1946
fn fail_sync(&mut self, generation: u64, error: String, cx: &mut Context<Self>) {
1947
let quiet_retry = self.current.as_mut().and_then(|current| {
1948
let delay = QUIET_RETRY_DELAYS.get(current.quiet_retries).copied()?;
1949
current.quiet_retries += 1;
1950
Some(delay)
1951
});
1952
if let Some(delay) = quiet_retry {
1953
cx.spawn(async move |this, cx| {
1954
cx.background_executor().timer(delay).await;
1955
this.update(cx, |this, cx| {
1956
if this.sync_generation == generation {
1957
this.retry_fetch(cx);
1958
}
1959
})
1960
.ok();
1961
})
1962
.detach();
1963
return;
1964
}
1935
1965
if let Some(sync) = self.sync_of(generation) {
1936
1966
sync.failed = true;
1937
1967
sync.receipts = false;
@@ -111,6 +111,11 @@ pub const MEMBERS_BUTTON: &str = "shell/islands/main/members-button";111
pub const HEADER_DIVIDER: &str = "shell/islands/main/divider-header";111
pub const HEADER_DIVIDER: &str = "shell/islands/main/divider-header";112
pub const TIMELINE_TAG: &str = "shell/islands/main/timeline";112
pub const TIMELINE_TAG: &str = "shell/islands/main/timeline";113
pub const FEED_EDGE_TAG: &str = "shell/islands/main/timeline/divider-feed";113
pub const FEED_EDGE_TAG: &str = "shell/islands/main/timeline/divider-feed";114
const QUIET_RETRY_DELAYS: [Duration; 3] = [115
Duration::from_secs(2),116
Duration::from_secs(5),117
Duration::from_secs(15),118
];114
const HEADER_HEIGHT: f32 = 60.;119
const HEADER_HEIGHT: f32 = 60.;115
const HEADER_PADDING: f32 = 20.;120
const HEADER_PADDING: f32 = 20.;116
const HEADER_GAP: f32 = 12.;121
const HEADER_GAP: f32 = 12.;@@ -178,6 +183,7 @@ struct Current {178
has_older: bool,183
has_older: bool,179
loading_older: bool,184
loading_older: bool,180
older_blocked: bool,185
older_blocked: bool,186
quiet_retries: usize,181
fetched: bool,187
fetched: bool,182
first_unread: Option<String>,188
first_unread: Option<String>,183
posts_new_after: Option<DateTime<Utc>>,189
posts_new_after: Option<DateTime<Utc>>,@@ -929,6 +935,7 @@ impl ConversationView {929
loading_older: false,935
loading_older: false,930
older_blocked: false,936
older_blocked: false,931
fetched: false,937
fetched: false,938
quiet_retries: 0,932
first_unread,939
first_unread,933
posts_new_after,940
posts_new_after,934
sync: SyncProgress::default(),941
sync: SyncProgress::default(),@@ -1923,15 +1930,38 @@ impl ConversationView {1923
sync.messages = false;1930
sync.messages = false;1924
let (newest_cached, started_at) = (sync.newest_cached, sync.started_at);1931
let (newest_cached, started_at) = (sync.newest_cached, sync.started_at);1925
match result {1932
match result {1926
Ok(Ok(_)) => self.mark_fetched_new(newest_cached, started_at, cx),1933
Ok(Ok(_)) => {1927
Ok(Err(error)) => self.fail_sync(generation, short_error(&error)),1934
if let Some(current) = self.current.as_mut() {1928
Err(error) => self.fail_sync(generation, short_error(&error)),1935
current.quiet_retries = 0;1936
}1937
self.mark_fetched_new(newest_cached, started_at, cx)1938
}1939
Ok(Err(error)) => self.fail_sync(generation, short_error(&error), cx),1940
Err(error) => self.fail_sync(generation, short_error(&error), cx),1929
}1941
}1930
self.rebuild(false, cx);1942
self.rebuild(false, cx);1931
self.settle_progress(generation, cx);1943
self.settle_progress(generation, cx);1932
}1944
}1933
1945
1934
fn fail_sync(&mut self, generation: u64, error: String) {1946
fn fail_sync(&mut self, generation: u64, error: String, cx: &mut Context<Self>) {1947
let quiet_retry = self.current.as_mut().and_then(|current| {1948
let delay = QUIET_RETRY_DELAYS.get(current.quiet_retries).copied()?;1949
current.quiet_retries += 1;1950
Some(delay)1951
});1952
if let Some(delay) = quiet_retry {1953
cx.spawn(async move |this, cx| {1954
cx.background_executor().timer(delay).await;1955
this.update(cx, |this, cx| {1956
if this.sync_generation == generation {1957
this.retry_fetch(cx);1958
}1959
})1960
.ok();1961
})1962
.detach();1963
return;1964
}1935
if let Some(sync) = self.sync_of(generation) {1965
if let Some(sync) = self.sync_of(generation) {1936
sync.failed = true;1966
sync.failed = true;1937
sync.receipts = false;1967
sync.receipts = false;