fix(meetings): recording lines no longer jump when the expiry loads
- The recording expiry per chat is cached in the store and used before the first rebuild - The SharePoint lookup only rebuilds when the expiry changed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -7,7 +7,7 @@ use chatsvc::{
7
7
Attendance, Occurrence, Recap, RecordingDetails, TranscriptFormat, TranscriptTurn,
8
8
days_until_expiry,
9
9
};
10
use chrono::Utc;
10
use chrono::{DateTime, Utc};
11
11
use gpui_kit::component::WindowExt as _;
12
12
use gpui_kit::component::button::{Button, ButtonVariants as _};
13
13
use gpui_kit::component::dialog::DialogFooter;
@@ -31,6 +31,7 @@ use crate::views::shared_tab::{SharedCommand, SharedRun};
31
31
const SEARCH_PLACEHOLDER: &str = "Search transcript";
32
32
const RECORDING_EXTENSION: &str = "mp4";
33
33
const EXPIRY_OCCURRENCES: usize = 3;
34
const EXPIRY_CACHE_PREFIX: &str = "recording_expiry/";
34
35
35
36
pub(super) fn search_input(
36
37
window: &mut Window,
@@ -144,6 +145,7 @@ impl ConversationView {
144
145
let Some(engine) = engine else {
145
146
return;
146
147
};
148
self.recap.expiry_days = expiry_days(&cached_expiry(state, &conversation_id), Utc::now());
147
149
let generation = self.recap.generation;
148
150
let receiver = runtime::spawn(async move {
149
151
Recap::new(engine.remote().session())
@@ -211,14 +213,22 @@ impl ConversationView {
211
213
if this.conversation_id().as_deref() != Some(conversation_id.as_str()) {
212
214
return;
213
215
}
214
let now = Utc::now();
215
this.recap.expiry_days = found
216
.into_iter()
217
.filter_map(|(message_id, expires_at)| {
218
Some((message_id, days_until_expiry(expires_at?, now)))
219
})
220
.collect();
221
this.rebuild(false, cx);
216
let state = this.app.read(cx);
217
let mut cached = cached_expiry(state, &conversation_id);
218
cached.extend(
219
found
220
.into_iter()
221
.filter_map(|(message_id, expires_at)| Some((message_id, expires_at?))),
222
);
223
if let Ok(json) = serde_json::to_string(&cached) {
224
let key = format!("{EXPIRY_CACHE_PREFIX}{conversation_id}");
225
state.store.set_meta(&key, &json).ok();
226
}
227
let expiry = expiry_days(&cached, Utc::now());
228
if expiry != this.recap.expiry_days {
229
this.recap.expiry_days = expiry;
230
this.rebuild(false, cx);
231
}
222
232
})
223
233
.ok();
224
234
})
@@ -692,3 +702,24 @@ async fn save_download(
692
702
}
693
703
Ok(target)
694
704
}
705
706
/// Expiry from the last open, so the recording lines have their final text in the first frame.
707
fn cached_expiry(state: &AppState, conversation_id: &str) -> HashMap<String, DateTime<Utc>> {
708
state
709
.store
710
.meta(&format!("{EXPIRY_CACHE_PREFIX}{conversation_id}"))
711
.ok()
712
.flatten()
713
.and_then(|json| serde_json::from_str(&json).ok())
714
.unwrap_or_default()
715
}
716
717
fn expiry_days(
718
expiry: &HashMap<String, DateTime<Utc>>,
719
now: DateTime<Utc>,
720
) -> HashMap<String, i64> {
721
expiry
722
.iter()
723
.map(|(message_id, expires_at)| (message_id.clone(), days_until_expiry(*expires_at, now)))
724
.collect()
725
}
@@ -7,7 +7,7 @@ use chatsvc::{7
Attendance, Occurrence, Recap, RecordingDetails, TranscriptFormat, TranscriptTurn,7
Attendance, Occurrence, Recap, RecordingDetails, TranscriptFormat, TranscriptTurn,8
days_until_expiry,8
days_until_expiry,9
};9
};10
use chrono::Utc;10
use chrono::{DateTime, Utc};11
use gpui_kit::component::WindowExt as _;11
use gpui_kit::component::WindowExt as _;12
use gpui_kit::component::button::{Button, ButtonVariants as _};12
use gpui_kit::component::button::{Button, ButtonVariants as _};13
use gpui_kit::component::dialog::DialogFooter;13
use gpui_kit::component::dialog::DialogFooter;@@ -31,6 +31,7 @@ use crate::views::shared_tab::{SharedCommand, SharedRun};31
const SEARCH_PLACEHOLDER: &str = "Search transcript";31
const SEARCH_PLACEHOLDER: &str = "Search transcript";32
const RECORDING_EXTENSION: &str = "mp4";32
const RECORDING_EXTENSION: &str = "mp4";33
const EXPIRY_OCCURRENCES: usize = 3;33
const EXPIRY_OCCURRENCES: usize = 3;34
const EXPIRY_CACHE_PREFIX: &str = "recording_expiry/";34
35
35
pub(super) fn search_input(36
pub(super) fn search_input(36
window: &mut Window,37
window: &mut Window,@@ -144,6 +145,7 @@ impl ConversationView {144
let Some(engine) = engine else {145
let Some(engine) = engine else {145
return;146
return;146
};147
};148
self.recap.expiry_days = expiry_days(&cached_expiry(state, &conversation_id), Utc::now());147
let generation = self.recap.generation;149
let generation = self.recap.generation;148
let receiver = runtime::spawn(async move {150
let receiver = runtime::spawn(async move {149
Recap::new(engine.remote().session())151
Recap::new(engine.remote().session())@@ -211,14 +213,22 @@ impl ConversationView {211
if this.conversation_id().as_deref() != Some(conversation_id.as_str()) {213
if this.conversation_id().as_deref() != Some(conversation_id.as_str()) {212
return;214
return;213
}215
}214
let now = Utc::now();216
let state = this.app.read(cx);215
this.recap.expiry_days = found217
let mut cached = cached_expiry(state, &conversation_id);216
.into_iter()218
cached.extend(217
.filter_map(|(message_id, expires_at)| {219
found218
Some((message_id, days_until_expiry(expires_at?, now)))220
.into_iter()219
})221
.filter_map(|(message_id, expires_at)| Some((message_id, expires_at?))),220
.collect();222
);221
this.rebuild(false, cx);223
if let Ok(json) = serde_json::to_string(&cached) {224
let key = format!("{EXPIRY_CACHE_PREFIX}{conversation_id}");225
state.store.set_meta(&key, &json).ok();226
}227
let expiry = expiry_days(&cached, Utc::now());228
if expiry != this.recap.expiry_days {229
this.recap.expiry_days = expiry;230
this.rebuild(false, cx);231
}222
})232
})223
.ok();233
.ok();224
})234
})@@ -692,3 +702,24 @@ async fn save_download(692
}702
}693
Ok(target)703
Ok(target)694
}704
}705
706
/// Expiry from the last open, so the recording lines have their final text in the first frame.707
fn cached_expiry(state: &AppState, conversation_id: &str) -> HashMap<String, DateTime<Utc>> {708
state709
.store710
.meta(&format!("{EXPIRY_CACHE_PREFIX}{conversation_id}"))711
.ok()712
.flatten()713
.and_then(|json| serde_json::from_str(&json).ok())714
.unwrap_or_default()715
}716
717
fn expiry_days(718
expiry: &HashMap<String, DateTime<Utc>>,719
now: DateTime<Utc>,720
) -> HashMap<String, i64> {721
expiry722
.iter()723
.map(|(message_id, expires_at)| (message_id.clone(), days_until_expiry(*expires_at, now)))724
.collect()725
}