Skip to content

Commit 98b0395

Browse files
feat(notifications): show success/fail status icons for CheckSuite notifications
Parse workflow-run notification titles for “failed”/“succeeded” keywords and indicate the status in dash by setting the icon accordingly, in the appropriate green or not-green color — similar to what gitify does.
1 parent 44609e5 commit 98b0395

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

internal/tui/components/notificationrow/notificationrow.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package notificationrow
22

33
import (
44
"fmt"
5+
"strings"
56

67
"github.com/charmbracelet/lipgloss"
78

@@ -81,8 +82,25 @@ func (n *Notification) renderType() string {
8182
icon = ""
8283
style = style.Foreground(n.Ctx.Theme.SecondaryText)
8384
case "CheckSuite":
84-
icon = constants.WorkflowIcon
85-
style = style.Foreground(n.Ctx.Theme.WarningText)
85+
// Parse title to determine workflow status (similar to gitify approach)
86+
title := strings.ToLower(n.Data.GetTitle())
87+
switch {
88+
case strings.Contains(title, "failed"):
89+
icon = constants.FailureIcon
90+
style = style.Foreground(n.Ctx.Theme.ErrorText)
91+
case strings.Contains(title, "succeeded"):
92+
icon = constants.SuccessIcon
93+
style = style.Foreground(n.Ctx.Theme.SuccessText)
94+
case strings.Contains(title, "cancelled"), strings.Contains(title, "canceled"):
95+
icon = constants.WorkflowRunIcon
96+
style = style.Foreground(n.Ctx.Theme.FaintText)
97+
case strings.Contains(title, "skipped"):
98+
icon = constants.WorkflowRunIcon
99+
style = style.Foreground(n.Ctx.Theme.FaintText)
100+
default:
101+
icon = constants.WorkflowRunIcon
102+
style = style.Foreground(n.Ctx.Theme.WarningText)
103+
}
86104
case "RepositoryVulnerabilityAlert":
87105
icon = constants.SecurityIcon
88106
style = style.Foreground(n.Ctx.Theme.ErrorText)

internal/tui/constants/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const (
7575

7676
// Notification type icons
7777
WorkflowIcon = "" // \uf52e nf-oct-checklist (for CheckSuite/CI)
78+
WorkflowRunIcon = "" // \uebd6 nf-cod-workflow (for CheckSuite default)
7879
SecurityIcon = "󰒃" // \udb80\udc83 nf-md-shield_alert (for security alerts)
7980
NotificationIcon = "" // \ueaa2 nf-cod-bell (generic notification fallback)
8081
SearchIcon = "" // \uf002 nf-fa-search

0 commit comments

Comments
 (0)