fix: session downgrade (#8196)

The problem is that the `tokio` task own an `Arc` reference of the
session and that this task only exit with the broadcast channel get
closed. But this never get closed if the session is not dropped. So it's
a snake biting his tail basically

The most notable result was that non of the `Drop` implementation were
triggered (temporary files, shell snapshots, session cleaning etc etc)
when closing the session (through a `/new` for example)

The fix is just to weaken the `Arc` and upgrade it on the fly
This commit is contained in:
jif-oai
2025-12-17 18:44:39 +00:00
committed by GitHub
parent 9f28c6251d
commit 167553f00d
2 changed files with 39 additions and 1 deletions

View File

@@ -738,11 +738,14 @@ impl Session {
.services
.skills_manager
.subscribe_skills_update_notifications();
let sess = Arc::clone(&sess);
let sess = Arc::downgrade(&sess);
tokio::spawn(async move {
loop {
match rx.recv().await {
Ok(()) => {
let Some(sess) = sess.upgrade() else {
break;
};
let turn_context = sess.new_default_turn().await;
sess.send_event(turn_context.as_ref(), EventMsg::SkillsUpdateAvailable)
.await;