Skip to content

Commit 1788c27

Browse files
feat(whatsnew): sober redesign with per-commit type icons
Reworks the "What's new" dialog per the chosen direction: drop the decorative sparkles icon (the "too AI" look) for a sober release-notes layout, and derive a real per-item icon from each commit's conventional type (feat → check, fix → wrench, perf → bolt, docs → book, else a neutral dot). The API now returns STRUCTURED entries instead of a markdown blob: each commit is parsed into { type, title, body }, with the type(scope): prefix stripped and the title capitalised. Commit bodies are verbose, so they are tucked behind a per-item "Details" toggle and stay collapsed by default — keeping the list clean and faithful to the real (long, unstructured) commit text. - API: getChangelog/getRecentChangelog return ChangelogEntry[]; the route serves `entries` + version + count. - Web: rewritten WhatsNew with type-icon rows and collapsible details. - Tests/i18n updated for the structured shape.
1 parent 0b9c4d3 commit 1788c27

5 files changed

Lines changed: 119 additions & 44 deletions

File tree

‎apps/api/src/routes/version.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const versionRoutes: FastifyPluginAsync = async (app) => {
4545
await prisma.user.update({ where: { id: req.user!.id }, data: { lastSeenVersion: local.sha } });
4646
return { show: false };
4747
}
48-
return { show: true, version: local.shortSha, notes: log.markdown, count: log.count };
48+
return { show: true, version: local.shortSha, entries: log.entries, count: log.count };
4949
});
5050

5151
// POST /version/whats-new/seen — dismiss the dialog for the current build.

‎apps/api/src/services/version.ts‎

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,36 @@ function cleanBody(body: string): string {
9797
.trim();
9898
}
9999

100+
/** One commit, parsed for the "What's new" UI. `type` is the conventional-commit type
101+
* (feat/fix/docs/…), or null for a free-form subject; `title` is the description with the
102+
* `type(scope):` prefix stripped and capitalised; `body` is the cleaned, long-form detail. */
103+
export interface ChangelogEntry {
104+
type: string | null;
105+
title: string;
106+
body: string;
107+
}
108+
100109
export interface Changelog {
101-
/** Markdown ready to render in the "What's new" dialog. */
102-
markdown: string;
103-
/** Number of commits summarised (after capping). */
110+
entries: ChangelogEntry[];
111+
/** Total commits in the range (may exceed entries.length, which is capped). */
104112
count: number;
105113
}
106114

107-
// Beyond this many commits the notes get unwieldy; we summarise the newest and note the rest.
115+
// Beyond this many commits the dialog gets unwieldy; we list the newest and report the rest.
108116
const MAX_CHANGELOG_COMMITS = 40;
109117

118+
/** Split a commit subject into its conventional-commit type and a clean, capitalised title. */
119+
function parseSubject(subject: string): { type: string | null; title: string } {
120+
const m = subject.match(/^([a-zA-Z]+)(?:\([^)]*\))?(?:!)?:\s*(.+)$/);
121+
const raw = m ? m[2]!.trim() : subject.trim();
122+
const title = raw.charAt(0).toUpperCase() + raw.slice(1);
123+
return { type: m ? m[1]!.toLowerCase() : null, title };
124+
}
125+
110126
/**
111-
* Build human-readable release notes for the commits in `from..to` (newest first), as Markdown.
112-
* Returns null when there is nothing to show or git can't produce a range (e.g. a force-push made
113-
* `from` unreachable — the caller falls back to the most recent commits instead).
127+
* Build structured release notes for the commits in `from..to` (newest first). Returns null when
128+
* there is nothing to show or git can't produce a range (e.g. a force-push made `from` unreachable
129+
* — the caller falls back to the most recent commits instead).
114130
*/
115131
export async function getChangelog(from: string, to: string): Promise<Changelog | null> {
116132
if (!repoRoot || from === to) return null;
@@ -126,7 +142,7 @@ export async function getChangelog(from: string, to: string): Promise<Changelog
126142
return renderChangelog(stdout);
127143
}
128144

