:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(desktop): keep the update banner reachable without the sidebar (#98895)
Charles Vien3ba9b9e2eb87
diff --git a/products/desktop/apps/code/src/renderer/platform-adapters/updates.ts b/products/desktop/apps/code/src/renderer/platform-adapters/updates.tsindex 295f3a08a9d7..594fa1fd4bdb 100644--- a/products/desktop/apps/code/src/renderer/platform-adapters/updates.ts+++ b/products/desktop/apps/code/src/renderer/platform-adapters/updates.ts@@ -7,6 +7,7 @@ import {} from "@posthog/core/updates/updateStore";import { resolveService } from "@posthog/di/container";import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";+import { useUpdateModalStore } from "@posthog/ui/features/updates/updateModalStore";import {UPDATES_CLIENT,type UpdatesClient,@@ -88,6 +89,9 @@ client.onStatus({if (outcome.toast) {showToast(outcome.toast);}+ if (outcome.openUpdateModal) {+ useUpdateModalStore.getState().open();+ }}},onError: (error) => {diff --git a/products/desktop/docs/UPDATES.md b/products/desktop/docs/UPDATES.mdindex 89ca1ed3f402..535fac680808 100644--- a/products/desktop/docs/UPDATES.md+++ b/products/desktop/docs/UPDATES.md@@ -27,6 +27,14 @@ GitHub Releases in `PostHog/posthog` remain the human-facing changelog and downlRemote announcements can drive this flow: a `required-update` announcement blocks apps below a version and reuses the updater; where the updater is unavailable it degrades to a manual download link. See [ANNOUNCEMENTS.md](./ANNOUNCEMENTS.md).+## In-app update surfaces++- The sidebar footer shows the update banner while the sidebar is on screen. It covers the available, downloading, ready and installing states.+- The title bar shows a compact chip for the same states while the sidebar is collapsed, peeked away or absent, so only one copy is on screen at a time.+- Both surfaces open the update modal, which shows the release notes and holds the Download and Restart actions. The sidebar card also has its own Restart button for a staged update.+- "Check for Updates..." in the app menu runs a check. It shows a toast when the app is up to date or the check fails, and opens the update modal when the check finds an available, downloading or staged update.+- The modal is mounted in the app shell above the router, so it also opens from the sign-in, access and consent screens.+## How it works1. A base tag like `desktop-v0.15` marks the start of a minor version.diff --git a/products/desktop/packages/core/src/updates/updateStore.test.ts b/products/desktop/packages/core/src/updates/updateStore.test.tsindex 2f7d20eb9acf..d61290c6e5f1 100644--- a/products/desktop/packages/core/src/updates/updateStore.test.ts+++ b/products/desktop/packages/core/src/updates/updateStore.test.ts@@ -147,6 +147,17 @@ describe("resolveMenuCheckFromStatus", () => {it("keeps pending while still checking", () => {expect(resolveMenuCheckFromStatus({ checking: true }, true)).toBeNull();});++ it.each([+ ["available", { checking: false, available: true }],+ ["downloading", { checking: true, downloading: true }],+ ["staged", { checking: false, updateReady: true }],+ ])("opens the update modal on an %s result", (_label, payload) => {+ expect(resolveMenuCheckFromStatus(payload, true)).toEqual({+ clearPending: true,+ openUpdateModal: true,+ });+ });});describe("resolveMenuCheckResult", () => {diff --git a/products/desktop/packages/core/src/updates/updateStore.ts b/products/desktop/packages/core/src/updates/updateStore.tsindex b9f9620e8f03..67219a6cdca9 100644--- a/products/desktop/packages/core/src/updates/updateStore.ts+++ b/products/desktop/packages/core/src/updates/updateStore.ts@@ -147,6 +147,7 @@ export interface MenuCheckToast {export interface MenuCheckOutcome {toast?: MenuCheckToast;clearPending: boolean;+ openUpdateModal?: boolean;}export function resolveMenuCheckFromStatus(@@ -175,6 +176,10 @@ export function resolveMenuCheckFromStatus(};}+ if (payload.available || payload.downloading || payload.updateReady) {+ return { clearPending: true, openUpdateModal: true };+ }+if (payload.checking === false) {return { clearPending: true };}diff --git a/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.stories.tsx b/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.stories.tsxnew file mode 100644index 000000000000..a98b7ded13fe--- /dev/null+++ b/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.stories.tsx@@ -0,0 +1,74 @@+import {+ type UpdateUiStatus,+ updateStore,+} from "@posthog/core/updates/updateStore";+import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";+import { UpdateBanner } from "@posthog/ui/features/sidebar/components/UpdateBanner";+import type { Decorator, Meta, StoryObj } from "@storybook/react-vite";+import { useEffect } from "react";++function withUpdateState(status: UpdateUiStatus): Decorator {+ return function WithUpdateState(Story) {+ useEffect(() => {+ const previousUpdate = updateStore.getState();+ const previousDismissible =+ useSettingsStore.getState().dismissibleUpdateBanners;+ useSettingsStore.setState({ dismissibleUpdateBanners: false });+ updateStore.setState({+ status,+ isEnabled: true,+ version: status === "available" ? null : "0.24.1",+ availableVersion: "0.24.1",+ downloadPercent: 42,+ downloadSizeBytes: 180 * 1024 * 1024,+ });+ return () => {+ updateStore.setState(previousUpdate);+ useSettingsStore.setState({+ dismissibleUpdateBanners: previousDismissible,+ });+ };+ }, [status]);+ return <Story />;+ };+}++const meta = {+ title: "Sidebar/UpdateBanner",+ component: UpdateBanner,+} satisfies Meta<typeof UpdateBanner>;++export default meta;++type Story = StoryObj<typeof meta>;++export const InSidebar: Story = {+ decorators: [withUpdateState("ready")],+ render: (args) => (+ <div className="flex h-[320px] w-[280px] flex-col justify-end bg-chrome">+ <UpdateBanner {...args} />+ </div>+ ),+};++export const InTitleBar: Story = {+ args: { variant: "compact" },+ decorators: [withUpdateState("ready")],+ render: (args) => (+ <div className="flex h-[38px] w-[720px] items-center bg-chrome px-3">+ <span className="text-[13px] text-muted-foreground">Tabs</span>+ <div className="ml-auto flex items-center pr-2">+ <UpdateBanner {...args} />+ </div>+ </div>+ ),+};++export const Downloading: Story = {+ decorators: [withUpdateState("downloading")],+ render: (args) => (+ <div className="flex w-[280px] flex-col bg-chrome">+ <UpdateBanner {...args} />+ </div>+ ),+};diff --git a/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.test.tsx b/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.test.tsxindex ec0fd47eeaae..621c88a671f9 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.test.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.test.tsx@@ -49,7 +49,7 @@ function renderBanner(variant?: "sidebar" | "compact") {const VARIANTS = [{ variant: "sidebar", readyText: "1.2.3 ready" },- { variant: "compact", readyText: "1.2.3 ready — Restart" },+ { variant: "compact", readyText: "1.2.3 ready" },] as const;function dismissButton() {diff --git a/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.tsx b/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.tsxindex e495c53f457d..6226a5d7f501 100644--- a/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.tsx+++ b/products/desktop/packages/ui/src/features/sidebar/components/UpdateBanner.tsx@@ -1,42 +1,62 @@import { ArrowsClockwise, Gift, X } from "@phosphor-icons/react";+import { updateStore } from "@posthog/core/updates/updateStore";import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";import { useUpdateBannerStore } from "@posthog/ui/features/updates/updateBannerStore";import { useUpdateModalStore } from "@posthog/ui/features/updates/updateModalStore";import {+ useHasActiveUpdate,useInstallUpdate,useUpdateView,} from "@posthog/ui/features/updates/updateStore";import { Spin, Spinner } from "@posthog/ui/primitives/Spinner";import { Box } from "@radix-ui/themes";import { AnimatePresence, motion } from "framer-motion";+import { useStore } from "zustand";interface UpdateBannerProps {variant?: "sidebar" | "compact";}+function dismissKeyFor(+ version: string | null,+ availableVersion: string | null,+): string {+ return version ?? availableVersion ?? "unknown";+}++// Primitive selectors only, so download progress does not re-render the app shell.+export function useUpdateBannerVisible(): boolean {+ const hasActiveUpdate = useHasActiveUpdate();+ const isEnabled = useStore(updateStore, (state) => state.isEnabled);+ const dismissKey = useStore(updateStore, (state) =>+ dismissKeyFor(state.version, state.availableVersion),+ );+ const canDismiss = useSettingsStore(+ (state) => state.dismissibleUpdateBanners,+ );+ const dismissedVersion = useUpdateBannerStore(+ (state) => state.dismissedVersion,+ );++ return (+ isEnabled &&+ hasActiveUpdate &&+ !(canDismiss && dismissedVersion === dismissKey)+ );+}+export function UpdateBanner({ variant = "sidebar" }: UpdateBannerProps) {- const { status, version, availableVersion, downloadPercent, isEnabled } =+ const { status, version, availableVersion, downloadPercent } =useUpdateView();const installUpdate = useInstallUpdate();const openModal = useUpdateModalStore((state) => state.open);const canDismiss = useSettingsStore((state) => state.dismissibleUpdateBanners,);- const dismissedVersion = useUpdateBannerStore(- (state) => state.dismissedVersion,- );const dismissBanner = useUpdateBannerStore((state) => state.dismiss);- const dismissKey = version ?? availableVersion ?? "unknown";- const isDismissed = canDismiss && dismissedVersion === dismissKey;-- const isVisible =- isEnabled &&- !isDismissed &&- (status === "available" ||- status === "downloading" ||- status === "ready" ||- status === "installing");+ const dismissKey = dismissKeyFor(version, availableVersion);+ const isVisible = useUpdateBannerVisible();const percent = Math.round(downloadPercent ?? 0);@@ -82,12 +102,10 @@ export function UpdateBanner({ variant = "sidebar" }: UpdateBannerProps) {<buttontype="button"className="flex items-center gap-1.5 rounded-2 border border-(--green-a5) bg-(--green-a3) px-2.5 py-1 font-medium text-(--green-11) text-[13px] transition-colors hover:bg-(--green-a4)"- onClick={() => void installUpdate()}+ onClick={openModal}><Gift size={14} weight="duotone" />- <span>- {version ? `${version} ready` : "Update ready"} — Restart- </span>+ <span>{version ? `${version} ready` : "Update ready"}</span></button>{canDismiss && (<DismissButton onClick={() => dismissBanner(dismissKey)} />diff --git a/products/desktop/packages/ui/src/router/routes/__root.tsx b/products/desktop/packages/ui/src/router/routes/__root.tsxindex 6928a81e5770..df4457e05deb 100644--- a/products/desktop/packages/ui/src/router/routes/__root.tsx+++ b/products/desktop/packages/ui/src/router/routes/__root.tsx@@ -48,6 +48,10 @@ import { useIntegrations } from "@posthog/ui/features/integrations/useIntegratioimport { useLoopDeepLink } from "@posthog/ui/features/loops/hooks/useLoopDeepLink";import { useScoutDeepLink } from "@posthog/ui/features/scouts/hooks/useScoutDeepLink";import { useSetupDiscovery } from "@posthog/ui/features/setup/useSetupDiscovery";+import {+ UpdateBanner,+ useUpdateBannerVisible,+} from "@posthog/ui/features/sidebar/components/UpdateBanner";import { NAV_RAIL_WIDTH } from "@posthog/ui/features/sidebar/constants";import {beginSidebarPeek,@@ -61,7 +65,6 @@ import { ExistingWorktreeDialog } from "@posthog/ui/features/task-detail/componeimport { RemoteBranchCheckoutDialog } from "@posthog/ui/features/task-detail/components/RemoteBranchCheckoutDialog";import { useTasks } from "@posthog/ui/features/tasks/useTasks";import { TourOverlay } from "@posthog/ui/features/tour/components/TourOverlay";-import { UpdateAvailableModal } from "@posthog/ui/features/updates/UpdateAvailableModal";import { WhatsNewModal } from "@posthog/ui/features/updates/WhatsNewModal";import { useWorkspaces } from "@posthog/ui/features/workspace/useWorkspace";import { AnimatedLogo } from "@posthog/ui/primitives/AnimatedLogo";@@ -219,6 +222,9 @@ function RootLayout() {const toggleSidebar = useSidebarStore((s) => s.toggle);const sidebarPeek = useSidebarPeekStore((s) => s.peek);+ const updateBannerVisible = useUpdateBannerVisible();+ const showTitleBarUpdate =+ updateBannerVisible && !sidebarDocked && !sidebarPeek;// Toggling makes any hover-peek redundant (opening replaces the overlay;// closing must not leave it lingering under the pointer).const handleToggleSidebar = (): void => {@@ -348,7 +354,7 @@ function RootLayout() {aria-label="Toggle sidebar"onClick={handleToggleSidebar}onMouseEnter={() => {- if (!sidebarOpen) beginSidebarPeek();+ if (!sidebarOpen && hasSidebar) beginSidebarPeek();}}>{sidebarOpen ? (@@ -386,6 +392,11 @@ function RootLayout() {also the only global owner of Cmd+W, so the fallback has to holdthat key wherever the strip isn't mounted. */}<BrowserTabStrip />+ {showTitleBarUpdate && (+ <div className="no-drag ml-auto flex items-center pr-2">+ <UpdateBanner variant="compact" />+ </div>+ )}{/* Gated so an empty right-side group can't claim a no-drag rectin the title bar for nothing — every pixel without controlsshould drag the window. */}@@ -493,7 +504,6 @@ function RootLayout() {<TourOverlay />{billingEnabled && <UsageLimitModal />}<AnnouncementsHost />- <UpdateAvailableModal /><WhatsNewModal /><RemoteBranchCheckoutDialog /><FeedbackModaldiff --git a/products/desktop/packages/ui/src/shell/App.tsx b/products/desktop/packages/ui/src/shell/App.tsxindex 8d86c3047b5e..e5a62cf22bf9 100644--- a/products/desktop/packages/ui/src/shell/App.tsx+++ b/products/desktop/packages/ui/src/shell/App.tsx@@ -28,6 +28,7 @@ import { useOnboardingStore } from "@posthog/ui/features/onboarding/onboardingStimport { SettingsDialog } from "@posthog/ui/features/settings/SettingsDialog";import { UpdateBanner } from "@posthog/ui/features/sidebar/components/UpdateBanner";import { PendingPromptRecovery } from "@posthog/ui/features/task-detail/components/PendingPromptRecovery";+import { UpdateAvailableModal } from "@posthog/ui/features/updates/UpdateAvailableModal";import { router } from "@posthog/ui/router/router";import { AppLoadingScreen } from "@posthog/ui/shell/AppLoadingScreen";import {@@ -336,6 +337,7 @@ function App({ devToolbar }: AppProps) {<ScopeReauthPrompt /><AddDirectoryDialog /><ErrorDetailsDialog />+ <UpdateAvailableModal /></div>{devToolbar}</div>