Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/jp_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ fn run_inner(cli: Cli) -> Result<Success> {
)
.map_err(Error::Task)?;

// Remove ephemeral conversations that are no longer needed.
ctx.workspace.remove_ephemeral_conversations();

output.map_err(Into::into)
}
}
Expand Down
15 changes: 13 additions & 2 deletions crates/jp_workspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ impl Workspace {

trace!("Persisting state.");

let active_id = self.active_conversation_id();
let Some(storage) = self.storage.as_mut() else {
return Ok(());
};
Expand All @@ -261,7 +260,6 @@ impl Workspace {
.active_conversation_id,
&self.state.local.active_conversation,
)?;
storage.remove_ephemeral_conversations(&[active_id]);

info!(path = %self.root.display(), "Persisted state.");
Ok(())
Expand Down Expand Up @@ -294,6 +292,19 @@ impl Workspace {
Ok(())
}

pub fn remove_ephemeral_conversations(&mut self) {
if self.disable_persistence {
return;
}

let active_id = self.active_conversation_id();
let Some(storage) = self.storage.as_mut() else {
return;
};

storage.remove_ephemeral_conversations(&[active_id]);
}

/// Gets the ID of the active conversation.
#[must_use]
pub fn active_conversation_id(&self) -> ConversationId {
Expand Down
Loading