diff --git a/packages/app/src/__tests__/DBSearchPage.directTrace.test.tsx b/packages/app/src/__tests__/DBSearchPage.directTrace.test.tsx
index a6fe0278b6..fdee8e270e 100644
--- a/packages/app/src/__tests__/DBSearchPage.directTrace.test.tsx
+++ b/packages/app/src/__tests__/DBSearchPage.directTrace.test.tsx
@@ -132,6 +132,7 @@ jest.mock('@/hooks/useExplainQuery', () => ({
jest.mock('@/theme/ThemeProvider', () => ({
useAppTheme: () => ({ themeName: 'hyperdx' }),
useBrandDisplayName: () => 'HyperDX',
+ usePageTitle: (page?: string) => (page ? `${page} - HyperDX` : 'HyperDX'),
}));
jest.mock('../hooks/useMetadata', () => ({
diff --git a/packages/app/src/__tests__/config.instanceLabel.emoji.test.ts b/packages/app/src/__tests__/config.instanceLabel.emoji.test.ts
new file mode 100644
index 0000000000..7131f979b4
--- /dev/null
+++ b/packages/app/src/__tests__/config.instanceLabel.emoji.test.ts
@@ -0,0 +1,12 @@
+jest.mock('next-runtime-env', () => ({
+ env: (key: string) =>
+ key === 'NEXT_PUBLIC_INSTANCE_LABEL' ? ' prod-U😀 ' : undefined,
+}));
+
+import { INSTANCE_LABEL } from '@/config';
+
+describe('INSTANCE_LABEL (emoji input)', () => {
+ it('trims without mangling multi-byte characters', () => {
+ expect(INSTANCE_LABEL).toBe('prod-U😀');
+ });
+});
diff --git a/packages/app/src/__tests__/config.instanceLabel.test.ts b/packages/app/src/__tests__/config.instanceLabel.test.ts
new file mode 100644
index 0000000000..e0c8b69cdc
--- /dev/null
+++ b/packages/app/src/__tests__/config.instanceLabel.test.ts
@@ -0,0 +1,12 @@
+jest.mock('next-runtime-env', () => ({
+ env: (key: string) =>
+ key === 'NEXT_PUBLIC_INSTANCE_LABEL' ? ' ExtraLongLabel ' : undefined,
+}));
+
+import { INSTANCE_LABEL } from '@/config';
+
+describe('INSTANCE_LABEL', () => {
+ it('trims whitespace without capping length', () => {
+ expect(INSTANCE_LABEL).toBe('ExtraLongLabel');
+ });
+});
diff --git a/packages/app/src/__tests__/config.instanceLabel.whitespace.test.ts b/packages/app/src/__tests__/config.instanceLabel.whitespace.test.ts
new file mode 100644
index 0000000000..afa9478224
--- /dev/null
+++ b/packages/app/src/__tests__/config.instanceLabel.whitespace.test.ts
@@ -0,0 +1,12 @@
+jest.mock('next-runtime-env', () => ({
+ env: (key: string) =>
+ key === 'NEXT_PUBLIC_INSTANCE_LABEL' ? 'EU West' : undefined,
+}));
+
+import { INSTANCE_LABEL } from '@/config';
+
+describe('INSTANCE_LABEL (internal whitespace run)', () => {
+ it('collapses internal whitespace to a single space', () => {
+ expect(INSTANCE_LABEL).toBe('EU West');
+ });
+});
diff --git a/packages/app/src/__tests__/config.instanceTitleSuffix.no-label.test.ts b/packages/app/src/__tests__/config.instanceTitleSuffix.no-label.test.ts
new file mode 100644
index 0000000000..89994228f5
--- /dev/null
+++ b/packages/app/src/__tests__/config.instanceTitleSuffix.no-label.test.ts
@@ -0,0 +1,12 @@
+jest.mock('next-runtime-env', () => ({
+ env: (key: string) =>
+ key === 'NEXT_PUBLIC_INSTANCE_LABEL' ? undefined : 'unexpected',
+}));
+
+import { INSTANCE_TITLE_SUFFIX } from '@/config';
+
+describe('INSTANCE_TITLE_SUFFIX (INSTANCE_LABEL unset)', () => {
+ it('is empty', () => {
+ expect(INSTANCE_TITLE_SUFFIX).toBe('');
+ });
+});
diff --git a/packages/app/src/__tests__/config.instanceTitleSuffix.test.ts b/packages/app/src/__tests__/config.instanceTitleSuffix.test.ts
new file mode 100644
index 0000000000..17dfc176c9
--- /dev/null
+++ b/packages/app/src/__tests__/config.instanceTitleSuffix.test.ts
@@ -0,0 +1,12 @@
+jest.mock('next-runtime-env', () => ({
+ env: (key: string) =>
+ key === 'NEXT_PUBLIC_INSTANCE_LABEL' ? 'UK' : undefined,
+}));
+
+import { INSTANCE_TITLE_SUFFIX } from '@/config';
+
+describe('INSTANCE_TITLE_SUFFIX', () => {
+ it('is the label with a leading space, ready to append to a title', () => {
+ expect(INSTANCE_TITLE_SUFFIX).toBe(' UK');
+ });
+});
diff --git a/packages/app/src/components/AppNav/AppNav.module.scss b/packages/app/src/components/AppNav/AppNav.module.scss
index 9613ba65f9..80415250fb 100644
--- a/packages/app/src/components/AppNav/AppNav.module.scss
+++ b/packages/app/src/components/AppNav/AppNav.module.scss
@@ -109,6 +109,11 @@ $transition-slow: 0.2s ease;
align-items: center;
justify-content: center;
color: var(--color-text);
+
+ // Shrinkable (not growable) so a long label can still ellipsis when the
+ // sidebar is narrow, without stretching this link to fill the empty
+ // header space next to it (that space shouldn't be part of the link).
+ min-width: 0;
}
.logoIconWrapper {
diff --git a/packages/app/src/components/AppNav/AppNav.tsx b/packages/app/src/components/AppNav/AppNav.tsx
index 32ef55d9be..2d9bccd8a5 100644
--- a/packages/app/src/components/AppNav/AppNav.tsx
+++ b/packages/app/src/components/AppNav/AppNav.tsx
@@ -30,6 +30,7 @@ import {
import api from '@/api';
import { AlertStatusIcon } from '@/components/AlertStatusIcon';
+import { InstanceLabel } from '@/components/AppNav/InstanceLabel';
import { APP_VERSION, IS_LOCAL_MODE } from '@/config';
import { Dashboard, useDashboards } from '@/dashboard';
import { useFavorites } from '@/favorites';
@@ -364,19 +365,30 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
{isCollapsed ? (
{logomark}
) : (
-
+
{wordmark}
- {isUTC && (
-
- UTC
-
- )}
+ {/* Label and UTC badge are mutually exclusive - showing both
+ would be redundant and crowd this already-tight row. */}
+
+ UTC
+
+ )
+ }
+ />
)}
diff --git a/packages/app/src/components/AppNav/InstanceLabel.tsx b/packages/app/src/components/AppNav/InstanceLabel.tsx
new file mode 100644
index 0000000000..eaf755891e
--- /dev/null
+++ b/packages/app/src/components/AppNav/InstanceLabel.tsx
@@ -0,0 +1,32 @@
+import { ReactNode } from 'react';
+import { Badge } from '@mantine/core';
+
+import { INSTANCE_LABEL } from '@/config';
+
+// Styled to match the sidebar's UTC badge. `fallback` lets AppNav render the
+// UTC badge in the same slot without needing its own INSTANCE_LABEL check -
+// this component owns the one guard for whether a label is configured.
+export function InstanceLabel({ fallback = null }: { fallback?: ReactNode }) {
+ if (!INSTANCE_LABEL) {
+ return fallback;
+ }
+ return (
+
+ {INSTANCE_LABEL}
+
+ );
+}
diff --git a/packages/app/src/components/AppNav/__tests__/InstanceLabel.no-label.test.tsx b/packages/app/src/components/AppNav/__tests__/InstanceLabel.no-label.test.tsx
new file mode 100644
index 0000000000..f3176b51ce
--- /dev/null
+++ b/packages/app/src/components/AppNav/__tests__/InstanceLabel.no-label.test.tsx
@@ -0,0 +1,17 @@
+import { render, screen } from '@testing-library/react';
+
+jest.mock('@/config', () => ({ INSTANCE_LABEL: '' }));
+
+import { InstanceLabel } from '@/components/AppNav/InstanceLabel';
+
+describe('InstanceLabel (INSTANCE_LABEL unset)', () => {
+ it('renders nothing by default', () => {
+ const { container } = render();
+ expect(container).toBeEmptyDOMElement();
+ });
+
+ it('renders the fallback instead, e.g. the sidebar UTC badge', () => {
+ render(UTC} />);
+ expect(screen.getByText('UTC')).toBeInTheDocument();
+ });
+});
diff --git a/packages/app/src/components/AppNav/__tests__/InstanceLabel.test.tsx b/packages/app/src/components/AppNav/__tests__/InstanceLabel.test.tsx
new file mode 100644
index 0000000000..0313e526f2
--- /dev/null
+++ b/packages/app/src/components/AppNav/__tests__/InstanceLabel.test.tsx
@@ -0,0 +1,27 @@
+import { MantineProvider } from '@mantine/core';
+import { render, screen } from '@testing-library/react';
+
+jest.mock('@/config', () => ({ INSTANCE_LABEL: 'UK' }));
+
+import { InstanceLabel } from '@/components/AppNav/InstanceLabel';
+
+describe('InstanceLabel', () => {
+ it('renders the label when INSTANCE_LABEL is set', () => {
+ render(
+
+
+ ,
+ );
+ expect(screen.getByText('UK')).toBeInTheDocument();
+ });
+
+ it('ignores the fallback when a label is set, so they stay mutually exclusive', () => {
+ render(
+
+ UTC} />
+ ,
+ );
+ expect(screen.getByText('UK')).toBeInTheDocument();
+ expect(screen.queryByText('UTC')).not.toBeInTheDocument();
+ });
+});
diff --git a/packages/app/src/components/Dashboards/DashboardTemplatesPage.tsx b/packages/app/src/components/Dashboards/DashboardTemplatesPage.tsx
index 27a0bc7dd6..2fe6470909 100644
--- a/packages/app/src/components/Dashboards/DashboardTemplatesPage.tsx
+++ b/packages/app/src/components/Dashboards/DashboardTemplatesPage.tsx
@@ -15,10 +15,10 @@ import { IconUpload } from '@tabler/icons-react';
import { DASHBOARD_TEMPLATES } from '@/dashboardTemplates';
import { withAppNav } from '@/layout';
-import { useBrandDisplayName } from '@/theme/ThemeProvider';
+import { usePageTitle } from '@/theme/ThemeProvider';
export default function DashboardTemplatesPage() {
- const brandName = useBrandDisplayName();
+ const title = usePageTitle('Dashboard Templates');
const templatesByTag = useMemo(() => {
const groups = new Map();
@@ -44,7 +44,7 @@ export default function DashboardTemplatesPage() {
return (
-
Dashboard Templates - {brandName}
+
{title}
diff --git a/packages/app/src/components/Dashboards/DashboardsListPage.tsx b/packages/app/src/components/Dashboards/DashboardsListPage.tsx
index 2a4b62e284..10299cd622 100644
--- a/packages/app/src/components/Dashboards/DashboardsListPage.tsx
+++ b/packages/app/src/components/Dashboards/DashboardsListPage.tsx
@@ -55,7 +55,7 @@ import {
} from '@/dashboard';
import { useFavorites } from '@/favorites';
import { withAppNav } from '@/layout';
-import { useBrandDisplayName } from '@/theme/ThemeProvider';
+import { usePageTitle } from '@/theme/ThemeProvider';
import { useConfirm } from '@/useConfirm';
function getDashboardAlerts(tiles: Dashboard['tiles']) {
@@ -97,7 +97,7 @@ const PRESET_DASHBOARDS = [
];
export default function DashboardsListPage() {
- const brandName = useBrandDisplayName();
+ const title = usePageTitle('Dashboards');
const { data: dashboards, isLoading, isError } = useDashboards();
const { data: me, isPending: isMePending } = api.useMe();
const confirm = useConfirm();
@@ -218,7 +218,7 @@ export default function DashboardsListPage() {
style={{ display: 'flex', flexDirection: 'column', minHeight: '100%' }}
>
- Dashboards - {brandName}
+ {title}
({
}));
jest.mock('@/theme/ThemeProvider', () => ({
useBrandDisplayName: () => 'HyperDX',
+ usePageTitle: (page?: string) => (page ? `${page} - HyperDX` : 'HyperDX'),
}));
jest.mock('@/useConfirm', () => ({
useConfirm: () => jest.fn(),
diff --git a/packages/app/src/components/SavedSearches/SavedSearchesListPage.tsx b/packages/app/src/components/SavedSearches/SavedSearchesListPage.tsx
index 415919d010..a97b062170 100644
--- a/packages/app/src/components/SavedSearches/SavedSearchesListPage.tsx
+++ b/packages/app/src/components/SavedSearches/SavedSearchesListPage.tsx
@@ -33,12 +33,12 @@ import { PageHeader } from '@/components/PageHeader';
import { useFavorites } from '@/favorites';
import { withAppNav } from '@/layout';
import { useDeleteSavedSearch, useSavedSearches } from '@/savedSearch';
-import { useBrandDisplayName } from '@/theme/ThemeProvider';
+import { usePageTitle } from '@/theme/ThemeProvider';
import { useConfirm } from '@/useConfirm';
import { groupByTags } from '@/utils/groupByTags';
export default function SavedSearchesListPage() {
- const brandName = useBrandDisplayName();
+ const title = usePageTitle('Saved Searches');
const { data: savedSearches, isLoading, isError } = useSavedSearches();
const confirm = useConfirm();
const deleteSavedSearch = useDeleteSavedSearch();
@@ -126,7 +126,7 @@ export default function SavedSearchesListPage() {
style={{ display: 'flex', flexDirection: 'column', height: '100%' }}
>
- Saved Searches - {brandName}
+ {title}
= {
promql: IS_PROMQL_ENABLED,
llmCost: IS_LLM_COST_ENABLED,
alertDetails: IS_ALERT_DETAILS_ENABLED,
+ instanceLabel: Boolean(INSTANCE_LABEL),
};
// config.ts's IS_OSS has a precedence quirk (`?? 'true' === 'true'`), so a set
diff --git a/packages/app/src/llm/dashboard/LLMDashboardPage.tsx b/packages/app/src/llm/dashboard/LLMDashboardPage.tsx
index 1d52766293..12f4bef3a1 100644
--- a/packages/app/src/llm/dashboard/LLMDashboardPage.tsx
+++ b/packages/app/src/llm/dashboard/LLMDashboardPage.tsx
@@ -39,7 +39,7 @@ import {
} from '@/llm/hooks/useLLMDashboardExpressions';
import { getEffectiveTraceSourceId } from '@/ServicesDashboardPage';
import { useSource, useSources } from '@/source';
-import { useBrandDisplayName } from '@/theme/ThemeProvider';
+import { usePageTitle } from '@/theme/ThemeProvider';
import { useDefaultTimeRange, useNewTimeQuery } from '@/timeQuery';
import { AgentToolCharts } from './AgentToolCharts';
@@ -76,7 +76,7 @@ const queryParamMap = {
*/
function LLMDashboardPage() {
const defaultTimeRange = useDefaultTimeRange(DEFAULT_INTERVAL);
- const brandName = useBrandDisplayName();
+ const title = usePageTitle('LLM Dashboard');
const [rawTab, setTab] = useQueryState(
'tab',
@@ -212,7 +212,7 @@ function LLMDashboardPage() {
return (
- LLM Dashboard – {brandName}
+ {title}
diff --git a/packages/app/src/theme/ThemeProvider.tsx b/packages/app/src/theme/ThemeProvider.tsx
index 071601dfa9..4ba8c23528 100644
--- a/packages/app/src/theme/ThemeProvider.tsx
+++ b/packages/app/src/theme/ThemeProvider.tsx
@@ -8,6 +8,8 @@ import React, {
useState,
} from 'react';
+import { INSTANCE_TITLE_SUFFIX } from '@/config';
+
import {
DEFAULT_THEME,
getDevThemeName,
@@ -241,3 +243,14 @@ export function useBrandDisplayName(): string {
const { theme } = useAppTheme();
return theme.displayName;
}
+
+/**
+ * Hook to build a ``/`` value: brand name plus the
+ * configured instance label, with an optional page name prepended.
+ * e.g. usePageTitle('Search') => "Search - HyperDX USA"
+ */
+export function usePageTitle(page?: string): string {
+ const brandName = useBrandDisplayName();
+ const brandTitle = `${brandName}${INSTANCE_TITLE_SUFFIX}`;
+ return page ? `${page} - ${brandTitle}` : brandTitle;
+}
diff --git a/packages/app/src/theme/__tests__/ThemeProvider.test.tsx b/packages/app/src/theme/__tests__/ThemeProvider.test.tsx
index 8f213d0829..008239a8f3 100644
--- a/packages/app/src/theme/__tests__/ThemeProvider.test.tsx
+++ b/packages/app/src/theme/__tests__/ThemeProvider.test.tsx
@@ -17,10 +17,13 @@ import {
AppThemeProvider,
useAppTheme,
useLogomark,
+ usePageTitle,
useThemeName,
useWordmark,
} from '@/theme/ThemeProvider';
+jest.mock('@/config', () => ({ INSTANCE_TITLE_SUFFIX: ' UK' }));
+
// Mock localStorage
let localStorageMock: jest.Mocked;
@@ -144,6 +147,24 @@ describe('ThemeProvider', () => {
});
});
+ describe('usePageTitle', () => {
+ const wrapper = ({ children }: { children: React.ReactNode }) => (
+ {children}
+ );
+
+ it('appends the brand name and instance suffix with no page name', () => {
+ const { result } = renderHook(() => usePageTitle(), { wrapper });
+
+ expect(result.current).toBe('HyperDX UK');
+ });
+
+ it('prepends the page name when given one', () => {
+ const { result } = renderHook(() => usePageTitle('Search'), { wrapper });
+
+ expect(result.current).toBe('Search - HyperDX UK');
+ });
+ });
+
describe('useThemeName', () => {
it('should return current theme name', () => {
const wrapper = ({ children }: { children: React.ReactNode }) => (
diff --git a/packages/app/tests/e2e/page-objects/DashboardPage.ts b/packages/app/tests/e2e/page-objects/DashboardPage.ts
index 419aaf3260..35bca0b325 100644
--- a/packages/app/tests/e2e/page-objects/DashboardPage.ts
+++ b/packages/app/tests/e2e/page-objects/DashboardPage.ts
@@ -275,7 +275,7 @@ export class DashboardPage {
// The document title comes from the saved dashboard, so it only changes
// once the rename has persisted.
const escaped = newName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
- await expect(this.page).toHaveTitle(new RegExp(`^${escaped} – `), {
+ await expect(this.page).toHaveTitle(new RegExp(`^${escaped} - `), {
timeout: 10000,
});
}