fix(app): smaller chat thumbnails and image budget, log older pages
- Thumbnails decode at most 720 px (tiles are 360 px), image cache budget 48 MB - Older page loads, empty ends and failures go to the diagnostics log Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -2352,6 +2352,7 @@ impl ConversationView {
2352
2352
current.loading_older = false;
2353
2353
match result {
2354
2354
Ok(Ok(records)) if !records.is_empty() => {
2355
app_base::diagnostics::record(&format!("chat: older page, {} messages", records.len()));
2355
2356
current.loaded_limit = current.loaded_count + records.len();
2356
2357
self.older_anchor = self
2357
2358
.rows
@@ -2360,8 +2361,12 @@ impl ConversationView {
2360
2361
.find(|row| matches!(row, Row::Message(_) | Row::Post(_)))
2361
2362
.map(|row| row.key().to_owned());
2362
2363
}
2363
Ok(Ok(_)) => current.older_blocked = true,
2364
Ok(Ok(_)) => {
2365
app_base::diagnostics::record("chat: no older messages");
2366
current.older_blocked = true;
2367
}
2364
2368
Ok(Err(error)) => {
2369
app_base::diagnostics::record(&format!("chat: older page failed: {}", short_error(&error)));
2365
2370
current.older_blocked = true;
2366
2371
self.notice = Some(format!(
2367
2372
"Could not load older messages: {}",
@@ -2352,6 +2352,7 @@ impl ConversationView {2352
current.loading_older = false;2352
current.loading_older = false;2353
match result {2353
match result {2354
Ok(Ok(records)) if !records.is_empty() => {2354
Ok(Ok(records)) if !records.is_empty() => {2355
app_base::diagnostics::record(&format!("chat: older page, {} messages", records.len()));2355
current.loaded_limit = current.loaded_count + records.len();2356
current.loaded_limit = current.loaded_count + records.len();2356
self.older_anchor = self2357
self.older_anchor = self2357
.rows2358
.rows@@ -2360,8 +2361,12 @@ impl ConversationView {2360
.find(|row| matches!(row, Row::Message(_) | Row::Post(_)))2361
.find(|row| matches!(row, Row::Message(_) | Row::Post(_)))2361
.map(|row| row.key().to_owned());2362
.map(|row| row.key().to_owned());2362
}2363
}2363
Ok(Ok(_)) => current.older_blocked = true,2364
Ok(Ok(_)) => {2365
app_base::diagnostics::record("chat: no older messages");2366
current.older_blocked = true;2367
}2364
Ok(Err(error)) => {2368
Ok(Err(error)) => {2369
app_base::diagnostics::record(&format!("chat: older page failed: {}", short_error(&error)));2365
current.older_blocked = true;2370
current.older_blocked = true;2366
self.notice = Some(format!(2371
self.notice = Some(format!(2367
"Could not load older messages: {}",2372
"Could not load older messages: {}",@@ -10,11 +10,11 @@ use gpui_kit::{
10
10
use image::imageops::FilterType;
11
11
use image::{Frame, ImageFormat, ImageReader};
12
12
13
const BUDGET_BYTES: u64 = 64 * MEGABYTE;
13
const BUDGET_BYTES: u64 = 48 * MEGABYTE;
14
14
const KEEP_RECENT: Duration = Duration::from_secs(10);
15
15
const REPORT_EVERY: Duration = Duration::from_secs(60);
16
16
const MEGABYTE: u64 = 1024 * 1024;
17
const PREVIEW_EDGE: u32 = 1024;
17
const PREVIEW_EDGE: u32 = 720;
18
18
19
19
/// An image source whose decoded pixels are freed again once the image has been off screen for a while and the budget is full.
20
20
pub fn bounded(source: impl Into<ImageSource>) -> ImageSource {
@@ -219,7 +219,7 @@ mod tests {
219
219
(2, now - Duration::from_secs(200), 30 * MEGABYTE),
220
220
(3, now - Duration::from_secs(100), 20 * MEGABYTE),
221
221
];
222
assert_eq!(evictions(sizes, now), vec![1]);
222
assert_eq!(evictions(sizes, now), vec![1, 2]);
223
223
}
224
224
225
225
#[test]
@@ -241,7 +241,7 @@ mod tests {
241
241
let photo = directory.path().join("photo");
242
242
image::RgbaImage::new(3000, 2000).save_with_format(&photo, ImageFormat::Png).unwrap();
243
243
let decoded = decode_preview(&photo).unwrap();
244
assert_eq!((decoded.size(0).width.0, decoded.size(0).height.0), (1024, 683));
244
assert_eq!((decoded.size(0).width.0, decoded.size(0).height.0), (720, 480));
245
245
let animation = directory.path().join("animation");
246
246
image::RgbaImage::new(10, 10).save_with_format(&animation, ImageFormat::Gif).unwrap();
247
247
assert!(decode_preview(&animation).is_none());
@@ -10,11 +10,11 @@ use gpui_kit::{10
use image::imageops::FilterType;10
use image::imageops::FilterType;11
use image::{Frame, ImageFormat, ImageReader};11
use image::{Frame, ImageFormat, ImageReader};12
12
13
const BUDGET_BYTES: u64 = 64 * MEGABYTE;13
const BUDGET_BYTES: u64 = 48 * MEGABYTE;14
const KEEP_RECENT: Duration = Duration::from_secs(10);14
const KEEP_RECENT: Duration = Duration::from_secs(10);15
const REPORT_EVERY: Duration = Duration::from_secs(60);15
const REPORT_EVERY: Duration = Duration::from_secs(60);16
const MEGABYTE: u64 = 1024 * 1024;16
const MEGABYTE: u64 = 1024 * 1024;17
const PREVIEW_EDGE: u32 = 1024;17
const PREVIEW_EDGE: u32 = 720;18
18
19
/// An image source whose decoded pixels are freed again once the image has been off screen for a while and the budget is full.19
/// An image source whose decoded pixels are freed again once the image has been off screen for a while and the budget is full.20
pub fn bounded(source: impl Into<ImageSource>) -> ImageSource {20
pub fn bounded(source: impl Into<ImageSource>) -> ImageSource {@@ -219,7 +219,7 @@ mod tests {219
(2, now - Duration::from_secs(200), 30 * MEGABYTE),219
(2, now - Duration::from_secs(200), 30 * MEGABYTE),220
(3, now - Duration::from_secs(100), 20 * MEGABYTE),220
(3, now - Duration::from_secs(100), 20 * MEGABYTE),221
];221
];222
assert_eq!(evictions(sizes, now), vec![1]);222
assert_eq!(evictions(sizes, now), vec![1, 2]);223
}223
}224
224
225
#[test]225
#[test]@@ -241,7 +241,7 @@ mod tests {241
let photo = directory.path().join("photo");241
let photo = directory.path().join("photo");242
image::RgbaImage::new(3000, 2000).save_with_format(&photo, ImageFormat::Png).unwrap();242
image::RgbaImage::new(3000, 2000).save_with_format(&photo, ImageFormat::Png).unwrap();243
let decoded = decode_preview(&photo).unwrap();243
let decoded = decode_preview(&photo).unwrap();244
assert_eq!((decoded.size(0).width.0, decoded.size(0).height.0), (1024, 683));244
assert_eq!((decoded.size(0).width.0, decoded.size(0).height.0), (720, 480));245
let animation = directory.path().join("animation");245
let animation = directory.path().join("animation");246
image::RgbaImage::new(10, 10).save_with_format(&animation, ImageFormat::Gif).unwrap();246
image::RgbaImage::new(10, 10).save_with_format(&animation, ImageFormat::Gif).unwrap();247
assert!(decode_preview(&animation).is_none());247
assert!(decode_preview(&animation).is_none());