Skip to content

Commit

Permalink
assistant2: Small efficiency improvements + add a todo
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Jan 10, 2025
1 parent 767f44b commit 663116a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
27 changes: 13 additions & 14 deletions crates/assistant2/src/context_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,26 @@ impl ContextStore {
collect_files_in_path(worktree, &project_path.path)
})?;

let open_buffer_tasks = project.update(&mut cx, |project, cx| {
files
.iter()
.map(|file_path| {
project.open_buffer(
ProjectPath {
worktree_id,
path: file_path.clone(),
},
cx,
)
})
.collect::<Vec<_>>()
let open_buffers_task = project.update(&mut cx, |project, cx| {
let tasks = files.iter().map(|file_path| {
project.open_buffer(
ProjectPath {
worktree_id,
path: file_path.clone(),
},
cx,
)
});
future::join_all(tasks)
})?;

let buffers = future::join_all(open_buffer_tasks).await;
let buffers = open_buffers_task.await;

let mut buffer_infos = Vec::new();
let mut text_tasks = Vec::new();
this.update(&mut cx, |_, cx| {
for (path, buffer_model) in files.into_iter().zip(buffers) {
// TODO: Collect multiple errors?
let buffer_model = buffer_model?;
let buffer = buffer_model.read(cx);
let (buffer_info, text_task) =
Expand Down
4 changes: 2 additions & 2 deletions crates/language_model/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ impl LanguageModelRequestMessage {
.content
.first()
.map(|content| match content {
MessageContent::Text(text) => text.trim().is_empty(),
MessageContent::Text(text) => text.chars().all(|c| c.is_whitespace()),
MessageContent::ToolResult(tool_result) => {
tool_result.content.trim().is_empty()
tool_result.content.chars().all(|c| c.is_whitespace())
}
MessageContent::ToolUse(_) | MessageContent::Image(_) => true,
})
Expand Down

0 comments on commit 663116a

Please sign in to comment.