Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Feat: Show CI fetch errors and improve warnings

Maximilian Roos96b8e510f8be
diff --git a/README.md b/README.md
index 547e30e5b..255352e31 100644
--- a/README.md
+++ b/README.md
@@ -722,7 +722,7 @@ Order: `+!? ✖⚠≡_ ↻⋈ ↑↓↕ ⇡⇣⇅ ⎇⌫⊠`
- `!` Modified files (unstaged changes)
- `?` Untracked files present
- `✖` **Merge conflicts** - unresolved conflicts in working tree (fix before continuing)
-- `⚠` **Would conflict** - merging into main would fail
+- `⊘` **Would conflict** - merging into main would fail
- `≡` Working tree matches main (identical contents, regardless of commit history)
- `_` No commits (no commits ahead AND no uncommitted changes)
- `↻` Rebase in progress
diff --git a/src/cli.rs b/src/cli.rs
index 36f9e3466..fb9d9f629 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -617,7 +617,7 @@ Order: `+!? ✖⚠≡_ ↻⋈ ↑↓↕ ⇡⇣⇅ ⎇⌫⊠`
- `!` Modified files (unstaged changes)
- `?` Untracked files present
- `✖` **Merge conflicts** - unresolved conflicts in working tree (fix before continuing)
-- `⚠` **Would conflict** - merging into main would fail
+- `⊘` **Would conflict** - merging into main would fail
- `≡` Working tree matches main (identical contents, regardless of commit history)
- `_` No commits (no commits ahead AND no uncommitted changes)
- `↻` Rebase in progress
diff --git a/src/commands/list/ci_status.rs b/src/commands/list/ci_status.rs
index 0b242610e..9aa9750e1 100644
--- a/src/commands/list/ci_status.rs
+++ b/src/commands/list/ci_status.rs
@@ -119,6 +119,22 @@ fn parse_json<T: DeserializeOwned>(stdout: &[u8], command: &str, branch: &str) -
.ok()
}
+/// Check if stderr indicates a retriable error (rate limit, network issues)
+fn is_retriable_error(stderr: &str) -> bool {
+ let lower = stderr.to_ascii_lowercase();
+ [
+ "rate limit",
+ "api rate",
+ "403",
+ "429",
+ "timeout",
+ "connection",
+ "network",
+ ]
+ .iter()
+ .any(|p| lower.contains(p))
+}
+
/// CI status from GitHub/GitLab checks
/// Matches the statusline.sh color scheme:
/// - Passed: Green (all checks passed)
@@ -126,6 +142,7 @@ fn parse_json<T: DeserializeOwned>(stdout: &[u8], command: &str, branch: &str) -
/// - Failed: Red (checks failed)
/// - Conflicts: Yellow (merge conflicts)
/// - NoCI: Gray (no PR/checks)
+/// - Error: Yellow (CI fetch failed, e.g., rate limit)
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum CiStatus {
@@ -134,6 +151,8 @@ pub enum CiStatus {
Failed,
Conflicts,
NoCI,
+ /// CI status could not be fetched (rate limit, network error, etc.)
+ Error,
}
/// Source of CI status
@@ -175,28 +194,19 @@ impl CiStatus {
/// - Failed: Red
/// - Conflicts: Yellow
/// - NoCI: BrightBlack (dimmed)
+ /// - Error: Yellow (warning color)
pub fn color(&self) -> anstyle::AnsiColor {
use anstyle::AnsiColor;
match self {
Self::Passed => AnsiColor::Green,
Self::Running => AnsiColor::Blue,
Self::Failed => AnsiColor::Red,
- Self::Conflicts => AnsiColor::Yellow,
+ Self::Conflicts | Self::Error => AnsiColor::Yellow,
Self::NoCI => AnsiColor::BrightBlack,
}
}
}
-impl CiSource {
- /// Get the indicator symbol for this CI source
- pub fn indicator(&self) -> &'static str {
- match self {
- Self::PullRequest => "●",
- Self::Branch => "○",
- }
- }
-}
-
impl PrStatus {
/// Get the style for this PR status (color + optional dimming for stale)
pub fn style(&self) -> anstyle::Style {
@@ -205,15 +215,40 @@ impl PrStatus {
if self.is_stale { style.dimmed() } else { style }
}
+ /// Get the indicator symbol for this status
+ ///
+ /// - Error: ⚠ (overrides source indicator)
+ /// - PullRequest: ● (filled circle)
+ /// - Branch: ○ (hollow circle)
+ pub fn indicator(&self) -> &'static str {
+ match self.ci_status {
+ CiStatus::Error => "⚠",
+ _ => match self.source {
+ CiSource::PullRequest => "●",
+ CiSource::Branch => "○",
+ },
+ }
+ }
+
/// Format CI status as a colored indicator for statusline output.
///
/// Returns a string like "●" with appropriate ANSI color.
pub fn format_indicator(&self) -> String {
let style = self.style();
- let indicator = self.source.indicator();
+ let indicator = self.indicator();
format!("{style}{indicator}{style:#}")
}
+ /// Create an error status for retriable failures (rate limit, network errors)
+ fn error() -> Self {
+ Self {
+ ci_status: CiStatus::Error,
+ source: CiSource::Branch,
+ is_stale: false,
+ url: None,
+ }
+ }
+
/// Detect CI status for a branch using gh/glab CLI
/// First tries to find PR/MR status, then falls back to workflow/pipeline runs
/// Returns None if no CI found or CLI tools unavailable
@@ -299,6 +334,9 @@ impl PrStatus {
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
log::debug!("gh pr list failed for {}: {}", branch, stderr.trim());
+ if is_retriable_error(&stderr) {
+ return Some(Self::error());
+ }
return None;
}
@@ -436,6 +474,9 @@ impl PrStatus {
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
log::debug!("gh run list failed for {}: {}", branch, stderr.trim());
+ if is_retriable_error(&stderr) {
+ return Some(Self::error());
+ }
return None;
}
diff --git a/src/commands/list/model.rs b/src/commands/list/model.rs
index f7353e740..6c443ca76 100644
--- a/src/commands/list/model.rs
+++ b/src/commands/list/model.rs
@@ -720,7 +720,7 @@ impl serde::Serialize for WorktreeState {
/// 1. Conflicts (✖) - blocking, must resolve
/// 2. Rebase (↻) - active operation
/// 3. Merge (⋈) - active operation
-/// 4. MergeTreeConflicts (⚠) - potential problem
+/// 4. MergeTreeConflicts (⊘) - potential problem
/// 5. MatchesMain (≡) - removable
/// 6. NoCommits (_) - removable
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, strum::IntoStaticStr)]
@@ -750,7 +750,7 @@ impl std::fmt::Display for BranchOpState {
Self::Conflicts => write!(f, "✖"),
Self::Rebase => write!(f, "↻"),
Self::Merge => write!(f, "⋈"),
- Self::MergeTreeConflicts => write!(f, "⚠"),
+ Self::MergeTreeConflicts => write!(f, "⊘"),
Self::MatchesMain => write!(f, "≡"),
Self::NoCommits => write!(f, "_"),
}
@@ -886,7 +886,7 @@ impl PositionMask {
#[derive(Debug, Clone, Default)]
pub struct StatusSymbols {
/// Combined branch and operation state (mutually exclusive with priority)
- /// Priority: Conflicts (✖) > Rebase (↻) > Merge (⋈) > MergeTreeConflicts (⚠) > MatchesMain (≡) > NoCommits (_)
+ /// Priority: Conflicts (✖) > Rebase (↻) > Merge (⋈) > MergeTreeConflicts (⊘) > MatchesMain (≡) > NoCommits (∅)
pub(crate) branch_op_state: BranchOpState,
/// Worktree state: ⎇ for branches, ⚐⌫⊠ for worktrees (priority: path_mismatch > prunable > locked)
diff --git a/src/commands/list/render.rs b/src/commands/list/render.rs
index d7bec9a2d..5c90d6194 100644
--- a/src/commands/list/render.rs
+++ b/src/commands/list/render.rs
@@ -81,7 +81,7 @@ impl PrStatus {
} else {
self.style()
};
- (self.source.indicator(), style)
+ (self.indicator(), style)
}
fn render_indicator(&self) -> StyledLine {
diff --git a/src/md_help.rs b/src/md_help.rs
index 131f34f35..bd7f3dcd2 100644
--- a/src/md_help.rs
+++ b/src/md_help.rs
@@ -102,14 +102,14 @@ fn colorize_status_symbols(text: &str) -> String {
.replace("● failed", &format!("{error}●{error:#} failed"))
.replace("● conflicts", &format!("{warning}●{warning:#} conflicts"))
.replace("● no-ci", &format!("{disabled}●{disabled:#} no-ci"))
- // Conflicts: ✖ is ERROR (red), ⚠ is WARNING (yellow)
+ // Conflicts: ✖ is ERROR (red), ⊘ is WARNING (yellow)
.replace(
"✖ Merge conflicts",
&format!("{error}✖{error:#} Merge conflicts"),
)
.replace(
- "⚠ Would conflict",
- &format!("{warning}⚠{warning:#} Would conflict"),
+ "⊘ Would conflict",
+ &format!("{warning}⊘{warning:#} Would conflict"),
)
// Git operations: WARNING (yellow)
.replace("↻ Rebase", &format!("{warning}↻{warning:#} Rebase"))
diff --git a/tests/snapshots/integration__integration_tests__help__help_list.snap b/tests/snapshots/integration__integration_tests__help__help_list.snap
index ab0fac1ff..fcf4298a7 100644
--- a/tests/snapshots/integration__integration_tests__help__help_list.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_list.snap
@@ -9,6 +9,7 @@ info:
CLICOLOR_FORCE: "1"
COLUMNS: "150"
GIT_EDITOR: ""
+ SOURCE_DATE_EPOCH: "1735776000"
WORKTRUNK_BIN: ""
WORKTRUNK_CONFIG_PATH: /nonexistent/test/config.toml
---
@@ -82,7 +83,7 @@ Order: +!? ✖⚠≡_ ↻⋈ ↑↓↕ ⇡⇣⇅ ⎇⌫⊠
- ! Modified files (unstaged changes)
- ? Untracked files present
- ✖ Merge conflicts - unresolved conflicts in working tree (fix before continuing)
-- ⚠ Would conflict - merging into main would fail
+- ⊘ Would conflict - merging into main would fail
- ≡ Working tree matches main (identical contents, regardless of commit history)
- _ No commits (no commits ahead AND no uncommitted changes)
- ↻ Rebase in progress
diff --git a/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap b/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap
index f70e4b08a..8d96fc8d9 100644
--- a/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap
+++ b/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap
@@ -26,6 +26,6 @@ exit_code: 0
----- stderr -----
Branch Status HEAD± main↕ main…± Path Remote⇅ CI Commit Age Message
@ main ^⇡ ./repo ⇡1 ⇣0 85ed6d3d 1d Main advances
-+ feature +!?⚠↕⇅⊠🤖 +2 -2 ↑2 ↓1 +3 -1 ./repo.feature ⇡1 ⇣1 4afb2b9e 1d Local commit
++ feature +!?⊘↕⇅⊠🤖 +2 -2 ↑2 ↓1 +3 -1 ./repo.feature ⇡1 ⇣1 4afb2b9e 1d Local commit
⚪ Showing 2 worktrees, 1 with changes, 1 ahead