Skip to content

Commit

Permalink
Merge branch 'zed-industries:main' into file_path_regex
Browse files Browse the repository at this point in the history
  • Loading branch information
nathansbradshaw committed May 2, 2024
2 parents 291d8b5 + 1abd580 commit 7d78e3b
Show file tree
Hide file tree
Showing 53 changed files with 1,428 additions and 1,030 deletions.
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ members = [
"crates/refineable",
"crates/refineable/derive_refineable",
"crates/release_channel",
"crates/remote_projects",
"crates/dev_server_projects",
"crates/rich_text",
"crates/rope",
"crates/rpc",
Expand Down Expand Up @@ -207,7 +207,7 @@ project_symbols = { path = "crates/project_symbols" }
quick_action_bar = { path = "crates/quick_action_bar" }
recent_projects = { path = "crates/recent_projects" }
release_channel = { path = "crates/release_channel" }
remote_projects = { path = "crates/remote_projects" }
dev_server_projects = { path = "crates/dev_server_projects" }
rich_text = { path = "crates/rich_text" }
rope = { path = "crates/rope" }
rpc = { path = "crates/rpc" }
Expand Down
1 change: 1 addition & 0 deletions assets/icons/code.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions assets/icons/spinner.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 1 addition & 7 deletions crates/assistant2/src/assistant2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl AssistantChat {
composer_editor: cx.new_view(|cx| {
let mut editor = Editor::auto_height(80, cx);
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
editor.set_placeholder_text("Type a message to the assistant", cx);
editor.set_placeholder_text("Send a message", cx);
editor
}),
list_state,
Expand Down Expand Up @@ -372,10 +372,6 @@ impl AssistantChat {
}));
}

fn can_submit(&self) -> bool {
self.pending_completion.is_none()
}

fn debug_project_index(&mut self, _: &DebugProjectIndex, cx: &mut ViewContext<Self>) {
if let Some(index) = &self.project_index {
index.update(cx, |project_index, cx| {
Expand Down Expand Up @@ -594,7 +590,6 @@ impl AssistantChat {
element.child(Composer::new(
body.clone(),
self.user_store.read(cx).current_user(),
true,
self.tool_registry.clone(),
crate::ui::ModelSelector::new(
cx.view().downgrade(),
Expand Down Expand Up @@ -773,7 +768,6 @@ impl Render for AssistantChat {
.child(Composer::new(
self.composer_editor.clone(),
self.user_store.read(cx).current_user(),
self.can_submit(),
self.tool_registry.clone(),
crate::ui::ModelSelector::new(cx.view().downgrade(), self.model.clone())
.into_any_element(),
Expand Down
73 changes: 62 additions & 11 deletions crates/assistant2/src/tools/project_index.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use anyhow::Result;
use assistant_tooling::LanguageModelTool;
use gpui::{prelude::*, AnyView, Model, Task};
use gpui::{percentage, prelude::*, Animation, AnimationExt, AnyView, Model, Task, Transformation};
use project::Fs;
use schemars::JsonSchema;
use semantic_index::{ProjectIndex, Status};
use serde::Deserialize;
use std::sync::Arc;
use std::{sync::Arc, time::Duration};
use ui::{
div, prelude::*, CollapsibleContainer, Color, Icon, IconName, Label, SharedString,
WindowContext,
div, prelude::*, ButtonLike, CollapsibleContainer, Color, Icon, IconName, Indicator, Label,
SharedString, Tooltip, WindowContext,
};
use util::ResultExt as _;

Expand Down Expand Up @@ -255,12 +255,63 @@ impl Render for ProjectIndexStatusView {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let status = self.project_index.read(cx).status();

h_flex().gap_2().map(|element| match status {
Status::Idle => element.child(Label::new("Project index ready")),
Status::Loading => element.child(Label::new("Project index loading...")),
Status::Scanning { remaining_count } => element.child(Label::new(format!(
"Project index scanning: {remaining_count} remaining..."
))),
})
let is_enabled = match status {
Status::Idle => true,
_ => false,
};

let icon = match status {
Status::Idle => Icon::new(IconName::Code)
.size(IconSize::XSmall)
.color(Color::Default),
Status::Loading => Icon::new(IconName::Code)
.size(IconSize::XSmall)
.color(Color::Muted),
Status::Scanning { .. } => Icon::new(IconName::Code)
.size(IconSize::XSmall)
.color(Color::Muted),
};

let indicator = match status {
Status::Idle => Some(Indicator::dot().color(Color::Success)),
Status::Scanning { .. } => Some(Indicator::dot().color(Color::Warning)),
Status::Loading => Some(Indicator::icon(
Icon::new(IconName::Spinner)
.color(Color::Accent)
.with_animation(
"arrow-circle",
Animation::new(Duration::from_secs(2)).repeat(),
|icon, delta| icon.transform(Transformation::rotate(percentage(delta))),
),
)),
};

ButtonLike::new("project-index")
.disabled(!is_enabled)
.child(
ui::IconWithIndicator::new(icon, indicator)
.indicator_border_color(Some(gpui::transparent_black())),
)
.tooltip({
move |cx| {
let (tooltip, meta) = match status {
Status::Idle => (
"Project index ready".to_string(),
Some("Click to disable".to_string()),
),
Status::Loading => ("Project index loading...".to_string(), None),
Status::Scanning { remaining_count } => (
"Project index scanning...".to_string(),
Some(format!("{} remaining...", remaining_count)),
),
};

if let Some(meta) = meta {
Tooltip::with_meta(tooltip, None, meta, cx)
} else {
Tooltip::text(tooltip, cx)
}
}
})
}
}

0 comments on commit 7d78e3b

Please sign in to comment.