Merge remote-tracking branch 'origin/main' into editor2-blocks

This commit is contained in:
Antonio Scandurra 2023-11-14 17:16:58 +01:00
commit 40c634e056
14 changed files with 124 additions and 64 deletions

4
Cargo.lock generated
View file

@ -9256,9 +9256,9 @@ dependencies = [
[[package]] [[package]]
name = "tiktoken-rs" name = "tiktoken-rs"
version = "0.5.4" version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9ae5a3c24361e5f038af22517ba7f8e3af4099e30e78a3d56f86b48238fce9d" checksum = "a4427b6b1c6b38215b92dd47a83a0ecc6735573d0a5a4c14acc0ac5b33b28adb"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.21.4", "base64 0.21.4",

View file

@ -154,6 +154,7 @@ tempdir = { version = "0.3.7" }
thiserror = { version = "1.0.29" } thiserror = { version = "1.0.29" }
time = { version = "0.3", features = ["serde", "serde-well-known"] } time = { version = "0.3", features = ["serde", "serde-well-known"] }
toml = { version = "0.5" } toml = { version = "0.5" }
tiktoken-rs = "0.5.7"
tree-sitter = "0.20" tree-sitter = "0.20"
unindent = { version = "0.1.7" } unindent = { version = "0.1.7" }
pretty_assertions = "1.3.0" pretty_assertions = "1.3.0"

View file

@ -174,7 +174,8 @@
// //
// 1. "gpt-3.5-turbo-0613"" // 1. "gpt-3.5-turbo-0613""
// 2. "gpt-4-0613"" // 2. "gpt-4-0613""
"default_open_ai_model": "gpt-4-0613" // 3. "gpt-4-1106-preview"
"default_open_ai_model": "gpt-4-1106-preview"
}, },
// Whether the screen sharing icon is shown in the os status bar. // Whether the screen sharing icon is shown in the os status bar.
"show_call_status_icon": true, "show_call_status_icon": true,
@ -270,9 +271,7 @@
"copilot": { "copilot": {
// The set of glob patterns for which copilot should be disabled // The set of glob patterns for which copilot should be disabled
// in any matching file. // in any matching file.
"disabled_globs": [ "disabled_globs": [".env"]
".env"
]
}, },
// Settings specific to journaling // Settings specific to journaling
"journal": { "journal": {
@ -381,12 +380,7 @@
// Default directories to search for virtual environments, relative // Default directories to search for virtual environments, relative
// to the current working directory. We recommend overriding this // to the current working directory. We recommend overriding this
// in your project's settings, rather than globally. // in your project's settings, rather than globally.
"directories": [ "directories": [".env", "env", ".venv", "venv"],
".env",
"env",
".venv",
"venv"
],
// Can also be 'csh', 'fish', and `nushell` // Can also be 'csh', 'fish', and `nushell`
"activate_script": "default" "activate_script": "default"
} }

View file

@ -29,7 +29,7 @@ postage.workspace = true
rand.workspace = true rand.workspace = true
log.workspace = true log.workspace = true
parse_duration = "2.1.1" parse_duration = "2.1.1"
tiktoken-rs = "0.5.0" tiktoken-rs.workspace = true
matrixmultiply = "0.3.7" matrixmultiply = "0.3.7"
rusqlite = { version = "0.29.0", features = ["blob", "array", "modern_sqlite"] } rusqlite = { version = "0.29.0", features = ["blob", "array", "modern_sqlite"] }
bincode = "1.3.3" bincode = "1.3.3"

View file

@ -29,7 +29,7 @@ postage.workspace = true
rand.workspace = true rand.workspace = true
log.workspace = true log.workspace = true
parse_duration = "2.1.1" parse_duration = "2.1.1"
tiktoken-rs = "0.5.0" tiktoken-rs.workspace = true
matrixmultiply = "0.3.7" matrixmultiply = "0.3.7"
rusqlite = { version = "0.29.0", features = ["blob", "array", "modern_sqlite"] } rusqlite = { version = "0.29.0", features = ["blob", "array", "modern_sqlite"] }
bincode = "1.3.3" bincode = "1.3.3"

View file

@ -29,7 +29,7 @@ postage.workspace = true
rand.workspace = true rand.workspace = true
log.workspace = true log.workspace = true
parse_duration = "2.1.1" parse_duration = "2.1.1"
tiktoken-rs = "0.5.0" tiktoken-rs.workspace = true
matrixmultiply = "0.3.7" matrixmultiply = "0.3.7"
rusqlite = { version = "0.29.0", features = ["blob", "array", "modern_sqlite"] } rusqlite = { version = "0.29.0", features = ["blob", "array", "modern_sqlite"] }
bincode = "1.3.3" bincode = "1.3.3"

