Replace dock shell with titlebar repository tabs

- Move repository navigation from the dock sidebar to titlebar tabs.
- Route main and detail panels through Workspace.
- Move sign-in into the main panel and remove unlinked navigation.
This commit is contained in:
2026-11-15 13:37:32 +07:00
parent d79d2c7a27
commit 5bd289b418
29 changed files with 1041 additions and 1242 deletions
+22 -14
View File
@@ -1,11 +1,11 @@
use gpui::{App, AppContext as _, SharedString, WeakEntity, Window};
use gpui_native_kit::layout::dock::DockState;
use nostr::prelude::EventId;
use signed_core::{Announcement, RepoAddr};
use signed_state::RepoStore;
use crate::repo::RepoDetailView;
use crate::shared::panels;
use crate::workspace::Workspace;
/// An item of a repository to open from outside its detail panel.
pub enum RepoItem {
@@ -14,9 +14,9 @@ pub enum RepoItem {
Patch,
}
/// Opens a repository as a dock panel, keyed by its address.
/// Opens a repository as the main panel, keyed by its address.
pub fn open_repo_panel(
dock: &WeakEntity<DockState>,
workspace: &WeakEntity<Workspace>,
addr: &RepoAddr,
hint: Option<&Announcement>,
window: &mut Window,
@@ -25,15 +25,15 @@ pub fn open_repo_panel(
let id = SharedString::from(format!("repo:{addr}"));
let addr = addr.clone();
let hint = hint.cloned();
let dock_for_build = dock.clone();
let workspace_for_build = workspace.clone();
panels::open(
dock,
panels::open_primary(
workspace,
id,
move |window, cx| {
let addr = addr.clone();
let hint = hint.clone();
cx.new(|cx| RepoDetailView::new(dock_for_build.clone(), addr, hint, window, cx))
cx.new(|cx| RepoDetailView::new(workspace_for_build.clone(), addr, hint, window, cx))
},
window,
cx,
@@ -42,7 +42,7 @@ pub fn open_repo_panel(
/// Opens an issue or pull request using a store built here.
pub fn open_repo_item(
dock: &WeakEntity<DockState>,
workspace: &WeakEntity<Workspace>,
addr: &RepoAddr,
hint: Option<&Announcement>,
item: RepoItem,
@@ -53,10 +53,14 @@ pub fn open_repo_item(
match item {
RepoItem::Issue(issue_id) => {
let id = SharedString::from(format!("issue:{issue_id}"));
let hex = issue_id.to_hex();
let short = hex.get(..8).unwrap_or(&hex);
let label = SharedString::from(format!("Issue {short}"));
let store = store.clone();
panels::open(
dock,
panels::open_detail(
workspace,
id,
label,
move |_, cx| {
cx.new(|cx| {
crate::issues::detail::IssueDetailView::new(store.clone(), issue_id, cx)
@@ -68,15 +72,19 @@ pub fn open_repo_item(
}
RepoItem::PullRequest(pr_id) => {
let id = SharedString::from(format!("pr:{pr_id}"));
let dock_for_build = dock.clone();
let hex = pr_id.to_hex();
let short = hex.get(..8).unwrap_or(&hex);
let label = SharedString::from(format!("PR {short}"));
let workspace_for_build = workspace.clone();
let store = store.clone();
panels::open(
dock,
panels::open_detail(
workspace,
id,
label,
move |window, cx| {
cx.new(|cx| {
crate::pull_requests::PullRequestDetailView::new(
dock_for_build.clone(),
workspace_for_build.clone(),
store.clone(),
pr_id,
window,
+3 -32
View File
@@ -12,19 +12,17 @@ use gpui_native_kit::clipboard::ClipboardButton;
use gpui_native_kit::common::{h_flex, v_flex};
use gpui_native_kit::data::tree::{Tree, TreeItem};
use gpui_native_kit::icons::{Icon, IconRole};
use gpui_native_kit::layout::dock::Panel;
use gpui_native_kit::layout::panel::Panel;
use gpui_native_kit::layout::resizable::{Resizable, ResizableState};
use gpui_native_kit::scrollbar::Scrollbar;
use gpui_native_kit::spinner::Spinner;
use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _};
use metadata::ProfileDirectory;
use signed_git::{CommitDiff, DiffStatus, FileCommit, FileDiff, Repo};
use signed_state::RepoStore;
use utils::relative_time_secs;
use super::helpers::{DiffRow, diff_rows, render_diff_row};
use crate::shared::tree::{TreeItemSeed, TreeRow, build_tree_items, collect_expanded, flatten};
use crate::shared::widgets::{empty_state, repo_tab_avatar};
use crate::shared::widgets::empty_state;
pub struct DiffPane {
diff: Option<CommitDiff>,
@@ -340,36 +338,23 @@ impl Render for DiffPane {
}
pub struct CommitDiffView {
store: Entity<RepoStore>,
worktree: PathBuf,
repo_name: SharedString,
commit: FileCommit,
/// The diff is being computed on a background task.
loading: bool,
error: Option<SharedString>,
pane: Entity<DiffPane>,
/// Profile for the repository owner in the tab title.
directory: Entity<ProfileDirectory>,
tasks: Vec<Task<Result<(), anyhow::Error>>>,
}
impl CommitDiffView {
pub fn new(
store: Entity<RepoStore>,
worktree: PathBuf,
repo_name: SharedString,
commit_id: String,
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
let pane = cx.new(DiffPane::new);
let directory = ProfileDirectory::new(cx);
if let Some(owner) = store.read(cx).announcement.as_ref().map(|a| a.owner) {
directory.update(cx, |directory, cx| {
directory.track([owner], cx);
});
}
let weak = cx.entity().downgrade();
window.defer(cx, move |window, cx| {
@@ -379,9 +364,7 @@ impl CommitDiffView {
});
Self {
store,
worktree,
repo_name,
commit: FileCommit {
id: commit_id,
summary: String::new(),
@@ -392,7 +375,6 @@ impl CommitDiffView {
loading: true,
error: None,
pane,
directory,
tasks: Vec::new(),
}
}
@@ -518,18 +500,7 @@ impl CommitDiffView {
}
}
impl Panel for CommitDiffView {
fn title(&self, _cx: &App) -> Option<SharedString> {
Some(SharedString::from(format!(
"{}/{}",
self.repo_name, self.commit.id
)))
}
fn lead(&self, cx: &App) -> Option<AnyElement> {
Some(repo_tab_avatar(self.store.read(cx), &self.directory, cx))
}
}
impl Panel for CommitDiffView {}
impl Render for CommitDiffView {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
+18 -8
View File
@@ -11,7 +11,6 @@ use gpui_native_kit::dialog::Dialog;
use gpui_native_kit::field::Field;
use gpui_native_kit::icons::{Icon, IconRole};
use gpui_native_kit::input::{Input, InputState};
use gpui_native_kit::layout::dock::DockState;
use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _};
use gpui_native_kit::tooltip::Tooltip;
use settings::SettingsStore;
@@ -21,6 +20,7 @@ use super::grasp_servers::{GraspServersState, grasp_servers_field, load_user_gra
use crate::repo::actions::open_repo_panel;
use crate::shared::dialogs::{close_global, open_global};
use crate::shared::progress::{DialogProgress, error_row, push_steps_row};
use crate::workspace::Workspace;
/// Progress of the create-repository flow, so async results can be rendered.
pub struct CreateRepoDialog {
@@ -30,11 +30,15 @@ pub struct CreateRepoDialog {
relay_input: Entity<InputState>,
state: Entity<DialogProgress>,
grasp_state: Entity<GraspServersState>,
dock: WeakEntity<DockState>,
workspace: WeakEntity<Workspace>,
}
impl CreateRepoDialog {
pub fn new(dock: WeakEntity<DockState>, window: &mut Window, cx: &mut App) -> Entity<Self> {
pub fn new(
workspace: WeakEntity<Workspace>,
window: &mut Window,
cx: &mut App,
) -> Entity<Self> {
let settings = SettingsStore::global(cx);
let default_folder = settings
.read(cx)
@@ -65,7 +69,7 @@ impl CreateRepoDialog {
relay_input,
state,
grasp_state,
dock,
workspace,
})
}
@@ -105,7 +109,7 @@ impl CreateRepoDialog {
backend.create_repository(&name, &description, folder, servers, cx)
});
let state = self.state.clone();
let dock = self.dock.clone();
let workspace = self.workspace.clone();
let handle = window.window_handle();
cx.spawn(async move |_this, cx| match task.await {
@@ -116,7 +120,13 @@ impl CreateRepoDialog {
store.record(local_path.clone(), announcement.addr(), cx);
});
cx.open_with_system(&local_path);
open_repo_panel(&dock, &announcement.addr(), Some(&announcement), window, cx);
open_repo_panel(
&workspace,
&announcement.addr(),
Some(&announcement),
window,
cx,
);
close_global(cx);
})
.ok();
@@ -267,6 +277,6 @@ fn choose_folder(folder_input: &Entity<InputState>, window: &mut Window, cx: &mu
}
/// Opens the create-repository form.
pub fn open(dock: WeakEntity<DockState>, window: &mut Window, cx: &mut App) {
open_global(CreateRepoDialog::new(dock, window, cx), cx);
pub fn open(workspace: WeakEntity<Workspace>, window: &mut Window, cx: &mut App) {
open_global(CreateRepoDialog::new(workspace, window, cx), cx);
}
+27 -21
View File
@@ -38,7 +38,7 @@ impl RepoDetailView {
return;
};
actions::open_repo_panel(&self.dock, &addr, None, window, cx);
actions::open_repo_panel(&self.workspace, &addr, None, window, cx);
}
/// Open the dialog that publishes the local repository to NIP-34.
@@ -55,15 +55,16 @@ impl RepoDetailView {
};
let id = SharedString::from(format!("pulls:{addr}"));
let dock = self.dock.clone();
let dock_for_build = dock.clone();
let workspace = self.workspace.clone();
let workspace_for_build = workspace.clone();
let store = self.store.clone();
crate::shared::panels::open(
&dock,
crate::shared::panels::open_detail(
&workspace,
id,
"Pull requests",
move |_, cx| {
cx.new(|cx| PullRequestsView::new(dock_for_build.clone(), store.clone(), cx))
cx.new(|cx| PullRequestsView::new(workspace_for_build.clone(), store.clone(), cx))
},
window,
cx,
@@ -76,17 +77,18 @@ impl RepoDetailView {
};
let id = SharedString::from(format!("new-pr:{addr}"));
let dock = self.dock.clone();
let dock_for_build = dock.clone();
let workspace = self.workspace.clone();
let workspace_for_build = workspace.clone();
let store = self.store.clone();
crate::shared::panels::open(
&dock,
crate::shared::panels::open_detail(
&workspace,
id.clone(),
"New pull request",
move |window, cx| {
cx.new(|cx| {
NewPullRequestView::new(
dock_for_build.clone(),
workspace_for_build.clone(),
id.clone(),
store.clone(),
window,
@@ -105,17 +107,18 @@ impl RepoDetailView {
};
let id = SharedString::from(format!("send-patch:{addr}"));
let dock = self.dock.clone();
let dock_for_build = dock.clone();
let workspace = self.workspace.clone();
let workspace_for_build = workspace.clone();
let store = self.store.clone();
crate::shared::panels::open(
&dock,
crate::shared::panels::open_detail(
&workspace,
id.clone(),
"Send patch",
move |window, cx| {
cx.new(|cx| {
SendPatchView::new(
dock_for_build.clone(),
workspace_for_build.clone(),
id.clone(),
store.clone(),
window,
@@ -133,14 +136,17 @@ impl RepoDetailView {
return;
};
let id = SharedString::from(format!("issues:{addr}"));
let dock = self.dock.clone();
let dock_for_build = dock.clone();
let workspace = self.workspace.clone();
let workspace_for_build = workspace.clone();
let store = self.store.clone();
crate::shared::panels::open(
&dock,
crate::shared::panels::open_detail(
&workspace,
id,
move |_, cx| cx.new(|cx| IssuesView::new(dock_for_build.clone(), store.clone(), cx)),
"Issues",
move |_, cx| {
cx.new(|cx| IssuesView::new(workspace_for_build.clone(), store.clone(), cx))
},
window,
cx,
);
+11 -20
View File
@@ -7,7 +7,6 @@ use gpui::{
Styled as _, Task, UniformListScrollHandle, WeakEntity, Window, div, uniform_list,
};
use gpui_native_kit::common::v_flex;
use gpui_native_kit::layout::dock::DockState;
use gpui_native_kit::scrollbar::Scrollbar;
use gpui_native_kit::spinner::Spinner;
use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _};
@@ -16,12 +15,12 @@ use signed_state::RepoStore;
use super::commit_diff::CommitDiffView;
use super::helpers::commit_row;
use super::helpers::repo_display_name;
use crate::shared::panels;
use crate::workspace::Workspace;
pub struct RepoHistoryView {
store: Entity<RepoStore>,
dock: WeakEntity<DockState>,
workspace: WeakEntity<Workspace>,
worktree: Option<PathBuf>,
all_commits: Option<CommitList>,
loading_all_commits: bool,
@@ -30,10 +29,10 @@ pub struct RepoHistoryView {
}
impl RepoHistoryView {
pub fn new(store: Entity<RepoStore>, dock: WeakEntity<DockState>) -> Self {
pub fn new(store: Entity<RepoStore>, workspace: WeakEntity<Workspace>) -> Self {
Self {
store,
dock,
workspace,
worktree: None,
all_commits: None,
loading_all_commits: false,
@@ -100,30 +99,22 @@ impl RepoHistoryView {
return;
};
// Same display name as the repo detail panel's title.
let repo_name = repo_display_name(self.store.read(cx));
let store = self.store.clone();
let short = commit_id.get(..8).unwrap_or(commit_id);
let label = SharedString::from(format!("Commit {short}"));
let commit_id = commit_id.to_owned();
let id = match store.read(cx).addr() {
Some(addr) => SharedString::from(format!("commit:{addr}:{commit_id}")),
None => SharedString::from(format!("commit:{}:{}", worktree.display(), commit_id)),
};
let dock = self.dock.clone();
let workspace = self.workspace.clone();
panels::open(
&dock,
panels::open_detail(
&workspace,
id,
label,
move |window, cx| {
cx.new(|cx| {
CommitDiffView::new(
store.clone(),
worktree.clone(),
repo_name.clone(),
commit_id.clone(),
window,
cx,
)
})
cx.new(|cx| CommitDiffView::new(worktree.clone(), commit_id.clone(), window, cx))
},
window,
cx,
+14 -22
View File
@@ -14,7 +14,7 @@ use gpui_native_kit::badge::Badge;
use gpui_native_kit::button::{Button, ButtonVariant};
use gpui_native_kit::common::{Sizable as _, h_flex, v_flex};
use gpui_native_kit::icons::{Icon, IconRole};
use gpui_native_kit::layout::dock::{DockState, Panel};
use gpui_native_kit::layout::panel::Panel;
use gpui_native_kit::spinner::Spinner;
use gpui_native_kit::theme::{ActiveTheme as _, TextRole, Typeset as _};
use metadata::ProfileDirectory;
@@ -38,12 +38,12 @@ pub mod refs;
use banners::Banners;
use files::RepoFilesView;
use helpers::{RepoData, load_repo_data, repo_display_name};
use helpers::{RepoData, load_repo_data};
use history::RepoHistoryView;
use refs::RefSwitcher;
use crate::shared::tree::{build_tree_items, sorted_worktree_paths};
use crate::shared::widgets::repo_tab_avatar;
use crate::workspace::Workspace;
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum RefKind {
@@ -54,7 +54,7 @@ pub enum RefKind {
}
pub struct RepoDetailView {
pub(super) dock: WeakEntity<DockState>,
pub(super) workspace: WeakEntity<Workspace>,
pub(super) store: Entity<RepoStore>,
/// A repository opened by address alone starts without an announcement.
repo_started: bool,
@@ -86,30 +86,30 @@ pub struct RepoDetailView {
impl RepoDetailView {
pub fn new(
dock: WeakEntity<DockState>,
workspace: WeakEntity<Workspace>,
addr: RepoAddr,
hint: Option<Announcement>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
let store = cx.new(|cx| RepoStore::new(addr, hint, cx));
Self::new_common(dock, store, window, cx)
Self::new_common(workspace, store, window, cx)
}
pub fn new_local(
dock: WeakEntity<DockState>,
workspace: WeakEntity<Workspace>,
local_path: PathBuf,
nip34: Option<Nip34Binding>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
let store = cx.new(move |_cx| RepoStore::new_local(local_path, nip34));
Self::new_common(dock, store, window, cx)
Self::new_common(workspace, store, window, cx)
}
/// A local repository whose detected binding matches an announcement.
pub fn new_local_announced(
dock: WeakEntity<DockState>,
workspace: WeakEntity<Workspace>,
announcement: Announcement,
local_path: PathBuf,
window: &mut Window,
@@ -117,18 +117,18 @@ impl RepoDetailView {
) -> Self {
let addr = announcement.addr();
let store = cx.new(move |cx| RepoStore::from_worktree(addr, announcement, local_path, cx));
Self::new_common(dock, store, window, cx)
Self::new_common(workspace, store, window, cx)
}
fn new_common(
dock: WeakEntity<DockState>,
workspace: WeakEntity<Workspace>,
store: Entity<RepoStore>,
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
let checkouts = CheckoutsStore::global(cx);
let files = cx.new(RepoFilesView::new);
let history = cx.new(|_| RepoHistoryView::new(store.clone(), dock.clone()));
let history = cx.new(|_| RepoHistoryView::new(store.clone(), workspace.clone()));
let weak = cx.entity().downgrade();
let refs = RefSwitcher::new(weak.clone(), window, cx);
@@ -147,7 +147,7 @@ impl RepoDetailView {
});
Self {
dock,
workspace,
store: store.clone(),
repo_started: false,
files,
@@ -1185,15 +1185,7 @@ impl RepoDetailView {
}
}
impl Panel for RepoDetailView {
fn title(&self, cx: &App) -> Option<SharedString> {
Some(repo_display_name(self.store.read(cx)))
}
fn lead(&self, cx: &App) -> Option<AnyElement> {
Some(repo_tab_avatar(self.store.read(cx), &self.directory, cx))
}
}
impl Panel for RepoDetailView {}
impl Render for RepoDetailView {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {