Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: Differentiate PR/MR from branch CI status
Maximilian Roos8ca41580bf17
diff --git a/src/commands/list/ci_status.rs b/src/commands/list/ci_status.rsindex 83169ecf1..cfcdb7c8e 100644--- a/src/commands/list/ci_status.rs+++ b/src/commands/list/ci_status.rs@@ -18,10 +18,30 @@ pub enum CiStatus {NoCI,}+/// Source of CI status+///+/// TODO: Current visual distinction (● for PR, ○ for branch) means main branch+/// always shows hollow circle when running branch CI. This may not be ideal.+/// Possible improvements:+/// - Use different symbols entirely (e.g., ● vs ◎ double circle, ● vs ⊙ circled dot)+/// - Add a third state for "primary branch" (main/master)+/// - Use different shape families (e.g., ● circle vs ■ square, ● vs ◆ diamond)+/// - Consider directional symbols for branch CI (e.g., ▶ right arrow)+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "lowercase")]+pub enum CiSource {+ /// Pull request or merge request+ PullRequest,+ /// Branch workflow/pipeline (no PR/MR)+ Branch,+}+/// PR/MR status including CI state and staleness#[derive(Debug, Clone, Serialize, Deserialize)]pub struct PrStatus {pub ci_status: CiStatus,+ /// Source of the CI status (PR/MR or branch workflow)+ pub source: CiSource,/// True if local HEAD differs from PR HEAD (unpushed changes)pub is_stale: bool,/// URL to the PR/MR (if available)@@ -156,6 +176,7 @@ impl PrStatus {Some(PrStatus {ci_status,+ source: CiSource::PullRequest,is_stale,url: pr_info.url.clone(),})@@ -206,8 +227,11 @@ impl PrStatus {Some(PrStatus {ci_status,+ source: CiSource::PullRequest,is_stale,- url: None, // GitLab MR URL not currently fetched+ // TODO: Fetch GitLab MR URL from glab output to enable clickable links+ // Currently only GitHub PRs have clickable underlined indicators+ url: None,})}@@ -268,6 +292,7 @@ impl PrStatus {Some(PrStatus {ci_status,+ source: CiSource::Branch,is_stale,url: None, // Workflow runs don't have a PR URL})@@ -310,8 +335,10 @@ impl PrStatus {Some(PrStatus {ci_status,+ source: CiSource::Branch,is_stale,- url: None, // GitLab pipeline URL not currently fetched+ // TODO: Fetch GitLab pipeline URL to enable clickable links+ url: None,})}}diff --git a/src/commands/list/render.rs b/src/commands/list/render.rsindex 7fd536b6d..2c1300462 100644--- a/src/commands/list/render.rs+++ b/src/commands/list/render.rs@@ -3,7 +3,7 @@ use anstyle::{AnsiColor, Color, Style};use std::path::Path;use worktrunk::styling::{CURRENT, StyledLine, println};-use super::ci_status::{CiStatus, PrStatus};+use super::ci_status::{CiSource, CiStatus, PrStatus};use super::columns::{ColumnKind, DiffVariant};use super::layout::{ColumnFormat, ColumnLayout, DiffColumnConfig, DiffDisplayConfig, LayoutConfig,@@ -81,10 +81,24 @@ impl PrStatus {}}+ /// Get indicator symbol and style for rendering+ fn indicator_and_style(&self) -> (&'static str, Style) {+ let indicator = match self.source {+ CiSource::PullRequest => "●",+ CiSource::Branch => "○",+ };++ let style = if self.url.is_some() {+ self.style().underline()+ } else {+ self.style()+ };++ (indicator, style)+ }+/// Format CI status as plain text with ANSI colors (for json-pretty)pub fn format_plain(&self) -> String {- let style = self.style();-let status_str = match self.ci_status {CiStatus::Passed => "passed",CiStatus::Running => "running",@@ -93,10 +107,10 @@ impl PrStatus {CiStatus::NoCI => "no-ci",};- // Create base text- let text = format!("● {}", status_str);+ let (indicator, style) = self.indicator_and_style();++ let text = format!("{} {}", indicator, status_str);- // Wrap with hyperlink if URL is availablelet content = if let Some(ref url) = self.url {use worktrunk::styling::hyperlink;hyperlink(&text, url)@@ -109,21 +123,19 @@ impl PrStatus {fn render_indicator(&self) -> StyledLine {let mut segment = StyledLine::new();- let indicator = "●";+ let (indicator, style) = self.indicator_and_style();- // If we have a URL, wrap the indicator with an OSC 8 hyperlinkif let Some(ref url) = self.url {use worktrunk::styling::hyperlink;- // Create styled indicator with hyperlinklet styled_indicator = format!("{}{}{}",- self.style(),+ style,hyperlink(indicator, url),- self.style().render_reset()+ style.render_reset());segment.push_raw(styled_indicator);} else {- segment.push_styled(indicator.to_string(), self.style());+ segment.push_styled(indicator.to_string(), style);}segment