Render messages as early as possible to show progress (#11569)
This shows "Researching..." as placeholder text as early as possible so that the user can see the model is working on reading/researching/etc. This also adds on an `Option<Value>` to the `render_running` function so that tools can hopefully render based on partially completed JSON (still to come). Release Notes: - N/A
This commit is contained in:
parent
dbebb40956
commit
689e4aef2f
6 changed files with 46 additions and 15 deletions
|
@ -16,7 +16,8 @@ use crate::{
|
|||
use ::ui::{div, prelude::*, Color, Tooltip, ViewContext};
|
||||
use anyhow::{Context, Result};
|
||||
use assistant_tooling::{
|
||||
AttachmentRegistry, ProjectContext, ToolFunctionCall, ToolRegistry, UserAttachment,
|
||||
tool_running_placeholder, AttachmentRegistry, ProjectContext, ToolFunctionCall, ToolRegistry,
|
||||
UserAttachment,
|
||||
};
|
||||
use client::{proto, Client, UserStore};
|
||||
use collections::HashMap;
|
||||
|
@ -864,6 +865,10 @@ impl AssistantChat {
|
|||
}
|
||||
}
|
||||
|
||||
if message_elements.is_empty() {
|
||||
message_elements.push(tool_running_placeholder());
|
||||
}
|
||||
|
||||
div()
|
||||
.when(is_first, |this| this.pt(padding))
|
||||
.child(
|
||||
|
|
|
@ -6,6 +6,7 @@ use project::ProjectPath;
|
|||
use schemars::JsonSchema;
|
||||
use semantic_index::{ProjectIndex, Status};
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
use std::{fmt::Write as _, ops::Range};
|
||||
use ui::{div, prelude::*, CollapsibleContainer, Color, Icon, IconName, Label, WindowContext};
|
||||
|
||||
|
@ -202,8 +203,14 @@ impl LanguageModelTool for ProjectIndexTool {
|
|||
cx.new_view(|_cx| ProjectIndexView::new(input, output))
|
||||
}
|
||||
|
||||
fn render_running(_: &mut WindowContext) -> impl IntoElement {
|
||||
CollapsibleContainer::new(ElementId::Name(nanoid::nanoid!().into()), false)
|
||||
.start_slot("Searching code base")
|
||||
fn render_running(arguments: &Option<Value>, _: &mut WindowContext) -> impl IntoElement {
|
||||
let text: String = arguments
|
||||
.as_ref()
|
||||
.and_then(|arguments| arguments.get("query"))
|
||||
.and_then(|query| query.as_str())
|
||||
.map(|query| format!("Searching for: {}", query))
|
||||
.unwrap_or_else(|| "Preparing search...".to_string());
|
||||
|
||||
CollapsibleContainer::new(ElementId::Name(nanoid::nanoid!().into()), false).start_slot(text)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue