Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(web): write numbers and dates in en-US whatever the browser's locale, and lint against locale-less calls (#1549)

Cihan751915d89e04
diff --git a/web/eslint.config.mjs b/web/eslint.config.mjs
index 213ed9028..a0ea83682 100644
--- a/web/eslint.config.mjs
+++ b/web/eslint.config.mjs
@@ -6,6 +6,56 @@ import prettier from "eslint-config-prettier";
const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
+ // The UI is English-only, so numbers and dates name their locale: the
+ // browser's would turn 1,232 into "1.232" (lib/format.ts). Tests may read
+ // the browser's on purpose.
+ {
+ files: ["src/**/*.{ts,tsx}"],
+ ignores: ["src/**/*.test.{ts,tsx}"],
+ rules: {
+ "no-restricted-syntax": [
+ "error",
+ // x.toLocaleString(), toLocaleDateString(undefined, …), ([], …)
+ {
+ selector:
+ "CallExpression[callee.property.name=/^toLocale(Date|Time)?String$/][arguments.length=0]",
+ message:
+ "Name the locale: use formatNumber / formatDate / formatDateTime from '@/lib/format', or pass 'en-US'.",
+ },
+ {
+ selector:
+ "CallExpression[callee.property.name=/^toLocale(Date|Time)?String$/][arguments.0.type='Identifier'][arguments.0.name='undefined']",
+ message: "Name the locale: pass 'en-US' instead of undefined.",
+ },
+ {
+ selector:
+ "CallExpression[callee.property.name=/^toLocale(Date|Time)?String$/][arguments.0.type='ArrayExpression'][arguments.0.elements.length=0]",
+ message: "Name the locale: pass 'en-US' instead of [].",
+ },
+ // new Intl.NumberFormat(), Intl.NumberFormat(undefined, …), new Intl.Collator([]).
+ // Intl.DateTimeFormat() alone reads the browser's time zone (lib/time-zone.ts).
+ {
+ selector: "NewExpression[callee.object.name='Intl'][arguments.length=0]",
+ message: "Name the locale: pass 'en-US'.",
+ },
+ {
+ selector:
+ "CallExpression[callee.object.name='Intl'][callee.property.name!='DateTimeFormat'][arguments.length=0]",
+ message: "Name the locale: pass 'en-US'.",
+ },
+ {
+ selector:
+ ":matches(NewExpression, CallExpression)[callee.object.name='Intl'][arguments.0.type='Identifier'][arguments.0.name='undefined']",
+ message: "Name the locale: pass 'en-US' instead of undefined.",
+ },
+ {
+ selector:
+ ":matches(NewExpression, CallExpression)[callee.object.name='Intl'][arguments.0.type='ArrayExpression'][arguments.0.elements.length=0]",
+ message: "Name the locale: pass 'en-US' instead of [].",
+ },
+ ],
+ },
+ },
// Disable ESLint rules that conflict with Prettier — keep ESLint for code
// quality and let Prettier own formatting. Must come last.
prettier,
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx
index 9bd0f8825..bc90261e7 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx
@@ -85,6 +85,7 @@ import {
} from '@/components/ui/table';
import { Skeleton } from '@/components/ui/skeleton';
import { cn } from '@/lib/utils';
+import { formatNumber } from '@/lib/format';
import { HeaderWithAiUsage } from '@/components/ai-usage/ai-usage-meter';
// ─── Constants ───────────────────────────────────────────────────────────────
@@ -1062,7 +1063,7 @@ export default function CitationsPage() {
() => [
{
title: t('kpiTotalCitations'),
- value: totals ? totals.citations.toLocaleString() : '—',
+ value: totals ? formatNumber(totals.citations) : '—',
sub: t('kpiTotalCitationsSub', {
results: totals?.results ?? 0,
}),
@@ -1070,7 +1071,7 @@ export default function CitationsPage() {
},
{
title: t('kpiUniqueDomains'),
- value: totals ? domainsInScope.toLocaleString() : '—',
+ value: totals ? formatNumber(domainsInScope) : '—',
sub: t('kpiUniqueDomainsSub', {
urls: totals?.urls ?? 0,
}),
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/citations/url/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/citations/url/page.tsx
index f0436ac3c..f692d6953 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/citations/url/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/citations/url/page.tsx
@@ -53,7 +53,7 @@ import {
Target,
TrendingUp,
} from 'lucide-react';
-import { formatDate } from '@/lib/format';
+import { formatDate, formatNumber } from '@/lib/format';
import { cn } from '@/lib/utils';
import { HeaderWithAiUsage } from '@/components/ai-usage/ai-usage-meter';
@@ -286,19 +286,19 @@ export default function CitationUrlDetailPage() {
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-5">
<KpiCard
title="Total citations"
- value={data.totals.citations.toLocaleString()}
+ value={formatNumber(data.totals.citations)}
sub={`across ${data.totals.answers} answers`}
icon={Quote}
/>
<KpiCard
title="Answers citing"
- value={data.totals.answers.toLocaleString()}
+ value={formatNumber(data.totals.answers)}
sub="AI answers include this URL"
icon={MessagesSquare}
/>
<KpiCard
title="Prompts"
- value={data.totals.prompts.toLocaleString()}
+ value={formatNumber(data.totals.prompts)}
sub="distinct prompts triggering it"
icon={ListChecks}
/>
@@ -382,7 +382,7 @@ export default function CitationUrlDetailPage() {
) : (
<div className="space-y-3">
<div className="text-2xl font-bold tabular-nums">
- {data.owned.traffic.totalVisits.toLocaleString()}
+ {formatNumber(data.owned.traffic.totalVisits)}
</div>
<ul className="space-y-1.5">
{data.owned.traffic.byPlatform.map((p) => (
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/competitors/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/competitors/page.tsx
index c05e0ccb8..754c60e05 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/competitors/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/competitors/page.tsx
@@ -524,7 +524,7 @@ function groupH2HByPrompt(groups: HeadToHeadGroup[]): PromptComparisonGroup[] {
function formatTimestamp(iso: string): string {
const d = new Date(iso);
- return d.toLocaleDateString(undefined, {
+ return d.toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
});
@@ -985,7 +985,7 @@ function GapStrengthList({ items, type }: { items: HeadToHeadGroup[]; type: 'gap
)}
{!hasMultiple && group.items[0].latestAt && (
<span className="text-muted-foreground">
- {new Date(group.items[0].latestAt).toLocaleDateString(undefined, {
+ {new Date(group.items[0].latestAt).toLocaleDateString('en-US', {
day: 'numeric',
month: 'short',
year: 'numeric',
@@ -1035,7 +1035,7 @@ function GapStrengthList({ items, type }: { items: HeadToHeadGroup[]; type: 'gap
</span>
{item.latestAt && (
<span className="text-muted-foreground whitespace-nowrap">
- {new Date(item.latestAt).toLocaleDateString(undefined, {
+ {new Date(item.latestAt).toLocaleDateString('en-US', {
day: 'numeric',
month: 'short',
})}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/insights/[id]/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/insights/[id]/page.tsx
index b0a0febff..d5a0cc4f8 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/insights/[id]/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/insights/[id]/page.tsx
@@ -23,6 +23,7 @@ import { cn } from '@/lib/utils';
import { PLATFORM_LABELS } from '@/config/platform-labels';
import { ResponseDetail } from '@/components/results/response-detail';
import { formatRegionDisplay } from '@/lib/region';
+import { formatDateTime } from '@/lib/format';
import { HeaderWithAiUsage } from '@/components/ai-usage/ai-usage-meter';
function SentimentBadge({ sentiment }: { sentiment: 'positive' | 'neutral' | 'negative' }) {
@@ -209,7 +210,7 @@ export default function ResultDetailPage() {
{/* Timestamp */}
<div className="flex items-center gap-2 text-xs text-muted-foreground pb-6">
<Clock className="h-3.5 w-3.5" />
- {tDetail('checkedAt', { date: new Date(result.createdAt).toLocaleString() })}
+ {tDetail('checkedAt', { date: formatDateTime(result.createdAt) })}
</div>
</div>
);
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/insights/_charts.tsx b/web/src/app/[locale]/(dashboard)/dashboard/insights/_charts.tsx
index bacc08256..35d66f4c5 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/insights/_charts.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/insights/_charts.tsx
@@ -30,6 +30,7 @@ import type {
import { getFaviconUrl } from '@/lib/favicon';
import { trendAxisTop, type TrendLine, type TrendMarker } from '@/lib/insights-trend';
import { numberFormat } from '@/lib/number-format';
+import { formatNumber } from '@/lib/format';
import { dayLabel } from './kpi-format';
// ─── Adaptive Y-axis ─────────────────────────────────────────────────────────
@@ -528,8 +529,8 @@ export function ShareOfVoicePlatformChart({
<div className="text-muted-foreground">
Your share of voice:{' '}
<span className="font-medium text-foreground">{p.sov.toFixed(1)}%</span> —
- your brand accounts for {p.brandMentions.toLocaleString()} of the{' '}
- {p.voiceMentions.toLocaleString()} brand + competitor mentions here
+ your brand accounts for {formatNumber(p.brandMentions)} of the{' '}
+ {formatNumber(p.voiceMentions)} brand + competitor mentions here
</div>
<div className="mt-1 text-muted-foreground">
{platformShare.toFixed(1)}% of all tracked mentions happened on {p.provider}{' '}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/prompts/[id]/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/prompts/[id]/page.tsx
index c9311ef8a..e0d68a9f1 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/prompts/[id]/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/prompts/[id]/page.tsx
@@ -74,6 +74,7 @@ import { TablePager, usePagination } from '@/components/table-pager';
import { MODEL_PROVIDER_LABELS, PLATFORM_LABELS } from '@/config/platform-labels';
import { groupByPlatform, type PlatformGroup } from './grouping';
import { dayRangeBounds, viewerTimeZone } from '@/lib/time-zone';
+import { formatNumber } from '@/lib/format';
import { HeaderWithAiUsage } from '@/components/ai-usage/ai-usage-meter';
// ─── Date range (kept in sync with the insights page filter bar) ─────────────
@@ -950,12 +951,12 @@ export default function PromptDetailPage() {
/>
<KpiCard
title="Mentions"
- value={data.summary.totalMentions.toLocaleString()}
+ value={formatNumber(data.summary.totalMentions)}
icon={MessageSquareText}
/>
<KpiCard
title="Citations"
- value={data.summary.totalCitations.toLocaleString()}
+ value={formatNumber(data.summary.totalCitations)}
icon={Quote}
/>
{volume && (
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/prompts/_topics-tab.tsx b/web/src/app/[locale]/(dashboard)/dashboard/prompts/_topics-tab.tsx
index 29ca02da0..fe3a4b23c 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/prompts/_topics-tab.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/prompts/_topics-tab.tsx
@@ -54,6 +54,7 @@ import {
import { cn } from '@/lib/utils';
import { toCsv } from '@/lib/csv';
import { formatRelative } from '@/lib/format-relative';
+import { formatNumber } from '@/lib/format';
import { compareNullsLast, type SortDir } from './prompt-sort';
// ─── Helpers ─────────────────────────────────────────────────────────────
@@ -707,10 +708,10 @@ export function TopicsTab({
{topic.shareOfVoice > 0 ? `${topic.shareOfVoice}%` : '—'}
</TableCell>
<TableCell className="text-right tabular-nums text-sm">
- {topic.totalMentions.toLocaleString()}
+ {formatNumber(topic.totalMentions)}
</TableCell>
<TableCell className="text-right tabular-nums text-sm">
- {topic.totalCitations.toLocaleString()}
+ {formatNumber(topic.totalCitations)}
</TableCell>
<TableCell>
{/* Under two days there is no line, only the change. */}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/prompts/similar-topics/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/prompts/similar-topics/page.tsx
index 09b13211a..d45a01987 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/prompts/similar-topics/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/prompts/similar-topics/page.tsx
@@ -19,7 +19,7 @@ import { getPromptVolumes } from '@/lib/actions/volumes';
import { aggregatePromptVolumeClusters } from '@/lib/prompt-volume-clusters';
import { useBrandStore } from '@/stores/use-brand-store';
import type { PromptVolume } from '@/types';
-import { formatCompactNumber } from '@/lib/format';
+import { formatCompactNumber, formatNumber } from '@/lib/format';
import { keywordVolumeEstimate, promptVolumeEstimate, sumEstimates } from '@/lib/volume-estimate';
import { useTranslations } from 'next-intl';
import {
@@ -117,7 +117,7 @@ export default function SimilarTopicsPage() {
</CardHeader>
<CardContent>
<div className="text-2xl font-semibold tabular-nums">
- {totals.clusters.toLocaleString()}
+ {formatNumber(totals.clusters)}
</div>
<p className="text-xs text-muted-foreground">unique keywords</p>
</CardContent>
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/prompts/topics/[id]/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/prompts/topics/[id]/page.tsx
index 3c1d0c8f7..4b3c46415 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/prompts/topics/[id]/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/prompts/topics/[id]/page.tsx
@@ -31,6 +31,7 @@ import {
} from 'lucide-react';
import { ShareOfVoicePlatformChart } from '../../../insights/_charts';
import { cn } from '@/lib/utils';
+import { formatNumber } from '@/lib/format';
import dynamic from 'next/dynamic';
import { HeaderWithAiUsage } from '@/components/ai-usage/ai-usage-meter';
const DynamicVisibilityTrendChart = dynamic(
@@ -296,13 +297,13 @@ export default function TopicDetailPage({ params }: { params: Promise<{ id: stri
<KpiCard
icon={Zap}
label="Brand mentions"
- value={summary.totalMentions.toLocaleString()}
+ value={formatNumber(summary.totalMentions)}
change={summary.mentionsChange}
/>
<KpiCard
icon={Quote}
label="Citations"
- value={summary.totalCitations.toLocaleString()}
+ value={formatNumber(summary.totalCitations)}
change={summary.citationsChange}
/>
<KpiCard
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx
index 0313a094b..241392450 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx
@@ -92,6 +92,7 @@ import { toCsv } from '@/lib/csv';
import { PLATFORM_LABELS } from '@/config/platform-labels';
import { formatRegionDisplay } from '@/lib/region';
import type { AmazonShareDropAlert } from '@/lib/shopping-amazon-share-alert';
+import { formatNumber } from '@/lib/format';
import { HeaderWithAiUsage } from '@/components/ai-usage/ai-usage-meter';
import { ShoppingMarketSwitch, useShoppingMarket } from './_market-switch';
import { MerchantSplitCard } from './merchant_split_card';
@@ -699,7 +700,7 @@ function PromptsTabContent({
</div>
</TableCell>
<TableCell className="text-right font-medium tabular-nums">
- {row.totalCards.toLocaleString()}
+ {formatNumber(row.totalCards)}
</TableCell>
<TableCell>
<div
@@ -768,7 +769,7 @@ function PromptsTabContent({
)}
<span className="flex items-center gap-1">
<Calendar className="h-3 w-3" />
- {new Date(app.timestamp).toLocaleString(undefined, {
+ {new Date(app.timestamp).toLocaleString('en-US', {
month: 'short',
day: 'numeric',
hour: '2-digit',
@@ -990,7 +991,7 @@ function KpiGrid({
/>
<KpiCard
title={t('kpiOwnProducts')}
- value={productsSurfaced.toLocaleString()}
+ value={formatNumber(productsSurfaced)}
subtitle={t('kpiOwnProductsSub')}
icon={ArrowUpRight}
locked={!hasFullAccess}
@@ -1248,7 +1249,7 @@ function ProductTable({
{sortedProducts.map((p, idx) => {
const formattedPrice =
p.last_price !== null
- ? new Intl.NumberFormat(undefined, {
+ ? new Intl.NumberFormat('en-US', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(p.last_price)
@@ -1256,7 +1257,7 @@ function ProductTable({
const lastPriceStr =
p.last_price !== null ? `${formattedPrice} ${p.price_currency || ''}` : '—';
const formattedDate = p.last_seen
- ? new Date(p.last_seen).toLocaleDateString(undefined, {
+ ? new Date(p.last_seen).toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
})
@@ -1323,7 +1324,7 @@ function ProductTable({
</div>
</TableCell>
<TableCell className="text-right font-semibold tabular-nums">
- {p.impressions.toLocaleString()}
+ {formatNumber(p.impressions)}
</TableCell>
<TableCell className="text-right font-medium tabular-nums">
{lastPriceStr}
@@ -1451,7 +1452,7 @@ function ProductAppearancesDrawer({
<ProductMatchScores brandId={brandId} filters={filters} product={product} />
)}
{product?.appearances.map((app) => {
- const dateStr = new Date(app.created_at).toLocaleDateString(undefined, {
+ const dateStr = new Date(app.created_at).toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
hour: '2-digit',
diff --git a/web/src/components/content/opportunity-basket.tsx b/web/src/components/content/opportunity-basket.tsx
index 2491f39cc..e1231e6ab 100644
--- a/web/src/components/content/opportunity-basket.tsx
+++ b/web/src/components/content/opportunity-basket.tsx
@@ -11,6 +11,7 @@ import { Skeleton } from '@/components/ui/skeleton';
import { LoadingDots } from '@/components/ui/loading-dots';
import { useAssetTypeLabel } from '@/hooks/use-asset-type-label';
import { getOpportunityActions, type OpportunityActionResult } from '@/lib/actions/content';
+import { formatDate } from '@/lib/format';
import type {
ContentOpportunityDecision,
ContentOpportunitySourceData,
@@ -391,7 +392,11 @@ export function OpportunityResultsCard({ actionIds }: { actionIds: string[] }) {
{a.title && <p className="text-xs text-muted-foreground line-clamp-2">{a.title}</p>}
{a.status === 'completed' && a.outcome === 'pending_measurement' && measureFrom ? (
<p className="text-xs text-muted-foreground">
- {t('resultsPending', { date: measureFrom.toLocaleDateString() })}
+ {t('resultsPending', {
+ date: formatDate(
+ Number.isNaN(measureFrom.getTime()) ? null : measureFrom.toISOString(),
+ ),
+ })}
</p>
) : a.status === 'completed' ? (
<div className="space-y-1">
diff --git a/web/src/components/content/opportunity-detail.tsx b/web/src/components/content/opportunity-detail.tsx
index 11adfa965..beeae8966 100644
--- a/web/src/components/content/opportunity-detail.tsx
+++ b/web/src/components/content/opportunity-detail.tsx
@@ -76,6 +76,7 @@ import { NewContentDialog, type DialogPreset } from '@/components/content/new-co
import { useAssetTypeLabel } from '@/hooks/use-asset-type-label';
import { toast } from 'sonner';
import { suggestedDate } from '@/lib/suggested-date';
+import { formatNumber } from '@/lib/format';
export const IMPACT_COLORS: Record<string, string> = {
high: 'border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-400',
@@ -807,7 +808,7 @@ export function OpportunityDetail({
{brief.contentType.replace(/-/g, ' ')}
</Badge>
<Badge variant="outline" className="text-xs tabular-nums">
- ~{brief.targetWordCount.toLocaleString()} words
+ ~{formatNumber(brief.targetWordCount)} words
</Badge>
</div>
</div>
diff --git a/web/src/components/layout/sidebar.tsx b/web/src/components/layout/sidebar.tsx
index 9a0984ec5..e05977faa 100644
--- a/web/src/components/layout/sidebar.tsx
+++ b/web/src/components/layout/sidebar.tsx
@@ -22,6 +22,7 @@ import { useFeatureGate } from '@/hooks/use-feature-gate';
import { useAgentKeyStatus } from '@/hooks/use-agent-key-status';
import { siteConfig } from '@/config/site';
import { cn } from '@/lib/utils';
+import { formatNumber } from '@/lib/format';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { ScrollArea } from '@/components/ui/scroll-area';
@@ -464,7 +465,7 @@ export function Sidebar() {
)}
{child.href.endsWith('/tracked') && trackedCount !== null && (
<span className="text-[11px] tabular-nums text-muted-foreground">
- {trackedCount.toLocaleString()}
+ {formatNumber(trackedCount)}
</span>
)}
</Link>
diff --git a/web/src/components/prompts/prompt-improve-tab.test.tsx b/web/src/components/prompts/prompt-improve-tab.test.tsx
index 8ec6dc4b0..e35508eab 100644
--- a/web/src/components/prompts/prompt-improve-tab.test.tsx
+++ b/web/src/components/prompts/prompt-improve-tab.test.tsx
@@ -4,7 +4,7 @@ import { NextIntlClientProvider } from 'next-intl';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import messages from '../../../messages/en.json';
import type { PlanId } from '@/config/plans';
-import type { ImproveQuota } from '@/lib/prompt-improve';
+import type { ImproveQuota, ImproveSet } from '@/lib/prompt-improve';
import { ImproveTab, type ImproveController } from './prompt-improve-tab';
vi.mock('@/i18n/navigation', () => ({
@@ -24,9 +24,13 @@ vi.mock('@/i18n/navigation', () => ({
let container: HTMLDivElement;
let root: Root;
-const controller = (quota: ImproveQuota | null, planId: PlanId | null): ImproveController => ({
+const controller = (
+ quota: ImproveQuota | null,
+ planId: PlanId | null,
+ set: ImproveSet | null = null,
+): ImproveController => ({
status: 'ready',
- set: null,
+ set,
quota,
planId,
drafts: [],
@@ -40,11 +44,15 @@ const controller = (quota: ImproveQuota | null, planId: PlanId | null): ImproveC
sending: false,
});
-async function render(quota: ImproveQuota | null, planId: PlanId | null) {
+async function render(
+ quota: ImproveQuota | null,
+ planId: PlanId | null,
+ set: ImproveSet | null = null,
+) {
await act(async () => {
root.render(
<NextIntlClientProvider locale="en" messages={messages}>
- <ImproveTab improve={controller(quota, planId)} />
+ <ImproveTab improve={controller(quota, planId, set)} />
</NextIntlClientProvider>,
);
});
@@ -64,6 +72,7 @@ beforeEach(() => {
afterEach(() => {
act(() => root.unmount());
container.remove();
+ vi.restoreAllMocks();
});
describe('the Improve tab’s budget', () => {
@@ -118,3 +127,42 @@ describe('the Improve tab’s budget', () => {
expect(container.textContent).not.toContain('used up');
});
});
+
+describe('the Improve tab’s dates', () => {
+ it('reads them in English whatever the browser’s locale is', async () => {
+ // A Turkish browser: a date without a locale would read "17.10.2026".
+ const toLocaleDateString = Date.prototype.toLocaleDateString;
+ const toLocaleString = Date.prototype.toLocaleString;
+ vi.spyOn(Date.prototype, 'toLocaleDateString').mockImplementation(function (
+ this: Date,
+ locales?: Intl.LocalesArgument,
+ options?: Intl.DateTimeFormatOptions,
+ ) {
+ return toLocaleDateString.call(this, locales ?? 'tr-TR', options);
+ });
+ vi.spyOn(Date.prototype, 'toLocaleString').mockImplementation(function (
+ this: Date,
+ locales?: Intl.LocalesArgument,
+ options?: Intl.DateTimeFormatOptions,
+ ) {
+ return toLocaleString.call(this, locales ?? 'tr-TR', options);
+ });
+ // The day and time it shows follow the time zone the tests run in.
+ const at = '2026-10-17T11:05:00.000Z';
+ await render(null, 'self_hosted', {
+ sent: {
+ latest: { actionId: 'a1', actionNo: 12, sentAt: at, suggestionIds: [] },
+ sentSuggestionIds: [],
+ },
+ rangeKey: '30d',
+ region: 'us',
+ platforms: [],
+ suggestions: [],
+ latestResultAt: at,
+ generatedAt: at,
+ stale: false,
+ });
+ expect(container.textContent).toMatch(/Generated Oct \d{1,2}, 2026, \d{1,2}:\d{2}\s(AM|PM)/);
+ expect(container.textContent).toMatch(/Sent Oct \d{1,2}, 2026 · AC-12/);
+ });
+});
diff --git a/web/src/components/prompts/prompt-improve-tab.tsx b/web/src/components/prompts/prompt-improve-tab.tsx
index 3d6fc47ae..01ca07fa7 100644
--- a/web/src/components/prompts/prompt-improve-tab.tsx
+++ b/web/src/components/prompts/prompt-improve-tab.tsx
@@ -37,6 +37,7 @@ import { Skeleton } from '@/components/ui/skeleton';
import { Textarea } from '@/components/ui/textarea';
import { AIProviderAvatar, resolveAIProvider } from '@/components/ai-provider-avatar';
import { cn } from '@/lib/utils';
+import { formatDate, formatDateTime } from '@/lib/format';
import { PLANS, hasFeature, type PlanId } from '@/config/plans';
import {
generateImproveSuggestions,
@@ -379,13 +380,13 @@ export function ImproveTab({ improve }: { improve: ImproveController }) {
{summary.selected} of {summary.total} selected · {summary.platforms} platform
{summary.platforms === 1 ? '' : 's'}
<span className="ml-2 text-muted-foreground/70">
- Generated {new Date(set.generatedAt).toLocaleString()}
+ Generated {formatDateTime(set.generatedAt)}
</span>
<QuotaNote quota={quota} planId={planId} className="ml-2" />
{sentLatest && (
<span className="mt-1 flex items-center gap-1 text-emerald-700 dark:text-emerald-400">
<CircleCheck className="h-3.5 w-3.5" />
- Sent {new Date(sentLatest.sentAt).toLocaleDateString()} · AC-{sentLatest.actionNo}
+ Sent {formatDate(sentLatest.sentAt)} · AC-{sentLatest.actionNo}
</span>
)}
</span>
diff --git a/web/src/components/settings/team-section.tsx b/web/src/components/settings/team-section.tsx
index d95d0053a..aab22c947 100644
--- a/web/src/components/settings/team-section.tsx
+++ b/web/src/components/settings/team-section.tsx
@@ -53,6 +53,7 @@ import {
UserPlus,
} from 'lucide-react';
import { useRouter } from '@/i18n/navigation';
+import { formatDate } from '@/lib/format';
import {
DropdownMenu,
DropdownMenuContent,
@@ -381,7 +382,7 @@ function InvitationRow({
<p className="text-xs text-muted-foreground">
{expired
? t('team_expired')
- : t('team_expires', { date: new Date(invitation.expiresAt).toLocaleDateString() })}
+ : t('team_expires', { date: formatDate(invitation.expiresAt) })}
</p>
</div>
<Badge variant="outline">{roleLabel(t, invitation.role)}</Badge>
diff --git a/web/src/lib/actions/shopping.ts b/web/src/lib/actions/shopping.ts
index 2a72871f6..24486b414 100644
--- a/web/src/lib/actions/shopping.ts
+++ b/web/src/lib/actions/shopping.ts
@@ -871,7 +871,7 @@ export interface CardEligiblePromptsResponse {
function formatPrice(amount: number | null, currency: string | null): string {
if (amount == null) return '—';
- const formattedAmount = new Intl.NumberFormat(undefined, {
+ const formattedAmount = new Intl.NumberFormat('en-US', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(amount);