From 3b3a517e7dd18b1494fce0bfe059665a09c4490d Mon Sep 17 00:00:00 2001 From: Chris Arderne Date: Mon, 6 Jul 2026 16:40:55 +0100 Subject: [PATCH 1/2] feat: auto-update dev and preview branch selector --- .../env-selector-dropdown-auto-revalidate.md | 6 ++++++ .../components/navigation/EnvironmentSelector.tsx | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 .server-changes/env-selector-dropdown-auto-revalidate.md diff --git a/.server-changes/env-selector-dropdown-auto-revalidate.md b/.server-changes/env-selector-dropdown-auto-revalidate.md new file mode 100644 index 0000000000..3210d8a149 --- /dev/null +++ b/.server-changes/env-selector-dropdown-auto-revalidate.md @@ -0,0 +1,6 @@ +--- +area: webapp +type: improvement +--- + +The environment and branch selector dropdown will automatically revalidate (poll) while it's open so that new branches show up. diff --git a/apps/webapp/app/components/navigation/EnvironmentSelector.tsx b/apps/webapp/app/components/navigation/EnvironmentSelector.tsx index 58c3aae5a0..30aac11a80 100644 --- a/apps/webapp/app/components/navigation/EnvironmentSelector.tsx +++ b/apps/webapp/app/components/navigation/EnvironmentSelector.tsx @@ -5,6 +5,7 @@ import { DropdownIcon } from "~/assets/icons/DropdownIcon"; import { useNavigation } from "@remix-run/react"; import { useEffect, useRef, useState } from "react"; import { BranchEnvironmentIconSmall } from "~/assets/icons/EnvironmentIcons"; +import { useAutoRevalidate } from "~/hooks/useAutoRevalidate"; import { useEnvironment } from "~/hooks/useEnvironment"; import { useEnvironmentSwitcher } from "~/hooks/useEnvironmentSwitcher"; import { useFeatures } from "~/hooks/useFeatures"; @@ -53,10 +54,21 @@ export function EnvironmentSelector({ const navigation = useNavigation(); const { urlForEnvironment } = useEnvironmentSwitcher(); + // Keep branch list fresh, only fires while the menu is open + const revalidator = useAutoRevalidate({ interval: 5000, disabled: !isMenuOpen }); + useEffect(() => { setIsMenuOpen(false); }, [navigation.location?.pathname]); + // Fetch immediately on open so the list is fresh right away + useEffect(() => { + if (isMenuOpen && revalidator.state !== "loading") { + revalidator.revalidate(); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isMenuOpen]); + const hasStaging = project.environments.some((env) => env.type === "STAGING"); return ( setIsMenuOpen(open)} open={isMenuOpen}> From 36911e4bfd4ce4fc7fc32dda8202782450e576e3 Mon Sep 17 00:00:00 2001 From: Chris Arderne Date: Mon, 6 Jul 2026 22:32:44 +0100 Subject: [PATCH 2/2] remove polling --- .../app/components/navigation/EnvironmentSelector.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/webapp/app/components/navigation/EnvironmentSelector.tsx b/apps/webapp/app/components/navigation/EnvironmentSelector.tsx index 30aac11a80..862ea02dea 100644 --- a/apps/webapp/app/components/navigation/EnvironmentSelector.tsx +++ b/apps/webapp/app/components/navigation/EnvironmentSelector.tsx @@ -2,10 +2,9 @@ import { ChevronRightIcon, Cog8ToothIcon } from "@heroicons/react/20/solid"; import { DEFAULT_DEV_BRANCH } from "@trigger.dev/core/v3/utils/gitBranch"; import { isBranchableEnvironment } from "~/utils/branchableEnvironment"; import { DropdownIcon } from "~/assets/icons/DropdownIcon"; -import { useNavigation } from "@remix-run/react"; +import { useNavigation, useRevalidator } from "@remix-run/react"; import { useEffect, useRef, useState } from "react"; import { BranchEnvironmentIconSmall } from "~/assets/icons/EnvironmentIcons"; -import { useAutoRevalidate } from "~/hooks/useAutoRevalidate"; import { useEnvironment } from "~/hooks/useEnvironment"; import { useEnvironmentSwitcher } from "~/hooks/useEnvironmentSwitcher"; import { useFeatures } from "~/hooks/useFeatures"; @@ -53,9 +52,7 @@ export function EnvironmentSelector({ const [isMenuOpen, setIsMenuOpen] = useState(false); const navigation = useNavigation(); const { urlForEnvironment } = useEnvironmentSwitcher(); - - // Keep branch list fresh, only fires while the menu is open - const revalidator = useAutoRevalidate({ interval: 5000, disabled: !isMenuOpen }); + const revalidator = useRevalidator(); useEffect(() => { setIsMenuOpen(false);