Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/app/shell/left_sidebar/content/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::rc::Rc;

use gpui::{App, Window};

pub type ThreadIdCallback = Rc<dyn Fn(String, &mut Window, &mut App)>;
pub type ThreadSelectCallback = Rc<dyn Fn(String, bool, &mut Window, &mut App)>;
pub type ThreadHoverCallback = Rc<dyn Fn(Option<String>, &mut Window, &mut App)>;
pub type ThreadMoveCallback = Rc<dyn Fn(String, isize, &mut Window, &mut App)>;
pub type ThreadDragOverCallback = Rc<dyn Fn(String, bool, &mut Window, &mut App)>;
pub type ThreadDropCallback = Rc<dyn Fn(String, String, &mut Window, &mut App)>;
pub type AtomIdCallback = Rc<dyn Fn(String, &mut Window, &mut App)>;
pub type AtomSelectCallback = Rc<dyn Fn(String, bool, &mut Window, &mut App)>;
pub type AtomHoverCallback = Rc<dyn Fn(Option<String>, &mut Window, &mut App)>;
pub type AtomMoveCallback = Rc<dyn Fn(String, isize, &mut Window, &mut App)>;
pub type AtomDragOverCallback = Rc<dyn Fn(String, bool, &mut Window, &mut App)>;
pub type AtomDropCallback = Rc<dyn Fn(String, String, &mut Window, &mut App)>;
42 changes: 20 additions & 22 deletions src/app/shell/left_sidebar/content/draft_row.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Draft row for unsent composer sessions — matches active card row interaction.
//! Draft row for unsent composer content in a new atom — matches active card row interaction.

