chore: rework pull request detail into a split layout
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s

This commit is contained in:
2026-11-26 21:11:05 +07:00
parent bc39668f5d
commit db3d53f2aa
11 changed files with 596 additions and 551 deletions
+26 -26
View File
@@ -41,6 +41,32 @@ pub struct IssueDetailView {
}
impl IssueDetailView {
pub fn new(store: Entity<RepoStore>, issue_id: EventId, cx: &mut Context<Self>) -> Self {
let comment_input = InputState::builder().multiline().build(cx);
let directory = ProfileDirectory::new(cx);
let weak = cx.entity().downgrade();
let subscription = cx.observe(&store, |this, _store, cx| {
this.track_participants(cx);
cx.notify();
});
cx.defer(move |cx| {
log_dropped(weak.update(cx, |this, cx| {
this.track_participants(cx);
}));
});
Self {
store,
issue_id,
comment_input,
directory,
scroll_handle: ScrollHandle::new(),
_subscription: subscription,
}
}
/// Opens the issue's detail as the main panel and its sidebar in the split pane.
pub fn open(
workspace: &WeakEntity<AppRoot>,
@@ -83,32 +109,6 @@ impl IssueDetailView {
}));
}
pub fn new(store: Entity<RepoStore>, issue_id: EventId, cx: &mut Context<Self>) -> Self {
let comment_input = InputState::builder().multiline().build(cx);
let directory = ProfileDirectory::new(cx);
let weak = cx.entity().downgrade();
let subscription = cx.observe(&store, |this, _store, cx| {
this.track_participants(cx);
cx.notify();
});
cx.defer(move |cx| {
log_dropped(weak.update(cx, |this, cx| {
this.track_participants(cx);
}));
});
Self {
store,
issue_id,
comment_input,
directory,
scroll_handle: ScrollHandle::new(),
_subscription: subscription,
}
}
/// Track the issue author, everyone who commented and the repository owner.
fn track_participants(&mut self, cx: &mut Context<Self>) {
let store = self.store.read(cx);
+12 -2
View File
@@ -6,6 +6,7 @@ use nostr::prelude::{Event, EventId};
use signed_core::RepoStatus;
use signed_state::RepoStore;
use ui::avatar::Avatar;
use ui::badge::Badge;
use ui::button::Button;
use ui::common::{Sizable as _, StyledExt as _, h_flex, v_flex};
use ui::icons::{Icon, IconRole};
@@ -82,11 +83,20 @@ pub(crate) fn comments_section(
) -> AnyElement {
let store = store.read(cx);
let comments: Vec<&Event> = store.comments_of(&root).collect();
let title = SharedString::from(format!("Discussions {}", comments.len()));
let count = comments.len();
v_flex()
.gap_4()
.child(div().text_xs().font_semibold().child(title))
.child(
h_flex()
.gap_2()
.child(Icon::named(IconRole::Message))
.child(div().text_sm().font_semibold().child("Discussions"))
.child(Badge::new(
format!("discussion-count:{root}"),
count.to_string(),
)),
)
.children(comments.iter().map(|comment| {
let profile = directory.read(cx).profile(&comment.pubkey, cx);
let author = profile.name();
File diff suppressed because it is too large Load Diff
+7 -29
View File
@@ -371,35 +371,13 @@ impl Render for PullRequestsView {
.border_color(cx.theme().colors.border)
.hover(|this| this.bg(cx.theme().colors.muted_hover))
.on_click(move |_, window, cx| {
let id = SharedString::from(format!("pr:{pr_id}"));
let workspace_for_build = workspace.clone();
let store = store.clone();
log_dropped(workspace.update(cx, |root, cx| {
root.panels().clone().update(
cx,
|panels, cx| {
panels.open(
PanelSlot::Main,
id,
move |window, cx| {
cx.new(|cx| {
PullRequestDetailView::new(
workspace_for_build
.clone(),
store.clone(),
pr_id,
window,
cx,
)
})
},
window,
cx,
)
},
)
}));
PullRequestDetailView::open(
&workspace,
store.clone(),
pr_id,
window,
cx,
);
})
.child(
h_flex()
+1 -24
View File
@@ -64,30 +64,7 @@ pub fn open_repo_item(
IssueDetailView::open(workspace, store, issue_id, window, cx);
}
RepoItem::PullRequest(pr_id) => {
let id = SharedString::from(format!("pr:{pr_id}"));
let workspace_for_build = workspace.clone();
let store = store.clone();
log_dropped(workspace.update(cx, |root, cx| {
root.panels().update(cx, |panels, cx| {
panels.open(
PanelSlot::Main,
id,
move |window, cx| {
cx.new(|cx| {
PullRequestDetailView::new(
workspace_for_build.clone(),
store.clone(),
pr_id,
window,
cx,
)
})
},
window,
cx,
)
})
}));
PullRequestDetailView::open(workspace, store.clone(), pr_id, window, cx);
}
// Opening a patch series directly is not a feature.
_ => {}
+65 -22
View File
@@ -320,8 +320,12 @@ impl DiffPane {
}
}
fn render_toolbar(&self, cx: &mut Context<Self>) -> AnyElement {
let view = cx.entity().downgrade();
fn render_toolbar(
&self,
show_tree_toggle: bool,
view: WeakEntity<Self>,
cx: &App,
) -> AnyElement {
let (insertions, deletions) = self.diff().map_or((0, 0), |diff| {
(
diff.files.iter().map(|file| file.insertions).sum(),
@@ -338,22 +342,24 @@ impl DiffPane {
.flex_none()
.border_b_1()
.border_color(cx.theme().colors.border)
.child(
Toggle::new("toggle-tree")
.icon(Icon::named(IconRole::PanelLeft))
.pressed(self.tree_visible)
.accessibility_label("Toggle file tree")
.on_change({
let view = view.clone();
move |pressed, _, cx| {
if let Err(error) =
view.update(cx, |this, cx| this.set_tree_visible(pressed, cx))
{
log::warn!("failed to toggle file tree: {error}");
.when(show_tree_toggle, |this| {
this.child(
Toggle::new("toggle-tree")
.icon(Icon::named(IconRole::PanelLeft))
.pressed(self.tree_visible)
.accessibility_label("Toggle file tree")
.on_change({
let view = view.clone();
move |pressed, _, cx| {
if let Err(error) =
view.update(cx, |this, cx| this.set_tree_visible(pressed, cx))
{
log::warn!("failed to toggle file tree: {error}");
}
}
}
}),
)
}),
)
})
.when(insertions > 0 || deletions > 0, |this| {
this.child(GroupedBadge::new(
"toolbar-diff-stats",
@@ -393,7 +399,7 @@ impl DiffPane {
.variant(ButtonVariant::Ghost)
.small()
.on_click({
let view = view;
let view = view.clone();
move |_, _, cx| {
if let Err(error) =
view.update(cx, |this, cx| this.toggle_all_files(cx))
@@ -411,9 +417,13 @@ impl DiffPane {
.variant(ButtonVariant::Ghost)
.tooltip(Tooltip::text("Download commit"))
.small()
.on_click(cx.listener(|_, _, _, cx| {
cx.emit(DiffPaneEvent::DownloadCommit);
})),
.on_click(move |_, _, cx| {
if let Err(error) = view.update(cx, |_, cx| {
cx.emit(DiffPaneEvent::DownloadCommit);
}) {
log::warn!("failed to download commit patch: {error}");
}
}),
)
})
.into_any_element()
@@ -448,6 +458,39 @@ impl DiffPane {
.child(Scrollbar::vertical("commit-diff-files", self.list.clone()))
.into_any_element()
}
/// Renders every diff row inline, for embedding in a page that scrolls as a whole.
pub fn render_flow(&self, view: WeakEntity<Self>, cx: &App) -> AnyElement {
let Some(diff) = self.diff.as_ref() else {
return div()
.p_4()
.text_sm()
.text_color(cx.theme().colors.muted_foreground)
.child("No changes")
.into_any_element();
};
if diff.files.is_empty() {
return div()
.p_4()
.text_sm()
.text_color(cx.theme().colors.muted_foreground)
.child("No files changed")
.into_any_element();
}
let wrap = self.wrap;
let rows = self
.pane_rows
.iter()
.map(|row| render_pane_row(row, &diff.files, &view, wrap, cx))
.collect::<Vec<_>>();
v_flex()
.w_full()
.child(self.render_toolbar(false, view, cx))
.child(v_flex().w_full().p_2().children(rows))
.into_any_element()
}
}
fn render_pane_row(
@@ -572,7 +615,7 @@ impl Render for DiffPane {
return EmptyState::centered("No files changed");
}
let toolbar = self.render_toolbar(cx);
let toolbar = self.render_toolbar(true, cx.entity().downgrade(), cx);
let file_list = self.render_file_list(cx);
let content = if self.tree_visible {