Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions apps/web/src/components/WhatsNewDialog.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("What's new", () => {
await resetTestPage();
});

it("lists a nightly's changes since the build you had, then the earlier nightlies", async () => {
it("groups a nightly's changes by type across builds and keeps earlier nightlies closed until opened", async () => {
window.desktopBridge = {
getPreviousAppVersion: () => "0.8.0-nightly.20261028.352",
} as unknown as DesktopBridge;
Expand All @@ -96,16 +96,23 @@ describe("What's new", () => {
await expect
.element(list)
.toMatchTextContent(/3 changes since build 352, the one you had before/);
await expect.element(list).toMatchTextContent(/FixedA computer on 0\.7\.1 keeps working/);
await expect.element(list).toMatchTextContent(/NewRename computers from the Fleet list/);
// New, then Security, then Fixed across builds 354 and 353 combined.
await expect
.element(list)
.toMatchTextContent(/SecurityBump hono for the serveStatic path bypass/);
.toMatchTextContent(
/New1Rename computers from the Fleet listSecurity1Bump hono for the serveStatic path bypassFixed1A computer on 0\.7\.1 keeps working/,
);
await expect.element(list).not.toMatchTextContent(/Fleet video/);
// The menu's newest stable release before this nightly is 0.7.1.
// Earlier builds start closed and open on click.
const earlier = page.getByTestId("whats-new-nightly-earlier");
await expect.element(earlier).toMatchTextContent(/Earlier builds since v0\.7\.1/);
await expect.element(earlier).toMatchTextContent(/Build 352.*FixedOlder/);
const earlierTrigger = earlier.getByRole("button", { name: /Earlier builds since v0\.7\.1/ });
await expect.element(earlierTrigger).toHaveAttribute("aria-expanded", "false");
await expect.element(earlierTrigger).toMatchTextContent(/Newest build · 1 change/);
await expect.element(earlier.getByText("Build 352")).not.toBeInTheDocument();

await earlierTrigger.click();
await expect.element(earlierTrigger).toHaveAttribute("aria-expanded", "true");
await expect.element(earlier).toMatchTextContent(/Build 352.*Fixed1Older/);
expect(fetchSpy).toHaveBeenCalledTimes(1);
});

Expand Down
139 changes: 95 additions & 44 deletions apps/web/src/components/WhatsNewDialogContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
RELEASE_NOTES_SITE_URL,
type ReleaseNotesEntry,
} from "@threadlines/shared/releaseNotes";
import { PlayIcon } from "lucide-react";
import { ChevronRightIcon, PlayIcon } from "lucide-react";
import { useState } from "react";
import releaseNotes from "virtual:release-notes";

Expand All @@ -21,14 +21,18 @@ import { openExternalUrl } from "../lib/externalLinks";
import { readPreviousAppVersion, useNightlyBuilds } from "../lib/whatsNew";
import {
describeBuild,
describeEarlierBuildsSummary,
describeNightlyLead,
groupNightlyChanges,
type NightlyBuildChanges,
type NightlyChangeGroup,
planNightlyList,
releaseChangeTag,
releaseNotesUpTo,
splitNightlyBuilds,
} from "../lib/whatsNew.logic";
import { Button } from "./ui/button";
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "./ui/collapsible";
import { DialogFooter, DialogHeader, DialogPanel, DialogPopup, DialogTitle } from "./ui/dialog";
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select";
import { closeWhatsNewDialog } from "./WhatsNewDialog";
Expand Down Expand Up @@ -198,8 +202,9 @@ function ReleaseVideo({ video }: { readonly video: NonNullable<ReleaseNotesEntry
}

/**
* A nightly's list: the builds since the one this device ran before, then the
* earlier nightlies back to the last stable release, read from GitHub.
* A nightly's list: the changes since the build this device ran before,
* grouped by type across builds, then the earlier nightlies back to the last
* stable release (closed until opened), read from GitHub.
*/
function NightlyChangesView({ lastStableVersion }: { readonly lastStableVersion: string | null }) {
const { since, range } = planNightlyList({
Expand All @@ -223,67 +228,113 @@ function NightlyChangesView({ lastStableVersion }: { readonly lastStableVersion:
const { fresh, earlier } = splitNightlyBuilds(builds, since, APP_VERSION);
// Any earlier build means the list reached back past the one you had.
const freshComplete = complete || since === null || earlier.length > 0;
const freshGroups = groupNightlyChanges(fresh);
const earlierWithChanges = earlier.filter((build) => build.changes.length > 0);

return (
<div className="grid gap-3" data-testid="whats-new-nightly">
<div className="grid gap-4" data-testid="whats-new-nightly">
<p className="text-[13px] text-muted-foreground">
{describeNightlyLead({ fresh, since, freshComplete, appVersion: APP_VERSION })}
</p>
{fresh
.filter((build) => build.changes.length > 0)
.map((build) => (
<NightlyBuildSection key={build.version} build={build} />
))}
{freshGroups.length > 0 ? <NightlyChangeGroups groups={freshGroups} /> : null}
{earlierWithChanges.length > 0 ? (
<section className="grid gap-3 border-t pt-3" data-testid="whats-new-nightly-earlier">
<h3 className="font-semibold text-muted-foreground text-xs">
{range.after === null
? "Earlier builds"
: `Earlier builds since ${describeBuild(range.after)}`}
</h3>
{earlierWithChanges.map((build) => (
<NightlyBuildSection key={build.version} build={build} />
))}
</section>
) : null}
{!complete && freshComplete ? (
<Collapsible className="border-t pt-2.5" data-testid="whats-new-nightly-earlier">
<CollapsibleTrigger className="group -mx-2 flex w-[calc(100%+1rem)] select-none items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-ring">
<ChevronRightIcon
aria-hidden="true"
className="size-3.5 shrink-0 transition-transform duration-150 group-data-[panel-open]:rotate-90"
/>
<span className="min-w-0 flex-1">
{range.after === null
? "Earlier builds"
: `Earlier builds since ${describeBuild(range.after)}`}
</span>
<span className="shrink-0 font-mono text-[11px] font-normal text-muted-foreground tabular-nums">
{describeEarlierBuildsSummary(earlierWithChanges, complete)}
</span>
</CollapsibleTrigger>
<CollapsiblePanel>
<div className="grid gap-4 pt-3">
{earlierWithChanges.map((build) => (
<NightlyBuildSection key={build.version} build={build} />
))}
{!complete && freshComplete ? (
<p className="text-muted-foreground text-xs">Older builds are on GitHub.</p>
) : null}
</div>
</CollapsiblePanel>
</Collapsible>
) : !complete && freshComplete ? (
<p className="text-muted-foreground text-xs">Older builds are on GitHub.</p>
) : null}
</div>
);
}

function changeKindHeadingClass(kind: NightlyChangeGroup["kind"]): string {
switch (kind) {
case "new":
return "text-primary-readable";
case "security":
return "text-warning-foreground";
default:
return "text-foreground";
}
}

function NightlyChangeGroups({
groups,
compact = false,
}: {
readonly groups: ReadonlyArray<NightlyChangeGroup>;
readonly compact?: boolean;
}) {
const Heading = compact ? "h5" : "h3";
return (
<div className={compact ? "grid gap-2.5" : "grid gap-3.5"}>
{groups.map((group) => (
<section
key={group.kind}
className="grid gap-1.5"
data-testid={compact ? undefined : `whats-new-group-${group.kind}`}
>
<Heading
className={
compact
? "flex items-baseline gap-1.5 font-semibold text-xs"
: "flex items-baseline gap-1.5 font-semibold text-[13px]"
}
>
<span className={changeKindHeadingClass(group.kind)}>
{releaseChangeTag(group.kind)}
</span>
<span className="font-mono text-[11px] font-normal text-muted-foreground tabular-nums">
{group.items.length}
</span>
</Heading>
<ul className="grid list-disc gap-1 ps-4 text-[13px] leading-[19px] marker:text-muted-foreground">
{group.items.map(({ build, change }, index) => (
<li key={`${build}:${change.pullRequest ?? ""}:${index}:${change.text}`}>
{change.text}
</li>
))}
</ul>
</section>
))}
</div>
);
}

function NightlyBuildSection({ build }: { readonly build: NightlyBuildChanges }) {
const day = build.publishedAt?.slice(0, 10);
const groups = groupNightlyChanges([build]);
return (
<section className="grid gap-1">
<section className="grid gap-2">
<h4 className="font-mono text-[11px] text-muted-foreground">
Build {build.build}
{day ? ` · ${formatReleaseDay(day)}` : ""}
</h4>
<ul className="grid gap-1">
{build.changes.map((change) => {
const tag = releaseChangeTag(change.kind);
return (
<li
key={`${change.pullRequest ?? ""}:${change.text}`}
className="flex items-baseline gap-2 text-[13px]"
>
<span
className={
tag === "New"
? "w-13 shrink-0 rounded-[4px] bg-primary-readable/14 text-center font-mono text-[10.5px] text-primary-readable leading-4"
: "w-13 shrink-0 rounded-[4px] bg-foreground/8 text-center font-mono text-[10.5px] text-muted-foreground leading-4"
}
>
{tag}
</span>
<span className="min-w-0">{change.text}</span>
</li>
);
})}
</ul>
<NightlyChangeGroups groups={groups} compact />
</section>
);
}
65 changes: 65 additions & 0 deletions apps/web/src/lib/whatsNew.logic.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { describe, expect, it } from "vite-plus/test";

import {
describeEarlierBuildsSummary,
describeNightlyLead,
describeNightlyUpdate,
describeWaitingUpdate,
groupNightlyChanges,
type NightlyBuildChanges,
nightlyReleasesPageSize,
planNightlyList,
Expand Down Expand Up @@ -153,4 +155,67 @@ describe("a nightly's list", () => {
);
expect(notice([build(357, [])])).toBeNull();
});

it("groups nightly changes across builds by type in display order and summarizes earlier builds", () => {
const builds: ReadonlyArray<NightlyBuildChanges> = [
{
version: "0.8.1-nightly.20261030.358",
build: 358,
publishedAt: null,
url: "",
changes: [
{ kind: "fixed", text: "Newest fix" },
{ kind: "changed", text: "Fallback change" },
{ kind: "new", text: "Newest feature" },
],
},
{
version: "0.8.1-nightly.20261029.357",
build: 357,
publishedAt: null,
url: "",
changes: [
{ kind: "security", text: "Patch advisory" },
{ kind: "fixed", text: "Older fix" },
{ kind: "faster", text: "Cut redraw cost" },
{ kind: "new", text: "Older feature" },
],
},
];

expect(
groupNightlyChanges(builds).map((group) => ({
kind: group.kind,
items: group.items.map((item) => [item.build, item.change.text]),
})),
).toEqual([
{
kind: "new",
items: [
[358, "Newest feature"],
[357, "Older feature"],
],
},
{ kind: "faster", items: [[357, "Cut redraw cost"]] },
{ kind: "security", items: [[357, "Patch advisory"]] },
{
kind: "fixed",
items: [
[358, "Newest fix"],
[357, "Older fix"],
],
},
{ kind: "changed", items: [[358, "Fallback change"]] },
]);

expect(groupNightlyChanges([build(357, ["Only fix"])]).map((group) => group.kind)).toEqual([
"fixed",
]);
expect(describeEarlierBuildsSummary(builds)).toBe("2 builds · 7 changes");
expect(describeEarlierBuildsSummary([build(357, ["Only fix"])])).toBe("1 build · 1 change");
expect(describeEarlierBuildsSummary(builds, false)).toBe("Newest 2 builds · 7 changes");
expect(describeEarlierBuildsSummary([build(357, ["Only fix"])], false)).toBe(
"Newest build · 1 change",
);
});
});
63 changes: 62 additions & 1 deletion apps/web/src/lib/whatsNew.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,68 @@ export function describeWaitingUpdate(input: {
return nightly.complete ? `${changes} since yours` : `${changes} in the newest builds`;
}

/** The tag a change wears in the nightly list. */
/** The order type groups show in the nightly list: shorter sections above Fixed. */
export const NIGHTLY_CHANGE_KIND_ORDER: ReadonlyArray<ReleaseChange["kind"]> = [
"new",
"faster",
"security",
"fixed",
"changed",
];

/** One change in a type-grouped nightly list, keeping the build it landed in. */
export interface NightlyGroupedChange {
readonly build: number;
readonly change: ReleaseChange;
}

/** Changes of one kind across one or more nightly builds, in build order. */
export interface NightlyChangeGroup {
readonly kind: ReleaseChange["kind"];
readonly items: ReadonlyArray<NightlyGroupedChange>;
}

/**
* Groups changes across nightly builds by kind in display order, omitting
* empty kinds. Preserves the order of builds (newest first) and changes
* within each build.
*/
export function groupNightlyChanges(
builds: ReadonlyArray<NightlyBuildChanges>,
): ReadonlyArray<NightlyChangeGroup> {
const byKind = new Map<ReleaseChange["kind"], Array<NightlyGroupedChange>>();
for (const build of builds) {
for (const change of build.changes) {
let bucket = byKind.get(change.kind);
if (!bucket) {
bucket = [];
byKind.set(change.kind, bucket);
}
bucket.push({ build: build.build, change });
}
}
return NIGHTLY_CHANGE_KIND_ORDER.flatMap((kind) => {
const items = byKind.get(kind);
return items && items.length > 0 ? [{ kind, items }] : [];
});
}

/** Short summary shown on the collapsed earlier-builds row. */
export function describeEarlierBuildsSummary(
builds: ReadonlyArray<NightlyBuildChanges>,
complete = true,
): string {
const buildLabel = complete
? builds.length === 1
? "1 build"
: `${builds.length} builds`
: builds.length === 1
? "Newest build"
: `Newest ${builds.length} builds`;
return `${buildLabel} · ${changeCount(countChanges(builds))}`;
}

/** The heading a change kind wears in the nightly list. */
export function releaseChangeTag(kind: ReleaseChange["kind"]): string {
switch (kind) {
case "new":
Expand Down
Loading