From b491ae9d03845ed14723acb5e11a6859853dfecf Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Tue, 17 Nov 2026 19:23:26 +0700 Subject: [PATCH] wire explore view into workspace and titlebar --- crates/signed_app/src/app/mod.rs | 25 +++++++++++++------ crates/signed_app/src/explore/mod.rs | 24 +++++++++++++++--- crates/signed_app/src/lib.rs | 1 - crates/signed_app/src/titlebar/mod.rs | 22 ++++++++++++++++ .../src/titlebar/repository_switcher.rs | 1 - 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/crates/signed_app/src/app/mod.rs b/crates/signed_app/src/app/mod.rs index d93b43a..4a66983 100644 --- a/crates/signed_app/src/app/mod.rs +++ b/crates/signed_app/src/app/mod.rs @@ -20,6 +20,7 @@ use ui::toast::{Toast, Toasts}; use crate::app::placeholder::PlaceholderView; use crate::app::sign_in::SignedOutView; +use crate::explore::ExploreView; use crate::identity; use crate::shared::dialogs::DialogHost; use crate::titlebar::{ @@ -54,24 +55,31 @@ impl AppRoot { let backend = Backend::global(cx); let settings = SettingsStore::global(cx); - let mut subscriptions = Vec::new(); - subscriptions.push( - cx.subscribe(&backend, |this, _backend, event, cx| match event { - BackendEvent::PassphraseRequired => identity::helpers::open_passphrase(cx), + subscriptions.push(cx.subscribe_in( + &backend, + window, + |this, backend, event, window, cx| match event { + BackendEvent::PassphraseRequired => { + identity::helpers::open_passphrase(cx); + } BackendEvent::Error(message) => { this.toasts.update(cx, |toasts, cx| { toasts.push(Toast::new(message.clone()).icon(IconRole::Warning), cx); }); } BackendEvent::SignerChanged => { - this.workspace - .update(cx, |workspace, cx| workspace.clear(cx)); + this.workspace.update(cx, |workspace, cx| { + workspace.clear(cx); + }); + if backend.read(cx).current_user().is_some() { + ExploreView::open(&this.workspace.downgrade(), window, cx); + } } _ => {} - }), - ); + }, + )); subscriptions.push(cx.observe(&settings, |_this, store, cx| { let settings = store.read(cx).settings().clone(); @@ -108,6 +116,7 @@ impl Render for AppRoot { let prefix = h_flex() .gap_1() .child(titlebar_view.render_new_repository()) + .child(titlebar_view.render_explore()) .child(titlebar_view.repository_switcher()); let tab_bar = h_flex().gap_1().when_some( diff --git a/crates/signed_app/src/explore/mod.rs b/crates/signed_app/src/explore/mod.rs index 71f6c5f..f7ef621 100644 --- a/crates/signed_app/src/explore/mod.rs +++ b/crates/signed_app/src/explore/mod.rs @@ -2,9 +2,9 @@ mod helpers; use gpui::prelude::FluentBuilder as _; use gpui::{ - AnyElement, Context, Entity, InteractiveElement as _, IntoElement, ParentElement as _, Render, - SharedString, Styled as _, Subscription, UniformListScrollHandle, WeakEntity, Window, div, px, - uniform_list, + AnyElement, App, AppContext as _, Context, Entity, InteractiveElement as _, IntoElement, + ParentElement as _, Render, SharedString, Styled as _, Subscription, UniformListScrollHandle, + WeakEntity, Window, div, px, uniform_list, }; use helpers::{RepoFilter, render_card}; use metadata::ProfileDirectory; @@ -19,6 +19,7 @@ use ui::scrollbar::Scrollbar; use ui::segmented::{Segmented, SegmentedOption}; use ui::theme::{ActiveTheme as _, TextRole, Typeset as _}; +use crate::shared::panels; use crate::workspace::Workspace; const COLUMNS: usize = 2; @@ -39,6 +40,23 @@ pub struct ExploreView { } impl ExploreView { + /// The identifier of the explore panel in the workspace; shown as its tab label. + pub(crate) const PANEL_ID: &'static str = "Explore"; + + /// Opens the explore panel in the main panel, reusing it when it is already cached. + pub(crate) fn open(workspace: &WeakEntity, window: &mut Window, cx: &mut App) { + panels::open_primary( + workspace, + Self::PANEL_ID, + { + let workspace = workspace.clone(); + move |_, cx| cx.new(|cx| Self::new(workspace.clone(), cx)) + }, + window, + cx, + ); + } + pub fn new(workspace: WeakEntity, cx: &mut Context) -> Self { let store = RepoListStore::global(cx); let directory = ProfileDirectory::new(cx); diff --git a/crates/signed_app/src/lib.rs b/crates/signed_app/src/lib.rs index 3f7ca9f..2147dfa 100644 --- a/crates/signed_app/src/lib.rs +++ b/crates/signed_app/src/lib.rs @@ -1,5 +1,4 @@ mod app; -#[allow(dead_code)] // temporarily unlinked while the shell migrates mod explore; mod identity; #[allow(dead_code)] // temporarily unlinked while the shell migrates diff --git a/crates/signed_app/src/titlebar/mod.rs b/crates/signed_app/src/titlebar/mod.rs index a59d7b2..03a0548 100644 --- a/crates/signed_app/src/titlebar/mod.rs +++ b/crates/signed_app/src/titlebar/mod.rs @@ -18,8 +18,10 @@ use ui::command_palette::{Command, CommandPalette, CommandPaletteState}; use ui::icons::{Icon, IconRole}; use ui::menu::{Menu, MenuItem}; use ui::tabs::{Tab, Tabs, TabsVariant}; +use ui::theme::ActiveTheme as _; use ui::tooltip::Tooltip; +use crate::explore::ExploreView; use crate::repo::{RepoDetailView, actions, dialogs}; use crate::shared::{log_dropped, panels}; use crate::workspace::Workspace; @@ -381,6 +383,12 @@ impl TitlebarView { let mut tab = Tab::new(id.clone(), label).closeable(true); if let Some(entry) = entry { tab = tab.lead(entry.avatar(&lookup_directory, cx)); + } else if *id == ExploreView::PANEL_ID { + tab = tab.lead( + Icon::named(IconRole::Grid) + .small() + .color(cx.theme().colors.muted_foreground), + ); } tab }) @@ -505,6 +513,20 @@ impl TitlebarView { Some(self.render_user(&profile, cx).into_any_element()) } + pub fn render_explore(&self) -> AnyElement { + let workspace = self.workspace.clone(); + + Button::new("open-explore") + .icon(IconRole::Grid) + .variant(ButtonVariant::Ghost) + .fully_rounded(true) + .tooltip(Tooltip::text("Explore repositories")) + .on_click(move |_, window, cx| { + ExploreView::open(&workspace, window, cx); + }) + .into_any_element() + } + pub fn render_new_repository(&self) -> AnyElement { let workspace = self.workspace.clone(); diff --git a/crates/signed_app/src/titlebar/repository_switcher.rs b/crates/signed_app/src/titlebar/repository_switcher.rs index edf0ce9..242dc6d 100644 --- a/crates/signed_app/src/titlebar/repository_switcher.rs +++ b/crates/signed_app/src/titlebar/repository_switcher.rs @@ -269,7 +269,6 @@ impl Render for RepositorySwitcher { on_create(window, cx); }), ) - .child(Separator::horizontal()) .child( Button::new("repo-switcher-rescan") .variant(ButtonVariant::Ghost)