feat: subtext under pr title

This commit is contained in:
2026-05-12 01:34:33 +08:00
parent bfcfac61e8
commit 2fe3f7b94f
12 changed files with 290 additions and 105 deletions

View File

@@ -1,6 +1,6 @@
use gpui::{
AppContext, InteractiveElement, IntoElement, ParentElement, StatefulInteractiveElement, Styled,
div, prelude::FluentBuilder,
div, img, prelude::FluentBuilder,
};
use crate::{
@@ -118,20 +118,80 @@ impl PullRequestView {
}
}
let author_pill = div()
.px_2()
.border_1()
.border_color(theme.colors.border)
.rounded_full()
.bg(theme.colors.surface_elevated)
.child(text("kennethnym").text_xs());
let merge_text = match (
pr.author.as_ref(),
pr.base_branch_name.as_ref(),
pr.head_branch_name.as_ref(),
) {
| (Some(author), Some(base_branch), Some(head_branch)) => {
let str = format!(
"{} requested to merge {} into {}",
author.login, head_branch, base_branch
);
let row = div()
.flex()
.flex_row()
.gap_2()
.child(status_pill)
.child(author_pill);
let head_branch_text_offset = author.login.len() + 20;
let base_branch_text_offset = head_branch_text_offset + head_branch.len() + 6;
let highlights = [
(
0..author.login.len(),
gpui::HighlightStyle {
font_weight: Some(gpui::FontWeight::BOLD),
..Default::default()
},
),
(
head_branch_text_offset..head_branch_text_offset + head_branch.len(),
gpui::HighlightStyle {
font_weight: Some(gpui::FontWeight::BOLD),
color: Some(theme.colors.accent.into()),
..Default::default()
},
),
(
base_branch_text_offset..base_branch_text_offset + base_branch.len(),
gpui::HighlightStyle {
font_weight: Some(gpui::FontWeight::BOLD),
color: Some(theme.colors.accent.into()),
..Default::default()
},
),
];
Some((
author,
gpui::StyledText::new(str).with_highlights(highlights),
))
}
| _ => None,
};
let metadata_line =
div()
.flex()
.flex_row()
.gap_2()
.when_some(merge_text, |it, (author, t)| {
it.child(
div()
.flex()
.flex_row()
.items_center()
.gap_1p5()
.child(img(author.avatar_url.clone()).size_4().rounded_full())
.child(
div()
.min_w_0()
.w_full()
.text_color(theme.colors.text)
.text_xs()
.font_weight(gpui::FontWeight::LIGHT)
.opacity(0.8)
.child(t),
),
)
});
div()
.size_full()
@@ -145,8 +205,8 @@ impl PullRequestView {
.py_3()
.border_b_1()
.border_color(theme.colors.border)
.child(text(pr.title.clone()).w_full().text_xl().mb_2())
.child(row),
.child(text(pr.title.clone()).w_full().text_xl().mb_1())
.child(metadata_line),
)
.child(
div().flex_1().min_h_0().w_full().child(