View file

@ -40,7 +40,7 @@ schemars.workspace = true
serde.workspace = true serde.workspace = true
serde_json.workspace = true serde_json.workspace = true
smol.workspace = true smol.workspace = true
tiktoken-rs = "0.5" tiktoken-rs.workspace = true
[dev-dependencies] [dev-dependencies]
editor = { path = "../editor", features = ["test-support"] } editor = { path = "../editor", features = ["test-support"] }

View file

@ -9,6 +9,8 @@ pub enum OpenAIModel {
ThreePointFiveTurbo, ThreePointFiveTurbo,
#[serde(rename = "gpt-4-0613")] #[serde(rename = "gpt-4-0613")]
Four, Four,
#[serde(rename = "gpt-4-1106-preview")]
FourTurbo,
} }
impl OpenAIModel { impl OpenAIModel {
@ -16,6 +18,7 @@ impl OpenAIModel {
match self { match self {
OpenAIModel::ThreePointFiveTurbo => "gpt-3.5-turbo-0613", OpenAIModel::ThreePointFiveTurbo => "gpt-3.5-turbo-0613",
OpenAIModel::Four => "gpt-4-0613", OpenAIModel::Four => "gpt-4-0613",
OpenAIModel::FourTurbo => "gpt-4-1106-preview",
} }
} }
@ -23,13 +26,15 @@ impl OpenAIModel {
match self { match self {
OpenAIModel::ThreePointFiveTurbo => "gpt-3.5-turbo", OpenAIModel::ThreePointFiveTurbo => "gpt-3.5-turbo",
OpenAIModel::Four => "gpt-4", OpenAIModel::Four => "gpt-4",
OpenAIModel::FourTurbo => "gpt-4-turbo",
} }
} }
pub fn cycle(&self) -> Self { pub fn cycle(&self) -> Self {
match self { match self {
OpenAIModel::ThreePointFiveTurbo => OpenAIModel::Four, OpenAIModel::ThreePointFiveTurbo => OpenAIModel::Four,
OpenAIModel::Four => OpenAIModel::ThreePointFiveTurbo, OpenAIModel::Four => OpenAIModel::FourTurbo,
OpenAIModel::FourTurbo => OpenAIModel::ThreePointFiveTurbo,
} }
} }
} }

View file

@ -33,7 +33,7 @@ lazy_static.workspace = true
serde.workspace = true serde.workspace = true
serde_json.workspace = true serde_json.workspace = true
async-trait.workspace = true async-trait.workspace = true
tiktoken-rs = "0.5.0" tiktoken-rs.workspace = true
parking_lot.workspace = true parking_lot.workspace = true
rand.workspace = true rand.workspace = true
schemars.workspace = true schemars.workspace = true

View file