use gpui::{
App, AppContext, ClickEvent, InteractiveElement, IntoElement, ParentElement, SharedString,
Expand All @@ -18,13 +18,13 @@ use super::super::surfaces::{
row_selected_bg,
};
use super::super::tokens::{FAVICON_SIZE, ROW_CONTENT_INSET, ROW_HEIGHT_CARD};
use super::callbacks::{ThreadDragOverCallback, ThreadDropCallback, ThreadIdCallback};
use super::pinned_drag::{PinnedRowDragUi, PinnedThreadDrag, ThreadDragScope};
use super::callbacks::{AtomDragOverCallback, AtomDropCallback, AtomIdCallback};
use super::pinned_drag::{AtomDragScope, PinnedAtomDrag, PinnedRowDragUi};

pub struct DraftRowDragActions {
pub on_drag_start: ThreadIdCallback,
pub on_drag_over: ThreadDragOverCallback,
pub on_drop: ThreadDropCallback,
pub on_drag_start: AtomIdCallback,
pub on_drag_over: AtomDragOverCallback,
pub on_drop: AtomDropCallback,
}

pub fn sidebar_draft_row(
Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn sidebar_draft_row(
let on_drag_start = drag_actions.on_drag_start.clone();
let on_drag_over = drag_actions.on_drag_over.clone();
let on_drop = drag_actions.on_drop.clone();
let drag_scope = ThreadDragScope::Active;
let drag_scope = AtomDragScope::Active;

div()
.id(format!("left-sidebar-draft-{}", draft.id))
Expand Down Expand Up @@ -104,8 +104,8 @@ pub fn sidebar_draft_row(
})
.when(row_drag.is_source, |row| row.opacity(0.45))
.on_drag(
PinnedThreadDrag {
thread_id: draft_id.clone(),
PinnedAtomDrag {
atom_id: draft_id.clone(),
scope: drag_scope,
title: preview.into(),
preview_bg: theme.surface(BackgroundToken::Secondary),
Expand All @@ -115,7 +115,7 @@ pub fn sidebar_draft_row(
let on_drag_start = on_drag_start.clone();
move |drag, _, window, cx| {
cx.stop_propagation();
on_drag_start(drag.thread_id.clone(), window, cx);
on_drag_start(drag.atom_id.clone(), window, cx);
cx.new(|_| DraftDragPreview {
title: drag.title.clone(),
bg: drag.preview_bg,
Expand All @@ -127,28 +127,26 @@ pub fn sidebar_draft_row(
.can_drop({
let self_id = draft_id.clone();
move |value, _, _| {
value
.downcast_ref::<PinnedThreadDrag>()
.is_some_and(|drag| {
drag.thread_id != self_id && drag.scope.allows_drop(drag_scope)
})
value.downcast_ref::<PinnedAtomDrag>().is_some_and(|drag| {
drag.atom_id != self_id && drag.scope.allows_drop(drag_scope)
})
}
})
.drag_over::<PinnedThreadDrag>({
.drag_over::<PinnedAtomDrag>({
let self_id = draft_id.clone();
move |style, drag, _, _| {
if drag.thread_id == self_id || !drag.scope.allows_drop(drag_scope) {
if drag.atom_id == self_id || !drag.scope.allows_drop(drag_scope) {
return style;
}
style.bg(drag_hover_bg)
}
})
.on_drag_move::<PinnedThreadDrag>({
.on_drag_move::<PinnedAtomDrag>({
let target_id = draft_id.clone();
let on_drag_over = on_drag_over.clone();
move |event, window, cx| {
let drag = event.drag(cx);
if drag.thread_id == target_id || !drag.scope.allows_drop(drag_scope) {
if drag.atom_id == target_id || !drag.scope.allows_drop(drag_scope) {
return;
}
let pointer = event.event.position;
Expand All @@ -169,11 +167,11 @@ pub fn sidebar_draft_row(
.on_drop({
let target_id = draft_id.clone();
let on_drop = on_drop.clone();
move |drag: &PinnedThreadDrag, window, cx| {
if drag.thread_id == target_id || !drag.scope.allows_drop(drag_scope) {
move |drag: &PinnedAtomDrag, window, cx| {
if drag.atom_id == target_id || !drag.scope.allows_drop(drag_scope) {
return;
}
on_drop(drag.thread_id.clone(), target_id.clone(), window, cx);
on_drop(drag.atom_id.clone(), target_id.clone(), window, cx);
}
})
.on_click({
Expand Down
2 changes: 1 addition & 1 deletion src/app/shell/left_sidebar/content/empty_state.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Empty states for zero-project and zero-thread shelves.
//! Empty states for zero-project and zero-atom shelves.

use gpui::{IntoElement, ParentElement, SharedString, Styled, div, px, relative};
use gpui_component::{
Expand Down
6 changes: 2 additions & 4 deletions src/app/shell/left_sidebar/content/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod atom_row;
mod callbacks;
mod draft_row;
mod empty_state;
Expand All @@ -7,8 +8,8 @@ mod search_result_row;
mod search_row;
mod shelf_body;
mod shelf_header;
mod thread_row;

pub use atom_row::{AtomRowActions, AtomRowVariant, sidebar_atom_row, sidebar_show_more_button};
pub use draft_row::{DraftRowDragActions, sidebar_draft_row};
pub use empty_state::{sidebar_add_project_button, sidebar_empty_state};
pub use pinned_drag::{PinnedDragState, PinnedRowDragUi};
Expand All @@ -17,6 +18,3 @@ pub use search_result_row::sidebar_search_result_row;
pub use search_row::sidebar_search_row;
pub use shelf_body::sidebar_shelf_body;
pub use shelf_header::{ShelfTone, sidebar_section_header, sidebar_shelf_header};
pub use thread_row::{
ThreadRowActions, ThreadRowVariant, sidebar_show_more_button, sidebar_thread_row,
};
28 changes: 14 additions & 14 deletions src/app/shell/left_sidebar/content/pinned_drag.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
//! Drag-and-drop payload and drop-indicator state for thread row reordering.
//! Drag-and-drop payload and drop-indicator state for atom row reordering.

use super::super::demo_data::ThreadShelf;
use super::super::demo_data::AtomShelf;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ThreadDragScope {
pub enum AtomDragScope {
Pinned,
Active,
Settled,
Archived,
}

impl ThreadDragScope {
pub fn from_thread(_thread_id: &str, effective_shelf: ThreadShelf, is_archived: bool) -> Self {
impl AtomDragScope {
pub fn from_atom(_atom_id: &str, effective_shelf: AtomShelf, is_archived: bool) -> Self {
if is_archived {
return Self::Archived;
}
match effective_shelf {
ThreadShelf::Pinned => Self::Pinned,
ThreadShelf::Active => Self::Active,
ThreadShelf::Settled => Self::Settled,
AtomShelf::Pinned => Self::Pinned,
AtomShelf::Active => Self::Active,
AtomShelf::Settled => Self::Settled,
}
}

Expand All @@ -28,9 +28,9 @@ impl ThreadDragScope {
}

#[derive(Clone, Debug)]
pub struct PinnedThreadDrag {
pub thread_id: String,
pub scope: ThreadDragScope,
pub struct PinnedAtomDrag {
pub atom_id: String,
pub scope: AtomDragScope,
pub title: gpui::SharedString,
pub preview_bg: gpui::Hsla,
pub preview_text: gpui::Hsla,
Expand All @@ -50,13 +50,13 @@ pub struct PinnedDragState {
}

impl PinnedDragState {
pub fn for_thread(&self, thread_id: &str) -> PinnedRowDragUi {
pub fn for_atom(&self, atom_id: &str) -> PinnedRowDragUi {
let (drop_above, drop_below) = match &self.drop_target {
Some((id, insert_after)) if id == thread_id => (!*insert_after, *insert_after),
Some((id, insert_after)) if id == atom_id => (!*insert_after, *insert_after),
_ => (false, false),
};
PinnedRowDragUi {
is_source: self.dragging_id.as_deref() == Some(thread_id),
is_source: self.dragging_id.as_deref() == Some(atom_id),
drop_above,
drop_below,
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/shell/left_sidebar/content/project_scope_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::shared::theme::{
BackgroundToken, BorderToken, ForegroundToken, OpenCoreTheme, SpacingToken, TypeRole,
};

use super::super::demo_data::{ALL_PROJECTS_LABEL, DEMO_PROJECTS};
use super::super::demo_data::{ALL_ATOMS_LABEL, DEMO_PROJECTS};
use super::super::tokens::ICON_BUTTON_SIZE;

pub fn sidebar_project_scope_row(
Expand Down Expand Up @@ -63,9 +63,9 @@ pub fn sidebar_project_scope_row(
.dropdown_menu({
let on_scope = on_scope.clone();
move |menu, _window, _cx| {
let mut menu = menu.label("Projects");
let mut menu = menu.label("Scope");
let on_all = on_scope.clone();
menu = menu.item(PopupMenuItem::new(ALL_PROJECTS_LABEL).on_click(
menu = menu.item(PopupMenuItem::new(ALL_ATOMS_LABEL).on_click(
move |_, window, cx| {
on_all(None, window, cx);
},
Expand Down
20 changes: 10 additions & 10 deletions src/app/shell/left_sidebar/content/search_result_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ use gpui_component::{h_flex, v_flex};

use crate::shared::theme::{ForegroundToken, OpenCoreTheme, TypeRole};

use super::super::demo_data::{DEMO_PROJECTS, DemoThread};
use super::super::demo_data::{DEMO_PROJECTS, DemoAtom};
use super::super::state::SidebarViewModel;
use super::super::surfaces::{project_favicon_color, row_active_bg, row_hover_bg};
use super::super::tokens::{FAVICON_SIZE, ROW_CONTENT_INSET, ROW_HEIGHT_SLIM, ROW_RADIUS};

pub fn sidebar_search_result_row(
thread: &DemoThread,
atom: &DemoAtom,
view: &SidebarViewModel,
theme: &OpenCoreTheme,
on_activate: impl Fn(String, &mut Window, &mut App) + 'static,
) -> impl IntoElement {
let is_active = view.is_active(thread);
let title = view.display_title(thread);
let is_active = view.is_active(atom);
let title = view.display_title(atom);
let primary = theme.foreground(ForegroundToken::Primary);
let secondary = theme.foreground(ForegroundToken::Secondary);
let muted = theme.foreground(ForegroundToken::Muted);
let mono = mono_family();
let favicon_hue = DEMO_PROJECTS
.iter()
.find(|p| p.key == thread.project_key)
.find(|p| p.key == atom.project_key)
.map(|p| p.favicon_hue)
.unwrap_or(0x888888);

Expand All @@ -37,10 +37,10 @@ pub fn sidebar_search_result_row(
theme.surface(crate::shared::theme::BackgroundToken::Primary)
};

let thread_id = thread.id.to_string();
let atom_id = atom.id.to_string();

div()
.id(format!("left-sidebar-search-{}", thread.id))
.id(format!("left-sidebar-search-{}", atom.id))
.w_full()
.min_w_0()
.h(px(ROW_HEIGHT_SLIM))
Expand All @@ -50,7 +50,7 @@ pub fn sidebar_search_result_row(
.bg(bg)
.cursor_pointer()
.hover(|style| style.bg(row_hover_bg(theme)))
.on_click(move |_: &ClickEvent, window, cx| on_activate(thread_id.clone(), window, cx))
.on_click(move |_: &ClickEvent, window, cx| on_activate(atom_id.clone(), window, cx))
.child(
h_flex()
.w_full()
Expand Down Expand Up @@ -83,7 +83,7 @@ pub fn sidebar_search_result_row(
.font_family(mono)
.text_size(px(TypeRole::MonoSm.size()))
.text_color(secondary.alpha(0.8))
.child(thread.project_title),
.child(atom.project_title),
),
)
.child(
Expand All @@ -92,7 +92,7 @@ pub fn sidebar_search_result_row(
.font_family(mono_family())
.text_size(px(TypeRole::LabelMd.size()))
.text_color(muted)
.child(thread.time_label),
.child(atom.time_label),
),
)
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/shell/left_sidebar/content/search_row.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Search row with clear affordance and new-thread action.
//! Search row with clear affordance and new-atom action.

use gpui::{App, Entity, InteractiveElement, IntoElement, ParentElement, Styled, Window, div, px};
use gpui_component::{
Expand All @@ -19,7 +19,7 @@ pub fn sidebar_search_row(
query: &str,
theme: &OpenCoreTheme,
on_clear: impl Fn(&mut Window, &mut App) + 'static,
on_new_thread: impl Fn(&mut Window, &mut App) + 'static,
on_new_atom: impl Fn(&mut Window, &mut App) + 'static,
) -> impl IntoElement {
let surface = theme.surface(BackgroundToken::Secondary);
let border = theme.border_token(BorderToken::Default);
Expand Down Expand Up @@ -78,17 +78,17 @@ pub fn sidebar_search_row(
}),
)
.child(
Button::new("left-sidebar-new-thread")
Button::new("left-sidebar-new-atom")
.ghost()
.rounded(ButtonRounded::None)
.tooltip("New thread")
.tooltip("New atom")
.icon(Icon::new(IconName::File).text_color(primary))
.h(px(ICON_BUTTON_SIZE))
.w(px(ICON_BUTTON_SIZE))
.flex_shrink_0()
.border_1()
.border_color(border)
.bg(surface)
.on_click(move |_, window, cx| on_new_thread(window, cx)),
.on_click(move |_, window, cx| on_new_atom(window, cx)),
)
}
2 changes: 1 addition & 1 deletion src/app/shell/left_sidebar/content/shelf_body.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Animated clip wrapper for collapsible shelf thread rows.
//! Animated clip wrapper for collapsible shelf atom rows.

use gpui::{InteractiveElement, IntoElement, ParentElement, Styled, div, px};
use gpui_component::v_flex;
Expand Down
2 changes: 1 addition & 1 deletion src/app/shell/left_sidebar/content/shelf_header.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Collapsible shelf headers and static section labels for thread list shelves.
//! Collapsible shelf headers and static section labels for atom list shelves.

use gpui::{
App, InteractiveElement, IntoElement, MouseButton, ParentElement, Radians, SharedString,
Expand Down
Loading
Loading