agent: Allow renaming threads (#28102)
Release Notes: - agent: Add support for renaming threads --------- Co-authored-by: Danilo Leal <daniloleal09@gmail.com> Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de> Co-authored-by: Richard Feldman <oss@rtfeldman.com>
This commit is contained in:
parent
ef8fe52877
commit
1bc5618f61
4 changed files with 151 additions and 51 deletions
|
@ -385,14 +385,25 @@ impl Thread {
|
|||
self.summary.clone()
|
||||
}
|
||||
|
||||
pub const DEFAULT_SUMMARY: SharedString = SharedString::new_static("New Thread");
|
||||
|
||||
pub fn summary_or_default(&self) -> SharedString {
|
||||
const DEFAULT: SharedString = SharedString::new_static("New Thread");
|
||||
self.summary.clone().unwrap_or(DEFAULT)
|
||||
self.summary.clone().unwrap_or(Self::DEFAULT_SUMMARY)
|
||||
}
|
||||
|
||||
pub fn set_summary(&mut self, summary: impl Into<SharedString>, cx: &mut Context<Self>) {
|
||||
self.summary = Some(summary.into());
|
||||
cx.emit(ThreadEvent::SummaryChanged);
|
||||
let summary = summary.into();
|
||||
let old_summary = self.summary_or_default();
|
||||
|
||||
self.summary = if summary.is_empty() {
|
||||
Some(Self::DEFAULT_SUMMARY)
|
||||
} else {
|
||||
Some(summary)
|
||||
};
|
||||
|
||||
if Some(old_summary) != self.summary {
|
||||
cx.emit(ThreadEvent::SummaryChanged);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn latest_detailed_summary_or_text(&self) -> SharedString {
|
||||
|
@ -1293,7 +1304,7 @@ impl Thread {
|
|||
this.summary = Some(new_summary.into());
|
||||
}
|
||||
|
||||
cx.emit(ThreadEvent::SummaryChanged);
|
||||
cx.emit(ThreadEvent::SummaryGenerated);
|
||||
})?;
|
||||
|
||||
anyhow::Ok(())
|
||||
|
@ -1847,6 +1858,7 @@ pub enum ThreadEvent {
|
|||
MessageAdded(MessageId),
|
||||
MessageEdited(MessageId),
|
||||
MessageDeleted(MessageId),
|
||||
SummaryGenerated,
|
||||
SummaryChanged,
|
||||
UsePendingTools,
|
||||
ToolFinished {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue