From 6f705afd7aa00b205d1d03f2d1ff85e539a7848d Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Mon, 23 Nov 2026 10:51:53 +0000 Subject: [PATCH 1/3] Add a one-time What's new dialog to the home page Shown once per browser after cookie consent, to new users too: on shared school machines the change is new to the teacher even when the browser is not. Holds back the editor's welcome video for the rest of that page load so a new user doesn't get two dialogs in a row. --- lang/ui.en.json | 28 ++++++ src/e2e/app.ts | 4 +- src/e2e/home.test.ts | 18 +++- src/pages/HomePage.tsx | 3 + src/pages/WhatsNewDialog.tsx | 143 +++++++++++++++++++++++++++++ src/workbench/PreReleaseNotice.tsx | 2 + 6 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 src/pages/WhatsNewDialog.tsx diff --git a/lang/ui.en.json b/lang/ui.en.json index 018809bb0..8dbbba0ec 100644 --- a/lang/ui.en.json +++ b/lang/ui.en.json @@ -375,6 +375,10 @@ "defaultMessage": "Font size", "description": "Font size option text" }, + "get-started-action": { + "defaultMessage": "Get started", + "description": "Button that closes the what's new dialog on the home page" + }, "guide-link": { "defaultMessage": "For more support, see the Python Editor guide", "description": "Text with an external link to support/help content" @@ -1490,6 +1494,30 @@ "defaultMessage": "video introducing the Python Editor", "description": "iframe title for the welcome video" }, + "whats-new-copy": { + "defaultMessage": "Saving a HEX file to your computer is the most reliable way to keep a copy of your project.", + "description": "Body of the keep a copy point in the what's new dialog shown on the home page" + }, + "whats-new-copy-heading": { + "defaultMessage": "Keep a copy", + "description": "Heading of the point in the what's new dialog advising users to save a HEX file" + }, + "whats-new-home": { + "defaultMessage": "Your projects, ideas and help, all in one place.", + "description": "Body of the home page point in the what's new dialog shown on the home page" + }, + "whats-new-home-heading": { + "defaultMessage": "A new Home page", + "description": "Heading of the point in the what's new dialog introducing the home page" + }, + "whats-new-projects": { + "defaultMessage": "Your projects now stay in this browser between visits. Select \"{viewAll}\" to find, rename and delete them.", + "description": "Body of the My projects point in the what's new dialog. {viewAll} is the link label on the home page's My projects row (\"View all\")" + }, + "whats-new-title": { + "defaultMessage": "What's new in the Python Editor", + "description": "Title of the dialog shown once on the home page explaining the home page and saved projects" + }, "zoom-in-action": { "defaultMessage": "Zoom in", "description": "Text label for zoom in button" diff --git a/src/e2e/app.ts b/src/e2e/app.ts index 866d76b57..2b979df1e 100644 --- a/src/e2e/app.ts +++ b/src/e2e/app.ts @@ -36,6 +36,8 @@ export interface UrlOptions { language?: string; /** Iframe controller mode, as embedded by classroom. */ controller?: boolean; + /** Show the dialogs that greet a browser on its first visit. */ + welcome?: boolean; } interface SaveOptions { @@ -848,7 +850,7 @@ export const appUrlPattern = (path: string = ""): RegExp => { export const appUrl = (path: string, options: UrlOptions = {}): string => { const flags = new Set([ "none", - "noWelcome", + ...(options.welcome ? [] : ["noWelcome"]), ...(options.flags ?? []), ]); const params: Array<[string, string]> = Array.from(flags).map((f) => [ diff --git a/src/e2e/home.test.ts b/src/e2e/home.test.ts index 744a6d4f1..20a102ac2 100644 --- a/src/e2e/home.test.ts +++ b/src/e2e/home.test.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ import { expect } from "@playwright/test"; -import { appUrlPattern } from "./app.js"; +import { appUrlPattern, homeUrl } from "./app.js"; import { test } from "./app-test-fixtures.js"; import { modalDialog } from "./home-page.js"; @@ -32,6 +32,22 @@ test.describe("home page", () => { await homePage.expectNoNewAccessibilityViolations(); }); + test("shows what's new once", async ({ homePage }) => { + // Not homePage.goto(): the dialog repeats the heading it waits for. + await homePage.page.goto(homeUrl({ welcome: true })); + const dialog = modalDialog(homePage.page); + await expect( + dialog.getByRole("heading", { name: "What's new in the Python Editor" }) + ).toBeVisible(); + await homePage.expectNoNewAccessibilityViolations(); + await dialog.getByRole("button", { name: "Get started" }).click(); + await expect(dialog).toBeHidden(); + + await homePage.page.reload(); + await homePage.expectOnPage(); + await expect(dialog).toBeHidden(); + }); + test("creates a project and opens it in the editor", async ({ app, homePage, diff --git a/src/pages/HomePage.tsx b/src/pages/HomePage.tsx index 9ebc55e1e..7c28e6216 100644 --- a/src/pages/HomePage.tsx +++ b/src/pages/HomePage.tsx @@ -34,6 +34,7 @@ import ActionCard from "./ActionCard"; import DefaultPageLayout from "./DefaultPageLayout"; import IdeaDialog from "./IdeaDialog"; import ProjectIcon from "./ProjectIcon"; +import WhatsNewDialog, { useWhatsNewDialog } from "./WhatsNewDialog"; import HomepageBanner from "./HomepageBanner"; import HomepageFooter from "./HomepageFooter"; import { @@ -73,8 +74,10 @@ const HomePage = () => { ); useReportCreateProjectFailure(); useReportOpenFailure(); + const [whatsNewOpen, closeWhatsNew] = useWhatsNewDialog(); return ( + {selectedIdea && ( + typeof v === "object" && Number.isInteger((v as any).version); + +let shownThisPageLoad = false; + +/** + * Lets the editor hold back its welcome video so a new user is not given + * two dialogs in their first few minutes. + */ +export const wasWhatsNewShownThisPageLoad = (): boolean => shownThisPageLoad; + +/** + * Shown once per browser after cookie consent, to new users as well as + * returning ones: on shared school machines the change is new to the teacher + * even when the browser is not. + * + * Only the home page uses this, and it is only reachable with the projects + * database, so iframe mode and the session storage fallback never see it. + */ +export const useWhatsNewDialog = (): [boolean, () => void] => { + const [stored, setStored] = useStorage( + "local", + "whats-new", + { version: 0 }, + isWhatsNewStorage + ); + const [isOpen, setIsOpen] = useState(false); + const cookieConsent = useCookieConsent(); + useEffect(() => { + if (cookieConsent && !flags.noWelcome && stored.version < currentVersion) { + setIsOpen(true); + setStored({ version: currentVersion }); + shownThisPageLoad = true; + } + }, [cookieConsent, stored, setStored]); + return [isOpen, () => setIsOpen(false)]; +}; + +interface WhatsNewDialogProps { + isOpen: boolean; + onClose: () => void; +} + +const WhatsNewDialog = ({ isOpen, onClose }: WhatsNewDialogProps) => { + const intl = useIntl(); + return ( + + + + + + + + } + > + + + } + > + + + } + > + + + + + + + + + ); +}; + +const Point = ({ + icon, + heading, + children, +}: { + icon: IconType; + heading: ReactNode; + children: ReactNode; +}) => ( + + + + + {heading} + + {children} + + +); + +export default WhatsNewDialog; diff --git a/src/workbench/PreReleaseNotice.tsx b/src/workbench/PreReleaseNotice.tsx index cd5b830a9..539b49fa6 100644 --- a/src/workbench/PreReleaseNotice.tsx +++ b/src/workbench/PreReleaseNotice.tsx @@ -10,6 +10,7 @@ import { HStack, styled } from "styled-system/jsx"; import { useStorage } from "../common/use-storage"; import { useCookieConsent } from "../deployment"; import { flags } from "../flags"; +import { wasWhatsNewShownThisPageLoad } from "../pages/WhatsNewDialog"; export type ReleaseNoticeState = "info" | "feedback" | "closed"; @@ -46,6 +47,7 @@ export const useReleaseDialogState = (): [ if ( cookieConsent && !flags.noWelcome && + !wasWhatsNewShownThisPageLoad() && storedNotice.version < currentVersion ) { setReleaseDialog("info"); From e27acac59357607b36c564aaa787d6571ddf3c3c Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Mon, 23 Nov 2026 10:54:22 +0000 Subject: [PATCH 2/3] Show the welcome video after What's new as before A new user may see both: What's new on Home, then the video on first opening the editor. --- src/pages/WhatsNewDialog.tsx | 9 --------- src/workbench/PreReleaseNotice.tsx | 2 -- 2 files changed, 11 deletions(-) diff --git a/src/pages/WhatsNewDialog.tsx b/src/pages/WhatsNewDialog.tsx index e49abd4a6..09743e781 100644 --- a/src/pages/WhatsNewDialog.tsx +++ b/src/pages/WhatsNewDialog.tsx @@ -32,14 +32,6 @@ interface WhatsNewStorage { const isWhatsNewStorage = (v: unknown): v is WhatsNewStorage => typeof v === "object" && Number.isInteger((v as any).version); -let shownThisPageLoad = false; - -/** - * Lets the editor hold back its welcome video so a new user is not given - * two dialogs in their first few minutes. - */ -export const wasWhatsNewShownThisPageLoad = (): boolean => shownThisPageLoad; - /** * Shown once per browser after cookie consent, to new users as well as * returning ones: on shared school machines the change is new to the teacher @@ -61,7 +53,6 @@ export const useWhatsNewDialog = (): [boolean, () => void] => { if (cookieConsent && !flags.noWelcome && stored.version < currentVersion) { setIsOpen(true); setStored({ version: currentVersion }); - shownThisPageLoad = true; } }, [cookieConsent, stored, setStored]); return [isOpen, () => setIsOpen(false)]; diff --git a/src/workbench/PreReleaseNotice.tsx b/src/workbench/PreReleaseNotice.tsx index 539b49fa6..cd5b830a9 100644 --- a/src/workbench/PreReleaseNotice.tsx +++ b/src/workbench/PreReleaseNotice.tsx @@ -10,7 +10,6 @@ import { HStack, styled } from "styled-system/jsx"; import { useStorage } from "../common/use-storage"; import { useCookieConsent } from "../deployment"; import { flags } from "../flags"; -import { wasWhatsNewShownThisPageLoad } from "../pages/WhatsNewDialog"; export type ReleaseNoticeState = "info" | "feedback" | "closed"; @@ -47,7 +46,6 @@ export const useReleaseDialogState = (): [ if ( cookieConsent && !flags.noWelcome && - !wasWhatsNewShownThisPageLoad() && storedNotice.version < currentVersion ) { setReleaseDialog("info"); From 17e6c51342a7511aeb213ab9cdc2dd3bcfb153cb Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Mon, 23 Nov 2026 11:10:02 +0000 Subject: [PATCH 3/3] Use the breadcrumb's home icon in What's new --- src/pages/WhatsNewDialog.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/WhatsNewDialog.tsx b/src/pages/WhatsNewDialog.tsx index 09743e781..43a69e038 100644 --- a/src/pages/WhatsNewDialog.tsx +++ b/src/pages/WhatsNewDialog.tsx @@ -15,7 +15,7 @@ import { } from "@microbit/ui"; import { ReactNode, useEffect, useState } from "react"; import { IconType } from "react-icons"; -import { RiDownload2Line, RiFolderOpenLine, RiHome4Line } from "react-icons/ri"; +import { RiDownload2Line, RiFolderOpenLine, RiHome2Line } from "react-icons/ri"; import { FormattedMessage, useIntl } from "react-intl"; import { HStack, Stack } from "styled-system/jsx"; import { useStorage } from "../common/use-storage"; @@ -74,7 +74,7 @@ const WhatsNewDialog = ({ isOpen, onClose }: WhatsNewDialogProps) => { } >