From cf6d4260789ec4f289fc85acf3b9de5c9297ab45 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Tue, 13 Oct 2026 09:04:51 -0400 Subject: [PATCH] feat(notifications): show identifiers for releases and commits - Releases surface their tag; commits their abbreviated SHA - Identifiers reuse resources the handlers already fetch - Rename the "Show GitHub number" setting to "Show identifier" --- src/renderer/__mocks__/notifications-mocks.ts | 50 ++++++++++-- .../notifications/NotificationHeader.tsx | 2 +- .../notifications/NotificationRow.test.tsx | 27 +++++++ .../notifications/NotificationRow.tsx | 2 +- .../NotificationRow.test.tsx.snap | 12 +-- .../settings/NotificationSettings.tsx | 32 ++++++-- ...ifications-dark-classic-chromium-linux.png | Bin 44024 -> 35325 bytes ...otifications-dark-glass-chromium-linux.png | Bin 44340 -> 35348 bytes ...dark_colorblind-classic-chromium-linux.png | Bin 43972 -> 35277 bytes ...ons-dark_dimmed-classic-chromium-linux.png | Bin 43037 -> 35173 bytes ...dark_tritanopia-classic-chromium-linux.png | Bin 44084 -> 35308 bytes ...fications-light-classic-chromium-linux.png | Bin 44003 -> 35016 bytes ...tifications-light-glass-chromium-linux.png | Bin 43011 -> 33732 bytes ...ight_colorblind-classic-chromium-linux.png | Bin 43971 -> 35002 bytes ...ight_tritanopia-classic-chromium-linux.png | Bin 43944 -> 34969 bytes .../__snapshots__/Settings.test.tsx.snap | 2 +- src/renderer/types.ts | 8 +- .../forges/github/handlers/commit.test.ts | 19 +++++ .../utils/forges/github/handlers/commit.ts | 4 + .../forges/github/handlers/release.test.ts | 12 +++ .../utils/forges/github/handlers/release.ts | 1 + .../utils/notifications/formatters.test.ts | 72 ++++++++++++++---- .../utils/notifications/formatters.ts | 57 +++++++++++--- 23 files changed, 252 insertions(+), 48 deletions(-) diff --git a/src/renderer/__mocks__/notifications-mocks.ts b/src/renderer/__mocks__/notifications-mocks.ts index 501e5c85a..48a7fbe2d 100644 --- a/src/renderer/__mocks__/notifications-mocks.ts +++ b/src/renderer/__mocks__/notifications-mocks.ts @@ -1,6 +1,7 @@ import { AgentIcon, CopilotIcon, + GitCommitIcon, GitPullRequestIcon, IssueOpenedIcon, TagIcon, @@ -93,7 +94,7 @@ export const mockGitHubCloudGitifyNotifications: GitifyNotification[] = [ }, repository: mockGitHubRepository, display: { - number: '123', + identifier: '123', title: 'I am a robot and this is a test! [#123]', type: 'Open Issue', icon: { @@ -124,7 +125,7 @@ export const mockGitHubCloudGitifyNotifications: GitifyNotification[] = [ }, repository: mockGitHubRepository, display: { - number: '456', + identifier: '456', title: 'Improve the UI [#456]', type: 'Issue', icon: { @@ -175,10 +176,11 @@ export const mockGithubEnterpriseGitifyNotifications: GitifyNotification[] = [ 'https://github.gitify.io/api/v3/repos/myorg/notifications-test/releases/3' as Link, type: 'Release', reviewers: undefined, + tagName: '0.0.1', }, repository: mockEnterpriseRepository, display: { - number: '', + identifier: '0.0.1', title: 'Release 0.0.1', type: 'Release', icon: { @@ -209,7 +211,7 @@ export const mockGithubEnterpriseGitifyNotifications: GitifyNotification[] = [ }, repository: mockEnterpriseRepository, display: { - number: '123', + identifier: '123', title: 'Bump Version [#123]', type: 'Pull Request', icon: { @@ -223,6 +225,44 @@ export const mockGithubEnterpriseGitifyNotifications: GitifyNotification[] = [ export const mockGitifyNotification: GitifyNotification = mockGitHubCloudGitifyNotifications[0]; +/** + * Mock Gitify Notification for a GitHub commit. + * + * Subject type `Commit`, which identifies by its SHA rather than a number. + */ +export const mockCommitGitifyNotification: GitifyNotification = { + account: mockGitHubCloudAccount, + order: 0, + id: '1349837581', + unread: true, + reason: { + code: 'subscribed', + title: 'Updated', + description: "You're watching the repository.", + }, + updatedAt: '2024-03-12T10:00:00Z', + subject: { + title: 'Fix the thing', + url: 'https://api.github.com/repos/gitify-app/notifications-test/commits/d2a86d80e3d24ea9510d5de6c147e53c30f313a8' as Link, + latestCommentUrl: null, + type: 'Commit', + commitSha: 'd2a86d80e3d24ea9510d5de6c147e53c30f313a8', + user: mockSubjectUser, + author: mockSubjectUser, + }, + repository: mockGitHubRepository, + display: { + identifier: 'd2a86d8', + title: 'Fix the thing', + type: 'Commit', + icon: { + type: GitCommitIcon, + color: IconColor.GRAY, + }, + defaultUserType: 'User', + }, +}; + /** * Mock Gitify Notification for a GitHub Copilot cloud agent session. * @@ -248,7 +288,7 @@ export const mockAgentSessionGitifyNotification: GitifyNotification = { }, repository: mockGitHubRepository, display: { - number: '', + identifier: '', title: 'Analyzing and fixing GitHub Actions job failure', type: 'Agent Session Thread', icon: { diff --git a/src/renderer/components/notifications/NotificationHeader.tsx b/src/renderer/components/notifications/NotificationHeader.tsx index 94ee086ba..aeaedd95d 100644 --- a/src/renderer/components/notifications/NotificationHeader.tsx +++ b/src/renderer/components/notifications/NotificationHeader.tsx @@ -45,7 +45,7 @@ export const NotificationHeader: FC = ({ />
- {notification.display.number} + {notification.display.identifier}
diff --git a/src/renderer/components/notifications/NotificationRow.test.tsx b/src/renderer/components/notifications/NotificationRow.test.tsx index 830f7489e..998876bc8 100644 --- a/src/renderer/components/notifications/NotificationRow.test.tsx +++ b/src/renderer/components/notifications/NotificationRow.test.tsx @@ -5,6 +5,7 @@ import { useState } from 'react'; import { renderWithProviders } from '../../__helpers__/test-utils'; import { mockGitHubEnterpriseServerAccount } from '../../__mocks__/account-mocks'; import { + mockCommitGitifyNotification, mockGiteaGitifyNotification, mockGitifyNotification, } from '../../__mocks__/notifications-mocks'; @@ -81,6 +82,32 @@ describe('renderer/components/notifications/NotificationRow.tsx', () => { expect(tree.container).toMatchSnapshot(); }); + it('shows the release tag as the identifier', () => { + const props: NotificationRowProps = { + notification: { + ...mockGitifyNotification, + subject: { ...mockGitifyNotification.subject, type: 'Release', tagName: '0.0.1' }, + display: { ...mockGitifyNotification.display, identifier: '0.0.1' }, + }, + isRepositoryAnimatingExit: false, + }; + + const tree = renderWithProviders(); + + expect(tree.getByText('0.0.1')).toBeInTheDocument(); + }); + + it('shows the commit short SHA as the identifier', () => { + const props: NotificationRowProps = { + notification: mockCommitGitifyNotification, + isRepositoryAnimatingExit: false, + }; + + const tree = renderWithProviders(); + + expect(tree.getByText('d2a86d8')).toBeInTheDocument(); + }); + it('should render itself & its children - notification is read', async () => { const props: NotificationRowProps = { notification: { ...mockGitifyNotification, unread: false }, diff --git a/src/renderer/components/notifications/NotificationRow.tsx b/src/renderer/components/notifications/NotificationRow.tsx index c5623529b..23a35b647 100644 --- a/src/renderer/components/notifications/NotificationRow.tsx +++ b/src/renderer/components/notifications/NotificationRow.tsx @@ -146,7 +146,7 @@ export const NotificationRow: FC = ({ (isGroupByDate() || !showNumber) && 'hidden', )} > - {notification.display.number} + {notification.display.identifier} diff --git a/src/renderer/components/notifications/__snapshots__/NotificationRow.test.tsx.snap b/src/renderer/components/notifications/__snapshots__/NotificationRow.test.tsx.snap index e4658d282..3e1c41d82 100644 --- a/src/renderer/components/notifications/__snapshots__/NotificationRow.test.tsx.snap +++ b/src/renderer/components/notifications/__snapshots__/NotificationRow.test.tsx.snap @@ -1223,7 +1223,7 @@ exports[`renderer/components/notifications/NotificationRow.tsx > should render i data-wrap="nowrap" >