Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(studio): restore function deployment annotations FE-3921 (#50362)

Jordi Enricc228ca4f61de
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionInvocationsChart.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionInvocationsChart.tsx
index c494061ee64..e76bf3c86ef 100644
--- a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionInvocationsChart.tsx
+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionInvocationsChart.tsx
@@ -8,7 +8,14 @@ import {
XAxis,
YAxis,
} from 'recharts'
-import { ChartContainer, ChartTooltip, ChartTooltipContent } from 'ui'
+import {
+ ChartContainer,
+ ChartTooltip,
+ ChartTooltipContent,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from 'ui'
import {
formatChartTimestamp,
@@ -98,13 +105,25 @@ export const EdgeFunctionInvocationsChart = ({
</RechartBarChart>
</ChartContainer>
{updateAnnotation && (
- <span
- className="pointer-events-none absolute bottom-0 z-10 flex h-6 w-6 -translate-x-1/2 translate-y-1/2 items-center justify-center rounded-full border border-foreground/20 bg-background text-foreground shadow-xs"
- style={{ left: `${updateAnnotation.position}%` }}
- title={`Updated ${formatChartTimestamp(updateAnnotation.updatedAt, dateTimeFormat)}`}
- >
- <Rocket size={12} strokeWidth={1.75} />
- </span>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span
+ className="pointer-events-auto absolute bottom-0 z-10 flex h-6 w-6 -translate-x-1/2 translate-y-1/2 items-center justify-center rounded-full border border-foreground/20 bg-background text-foreground shadow-xs"
+ style={{ left: `${updateAnnotation.position}%` }}
+ role="img"
+ tabIndex={0}
+ aria-label={`Deployment at ${formatChartTimestamp(
+ updateAnnotation.updatedAt,
+ dateTimeFormat
+ )}`}
+ >
+ <Rocket size={12} strokeWidth={1.75} aria-hidden />
+ </span>
+ </TooltipTrigger>
+ <TooltipContent side="top" align="center">
+ Deployment at {formatChartTimestamp(updateAnnotation.updatedAt, dateTimeFormat)}
+ </TooltipContent>
+ </Tooltip>
)}
</div>
{timeRangeLabels && (
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.tsx
index 2b242a587b2..0949c270c55 100644
--- a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.tsx
+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.tsx
@@ -131,10 +131,7 @@ export const EdgeFunctionOverview = () => {
const invocationUpdateAnnotation = useMemo(
() =>
getInvocationUpdateAnnotation({
- updatedAt:
- selectedFunction?.updated_at === undefined
- ? undefined
- : String(selectedFunction.updated_at),
+ updatedAt: selectedFunction?.updated_at,
invocationChartData,
windowStart: selectedWindowStart,
windowEnd: selectedWindowEnd,
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.utils.test.ts b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.utils.test.ts
index 225c03f4c1d..8a56f8e64b8 100644
--- a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.utils.test.ts
+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.utils.test.ts
@@ -170,6 +170,23 @@ describe('EdgeFunctionOverview.utils', () => {
expect(annotation?.updatedAt.toISOString()).toBe('2026-03-20T10:16:30.000Z')
})
+ it('returns a deploy annotation for a numeric updated_at timestamp', () => {
+ const annotation = getInvocationUpdateAnnotation({
+ updatedAt: new Date('2026-03-20T10:16:30.000Z').valueOf(),
+ invocationChartData: [
+ { timestamp: '2026-03-20T10:00:00.000Z', ok_count: 3, warning_count: 0, error_count: 0 },
+ { timestamp: '2026-03-20T10:15:00.000Z', ok_count: 5, warning_count: 1, error_count: 1 },
+ { timestamp: '2026-03-20T10:30:00.000Z', ok_count: 2, warning_count: 0, error_count: 0 },
+ ],
+ windowStart: new Date('2026-03-20T09:45:00.000Z'),
+ windowEnd: new Date('2026-03-20T10:45:00.000Z'),
+ })
+
+ expect(annotation?.timestamp).toBe('2026-03-20T10:15:00.000Z')
+ expect(annotation?.position).toBeCloseTo(50)
+ expect(annotation?.updatedAt.toISOString()).toBe('2026-03-20T10:16:30.000Z')
+ })
+
it('hides the deploy annotation when updated_at is outside the selected window', () => {
const annotation = getInvocationUpdateAnnotation({
updatedAt: '2026-03-20T11:05:00.000Z',
@@ -183,6 +200,41 @@ describe('EdgeFunctionOverview.utils', () => {
expect(annotation).toBeUndefined()
})
+ it('hides the deploy annotation for an invalid updated_at timestamp', () => {
+ const annotation = getInvocationUpdateAnnotation({
+ updatedAt: 'invalid',
+ invocationChartData: [
+ { timestamp: '2026-03-20T10:00:00.000Z', ok_count: 3, warning_count: 0, error_count: 0 },
+ ],
+ windowStart: new Date('2026-03-20T09:45:00.000Z'),
+ windowEnd: new Date('2026-03-20T10:45:00.000Z'),
+ })
+
+ expect(annotation).toBeUndefined()
+ })
+
+ it.each([
+ {
+ updatedAt: undefined,
+ invocationChartData: [
+ { timestamp: '2026-03-20T10:00:00.000Z', ok_count: 3, warning_count: 0, error_count: 0 },
+ ],
+ },
+ { updatedAt: '2026-03-20T10:00:00.000Z', invocationChartData: [] },
+ ])(
+ 'hides the deploy annotation when required data is missing',
+ ({ updatedAt, invocationChartData }) => {
+ const annotation = getInvocationUpdateAnnotation({
+ updatedAt,
+ invocationChartData,
+ windowStart: new Date('2026-03-20T09:45:00.000Z'),
+ windowEnd: new Date('2026-03-20T10:45:00.000Z'),
+ })
+
+ expect(annotation).toBeUndefined()
+ }
+ )
+
it('builds bucketed and rolling time windows from the selected interval', () => {
const interval = EDGE_FUNCTION_CHART_INTERVALS.find((item) => item.key === '1hr')
expect(interval).toBeDefined()
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.utils.ts b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.utils.ts
index 02ad85f2795..dbb91f1aed2 100644
--- a/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.utils.ts
+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionOverview/EdgeFunctionOverview.utils.ts
@@ -246,12 +246,12 @@ export const getInvocationUpdateAnnotation = ({
windowStart,
windowEnd,
}: {
- updatedAt?: string
+ updatedAt?: number | string
invocationChartData: InvocationChartDatum[]
windowStart: Date
windowEnd: Date
}): InvocationUpdateAnnotation | undefined => {
- if (!updatedAt || invocationChartData.length === 0) return undefined
+ if (updatedAt === undefined || invocationChartData.length === 0) return undefined
const updatedAtDate = new Date(updatedAt)
const updatedAtValue = updatedAtDate.valueOf()