A local-first personal finance app
:art: Notifications style updates (#9084)
Michael Clark984ce4803898
diff --git a/packages/desktop-client/src/components/news/ChangelogSection.tsx b/packages/desktop-client/src/components/news/ChangelogSection.tsxnew file mode 100644index 0000000000..6f2669c090--- /dev/null+++ b/packages/desktop-client/src/components/news/ChangelogSection.tsx@@ -0,0 +1,66 @@+import { useId, useState } from 'react';+import { useTranslation } from 'react-i18next';++import { Button } from '@actual-app/components/button';+import {+ SvgCheveronDown,+ SvgCheveronRight,+} from '@actual-app/components/icons/v1';+import { View } from '@actual-app/components/view';++import type { ChangelogSection as ChangelogSectionData } from '#news/changelog';++import { NewsMarkdown } from './NewsMarkdown';++// Every change starts with a link to its pull request. Underlining all of+// them makes the list hard to scan, so they only underline when pointed at.+const changeListStyle = {+ '& li > a[href*="/pull/"]': { textDecoration: 'none' },+ '& li > a[href*="/pull/"]:hover, & li > a[href*="/pull/"]:focus-visible': {+ textDecoration: 'underline',+ },+};++type ChangelogSectionProps = Pick<+ ChangelogSectionData,+ 'title' | 'markdown' | 'changeCount'+>;++/** One category of a release's changes, collapsed until asked for. */+export function ChangelogSection({+ title,+ markdown,+ changeCount,+}: ChangelogSectionProps) {+ const { t } = useTranslation();+ const [isOpen, setIsOpen] = useState(false);+ const listId = useId();+ const Chevron = isOpen ? SvgCheveronDown : SvgCheveronRight;++ return (+ <View>+ <Button+ variant="bare"+ aria-expanded={isOpen}+ aria-controls={isOpen ? listId : undefined}+ onPress={() => setIsOpen(!isOpen)}+ style={{+ alignSelf: 'flex-start',+ gap: 6,+ // Lines the chevron up with the card's text edge.+ marginLeft: -5,+ fontSize: 14,+ fontWeight: 500,+ }}+ >+ <Chevron width={12} height={12} aria-hidden />+ {t('{{title}} ({{changeCount}})', { title, changeCount })}+ </Button>+ {isOpen && (+ <View id={listId} style={{ paddingLeft: 18, paddingBottom: 8 }}>+ <NewsMarkdown style={changeListStyle}>{markdown}</NewsMarkdown>+ </View>+ )}+ </View>+ );+}diff --git a/packages/desktop-client/src/components/news/NewsEntryCard.tsx b/packages/desktop-client/src/components/news/NewsEntryCard.tsxindex 80be8609a7..3cb6eabfb7 100644--- a/packages/desktop-client/src/components/news/NewsEntryCard.tsx+++ b/packages/desktop-client/src/components/news/NewsEntryCard.tsx@@ -1,4 +1,3 @@-import { useState } from 'react';import { VisuallyHidden } from 'react-aria-components';import { Trans, useTranslation } from 'react-i18next';@@ -9,27 +8,22 @@ import { View } from '@actual-app/components/view';import * as monthUtils from '@actual-app/core/shared/months';import { Link } from '#components/common/Link';-import { Markdown } from '#components/common/Markdown';import { Setting } from '#components/settings/UI';import { useDateFormat } from '#hooks/useDateFormat';import { useLocale } from '#hooks/useLocale';-import { admonitionsToBlockquotes } from '#news/admonitions';+import { countChanges, splitChangelog } from '#news/changelog';import type { NewsEntry } from '#news/types';-import { MarkdownBlockquote } from './MarkdownBlockquote';+import { ChangelogSection } from './ChangelogSection';+import { NewsMarkdown } from './NewsMarkdown';-const markdownComponents = { blockquote: MarkdownBlockquote };--const markdownStyle = {- lineHeight: 1.5,- '& h2, & h3, & h4': { fontSize: 14, fontWeight: 600, margin: '20px 0 8px' },- '& p:not(:first-child)': { marginTop: '0.75rem' },- '& ul, & ol': { marginTop: '0.5rem' },- // The shared markdown style tints rules purple, which suits notes but reads- // as decoration here; match the body text instead.- '& hr': { borderBottomColor: theme.pageText },- '& img': { maxWidth: '100%' },-};+// The release tooling titles release posts "Release X.Y.Z". The pill beside+// the title already says "Release", so only the version is shown.+function getDisplayTitle(entry: NewsEntry): string {+ return entry.type === 'release'+ ? entry.title.replace(/^Release\s+/, '')+ : entry.title;+}type NewsEntryCardProps = {entry: NewsEntry;@@ -37,10 +31,9 @@ type NewsEntryCardProps = {};export function NewsEntryCard({ entry, isUnread }: NewsEntryCardProps) {- const { t } = useTranslation();const locale = useLocale();+ // The date format chosen in Settings, as used everywhere else in the app.const dateFormat = useDateFormat() || 'MM/dd/yyyy';- const [isShowingDetails, setIsShowingDetails] = useState(false);const isRelease = entry.type === 'release';return (@@ -72,9 +65,9 @@ export function NewsEntryCard({ entry, isUnread }: NewsEntryCardProps) {<Trans context="news">Post</Trans>)}</Text>- <Text style={{ fontWeight: 600, fontSize: 16, flex: 1 }}>- {entry.title}- </Text>+ <h2 style={{ margin: 0, fontSize: 18, fontWeight: 600, flex: 1 }}>+ {getDisplayTitle(entry)}+ </h2>{isUnread && (<><View@@ -91,46 +84,16 @@ export function NewsEntryCard({ entry, isUnread }: NewsEntryCardProps) {</VisuallyHidden></>)}- <Text style={{ fontSize: 12 }}>+ <time dateTime={entry.date} style={{ fontSize: 12 }}>{monthUtils.format(entry.date, dateFormat, locale)}- </Text>+ </time></View>- <Markdown- style={markdownStyle}- components={markdownComponents}- preserveBlankLines={false}- >- {admonitionsToBlockquotes(entry.body)}- </Markdown>+ <NewsMarkdown>{entry.body}</NewsMarkdown>- {entry.details && isShowingDetails && (- <Markdown- style={markdownStyle}- components={markdownComponents}- preserveBlankLines={false}- >- {admonitionsToBlockquotes(entry.details)}- </Markdown>- )}+ {entry.details && <AllChanges details={entry.details} />}- <View- style={{- flexDirection: 'row',- gap: 12,- alignItems: 'center',- fontSize: 13,- }}- >- {entry.details && (- <Link- variant="text"- onClick={() => setIsShowingDetails(!isShowingDetails)}- style={{ color: theme.pageTextPositive }}- >- {isShowingDetails ? t('Hide all changes') : t('Show all changes')}- </Link>- )}+ <Text style={{ fontSize: 13 }}><Link variant="external" to={entry.url} linkColor="purple">{isRelease ? (<Trans>View on actualbudget.org</Trans>@@ -138,7 +101,42 @@ export function NewsEntryCard({ entry, isUnread }: NewsEntryCardProps) {<Trans>Read the full post</Trans>)}</Link>- </View>+ </Text></Setting>);}++/** The full list of a release's changes, one collapsed section per category. */+function AllChanges({ details }: { details: string }) {+ const { t } = useTranslation();+ const { preamble, sections } = splitChangelog(details);++ return (+ <View+ style={{+ gap: 2,+ paddingTop: 12,+ borderTop: `1px solid ${theme.pillBorderDark}`,+ }}+ >+ <h3 style={{ margin: '0 0 4px', fontSize: 14, fontWeight: 600 }}>+ <Trans>All changes</Trans>+ </h3>+ {sections.length === 0 ? (+ // Older release notes aren't split into categories.+ <ChangelogSection+ title={t('Changes')}+ markdown={preamble}+ changeCount={countChanges(preamble)}+ />+ ) : (+ <>+ {preamble && <NewsMarkdown>{preamble}</NewsMarkdown>}+ {sections.map(section => (+ <ChangelogSection key={section.title} {...section} />+ ))}+ </>+ )}+ </View>+ );+}diff --git a/packages/desktop-client/src/components/news/NewsMarkdown.tsx b/packages/desktop-client/src/components/news/NewsMarkdown.tsxnew file mode 100644index 0000000000..16d77402c1--- /dev/null+++ b/packages/desktop-client/src/components/news/NewsMarkdown.tsx@@ -0,0 +1,52 @@+import type { CSSProperties } from '@actual-app/components/styles';+import { theme } from '@actual-app/components/theme';++import { Markdown } from '#components/common/Markdown';+import { admonitionsToBlockquotes } from '#news/admonitions';++import { MarkdownBlockquote } from './MarkdownBlockquote';++const markdownComponents = { blockquote: MarkdownBlockquote };++// Overrides to the shared markdown style, which is tuned for short notes.+// Notifications are long-form reading, so they need calmer, roomier text.+const newsMarkdownStyle = {+ fontSize: 14,+ lineHeight: 1.5,+ '& h2, & h3, & h4': { fontSize: 14, fontWeight: 600, margin: '20px 0 8px' },+ '& p:not(:first-child)': { marginTop: '0.75rem' },+ // Bullets hang outside the text so wrapped lines stay aligned.+ '& ul, & ol': {+ listStylePosition: 'outside',+ paddingLeft: '1.25em',+ marginTop: '0.5rem',+ },+ // The shared style tints rules and inline code purple, which suits notes but+ // reads as decoration here; keep both neutral.+ '& hr': { borderBottomColor: theme.pageText },+ '& code': {+ backgroundColor: theme.cardBackground,+ color: theme.pageText,+ fontFamily: 'monospace',+ padding: '0.1rem 0.3rem',+ },+ '& img': { maxWidth: '100%' },+};++type NewsMarkdownProps = {+ children: string;+ style?: CSSProperties;+};++/** Markdown as written for the docs site: blog posts and release notes. */+export function NewsMarkdown({ children, style }: NewsMarkdownProps) {+ return (+ <Markdown+ style={{ ...newsMarkdownStyle, ...style }}+ components={markdownComponents}+ preserveBlankLines={false}+ >+ {admonitionsToBlockquotes(children)}+ </Markdown>+ );+}diff --git a/packages/desktop-client/src/components/news/NotificationsButton.test.tsx b/packages/desktop-client/src/components/news/NotificationsButton.test.tsxindex 8577337447..bf5bfa40f2 100644--- a/packages/desktop-client/src/components/news/NotificationsButton.test.tsx+++ b/packages/desktop-client/src/components/news/NotificationsButton.test.tsx@@ -19,7 +19,8 @@ vi.mock('#hooks/useNewsFeed', () => ({lastSeenNewsDate: undefined,markAllSeen: vi.fn(),isLoading: false,- error: null,+ errorKind: undefined,+ retry: vi.fn(),}),}));diff --git a/packages/desktop-client/src/components/news/NotificationsButton.tsx b/packages/desktop-client/src/components/news/NotificationsButton.tsxindex e7a9fe2608..89506dfd06 100644--- a/packages/desktop-client/src/components/news/NotificationsButton.tsx+++ b/packages/desktop-client/src/components/news/NotificationsButton.tsx@@ -33,7 +33,7 @@ export function NotificationsButton() {: t('Notifications');const displayedCount =unseenCount > MAX_DISPLAYED_COUNT- ? `${MAX_DISPLAYED_COUNT}+`+ ? t('{{max}}+', { max: MAX_DISPLAYED_COUNT }): String(unseenCount);return (diff --git a/packages/desktop-client/src/components/news/NotificationsPage.test.tsx b/packages/desktop-client/src/components/news/NotificationsPage.test.tsxindex 4296a0dcde..35cece10de 100644--- a/packages/desktop-client/src/components/news/NotificationsPage.test.tsx+++ b/packages/desktop-client/src/components/news/NotificationsPage.test.tsx@@ -10,9 +10,10 @@ import type { NewsEntry } from '#news/types';import { NotificationsPage } from './NotificationsPage';const mockMarkAllSeen = vi.fn();+const mockRetry = vi.fn();let mockEntries: NewsEntry[] = [];let mockIsLoading = false;-let mockError: Error | null = null;+let mockErrorKind: 'unavailable' | 'unsupported' | undefined = undefined;let mockLastSeenNewsDate: string | undefined = undefined;vi.mock('#hooks/useNewsFeed', () => ({@@ -23,12 +24,13 @@ vi.mock('#hooks/useNewsFeed', () => ({lastSeenNewsDate: mockLastSeenNewsDate,markAllSeen: mockMarkAllSeen,isLoading: mockIsLoading,- error: mockError,+ errorKind: mockErrorKind,+ retry: mockRetry,}),}));vi.mock('#hooks/useDateFormat', () => ({- useDateFormat: () => 'yyyy-MM-dd',+ useDateFormat: () => 'dd.MM.yyyy',}));vi.mock('#hooks/useGlobalPref', () => ({@@ -70,7 +72,7 @@ describe('NotificationsPage', () => {vi.clearAllMocks();mockEntries = [];mockIsLoading = false;- mockError = null;+ mockErrorKind = undefined;mockLastSeenNewsDate = undefined;});@@ -79,9 +81,16 @@ describe('NotificationsPage', () => {mockLastSeenNewsDate = '2026-07-15';renderPage();- expect(screen.getByText('Release 26.8.1')).toBeInTheDocument();- expect(screen.getByText('Hello world')).toBeInTheDocument();- expect(screen.getByText('2026-08-07')).toBeInTheDocument();+ // The pill already says "Release", so the title is just the version.+ expect(screen.getByRole('heading', { name: '26.8.1' })).toBeInTheDocument();+ expect(+ screen.getByRole('heading', { name: 'Hello world' }),+ ).toBeInTheDocument();+ // Dates follow the format chosen in Settings.+ expect(screen.getByText('07.08.2026')).toHaveAttribute(+ 'datetime',+ '2026-08-07',+ );expect(screen.getByText('freezes')).toBeInTheDocument();expect(screen.getByRole('link', { name: 'View on actualbudget.org' }),@@ -101,10 +110,17 @@ describe('NotificationsPage', () => {screen.getByText('Plain quote.').closest('blockquote'),).not.toBeNull();- // Full changelog is collapsed until requested.- expect(screen.queryByText('Bugfixes')).not.toBeInTheDocument();- await userEvent.click(screen.getByText('Show all changes'));- expect(screen.getByText('Bugfixes')).toBeInTheDocument();+ // Each category of changes is collapsed, with its count, until requested.+ const bugfixes = screen.getByRole('button', { name: 'Bugfixes (1)' });+ expect(bugfixes).toHaveAttribute('aria-expanded', 'false');+ expect(+ screen.queryByRole('link', { name: '#8628' }),+ ).not.toBeInTheDocument();++ await userEvent.click(bugfixes);++ expect(bugfixes).toHaveAttribute('aria-expanded', 'true');+ expect(screen.getByRole('link', { name: '#8628' })).toBeInTheDocument();expect(mockMarkAllSeen).toHaveBeenCalled();});@@ -119,16 +135,20 @@ describe('NotificationsPage', () => {expect(mockMarkAllSeen).not.toHaveBeenCalled();});- it('shows a friendly offline message when the feed cannot be loaded', () => {- mockError = new Error('offline');+ it('shows a calm notice with a retry when the feed cannot be loaded', async () => {+ mockErrorKind = 'unavailable';renderPage();- expect(screen.getByTestId('notifications-offline')).toHaveTextContent(- "The latest news isn't available right now",- );- expect(screen.getByTestId('notifications-offline')).toHaveTextContent(- /usually means you're offline/,- );+ expect(+ screen.getByText("Notifications aren't available right now."),+ ).toBeInTheDocument();+ expect(+ screen.getByText(/usually means you're offline/),+ ).toBeInTheDocument();++ await userEvent.click(screen.getByRole('button', { name: 'Try again' }));+ expect(mockRetry).toHaveBeenCalled();+expect(screen.getByRole('link', { name: 'All release notes' }),).toHaveAttribute('href', 'https://actualbudget.org/docs/releases');@@ -137,6 +157,18 @@ describe('NotificationsPage', () => {).toHaveAttribute('href', 'https://discord.gg/pRYNYr4W5A');});+ it('asks the user to update when the feed format is not understood', () => {+ mockErrorKind = 'unsupported';+ renderPage();++ expect(+ screen.getByText('Update Actual to see the latest notifications.'),+ ).toBeInTheDocument();+ expect(+ screen.queryByRole('button', { name: 'Try again' }),+ ).not.toBeInTheDocument();+ });+it('shows an empty state when there are no entries', () => {renderPage();expect(screen.getByText('Nothing new to show yet.')).toBeInTheDocument();diff --git a/packages/desktop-client/src/components/news/NotificationsPage.tsx b/packages/desktop-client/src/components/news/NotificationsPage.tsxindex 425bb55c02..3cbe79e153 100644--- a/packages/desktop-client/src/components/news/NotificationsPage.tsx+++ b/packages/desktop-client/src/components/news/NotificationsPage.tsx@@ -1,6 +1,7 @@import { useEffect, useEffectEvent, useRef } from 'react';import { Trans, useTranslation } from 'react-i18next';+import { Button } from '@actual-app/components/button';import { AnimatedLoading } from '@actual-app/components/icons/AnimatedLoading';import { styles } from '@actual-app/components/styles';import { Text } from '@actual-app/components/text';@@ -22,8 +23,14 @@ const DISCORD_URL = 'https://discord.gg/pRYNYr4W5A';export function NotificationsPage() {const { t } = useTranslation();- const { entries, isLoading, error, lastSeenNewsDate, markAllSeen } =- useNewsFeed();+ const {+ entries,+ isLoading,+ errorKind,+ retry,+ lastSeenNewsDate,+ markAllSeen,+ } = useNewsFeed();// Everything is marked as seen once the page shows it, but the unread// markers should reflect what was new when the page opened, so remember the@@ -47,29 +54,11 @@ export function NotificationsPage() {marginTop: 10,flexShrink: 0,gap: 30,+ // Keeps lines of text to a comfortable reading length.maxWidth: 800,paddingBottom: MOBILE_NAV_HEIGHT,}}>- <View- style={{- flexDirection: 'row',- gap: 16,- flexWrap: 'wrap',- fontSize: 13,- }}- >- <Link variant="external" to={RELEASE_NOTES_URL} linkColor="purple">- <Trans>All release notes</Trans>- </Link>- <Link variant="external" to={BLOG_URL} linkColor="purple">- <Trans>Blog</Trans>- </Link>- <Link variant="external" to={DISCORD_URL} linkColor="purple">- <Trans>Community (Discord)</Trans>- </Link>- </View>-{isLoading && (<View style={{ alignItems: 'center', padding: 30 }}><AnimatedLoading@@ -84,20 +73,37 @@ export function NotificationsPage() {)}{/* The settings card is reused on purpose so this page matches Settings. */}- {error && (+ {errorKind === 'unavailable' && (+ <Setting+ primaryAction={+ <Button onPress={retry}>+ <Trans>Try again</Trans>+ </Button>+ }+ >+ <Text>+ <Trans>+ <strong>Notifications aren't available right now.</strong>{' '}+ Actual couldn't load them, which usually means you're offline.+ Everything else keeps working, and they'll load next time you're+ connected.+ </Trans>+ </Text>+ </Setting>+ )}++ {errorKind === 'unsupported' && (<Setting>- <Text data-testid="notifications-offline">+ <Text><Trans>- <strong>The latest news isn't available right now.</strong>{' '}- Actual couldn't reach actualbudget.org, which usually means- you're offline. That's fine - everything else in Actual keeps- working, and the news will load next time you're connected.+ <strong>Update Actual to see the latest notifications.</strong>{' '}+ This version can't read the newest notifications format.</Trans></Text></Setting>)}- {!isLoading && !error && entries.length === 0 && (+ {!isLoading && !errorKind && entries.length === 0 && (<Setting><Text><Trans>Nothing new to show yet.</Trans>@@ -112,6 +118,25 @@ export function NotificationsPage() {isUnread={unseenOnOpen.has(entry.id)}/>))}++ <View+ style={{+ flexDirection: 'row',+ gap: 16,+ flexWrap: 'wrap',+ fontSize: 13,+ }}+ >+ <Link variant="external" to={RELEASE_NOTES_URL} linkColor="purple">+ <Trans>All release notes</Trans>+ </Link>+ <Link variant="external" to={BLOG_URL} linkColor="purple">+ <Trans>Blog</Trans>+ </Link>+ <Link variant="external" to={DISCORD_URL} linkColor="purple">+ <Trans>Community (Discord)</Trans>+ </Link>+ </View></View></Page>);diff --git a/packages/desktop-client/src/hooks/useNewsFeed.test.ts b/packages/desktop-client/src/hooks/useNewsFeed.test.tsindex d043b10315..242e7cb4eb 100644--- a/packages/desktop-client/src/hooks/useNewsFeed.test.ts+++ b/packages/desktop-client/src/hooks/useNewsFeed.test.ts@@ -74,4 +74,48 @@ describe('useNewsFeed', () => {expect(result.current.entries).toEqual([]);expect(fetchMock).not.toHaveBeenCalled();});++ // The feed query retries once before reporting a failure.+ const afterRetry = { timeout: 5000 };++ it('reports an unavailable feed when it cannot be downloaded', async () => {+ fetchMock.mockRejectedValue(new TypeError('Failed to fetch'));++ const { result } = renderHook(() => useNewsFeed(), {+ wrapper: TestProviders,+ });++ await waitFor(+ () => expect(result.current.errorKind).toBe('unavailable'),+ afterRetry,+ );+ expect(result.current.entries).toEqual([]);++ fetchMock.mockResolvedValue({+ ok: true,+ status: 200,+ json: () => Promise.resolve(newsFeedFixture),+ });+ result.current.retry();++ await waitFor(() => expect(result.current.entries).toHaveLength(2));+ expect(result.current.errorKind).toBeUndefined();+ });++ it('reports an unsupported feed when the format is not understood', async () => {+ fetchMock.mockResolvedValue({+ ok: true,+ status: 200,+ json: () => Promise.resolve({ ...newsFeedFixture, schemaVersion: 2 }),+ });++ const { result } = renderHook(() => useNewsFeed(), {+ wrapper: TestProviders,+ });++ await waitFor(+ () => expect(result.current.errorKind).toBe('unsupported'),+ afterRetry,+ );+ });});diff --git a/packages/desktop-client/src/hooks/useNewsFeed.ts b/packages/desktop-client/src/hooks/useNewsFeed.tsindex d96661e33f..4b22f40599 100644--- a/packages/desktop-client/src/hooks/useNewsFeed.ts+++ b/packages/desktop-client/src/hooks/useNewsFeed.ts@@ -1,5 +1,6 @@import { useQuery } from '@tanstack/react-query';+import { UNSUPPORTED_NEWS_FEED_FORMAT } from '#news/fetchNewsFeed';import { newsQueries } from '#news/queries';import type { NewsEntry } from '#news/types';import { getNewestDate, getUnseenEntries } from '#news/utils';@@ -8,6 +9,21 @@ import { useGlobalPref } from './useGlobalPref';const EMPTY_ENTRIES: NewsEntry[] = [];+/**+ * Why the feed couldn't be shown: it couldn't be downloaded (usually offline),+ * or it is in a newer format than this version of the app understands.+ */+type NewsFeedErrorKind = 'unavailable' | 'unsupported';++function getErrorKind(error: Error | null): NewsFeedErrorKind | undefined {+ if (!error) {+ return undefined;+ }+ return error.message === UNSUPPORTED_NEWS_FEED_FORMAT+ ? 'unsupported'+ : 'unavailable';+}+export function useNewsFeed() {// The setting (on by default) lets the user opt out of the feed and of the// request it makes to GitHub.@@ -35,6 +51,7 @@ export function useNewsFeed() {lastSeenNewsDate,markAllSeen,isLoading: isEnabled && query.isPending,- error: query.error,+ errorKind: getErrorKind(query.error),+ retry: () => void query.refetch(),};}diff --git a/packages/desktop-client/src/news/changelog.test.ts b/packages/desktop-client/src/news/changelog.test.tsnew file mode 100644index 0000000000..e46c60682f--- /dev/null+++ b/packages/desktop-client/src/news/changelog.test.ts@@ -0,0 +1,60 @@+import { describe, expect, it } from 'vitest';++import { countChanges, splitChangelog } from './changelog';++describe('splitChangelog', () => {+ it('splits the details into categories and counts their changes', () => {+ const details = `#### Features++- [#1](https://example.com/1) Add a thing+- [#2](https://example.com/2) Add another thing+ that wraps onto a second line++#### Bugfixes++- [#3](https://example.com/3) Fix a thing`;++ expect(splitChangelog(details)).toEqual({+ preamble: '',+ sections: [+ {+ title: 'Features',+ markdown:+ '- [#1](https://example.com/1) Add a thing\n- [#2](https://example.com/2) Add another thing\n that wraps onto a second line',+ changeCount: 2,+ },+ {+ title: 'Bugfixes',+ markdown: '- [#3](https://example.com/3) Fix a thing',+ changeCount: 1,+ },+ ],+ });+ });++ it('keeps text written before the first category as a preamble', () => {+ const changelog = splitChangelog(+ 'A note about this release.\n\n#### Maintenance\n\n- Tidy up',+ );++ expect(changelog.preamble).toBe('A note about this release.');+ expect(changelog.sections.map(section => section.title)).toEqual([+ 'Maintenance',+ ]);+ });++ it('returns everything as the preamble when there are no categories', () => {+ expect(splitChangelog('- One\n- Two')).toEqual({+ preamble: '- One\n- Two',+ sections: [],+ });+ expect(splitChangelog('')).toEqual({ preamble: '', sections: [] });+ });+});++describe('countChanges', () => {+ it('counts top-level bullets only', () => {+ expect(countChanges('- One\n - nested\n* Two\n\nText')).toBe(2);+ expect(countChanges('No list here')).toBe(0);+ });+});diff --git a/packages/desktop-client/src/news/changelog.ts b/packages/desktop-client/src/news/changelog.tsnew file mode 100644index 0000000000..8bb18b5056--- /dev/null+++ b/packages/desktop-client/src/news/changelog.ts@@ -0,0 +1,41 @@+export type ChangelogSection = {+ /** Category heading from the release notes, e.g. `Bugfixes`. */+ title: string;+ markdown: string;+ changeCount: number;+};++export type Changelog = {+ /** Anything written before the first category heading. */+ preamble: string;+ sections: ChangelogSection[];+};++const CATEGORY_HEADING_PATTERN = /^#{2,4} +(.+)$/m;++/** Number of top-level bullets, i.e. individual changes, in a markdown list. */+export function countChanges(markdown: string): number {+ return markdown.match(/^[-*] /gm)?.length ?? 0;+}++/**+ * Splits a release's detailed change list into its categories. The release+ * tooling writes them as `#### Features`, `#### Bugfixes`, etc., each followed+ * by a bullet list.+ */+export function splitChangelog(details: string): Changelog {+ // With a capture group, `split` alternates: preamble, title, body, title…+ const [preamble = '', ...parts] = details.split(CATEGORY_HEADING_PATTERN);+ const sections: ChangelogSection[] = [];++ for (let index = 0; index < parts.length; index += 2) {+ const markdown = (parts[index + 1] ?? '').trim();+ sections.push({+ title: parts[index].trim(),+ markdown,+ changeCount: countChanges(markdown),+ });+ }++ return { preamble: preamble.trim(), sections };+}diff --git a/packages/desktop-client/src/news/fetchNewsFeed.test.ts b/packages/desktop-client/src/news/fetchNewsFeed.test.tsindex a46092929e..ca9da16bc3 100644--- a/packages/desktop-client/src/news/fetchNewsFeed.test.ts+++ b/packages/desktop-client/src/news/fetchNewsFeed.test.ts@@ -1,7 +1,11 @@import type * as PlatformModule from '@actual-app/core/shared/platform';import { afterEach, describe, expect, it, vi } from 'vitest';-import { fetchNewsFeed, getNewsFeedUrl } from './fetchNewsFeed';+import {+ fetchNewsFeed,+ getNewsFeedUrl,+ UNSUPPORTED_NEWS_FEED_FORMAT,+} from './fetchNewsFeed';import { newsFeedFixture } from './fixtures';vi.mock('../data/news.json?url', () => ({ default: '/assets/news.json' }));@@ -64,24 +68,18 @@ describe('fetchNewsFeed', () => {it('rejects feeds with malformed entries', async () => {stubResponse({ schemaVersion: 1, entries: [null] });- await expect(fetchNewsFeed()).rejects.toThrow(- 'Unsupported news feed format',- );+ await expect(fetchNewsFeed()).rejects.toThrow(UNSUPPORTED_NEWS_FEED_FORMAT);stubResponse({...newsFeedFixture,entries: [{ ...newsFeedFixture.entries[0], type: 'other' }],});- await expect(fetchNewsFeed()).rejects.toThrow(- 'Unsupported news feed format',- );+ await expect(fetchNewsFeed()).rejects.toThrow(UNSUPPORTED_NEWS_FEED_FORMAT);});it('rejects other schema versions and HTTP errors', async () => {stubResponse({ ...newsFeedFixture, schemaVersion: 2 });- await expect(fetchNewsFeed()).rejects.toThrow(- 'Unsupported news feed format',- );+ await expect(fetchNewsFeed()).rejects.toThrow(UNSUPPORTED_NEWS_FEED_FORMAT);stubResponse(newsFeedFixture, false);await expect(fetchNewsFeed()).rejects.toThrow('HTTP 500');diff --git a/packages/desktop-client/src/news/fetchNewsFeed.ts b/packages/desktop-client/src/news/fetchNewsFeed.tsindex fdab01c17a..e9f6fdadb9 100644--- a/packages/desktop-client/src/news/fetchNewsFeed.ts+++ b/packages/desktop-client/src/news/fetchNewsFeed.ts@@ -6,6 +6,12 @@ import type { NewsEntry, NewsFeed } from './types';// Released builds read the file committed on `master`, the same way the custom// theme catalog is fetched (hooks/useThemeCatalog.ts).+/**+ * Message of the error thrown when the feed loaded but isn't in a format this+ * version understands, so callers can tell it apart from a failed download.+ */+export const UNSUPPORTED_NEWS_FEED_FORMAT = 'Unsupported news feed format';+const REPO_NEWS_FEED_URL ='https://raw.githubusercontent.com/actualbudget/actual/master/packages/desktop-client/src/data/news.json';@@ -78,7 +84,7 @@ export async function fetchNewsFeed(): Promise<NewsFeed> {const json: unknown = await response.json();if (!isNewsFeed(json)) {- throw new Error('Unsupported news feed format');+ throw new Error(UNSUPPORTED_NEWS_FEED_FORMAT);}return json;}diff --git a/packages/docs/docs/notifications.md b/packages/docs/docs/notifications.mdindex 48a793c395..7236c70bb9 100644--- a/packages/docs/docs/notifications.md+++ b/packages/docs/docs/notifications.md@@ -12,10 +12,12 @@ The bell sits in the top bar, next to the Help menu. When there are notificationEach notification is shown as a card:-- **Release** cards summarize what changed in a version of Actual. The card shows the highlights, and you can click **Show all changes** to expand the full list of changes in that release. A link on the card takes you to the same release announcement on the website.+- **Release** cards summarize what changed in a version of Actual. The card shows the highlights, followed by **All changes**: the full list of changes grouped into Features, Enhancements, Bugfixes, and Maintenance. Click a group to expand it. A link on the card takes you to the same release announcement on the website.- **Post** cards are announcements from the team, such as community news or project updates, with a link to the full post on the blog.-At the top of the page you will also find links to the full [release notes](./releases.md), the blog, and the community Discord.+At the bottom of the page you will also find links to the full [release notes](./releases.md), the blog, and the community Discord.++If Actual cannot load the notifications, for example because you are offline, the page tells you so and offers a **Try again** button. Everything else in Actual keeps working.## Release Messagesdiff --git a/upcoming-release-notes/notifications-page-readability.md b/upcoming-release-notes/notifications-page-readability.mdnew file mode 100644index 0000000000..5fa0c860a7--- /dev/null+++ b/upcoming-release-notes/notifications-page-readability.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [MikesGlitch]+---++Make the Notifications page easier to read, with collapsible lists of changes that work from the keyboard