129-
/** The most recent `n` commits as Markdown — a fallback when the range can't be computed. */
145+
/** The most recent `n` commits — a fallback when the range can't be computed. */
130146
export async function getRecentChangelog(n: number): Promise<Changelog | null> {
131147
if (!repoRoot) return null;
132148
try {
@@ -149,12 +165,11 @@ function renderChangelog(raw: string): Changelog | null {
149165
.filter((c) => c.subject);
150166
if (commits.length === 0) return null;
151167

152-
const shown = commits.slice(0, MAX_CHANGELOG_COMMITS);
153-
const blocks = shown.map((c) => (c.body ? `### ${c.subject}\n\n${c.body}` : `### ${c.subject}`));
154-
if (commits.length > shown.length) {
155-
blocks.push(`_…and ${commits.length - shown.length} more change(s)._`);
156-
}
157-
return { markdown: blocks.join('\n\n'), count: commits.length };
168+
const entries: ChangelogEntry[] = commits.slice(0, MAX_CHANGELOG_COMMITS).map((c) => {
169+
const { type, title } = parseSubject(c.subject);
170+
return { type, title, body: c.body };
171+
});
172+
return { entries, count: commits.length };
158173
}
159174

160175
export interface HistoryCommit {

‎apps/api/test/integration.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,10 @@ runIf('API integration', () => {
861861
await prisma.user.update({ where: { id: user.id }, data: { lastSeenVersion: 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' } });
862862
const shown = await app.inject({ method: 'GET', url: '/version/whats-new', headers: { cookie: auth.cookie } });
863863
expect(shown.json().show).toBe(true);
864-
expect(typeof shown.json().notes).toBe('string');
865-
expect(shown.json().notes.length).toBeGreaterThan(0);
864+
expect(Array.isArray(shown.json().entries)).toBe(true);
865+
expect(shown.json().entries.length).toBeGreaterThan(0);
866+
// Entries are structured (a title at minimum), not a raw markdown blob.
867+
expect(typeof shown.json().entries[0].title).toBe('string');
866868

867869
// Dismissing records the current build, so it never shows again for this version.
868870
const seen = await app.inject({ method: 'POST', url: '/version/whats-new/seen', headers: authHeaders(auth) });

‎apps/web/src/components/WhatsNew.tsx‎

Lines changed: 79 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,78 @@
11
'use client';
22

33
/**
4-
* "What's new" dialog, shown once per update to every signed-in user. After a build is deployed,
5-
* the API serves the release notes for everything that changed since the build the user last
6-
* acknowledged; dismissing it records the current build so it never reappears for that version.
4+
* "What's new" dialog, shown once per update to every signed-in user. The API serves the changes
5+
* since the build the user last acknowledged, parsed from the commit messages into structured
6+
* entries; dismissing it records the current build so it never reappears for that version.
77
*
8-
* The notes are Markdown built from the commit messages, rendered with the same pipeline as the
9-
* in-app document viewer.
8+
* Design: sober "release notes" — no decorative icon. Each entry shows an icon derived from the
9+
* commit's conventional-commit type (feat/fix/…), a clean title, and its long-form body tucked
10+
* behind a "Details" toggle (commit bodies are verbose, so they stay collapsed by default).
1011
*/
1112
import { useEffect, useState } from 'react';
1213
import { createPortal } from 'react-dom';
1314
import Markdown from 'react-markdown';
1415
import remarkGfm from 'remark-gfm';
15-
import { Sparkles, X } from 'lucide-react';
16+
import { Check, Wrench, Zap, BookOpen, ChevronDown, X, type LucideIcon } from 'lucide-react';
1617
import { api } from '@/lib/api';
1718
import { useAuth } from '@/lib/auth';
1819
import { useT } from '@/lib/i18n';
1920

21+
interface ChangelogEntry {
22+
type: string | null;
23+
title: string;
24+
body: string;
25+
}
2026
interface WhatsNew {
2127
show: boolean;
2228
version?: string;
23-
notes?: string;
29+
entries?: ChangelogEntry[];
2430
count?: number;
2531
}
2632

33+
// Map a conventional-commit type to a small, meaningful icon + tint. Anything unrecognised gets a
34+
// neutral dot, so the list stays calm rather than noisy.
35+
const TYPE_STYLE: Record<string, { icon: LucideIcon; cls: string }> = {
36+
feat: { icon: Check, cls: 'bg-violet-500/15 text-violet-300' },
37+
fix: { icon: Wrench, cls: 'bg-amber-500/15 text-amber-300' },
38+
perf: { icon: Zap, cls: 'bg-sky-500/15 text-sky-300' },
39+
docs: { icon: BookOpen, cls: 'bg-white/[0.06] text-zinc-300' },
40+
};
41+
42+
function EntryRow({ e }: { e: ChangelogEntry }) {
43+
const { t } = useT();
44+
const [open, setOpen] = useState(false);
45+
const style = e.type ? TYPE_STYLE[e.type] : undefined;
46+
const Icon = style?.icon;
47+
48+
return (
49+
<li className="flex gap-3">
50+
<span className={`mt-0.5 grid h-6 w-6 shrink-0 place-items-center rounded-md ${style?.cls ?? 'text-zinc-600'}`}>
51+
{Icon ? <Icon size={14} /> : <span className="h-1.5 w-1.5 rounded-full bg-zinc-600" />}
52+
</span>
53+
<div className="min-w-0 flex-1">
54+
<div className="flex items-start justify-between gap-2">
55+
<p className="text-[13.5px] leading-snug text-zinc-100">{e.title}</p>
56+
{e.body && (
57+
<button
58+
onClick={() => setOpen((o) => !o)}
59+
className="mt-0.5 flex shrink-0 items-center gap-0.5 text-[11px] text-zinc-500 transition hover:text-zinc-300"
60+
>
61+
{t('whatsnew.details')}
62+
<ChevronDown size={12} className={`transition ${open ? 'rotate-180' : ''}`} />
63+
</button>
64+
)}
65+
</div>
66+
{open && e.body && (
67+
<div className="md-prose mt-2 border-l border-white/10 pl-3 text-xs text-zinc-400">
68+
<Markdown remarkPlugins={[remarkGfm]}>{e.body}</Markdown>
69+
</div>
70+
)}
71+
</div>
72+
</li>
73+
);
74+
}
75+
2776
export function WhatsNew() {
2877
const { user } = useAuth();
2978
const { t } = useT();
@@ -51,40 +100,43 @@ export function WhatsNew() {
51100
}
52101

53102
if (!data?.show || typeof document === 'undefined') return null;
103+
const entries = data.entries ?? [];
104+
const extra = (data.count ?? entries.length) - entries.length;
54105

55106
return createPortal(
56107
<div className="fixed inset-0 z-[120] flex items-center justify-center p-4">
57108
<div className="absolute inset-0 bg-black/60 backdrop-blur-sm" onClick={dismiss} />
58-
<div className="relative flex max-h-[85vh] w-full max-w-lg flex-col overflow-hidden rounded-2xl border border-white/10 bg-[#15151d] shadow-2xl">
59-
<div className="flex items-start justify-between gap-3 border-b border-white/[0.07] px-5 py-4">
60-
<div className="flex items-center gap-3">
61-
<span className="grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-gradient-to-br from-violet-500/30 to-fuchsia-500/20 text-violet-200">
62-
<Sparkles size={20} />
63-
</span>
64-
<div>
65-
<h2 className="font-semibold text-white">{t('whatsnew.title')}</h2>
66-
{data.version && (
67-
<p className="text-xs text-zinc-500">
68-
{t('whatsnew.version', { version: data.version })}
69-
{typeof data.count === 'number' && data.count > 0 && ` · ${t('whatsnew.changes', { count: data.count })}`}
70-
</p>
71-
)}
72-
</div>
109+
<div className="relative flex max-h-[85vh] w-full max-w-md flex-col overflow-hidden rounded-2xl border border-white/10 bg-[#15151d] shadow-2xl">
110+
<div className="flex items-start justify-between gap-3 px-6 pt-5">
111+
<div>
112+
<p className="text-[11px] font-semibold uppercase tracking-[0.16em] text-violet-300/90">{t('whatsnew.label')}</p>
113+
<h2 className="mt-1.5 text-xl font-semibold tracking-tight text-white">{t('whatsnew.title')}</h2>
114+
{data.version && (
115+
<p className="mt-1 font-mono text-xs text-zinc-500">
116+
{t('whatsnew.version', { version: data.version })}
117+
{typeof data.count === 'number' && data.count > 0 && ` · ${t('whatsnew.changes', { count: data.count })}`}
118+
</p>
119+
)}
73120
</div>
74121
<button
75122
onClick={dismiss}
76123
aria-label={t('whatsnew.dismiss')}
77-
className="rounded-lg p-1.5 text-zinc-400 transition hover:bg-white/5 hover:text-zinc-100"
124+
className="-mr-1 rounded-lg p-1.5 text-zinc-500 transition hover:bg-white/5 hover:text-zinc-200"
78125
>
79126
<X size={18} />
80127
</button>
81128
</div>
82129

83-
<div className="md-prose overflow-y-auto px-5 py-4 text-sm">
84-
<Markdown remarkPlugins={[remarkGfm]}>{data.notes ?? ''}</Markdown>
85-
</div>
130+
<div className="mx-6 mt-4 border-t border-white/[0.07]" />
131+
132+
<ul className="space-y-3.5 overflow-y-auto px-6 py-4">
133+
{entries.map((e, i) => (
134+
<EntryRow key={i} e={e} />
135+
))}
136+
{extra > 0 && <li className="pl-9 text-xs italic text-zinc-500">{t('whatsnew.more', { count: extra })}</li>}
137+
</ul>
86138

87-
<div className="border-t border-white/[0.07] px-5 py-3 text-right">
139+
<div className="border-t border-white/[0.07] px-6 py-3.5 text-right">
88140
<button className="btn-primary" onClick={dismiss}>
89141
{t('whatsnew.gotIt')}
90142
</button>

‎apps/web/src/lib/i18n.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,12 @@ const fr: Dict = {
546546
'role.admin': 'Administrateur',
547547
'role.user': 'Utilisateur',
548548
// what's new
549+
'whatsnew.label': 'Nouveautés',
549550
'whatsnew.title': 'Quoi de neuf',
550551
'whatsnew.version': 'Version {version}',
551552
'whatsnew.changes': '{count} changement(s)',
553+
'whatsnew.details': 'Détails',
554+
'whatsnew.more': '+{count} autres changements',
552555
'whatsnew.gotIt': 'J’ai compris',
553556
'whatsnew.dismiss': 'Fermer',
554557
// shared spaces
@@ -1141,9 +1144,12 @@ const en: Dict = {
11411144
'role.admin': 'Administrator',
11421145
'role.user': 'User',
11431146
// what's new
1147+
'whatsnew.label': 'Update',
11441148
'whatsnew.title': 'What’s new',
11451149
'whatsnew.version': 'Version {version}',
11461150
'whatsnew.changes': '{count} change(s)',
1151+
'whatsnew.details': 'Details',
1152+
'whatsnew.more': '+{count} more changes',
11471153
'whatsnew.gotIt': 'Got it',
11481154
'whatsnew.dismiss': 'Close',
11491155
// shared spaces

0 commit comments

Comments
 (0)