assistant2: Expand some variable names (#22742)

This PR expands some variables names in the `ThreadStore` for better
readability.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-01-06 18:02:51 -05:00 committed by GitHub
parent e36ae0465c
commit 847596af6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -112,22 +112,22 @@ impl ContextStore {
} }
pub fn remove_context(&mut self, id: &ContextId) { pub fn remove_context(&mut self, id: &ContextId) {
let Some(ix) = self.context.iter().position(|c| c.id == *id) else { let Some(ix) = self.context.iter().position(|context| context.id == *id) else {
return; return;
}; };
match self.context.remove(ix).kind { match self.context.remove(ix).kind {
ContextKind::File => { ContextKind::File => {
self.files.retain(|_, p_id| p_id != id); self.files.retain(|_, context_id| context_id != id);
} }
ContextKind::Directory => { ContextKind::Directory => {
self.directories.retain(|_, p_id| p_id != id); self.directories.retain(|_, context_id| context_id != id);
} }
ContextKind::FetchedUrl => { ContextKind::FetchedUrl => {
self.fetched_urls.retain(|_, p_id| p_id != id); self.fetched_urls.retain(|_, context_id| context_id != id);
} }
ContextKind::Thread => { ContextKind::Thread => {
self.threads.retain(|_, p_id| p_id != id); self.threads.retain(|_, context_id| context_id != id);
} }
} }
} }
@ -170,23 +170,23 @@ pub enum IncludedFile {
InDirectory(PathBuf), InDirectory(PathBuf),
} }
pub(crate) fn push_fenced_codeblock(path: &Path, content: String, buf: &mut String) { pub(crate) fn push_fenced_codeblock(path: &Path, content: String, buffer: &mut String) {
buf.reserve(content.len() + 64); buffer.reserve(content.len() + 64);
write!(buf, "```").unwrap(); write!(buffer, "```").unwrap();
if let Some(extension) = path.extension().and_then(|ext| ext.to_str()) { if let Some(extension) = path.extension().and_then(|ext| ext.to_str()) {
write!(buf, "{} ", extension).unwrap(); write!(buffer, "{} ", extension).unwrap();
} }
write!(buf, "{}", path.display()).unwrap(); write!(buffer, "{}", path.display()).unwrap();
buf.push('\n'); buffer.push('\n');
buf.push_str(&content); buffer.push_str(&content);
if !buf.ends_with('\n') { if !buffer.ends_with('\n') {
buf.push('\n'); buffer.push('\n');
} }
buf.push_str("```\n"); buffer.push_str("```\n");
} }