@ -87,6 +87,7 @@ pub struct Button<V: 'static> {
label: SharedString, label: SharedString,
variant: ButtonVariant, variant: ButtonVariant,
width: Option<DefiniteLength>, width: Option<DefiniteLength>,
color: Option<LabelColor>,
} }
impl<V: 'static> Button<V> { impl<V: 'static> Button<V> {
@ -99,6 +100,7 @@ impl<V: 'static> Button<V> {
label: label.into(), label: label.into(),
variant: Default::default(), variant: Default::default(),
width: Default::default(), width: Default::default(),
color: None,
} }
} }
@ -139,25 +141,24 @@ impl<V: 'static> Button<V> {
self self
} }
fn label_color(&self) -> LabelColor { pub fn color(mut self, color: Option<LabelColor>) -> Self {
self.color = color;
self
}
pub fn label_color(&self, color: Option<LabelColor>) -> LabelColor {
if self.disabled { if self.disabled {
LabelColor::Disabled LabelColor::Disabled
} else if let Some(color) = color {
color
} else { } else {
Default::default() Default::default()
} }
} }
fn icon_color(&self) -> IconColor { fn render_label(&self, color: LabelColor) -> Label {
if self.disabled {
IconColor::Disabled
} else {
Default::default()
}
}
fn render_label(&self) -> Label {
Label::new(self.label.clone()) Label::new(self.label.clone())
.color(self.label_color()) .color(color)
.line_height_style(LineHeightStyle::UILabel) .line_height_style(LineHeightStyle::UILabel)
} }
@ -166,7 +167,11 @@ impl<V: 'static> Button<V> {
} }
pub fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> { pub fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let icon_color = self.icon_color(); let (icon_color, label_color) = match (self.disabled, self.color) {
(true, _) => (IconColor::Disabled, LabelColor::Disabled),
(_, None) => (IconColor::Default, LabelColor::Default),
(_, Some(color)) => (IconColor::from(color), color),
};
let mut button = h_stack() let mut button = h_stack()
.id(SharedString::from(format!("{}", self.label))) .id(SharedString::from(format!("{}", self.label)))
@ -182,16 +187,16 @@ impl<V: 'static> Button<V> {
(Some(_), Some(IconPosition::Left)) => { (Some(_), Some(IconPosition::Left)) => {
button = button button = button
.gap_1() .gap_1()
.child(self.render_label()) .child(self.render_label(label_color))
.children(self.render_icon(icon_color)) .children(self.render_icon(icon_color))
} }
(Some(_), Some(IconPosition::Right)) => { (Some(_), Some(IconPosition::Right)) => {
button = button button = button
.gap_1() .gap_1()
.children(self.render_icon(icon_color)) .children(self.render_icon(icon_color))
.child(self.render_label()) .child(self.render_label(label_color))
} }
(_, _) => button = button.child(self.render_label()), (_, _) => button = button.child(self.render_label(label_color)),
} }
if let Some(width) = self.width { if let Some(width) = self.width {

View file

@ -1,7 +1,7 @@
use gpui::{rems, svg, Hsla}; use gpui::{rems, svg, Hsla};
use strum::EnumIter; use strum::EnumIter;
use crate::prelude::*; use crate::{prelude::*, LabelColor};
#[derive(Default, PartialEq, Copy, Clone)] #[derive(Default, PartialEq, Copy, Clone)]
pub enum IconSize { pub enum IconSize {
@ -14,15 +14,20 @@ pub enum IconSize {
pub enum IconColor { pub enum IconColor {
#[default] #[default]
Default, Default,
Muted,
Disabled,
Placeholder,
Accent, Accent,
Created,
Deleted,
Disabled,
Error, Error,
Warning, Hidden,
Success,
Info, Info,
Modified,
Muted,
Placeholder,
Player(u32),
Selected, Selected,
Success,
Warning,
} }
impl IconColor { impl IconColor {
@ -38,6 +43,33 @@ impl IconColor {
IconColor::Success => cx.theme().status().success, IconColor::Success => cx.theme().status().success,
IconColor::Info => cx.theme().status().info, IconColor::Info => cx.theme().status().info,
IconColor::Selected => cx.theme().colors().icon_accent, IconColor::Selected => cx.theme().colors().icon_accent,
IconColor::Player(i) => cx.theme().styles.player.0[i.clone() as usize].cursor,
IconColor::Created => cx.theme().status().created,
IconColor::Modified => cx.theme().status().modified,
IconColor::Deleted => cx.theme().status().deleted,
IconColor::Hidden => cx.theme().status().hidden,
}
}
}
impl From<LabelColor> for IconColor {
fn from(label: LabelColor) -> Self {
match label {
LabelColor::Default => IconColor::Default,
LabelColor::Muted => IconColor::Muted,
LabelColor::Disabled => IconColor::Disabled,
LabelColor::Placeholder => IconColor::Placeholder,
LabelColor::Accent => IconColor::Accent,
LabelColor::Error => IconColor::Error,
LabelColor::Warning => IconColor::Warning,
LabelColor::Success => IconColor::Success,
LabelColor::Info => IconColor::Info,
LabelColor::Selected => IconColor::Selected,
LabelColor::Player(i) => IconColor::Player(i),
LabelColor::Created => IconColor::Created,
LabelColor::Modified => IconColor::Modified,
LabelColor::Deleted => IconColor::Deleted,
LabelColor::Hidden => IconColor::Hidden,
} }
} }
} }

View file

@ -1,10 +1,7 @@
use crate::{h_stack, prelude::*, ClickHandler, Icon, IconColor, IconElement, TextTooltip};
use gpui::{MouseButton, VisualContext};
use std::sync::Arc; use std::sync::Arc;
use gpui::{rems, MouseButton, VisualContext};
use crate::{h_stack, prelude::*, TextTooltip};
use crate::{ClickHandler, Icon, IconColor, IconElement};
struct IconButtonHandlers<V: 'static> { struct IconButtonHandlers<V: 'static> {
click: Option<ClickHandler<V>>, click: Option<ClickHandler<V>>,
} }
@ -95,9 +92,7 @@ impl<V: 'static> IconButton<V> {
.id(self.id.clone()) .id(self.id.clone())
.justify_center() .justify_center()
.rounded_md() .rounded_md()
// todo!("Where do these numbers come from?") .p_1()
.py(rems(0.21875))
.px(rems(0.375))
.bg(bg_color) .bg(bg_color)
.hover(|style| style.bg(bg_hover_color)) .hover(|style| style.bg(bg_hover_color))
.active(|style| style.bg(bg_active_color)) .active(|style| style.bg(bg_active_color))

View file

@ -7,28 +7,40 @@ use crate::styled_ext::StyledExt;
pub enum LabelColor { pub enum LabelColor {
#[default] #[default]
Default, Default,
Muted, Accent,
Created, Created,
Modified,
Deleted, Deleted,
Disabled, Disabled,
Error,
Hidden, Hidden,
Info,
Modified,
Muted,
Placeholder, Placeholder,
Accent, Player(u32),
Selected,
Success,
Warning,
} }
impl LabelColor { impl LabelColor {
pub fn hsla(&self, cx: &WindowContext) -> Hsla { pub fn hsla(&self, cx: &WindowContext) -> Hsla {
match self { match self {
Self::Default => cx.theme().colors().text, LabelColor::Default => cx.theme().colors().text,
Self::Muted => cx.theme().colors().text_muted, LabelColor::Muted => cx.theme().colors().text_muted,
Self::Created => cx.theme().status().created, LabelColor::Created => cx.theme().status().created,
Self::Modified => cx.theme().status().modified, LabelColor::Modified => cx.theme().status().modified,
Self::Deleted => cx.theme().status().deleted, LabelColor::Deleted => cx.theme().status().deleted,
Self::Disabled => cx.theme().colors().text_disabled, LabelColor::Disabled => cx.theme().colors().text_disabled,
Self::Hidden => cx.theme().status().hidden, LabelColor::Hidden => cx.theme().status().hidden,
Self::Placeholder => cx.theme().colors().text_placeholder, LabelColor::Info => cx.theme().status().info,
Self::Accent => cx.theme().colors().text_accent, LabelColor::Placeholder => cx.theme().colors().text_placeholder,
LabelColor::Accent => cx.theme().colors().text_accent,
LabelColor::Player(i) => cx.theme().styles.player.0[i.clone() as usize].cursor,
LabelColor::Error => cx.theme().status().error,
LabelColor::Selected => cx.theme().colors().text_accent,
LabelColor::Success => cx.theme().status().success,
LabelColor::Warning => cx.theme().status().warning,
} }
} }
} }

View file

@ -69,7 +69,7 @@ use std::{
}; };
use theme2::ActiveTheme; use theme2::ActiveTheme;
pub use toolbar::{ToolbarItemLocation, ToolbarItemView}; pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
use ui::{h_stack, Label}; use ui::{h_stack, Button, ButtonVariant, Label, LabelColor};
use util::ResultExt; use util::ResultExt;
use uuid::Uuid; use uuid::Uuid;
use workspace_settings::{AutosaveSetting, WorkspaceSettings}; use workspace_settings::{AutosaveSetting, WorkspaceSettings};
@ -2644,19 +2644,35 @@ impl Workspace {
h_stack() h_stack()
.id("titlebar") .id("titlebar")
.justify_between() .justify_between()
.w_full()
.h(rems(1.75))
.bg(cx.theme().colors().title_bar_background)
.when( .when(
!matches!(cx.window_bounds(), WindowBounds::Fullscreen), !matches!(cx.window_bounds(), WindowBounds::Fullscreen),
|s| s.pl_20(), |s| s.pl_20(),
) )
.w_full()
.h(rems(1.75))
.bg(cx.theme().colors().title_bar_background)
.on_click(|_, event, cx| { .on_click(|_, event, cx| {
if event.up.click_count == 2 { if event.up.click_count == 2 {
cx.zoom_window(); cx.zoom_window();
} }
}) })
.child(h_stack().child(Label::new("Left side titlebar item"))) // self.titlebar_item .child(
h_stack()
// TODO - Add player menu
.child(
Button::new("player")
.variant(ButtonVariant::Ghost)
.color(Some(LabelColor::Player(0))),
)
// TODO - Add project menu
.child(Button::new("project_name").variant(ButtonVariant::Ghost))
// TODO - Add git menu
.child(
Button::new("branch_name")
.variant(ButtonVariant::Ghost)
.color(Some(LabelColor::Muted)),
),
) // self.titlebar_item
.child(h_stack().child(Label::new("Right side titlebar item"))) .child(h_stack().child(Label::new("Right side titlebar item")))
} }