Skip to content

Commit 1f3e64a

Browse files
fix "what's changed" release toast attention level logic (#5959)
## Summary Currently, the "What's Changed" popup toast in bottom left appears after updating if three conditions are true: 1. Using Desktop app 2. Don't have notifications disabled in settings 3. Have not seen/dismissed the notification before Then the fourth condition is 4. At least 1 of the last 2 notifications is medium or high priority However, we only ever show the most recent notification, so this logic is flawed. In addition, it presents issues: - When the changelog is first generated by AI, it is marked as "low" priority until human review. But if the changelog _prior_ to that is "medium" or "high", the AI-generated one might get shown anyway - which frustrates the intended process. There's also a bug fixed here concidentally where if the server only returns a single entry, it is never shown (due to `slice(0, -1)` syntax when checking priorities). ## Changes - **What**: Updated Pinia release store to read `attention` from the newest release only and expanded unit coverage for toast visibility ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5959-fix-what-s-changed-release-toast-attention-level-logic-2856d73d36508141b9b2d8d3b11153b2) by [Unito](https://www.unito.io)
1 parent 0a83943 commit 1f3e64a

File tree

2 files changed

+19
-34
lines changed

2 files changed

+19
-34
lines changed

src/platform/updates/common/releaseStore.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,10 @@ export const useReleaseStore = defineStore('release', () => {
7272
) === 0
7373
)
7474

75-
const hasMediumOrHighAttention = computed(() =>
76-
recentReleases.value
77-
.slice(0, -1)
78-
.some(
79-
(release) =>
80-
release.attention === 'medium' || release.attention === 'high'
81-
)
82-
)
75+
const hasMediumOrHighAttention = computed(() => {
76+
const attention = recentRelease.value?.attention
77+
return attention === 'medium' || attention === 'high'
78+
})
8379

8480
// Show toast if needed
8581
const shouldShowToast = computed(() => {

tests-ui/tests/store/releaseStore.test.ts

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,22 @@ describe('useReleaseStore', () => {
145145

146146
it('should show toast for medium/high attention releases', () => {
147147
vi.mocked(semverCompare).mockReturnValue(1)
148+
store.releases = [mockRelease]
148149

149-
// Need multiple releases for hasMediumOrHighAttention to work
150-
const mediumRelease = {
150+
expect(store.shouldShowToast).toBe(true)
151+
})
152+
153+
it('should not show toast for low attention releases', () => {
154+
vi.mocked(semverCompare).mockReturnValue(1)
155+
156+
const lowAttentionRelease = {
151157
...mockRelease,
152-
id: 2,
153-
attention: 'medium' as const
158+
attention: 'low' as const
154159
}
155-
store.releases = [mockRelease, mediumRelease]
156160

157-
expect(store.shouldShowToast).toBe(true)
161+
store.releases = [lowAttentionRelease]
162+
163+
expect(store.shouldShowToast).toBe(false)
158164
})
159165

160166
it('should show red dot for new versions', () => {
@@ -490,12 +496,7 @@ describe('useReleaseStore', () => {
490496

491497
vi.mocked(semverCompare).mockReturnValue(1)
492498

493-
const mediumRelease = { ...mockRelease, attention: 'medium' as const }
494-
store.releases = [
495-
mockRelease,
496-
mediumRelease,
497-
{ ...mockRelease, attention: 'low' as const }
498-
]
499+
store.releases = [mockRelease]
499500

500501
expect(store.shouldShowToast).toBe(true)
501502
})
@@ -578,14 +579,7 @@ describe('useReleaseStore', () => {
578579

579580
it('should show toast when conditions are met', () => {
580581
vi.mocked(semverCompare).mockReturnValue(1)
581-
582-
// Need multiple releases for hasMediumOrHighAttention
583-
const mediumRelease = {
584-
...mockRelease,
585-
id: 2,
586-
attention: 'medium' as const
587-
}
588-
store.releases = [mockRelease, mediumRelease]
582+
store.releases = [mockRelease]
589583

590584
expect(store.shouldShowToast).toBe(true)
591585
})
@@ -615,12 +609,7 @@ describe('useReleaseStore', () => {
615609
vi.mocked(semverCompare).mockReturnValue(1)
616610

617611
// Set up all conditions that would normally show toast
618-
const mediumRelease = {
619-
...mockRelease,
620-
id: 2,
621-
attention: 'medium' as const
622-
}
623-
store.releases = [mockRelease, mediumRelease]
612+
store.releases = [mockRelease]
624613

625614
expect(store.shouldShowToast).toBe(false)
626615
})

0 commit comments

Comments
 (0)