Skip to content

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

feat(studio): worker detail page (FE-4189, FE-4197) (#49195)

Jordi Enric5fd2023708f6
diff --git a/apps/studio/TANSTACK_MIGRATION.md b/apps/studio/TANSTACK_MIGRATION.md
index fb8ba8cc114..13644b1c7ea 100644
--- a/apps/studio/TANSTACK_MIGRATION.md
+++ b/apps/studio/TANSTACK_MIGRATION.md
@@ -231,6 +231,7 @@ These are the layout-only TanStack files. Most hold a single product layout comp
### Project shell — `/workers/*`
- [x] A `routes/project/$ref/workers/index.tsx` ← `pages/project/[ref]/workers/index.tsx`
+- [x] A `routes/project/$ref/workers/$name.tsx` ← `pages/project/[ref]/workers/[name].tsx`
### Project shell — `/functions/*`
diff --git a/apps/studio/components/interfaces/Settings/Logs/LogColumnRenderers/WorkersLogsColumnRender.tsx b/apps/studio/components/interfaces/Settings/Logs/LogColumnRenderers/WorkersLogsColumnRender.tsx
new file mode 100644
index 00000000000..1c9c897c016
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/Logs/LogColumnRenderers/WorkersLogsColumnRender.tsx
@@ -0,0 +1,22 @@
+import { Column } from 'react-data-grid'
+import { TimestampInfo } from 'ui-patterns/TimestampInfo'
+
+import type { LogData } from '../Logs.types'
+import { RowLayout, SeverityFormatter, TextFormatter } from '../LogsFormatters'
+
+export const WorkersLogsColumnRender: Column<LogData>[] = [
+ {
+ name: 'workers-logs-first-column',
+ key: 'workers-logs-first-column',
+ renderHeaderCell: () => null,
+ renderCell: (props) => (
+ <RowLayout>
+ <TimestampInfo utcTimestamp={props.row.timestamp!} />
+ {props.row.severity_text ? (
+ <SeverityFormatter value={props.row.severity_text as string} />
+ ) : null}
+ <TextFormatter className="w-full" value={props.row.event_message} />
+ </RowLayout>
+ ),
+ },
+]
diff --git a/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx b/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx
index f1e17d4ec9d..89f17a3f8de 100644
--- a/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx
+++ b/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx
@@ -69,6 +69,7 @@ interface Props {
selectedLogError?: LogQueryError | ResponseError
onSelectedLogChange?: (log: LogData | null) => void
sqlQuery?: string
+ columnRenderers?: Column<LogData>[]
}
type LogMap = { [id: string]: LogData }
@@ -98,6 +99,7 @@ export const LogTable = ({
selectedLogError,
onSelectedLogChange,
sqlQuery,
+ columnRenderers,
}: Props) => {
const { ref } = useParams()
const { profile } = useProfile()
@@ -245,7 +247,9 @@ export const LogTable = ({
let columns = DEFAULT_COLUMNS
- if (!queryType) {
+ if (columnRenderers) {
+ columns = columnRenderers
+ } else if (!queryType) {
columns
} else {
switch (queryType) {
@@ -616,7 +620,7 @@ export const LogTable = ({
'data-grid--logs-explorer': !queryType,
})}
rowHeight={40}
- headerRowHeight={queryType ? 0 : 28}
+ headerRowHeight={queryType || columnRenderers ? 0 : 28}
columns={columns}
rowClass={(row: LogData) => {
const key = getRowKey(row)
diff --git a/apps/studio/components/interfaces/Workers/WorkerDetail/WorkerDetail.tsx b/apps/studio/components/interfaces/Workers/WorkerDetail/WorkerDetail.tsx
new file mode 100644
index 00000000000..88e8de4d71b
--- /dev/null
+++ b/apps/studio/components/interfaces/Workers/WorkerDetail/WorkerDetail.tsx
@@ -0,0 +1,148 @@
+import { useQuery } from '@tanstack/react-query'
+import { useParams } from 'common'
+import { Container, Package } from 'lucide-react'
+import Link from 'next/link'
+import { parseAsStringEnum, useQueryState } from 'nuqs'
+import {
+ BreadcrumbItem,
+ BreadcrumbLink,
+ BreadcrumbList,
+ BreadcrumbPage,
+ BreadcrumbSeparator,
+ Button,
+ Card,
+ NavMenu,
+ NavMenuItem,
+} from 'ui'
+import { PageBreadcrumbs } from 'ui-patterns/PageBreadcrumbs'
+import {
+ PageHeader,
+ PageHeaderDescription,
+ PageHeaderIcon,
+ PageHeaderMeta,
+ PageHeaderSummary,
+ PageHeaderTitle,
+} from 'ui-patterns/PageHeader'
+import { PageNav } from 'ui-patterns/PageNav'
+import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
+
+import { RuntimeBadge } from '../RuntimeBadge'
+import { WorkerStatePill } from '../WorkerStatePill'
+import { WorkerLogsTab } from './WorkerLogsTab'
+import { WorkerOverviewTab } from './WorkerOverviewTab'
+import { AlertError } from '@/components/ui/AlertError'
+import type { WorkerLogStream } from '@/data/workers/worker-logs-query'
+import { workerQueryOptions } from '@/data/workers/worker-query'
+import { PRODUCT_NAME } from '@/lib/constants/workers'
+
+type WorkerTab = 'overview' | 'invocations' | 'logs' | 'activity'
+const WORKER_TABS: WorkerTab[] = ['overview', 'invocations', 'logs', 'activity']
+
+const TAB_LABEL: Record<WorkerTab, string> = {
+ overview: 'Overview',
+ invocations: 'Invocations',
+ logs: 'Logs',
+ activity: 'Activity',
+}
+
+const TAB_STREAM: Partial<Record<WorkerTab, WorkerLogStream>> = {
+ invocations: 'requests',
+ logs: 'output',
+ activity: 'builds',
+}
+
+export const WorkerDetail = () => {
+ const { ref: projectRef, name: workerName } = useParams()
+
+ const [tab, setTab] = useQueryState(
+ 'tab',
+ parseAsStringEnum<WorkerTab>(WORKER_TABS)
+ .withDefault('overview')
+ .withOptions({ history: 'push' })
+ )
+
+ const {
+ data: worker,
+ error,
+ isPending,
+ isError,
+ } = useQuery(workerQueryOptions({ projectRef, name: workerName }))
+
+ if (!projectRef) return null
+ if (isPending) return <GenericSkeletonLoader className="p-6" />
+ if (isError) return <AlertError error={error} subject="Failed to retrieve worker" />
+
+ if (!worker) {
+ return (
+ <div className="flex flex-1 flex-col items-center justify-center gap-3 py-24 text-center">
+ <p className="text-sm text-foreground-light">
+ Worker "{workerName}" does not exist in this project
+ </p>
+ <Button asChild variant="default">
+ <Link href={`/project/${projectRef}/workers`}>Back to {PRODUCT_NAME}</Link>
+ </Button>
+ </div>
+ )
+ }
+
+ const stream = TAB_STREAM[tab]
+
+ return (
+ <div className="w-full min-h-full flex flex-col items-stretch">
+ <PageBreadcrumbs>
+ <BreadcrumbList>
+ <BreadcrumbItem>
+ <BreadcrumbLink asChild>
+ <Link href={`/project/${projectRef}/workers`}>{PRODUCT_NAME}</Link>
+ </BreadcrumbLink>
+ </BreadcrumbItem>
+ <BreadcrumbSeparator />
+ <BreadcrumbItem>
+ <BreadcrumbPage>{worker.name}</BreadcrumbPage>
+ </BreadcrumbItem>
+ </BreadcrumbList>
+ </PageBreadcrumbs>
+
+ <PageHeader className="py-4 [&>div]:px-4 [&>div]:xl:px-4">
+ <PageHeaderMeta className="px-0 xl:px-0">
+ <PageHeaderIcon>
+ <Card className="flex h-14 w-14 shrink-0 items-center justify-center">
+ <Container className="h-5 w-5" />
+ </Card>
+ </PageHeaderIcon>
+ <PageHeaderSummary>
+ <PageHeaderTitle>{worker.name}</PageHeaderTitle>
+ <PageHeaderDescription className="flex flex-row flex-wrap items-center gap-x-4 gap-y-1 text-sm">
+ <WorkerStatePill worker={worker} />
+ <RuntimeBadge runtime={worker.runtime} />
+ {worker.imageVersion !== undefined && (
+ <span className="flex items-center gap-2 text-foreground-light">
+ <Package size={14} strokeWidth={1.5} className="text-foreground-lighter" />
+ Image {worker.imageVersion}
+ </span>
+ )}
+ </PageHeaderDescription>
+ </PageHeaderSummary>
+ </PageHeaderMeta>
+ </PageHeader>
+ <PageNav>
+ <NavMenu>
+ {WORKER_TABS.map((item) => (
+ <NavMenuItem key={item} active={tab === item}>
+ <button type="button" tabIndex={0} onClick={() => setTab(item)}>
+ {TAB_LABEL[item]}
+ </button>
+ </NavMenuItem>
+ ))}
+ </NavMenu>
+ </PageNav>
+
+ {tab === 'overview' && <WorkerOverviewTab worker={worker} />}
+ {stream !== undefined && (
+ <div className="flex flex-1 flex-col min-h-0">
+ <WorkerLogsTab key={stream} workerName={worker.name} stream={stream} />
+ </div>
+ )}
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/Workers/WorkerDetail/WorkerLogsTab.tsx b/apps/studio/components/interfaces/Workers/WorkerDetail/WorkerLogsTab.tsx
new file mode 100644
index 00000000000..1056bd7295b
--- /dev/null
+++ b/apps/studio/components/interfaces/Workers/WorkerDetail/WorkerLogsTab.tsx
@@ -0,0 +1,92 @@
+import { useQuery } from '@tanstack/react-query'
+import { useParams } from 'common'
+import { RefreshCw } from 'lucide-react'
+import { useState } from 'react'
+import { Button } from 'ui'
+import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'
+
+import { WorkerCommandLine } from '../WorkerCommandLine'
+import { WorkersLogsColumnRender } from '@/components/interfaces/Settings/Logs/LogColumnRenderers/WorkersLogsColumnRender'
+import type { LogData } from '@/components/interfaces/Settings/Logs/Logs.types'
+import { LogTable } from '@/components/interfaces/Settings/Logs/LogTable'
+import { AlertError } from '@/components/ui/AlertError'
+import {
+ WORKER_LOG_STREAM_LABEL,
+ workerLogsQueryOptions,
+ type WorkerLogStream,
+} from '@/data/workers/worker-logs-query'
+import { CLI_NAME } from '@/lib/constants/workers'
+
+interface WorkerLogsTabProps {
+ workerName: string
+ stream: WorkerLogStream
+}
+
+export const WorkerLogsTab = ({ workerName, stream }: WorkerLogsTabProps) => {
+ const { ref: projectRef } = useParams()
+ const [selectedLog, setSelectedLog] = useState<LogData | null>(null)
+
+ const {
+ data: logs,
+ error,
+ isPending,
+ isError,
+ isFetching,
+ refetch,
+ } = useQuery(workerLogsQueryOptions({ projectRef, name: workerName, stream }))
+
+ const label = WORKER_LOG_STREAM_LABEL[stream].toLowerCase()
+
+ return (
+ <div className="flex flex-1 flex-col min-h-0">
+ <div className="flex items-center justify-end border-b border-default px-4 py-2">
+ <Button
+ variant="default"
+ icon={<RefreshCw />}
+ loading={isFetching}
+ onClick={() => refetch()}
+ >
+ Refresh
+ </Button>
+ </div>
+
+ {isError && (
+ <div className="p-4">
+ <AlertError error={error} subject="Failed to retrieve worker logs" />
+ </div>
+ )}
+
+ {!isError && isPending && (
+ <div className="p-4">
+ <GenericSkeletonLoader />
+ </div>
+ )}
+
+ {!isError && !isPending && (
+ <div className="relative flex flex-1 flex-col grow overflow-auto">
+ <LogTable
+ projectRef={projectRef ?? ''}
+ columnRenderers={WorkersLogsColumnRender}
+ data={logs ?? []}
+ isLoading={isPending}
+ showHeader={false}
+ showHistogramToggle={false}
+ selectedLog={selectedLog ?? undefined}
+ onSelectedLogChange={(log) => setSelectedLog(log)}
+ EmptyState={
+ <div className="mx-auto max-w-md space-y-3 py-16 text-center">
+ <p className="text-sm text-foreground">No {label} in the last 24 hours</p>
+ <p className="text-sm text-foreground-lighter">
+ Follow them from the Supabase CLI while you wait for traffic.
+ </p>
+ <div className="pt-1 text-left">
+ <WorkerCommandLine command={`supabase ${CLI_NAME} logs ${workerName} --follow`} />
+ </div>
+ </div>
+ }
+ />
+ </div>
+ )}
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/Workers/WorkerDetail/WorkerOverviewTab.tsx b/apps/studio/components/interfaces/Workers/WorkerDetail/WorkerOverviewTab.tsx
new file mode 100644
index 00000000000..39ee28eb509
--- /dev/null
+++ b/apps/studio/components/interfaces/Workers/WorkerDetail/WorkerOverviewTab.tsx
@@ -0,0 +1,260 @@
+import { ReactNode } from 'react'
+import { Badge } from 'ui'
+import { Admonition } from 'ui-patterns/Admonition'
+import { InfoTooltip } from 'ui-patterns/info-tooltip'
+import { PageContainer } from 'ui-patterns/PageContainer'
+import {
+ PageSection,
+ PageSectionContent,
+ PageSectionDescription,
+ PageSectionMeta,
+ PageSectionSummary,
+ PageSectionTitle,
+} from 'ui-patterns/PageSection'
+
+import { RuntimeBadge } from '../RuntimeBadge'
+import { WorkerCommandLine } from '../WorkerCommandLine'
+import { LISTENING_PORT, WORKERS_REGION_LABEL } from '../Workers.constants'
+import type { Worker } from '../Workers.types'
+import { formatSize, getRuntimeMeta } from '../Workers.utils'
+import { buildWorkerCliCommands } from '../workerSnippets'
+import { WorkerSnippetTabs } from '../WorkerSnippetTabs'
+import { CLI_NAME } from '@/lib/constants/workers'
+
+interface WorkerOverviewTabProps {
+ worker: Worker
+}
+
+const InstanceCount = ({
+ label,
+ value,
+ tooltip,
+}: {
+ label: string
+ value: number
+ tooltip: ReactNode
+}) => (
+ <div className="flex flex-col gap-1 px-5 py-4">
+ <span className="flex items-center gap-1.5 text-sm text-foreground-light">
+ {label}
+ <InfoTooltip side="top" className="max-w-56">
+ {tooltip}
+ </InfoTooltip>
+ </span>
+ <span className="text-2xl tabular-nums text-foreground">{value}</span>
+ </div>
+)
+
+const SettingsRow = ({
+ label,
+ children,
+ isFirst,
+}: {
+ label: string
+ children: ReactNode
+ isFirst?: boolean
+}) => (
+ <div
+ className={`flex items-center justify-between px-4 py-3 ${
+ isFirst ? '' : 'border-t border-default'
+ }`}
+ >
+ <span className="text-sm text-foreground-light">{label}</span>
+ <span className="text-sm text-foreground">{children}</span>
+ </div>
+)
+
+export const WorkerOverviewTab = ({ worker }: WorkerOverviewTabProps) => {
+ const runtime = getRuntimeMeta(worker.runtime)
+ const commands = buildWorkerCliCommands(worker.name)
+
+ return (
+ <PageContainer size="small">
+ {worker.buildState === 'failed' && (
+ <PageSection>
+ <PageSectionContent>
+ <Admonition type="destructive" title="This worker failed to build">
+ <div className="space-y-3">
+ <p>{worker.stateReason ?? 'The build did not complete.'}</p>
+ <WorkerCommandLine
+ comment="Redeploy after fixing the build"
+ command={`supabase ${CLI_NAME} push ${worker.name}`}
+ />
+ </div>
+ </Admonition>
+ </PageSectionContent>
+ </PageSection>
+ )}
+
+ {worker.instancesError !== undefined && (
+ <PageSection>
+ <PageSectionContent>
+ <Admonition type="warning" title="Instances reported an error">
+ {worker.instancesError}
+ </Admonition>
+ </PageSectionContent>
+ </PageSection>
+ )}
+
+ <PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle>Instances</PageSectionTitle>
+ </PageSectionSummary>
+ </PageSectionMeta>
+ <PageSectionContent>
+ {worker.instances === undefined ? (
+ <p className="text-sm text-foreground-light">
+ No instances are running for this worker yet.
+ </p>
+ ) : (
+ <div className="space-y-3">
+ <p className="text-sm text-foreground-light">
+ <span className="tabular-nums text-foreground">{worker.instances.ready}</span> of{' '}
+ <span className="tabular-nums text-foreground">{worker.instances.declared}</span>{' '}
+ instances ready
+ </p>
+ <div className="grid grid-cols-2 divide-x divide-y rounded-md border border-default bg-surface-100 sm:grid-cols-4 sm:divide-y-0">
+ <InstanceCount
+ label="Instances"
+ value={worker.instances.declared}
+ tooltip="The number of instances you configured for this worker."
+ />
+ <InstanceCount
+ label="Live"
+ value={worker.instances.live}
+ tooltip="Instances currently running."
+ />
+ <InstanceCount
+ label="Ready"
+ value={worker.instances.ready}
+ tooltip="Instances passing health checks and serving requests."
+ />
+ <InstanceCount
+ label="Stale"
+ value={worker.instances.stale}
+ tooltip="Instances from a previous deployment, being replaced."
+ />
+ </div>
+ </div>
+ )}
+ </PageSectionContent>
+ </PageSection>
+
+ <PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle>Container</PageSectionTitle>
+ <PageSectionDescription>
+ The runtime image and entrypoint resolved for this worker.
+ </PageSectionDescription>
+ </PageSectionSummary>
+ </PageSectionMeta>
+ <PageSectionContent>
+ <div className="rounded-md border border-default bg-surface-100">
+ <SettingsRow label="Runtime" isFirst>
+ <RuntimeBadge runtime={worker.runtime} />
+ </SettingsRow>
+ {worker.imageVersion !== undefined && (
+ <SettingsRow label="Image version">
+ <span className="font-mono text-xs text-foreground-light">
+ {worker.imageVersion}
+ </span>
+ </SettingsRow>
+ )}
+ {runtime !== undefined && (
+ <SettingsRow label="Base image">
+ <span className="font-mono text-xs text-foreground-light">{runtime.baseImage}</span>
+ </SettingsRow>
+ )}
+ {runtime !== undefined && (
+ <SettingsRow label="Entrypoint">
+ <span className="font-mono text-xs text-foreground-light">
+ {runtime.entrypoint}
+ </span>
+ </SettingsRow>
+ )}
+ <SettingsRow label="Listening port">
+ <span className="font-mono text-xs text-foreground-light">
+ $PORT → {LISTENING_PORT}
+ </span>
+ </SettingsRow>
+ </div>
+ </PageSectionContent>
+ </PageSection>
+
+ <PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle>Resources</PageSectionTitle>
+ </PageSectionSummary>
+ </PageSectionMeta>
+ <PageSectionContent>
+ <div className="rounded-md border border-default bg-surface-100">
+ <SettingsRow label="Size" isFirst>
+ {formatSize(worker.size)}
+ </SettingsRow>
+ <SettingsRow label="Instances">{worker.declaredInstances}</SettingsRow>
+ <SettingsRow label="Access">
+ {worker.access === 'public' ? (
+ <Badge variant="success">Public</Badge>
+ ) : (
+ <Badge>Private</Badge>
+ )}
+ </SettingsRow>
+ <SettingsRow label="Region">
+ <span className="text-foreground-light">
+ {WORKERS_REGION_LABEL} <span className="text-foreground-lighter">(locked)</span>
+ </span>
+ </SettingsRow>
+ </div>
+ </PageSectionContent>
+ </PageSection>
+
+ <PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle>How to call</PageSectionTitle>
+ <PageSectionDescription>
+ Call the worker over its gateway URL. Pass your project API key as a bearer token.
+ </PageSectionDescription>
+ </PageSectionSummary>
+ </PageSectionMeta>
+ <PageSectionContent>
+ <WorkerSnippetTabs
+ input={{
+ name: worker.name,
+ runtime: worker.runtime,
+ size: worker.size,
+ access: worker.access,
+ instances: worker.declaredInstances,
+ }}
+ tabs={['cli', 'js', 'python']}
+ />
+ </PageSectionContent>
+ </PageSection>
+
+ <PageSection>
+ <PageSectionMeta>
+ <PageSectionSummary>
+ <PageSectionTitle>Develop locally</PageSectionTitle>
+ <PageSectionDescription>
+ Manage this worker from the Supabase CLI.
+ </PageSectionDescription>
+ </PageSectionSummary>
+ </PageSectionMeta>
+ <PageSectionContent>
+ <div className="space-y-4 rounded-md border border-default bg-surface-100 p-4">
+ {commands.map((command) => (
+ <WorkerCommandLine
+ key={command.command}
+ comment={command.comment}
+ command={command.command}
+ />
+ ))}
+ </div>
+ </PageSectionContent>
+ </PageSection>
+ </PageContainer>
+ )
+}
diff --git a/apps/studio/components/interfaces/Workers/workerSnippets.ts b/apps/studio/components/interfaces/Workers/workerSnippets.ts
index 02499a1fcb0..de89c173050 100644
--- a/apps/studio/components/interfaces/Workers/workerSnippets.ts
+++ b/apps/studio/components/interfaces/Workers/workerSnippets.ts
@@ -114,7 +114,6 @@ export function buildWorkerCliCommands(name: string): WorkerCliCommand[] {
const slug = safeName(name)
return [
{ comment: 'Recreate the source locally', command: `supabase ${CLI_NAME} pull ${slug}` },
- { comment: 'Run it locally on a port', command: `supabase ${CLI_NAME} serve ${slug}` },
{ comment: 'Deploy a new version', command: `supabase ${CLI_NAME} push ${slug}` },
{ comment: 'Stream logs', command: `supabase ${CLI_NAME} logs ${slug} --follow` },
{ comment: 'Delete the worker', command: `supabase ${CLI_NAME} delete ${slug}` },
diff --git a/apps/studio/data/workers/keys.ts b/apps/studio/data/workers/keys.ts
index 2feecbc6431..9eedc104d21 100644
--- a/apps/studio/data/workers/keys.ts
+++ b/apps/studio/data/workers/keys.ts
@@ -2,4 +2,6 @@ export const workersKeys = {
list: (projectRef: string | undefined) => ['projects', projectRef, 'workers'] as const,
detail: (projectRef: string | undefined, name: string | undefined) =>
['projects', projectRef, 'worker', name, 'detail'] as const,
+ logs: (projectRef: string | undefined, name: string | undefined, stream: string) =>
+ ['projects', projectRef, 'worker', name, 'logs', stream] as const,
}
diff --git a/apps/studio/data/workers/worker-logs-query.test.ts b/apps/studio/data/workers/worker-logs-query.test.ts
new file mode 100644
index 00000000000..2c909f8459d
--- /dev/null
+++ b/apps/studio/data/workers/worker-logs-query.test.ts
@@ -0,0 +1,51 @@
+import { describe, expect, it } from 'vitest'
+
+import { parseWorkerLogRows, workerLogsSql } from './worker-logs-query'
+
+describe('workerLogsSql', () => {
+ it('reads one worker stream, newest first', () => {
+ expect(workerLogsSql('embed', 'output')).toBe(
+ "select id, timestamp, severity_text as severity, event_message as message from logs where log_attributes['worker'] = 'embed' and log_attributes['source'] = 'worker_guest_logs' order by timestamp desc limit 100"
+ )
+ })
+
+ it('names the right stream for each tab', () => {
+ expect(workerLogsSql('embed', 'requests')).toContain("'worker_ingress_logs'")
+ expect(workerLogsSql('embed', 'builds')).toContain("'worker_api_logs'")
+ })
+
+ it('escapes a worker name rather than interpolating it raw', () => {
+ expect(workerLogsSql("embed' or '1'='1", 'output')).toContain(
+ "log_attributes['worker'] = 'embed'' or ''1''=''1'"
+ )
+ })
+})
+
+describe('parseWorkerLogRows', () => {
+ it('shapes rows for the logs table with a numeric timestamp', () => {
+ const [row] = parseWorkerLogRows([
+ { id: 'a', timestamp: '2026-08-24T10:00:00.000000', severity: 'ERROR', message: 'boom' },
+ ])
+ expect(row.id).toBe('a')
+ expect(row.event_message).toBe('boom')
+ expect(row.severity_text).toBe('ERROR')
+ expect(typeof row.timestamp).toBe('number')
+ expect(Number.isFinite(row.timestamp)).toBe(true)
+ })
+
+ it('falls back to empty strings for null severity and message', () => {
+ const [row] = parseWorkerLogRows([
+ { id: 'a', timestamp: '2026-08-24T10:00:00.000000', severity: null, message: null },
+ ])
+ expect(row.severity_text).toBe('')
+ expect(row.event_message).toBe('')
+ })
+
+ it('returns an empty array for a missing result', () => {
+ expect(parseWorkerLogRows(undefined)).toEqual([])
+ })
+
+ it('rejects a malformed row rather than passing bad data to the table', () => {
+ expect(() => parseWorkerLogRows([{ timestamp: '2026-08-24T10:00:00.000000' }])).toThrow()
+ })
+})
diff --git a/apps/studio/data/workers/worker-logs-query.ts b/apps/studio/data/workers/worker-logs-query.ts
new file mode 100644
index 00000000000..eb68cd8968c
--- /dev/null
+++ b/apps/studio/data/workers/worker-logs-query.ts
@@ -0,0 +1,89 @@
+import { queryOptions } from '@tanstack/react-query'
+import dayjs from 'dayjs'
+import { z } from 'zod'
+
+import { workersKeys } from './keys'
+import type { LogData } from '@/components/interfaces/Settings/Logs/Logs.types'
+import { otelTimestampToMicros } from '@/components/interfaces/Settings/Logs/Logs.utils.otel'
+import { executeAnalyticsSql } from '@/data/logs/execute-analytics-sql'
+import { logsAllEndpointUrl } from '@/data/logs/logs-endpoint'
+import { analyticsLiteral, safeSql } from '@/data/logs/safe-analytics-sql'
+import { IS_PLATFORM } from '@/lib/constants'
+
+export const WORKER_LOG_SOURCES = {
+ requests: 'worker_ingress_logs',
+ output: 'worker_guest_logs',
+ builds: 'worker_api_logs',
+} as const
+
+export type WorkerLogStream = keyof typeof WORKER_LOG_SOURCES
+
+export const WORKER_LOG_STREAM_LABEL: Record<WorkerLogStream, string> = {
+ requests: 'Invocations',
+ output: 'Logs',
+ builds: 'Activity',
+}
+
+// Both are read from `log_attributes` rather than the endpoint's own `source` column:
+// that column is derived from a mapping which does not currently classify worker rows.
+const WORKER_NAME_KEY = 'worker'
+const STREAM_KEY = 'source'
+
+const LOOKBACK_HOURS = 24
+const LOG_LIMIT = 100
+
+const workerLogRowSchema = z.object({
+ id: z.string(),
+ timestamp: z.union([z.string(), z.number()]),
+ severity: z.string().nullish(),
+ message: z.string().nullish(),
+})
+
+export type WorkerLogsVariables = {
+ projectRef?: string
+ name?: string
+ stream: WorkerLogStream
+}
+
+export const workerLogsSql = (name: string, stream: WorkerLogStream) =>
+ safeSql`select id, timestamp, severity_text as severity, event_message as message from logs where log_attributes[${analyticsLiteral(WORKER_NAME_KEY)}] = ${analyticsLiteral(name)} and log_attributes[${analyticsLiteral(STREAM_KEY)}] = ${analyticsLiteral(WORKER_LOG_SOURCES[stream])} order by timestamp desc limit ${analyticsLiteral(LOG_LIMIT)}`
+
+export const parseWorkerLogRows = (result: unknown): LogData[] =>
+ z
+ .array(workerLogRowSchema)
+ .parse(result ?? [])
+ .map((row) => ({
+ id: row.id,
+ timestamp: otelTimestampToMicros(row.timestamp),
+ event_message: row.message ?? '',
+ severity_text: row.severity ?? '',
+ }))
+
+async function getWorkerLogs(
+ { projectRef, name, stream }: WorkerLogsVariables,
+ signal?: AbortSignal
+): Promise<LogData[]> {
+ if (!projectRef) throw new Error('projectRef is required')
+ if (!name) throw new Error('name is required')
+
+ const end = dayjs()
+ const start = end.subtract(LOOKBACK_HOURS, 'hour')
+
+ const data = await executeAnalyticsSql({
+ projectRef,
+ endpoint: logsAllEndpointUrl(true),
+ sql: workerLogsSql(name, stream),
+ iso_timestamp_start: start.toISOString(),
+ iso_timestamp_end: end.toISOString(),
+ signal,
+ })
+
+ return parseWorkerLogRows(data?.result)
+}
+
+export const workerLogsQueryOptions = ({ projectRef, name, stream }: WorkerLogsVariables) =>
+ queryOptions({
+ queryKey: workersKeys.logs(projectRef, name, stream),
+ queryFn: ({ signal }) => getWorkerLogs({ projectRef, name, stream }, signal),
+ enabled: IS_PLATFORM && typeof projectRef !== 'undefined' && typeof name !== 'undefined',
+ })
diff --git a/apps/studio/lib/constants/workers.ts b/apps/studio/lib/constants/workers.ts
index 02e9fa1b0e1..887f13c712a 100644
--- a/apps/studio/lib/constants/workers.ts
+++ b/apps/studio/lib/constants/workers.ts
@@ -1,47 +1,2 @@
export const PRODUCT_NAME = 'Workers'
export const CLI_NAME = 'workers'
-
-export const WORKERS_CLI_DEPLOY = `supabase ${CLI_NAME} push`
-
-export const WORKERS_SKILL_MARKDOWN = `# Supabase ${PRODUCT_NAME} — agent skill
-
-Deploy and manage backend workers (microVMs) that run next to a Supabase project's Postgres.
-
-## Deploy from config.toml
-
-Add a block to \`supabase/config.toml\`:
-
-\`\`\`toml
-[${CLI_NAME}.embed]
-runtime = "python" # node | deno | bun | python | dockerfile
-size = "2gb-1vcpu" # 2gb-1vcpu | 4gb-2vcpu — fixed at deploy
-access = "public" # public | private
-instances = 1 # 1..10 per deploy; 100 cap per project
-secrets = ["OPENAI_API_KEY"] # names only — values live in the Secrets API
-\`\`\`
-
-Then run:
-
-\`\`\`bash
-supabase ${CLI_NAME} new embed --runtime python
-supabase ${CLI_NAME} push embed
-\`\`\`
-
-Config precedence: \`--flag\` > \`config.toml\` > interactive prompt > default.
-
-## Conventions
-
-- Workers under \`supabase/${CLI_NAME}/<name>/\` are auto-discovered; the folder name is the slug.
-- \`entrypoint\` is inferred from the runtime (node index.js, deno run main.ts, python main.py, Dockerfile CMD).
-- \`region\` is locked to us-west-2 at alpha — do not set it.
-- Sizes are fixed at deploy time. To change size, delete the worker and redeploy.
-
-## Manage
-
-- \`supabase ${CLI_NAME} list\`
-- \`supabase ${CLI_NAME} status <name>\`
-- \`supabase ${CLI_NAME} logs <name> --follow\`
-- \`supabase ${CLI_NAME} stop <name>\` # scale to zero (reversible)
-- \`supabase ${CLI_NAME} start <name>\`
-- \`supabase ${CLI_NAME} delete <name>\`
-`
diff --git a/apps/studio/pages/project/[ref]/workers/[name].tsx b/apps/studio/pages/project/[ref]/workers/[name].tsx
new file mode 100644
index 00000000000..bb3eaf1f230
--- /dev/null
+++ b/apps/studio/pages/project/[ref]/workers/[name].tsx
@@ -0,0 +1,14 @@
+import { WorkerDetail } from '@/components/interfaces/Workers/WorkerDetail/WorkerDetail'
+import { DefaultLayout } from '@/components/layouts/DefaultLayout'
+import { WorkersLayout } from '@/components/layouts/WorkersLayout/WorkersLayout'
+import type { NextPageWithLayout } from '@/types'
+
+const WorkerDetailPage: NextPageWithLayout = () => <WorkerDetail />
+
+WorkerDetailPage.getLayout = (page) => (
+ <DefaultLayout>
+ <WorkersLayout title="Worker">{page}</WorkersLayout>
+ </DefaultLayout>
+)
+
+export default WorkerDetailPage
diff --git a/apps/studio/routeTree.gen.ts b/apps/studio/routeTree.gen.ts
index 350cfbc6ccd..7be3871d460 100644
--- a/apps/studio/routeTree.gen.ts
+++ b/apps/studio/routeTree.gen.ts
@@ -100,6 +100,7 @@ import { Route as ApiPlatformProfileIndexRouteImport } from './routes/api/platfo
import { Route as ApiPlatformOrganizationsIndexRouteImport } from './routes/api/platform/organizations/index'
import { Route as AppOrgSlugIndexRouteImport } from './routes/_app/org/$slug/index'
import { Route as AppAccountTokensIndexRouteImport } from './routes/_app/account/tokens/index'
+import { Route as ProjectRefWorkersNameRouteImport } from './routes/project/$ref/workers/$name'
import { Route as ProjectRefStorageS3RouteImport } from './routes/project/$ref/storage/s3'
import { Route as ProjectRefSqlTemplatesRouteImport } from './routes/project/$ref/sql/templates'
import { Route as ProjectRefSqlExamplesRouteImport } from './routes/project/$ref/sql/examples'
@@ -793,6 +794,11 @@ const AppAccountTokensIndexRoute = AppAccountTokensIndexRouteImport.update({
path: '/tokens/',
getParentRoute: () => AppAccountRoute,
} as any)
+const ProjectRefWorkersNameRoute = ProjectRefWorkersNameRouteImport.update({
+ id: '/$name',
+ path: '/$name',
+ getParentRoute: () => ProjectRefWorkersRoute,
+} as any)
const ProjectRefStorageS3Route = ProjectRefStorageS3RouteImport.update({
id: '/s3',
path: '/s3',
@@ -2270,6 +2276,7 @@ export interface FileRoutesByFullPath {
'/project/$ref/sql/examples': typeof ProjectRefSqlExamplesRoute
'/project/$ref/sql/templates': typeof ProjectRefSqlTemplatesRoute
'/project/$ref/storage/s3': typeof ProjectRefStorageS3Route
+ '/project/$ref/workers/$name': typeof ProjectRefWorkersNameRoute
'/account/tokens/': typeof AppAccountTokensIndexRoute
'/org/$slug/': typeof AppOrgSlugIndexRoute
'/api/platform/organizations/': typeof ApiPlatformOrganizationsIndexRoute
@@ -2572,6 +2579,7 @@ export interface FileRoutesByTo {
'/project/$ref/sql/examples': typeof ProjectRefSqlExamplesRoute
'/project/$ref/sql/templates': typeof ProjectRefSqlTemplatesRoute
'/project/$ref/storage/s3': typeof ProjectRefStorageS3Route
+ '/project/$ref/workers/$name': typeof ProjectRefWorkersNameRoute
'/account/tokens': typeof AppAccountTokensIndexRoute
'/org/$slug': typeof AppOrgSlugIndexRoute
'/api/platform/organizations': typeof ApiPlatformOrganizationsIndexRoute
@@ -2891,6 +2899,7 @@ export interface FileRoutesById {
'/project/$ref/sql/examples': typeof ProjectRefSqlExamplesRoute
'/project/$ref/sql/templates': typeof ProjectRefSqlTemplatesRoute
'/project/$ref/storage/s3': typeof ProjectRefStorageS3Route
+ '/project/$ref/workers/$name': typeof ProjectRefWorkersNameRoute
'/_app/account/tokens/': typeof AppAccountTokensIndexRoute
'/_app/org/$slug/': typeof AppOrgSlugIndexRoute
'/api/platform/organizations/': typeof ApiPlatformOrganizationsIndexRoute
@@ -3209,6 +3218,7 @@ export interface FileRouteTypes {
| '/project/$ref/sql/examples'
| '/project/$ref/sql/templates'
| '/project/$ref/storage/s3'
+ | '/project/$ref/workers/$name'
| '/account/tokens/'
| '/org/$slug/'
| '/api/platform/organizations/'
@@ -3511,6 +3521,7 @@ export interface FileRouteTypes {
| '/project/$ref/sql/examples'
| '/project/$ref/sql/templates'
| '/project/$ref/storage/s3'
+ | '/project/$ref/workers/$name'
| '/account/tokens'
| '/org/$slug'
| '/api/platform/organizations'
@@ -3829,6 +3840,7 @@ export interface FileRouteTypes {
| '/project/$ref/sql/examples'
| '/project/$ref/sql/templates'
| '/project/$ref/storage/s3'
+ | '/project/$ref/workers/$name'
| '/_app/account/tokens/'
| '/_app/org/$slug/'
| '/api/platform/organizations/'
@@ -4732,6 +4744,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AppAccountTokensIndexRouteImport
parentRoute: typeof AppAccountRoute
}
+ '/project/$ref/workers/$name': {
+ id: '/project/$ref/workers/$name'
+ path: '/$name'
+ fullPath: '/project/$ref/workers/$name'
+ preLoaderRoute: typeof ProjectRefWorkersNameRouteImport
+ parentRoute: typeof ProjectRefWorkersRoute
+ }
'/project/$ref/storage/s3': {
id: '/project/$ref/storage/s3'
path: '/s3'
@@ -6928,10 +6947,12 @@ const ProjectRefStorageRouteWithChildren =
ProjectRefStorageRoute._addFileChildren(ProjectRefStorageRouteChildren)
interface ProjectRefWorkersRouteChildren {
+ ProjectRefWorkersNameRoute: typeof ProjectRefWorkersNameRoute
ProjectRefWorkersIndexRoute: typeof ProjectRefWorkersIndexRoute
}
const ProjectRefWorkersRouteChildren: ProjectRefWorkersRouteChildren = {
+ ProjectRefWorkersNameRoute: ProjectRefWorkersNameRoute,
ProjectRefWorkersIndexRoute: ProjectRefWorkersIndexRoute,
}
diff --git a/apps/studio/routes/project/$ref/workers/$name.tsx b/apps/studio/routes/project/$ref/workers/$name.tsx
new file mode 100644
index 00000000000..a8c23bb553f
--- /dev/null
+++ b/apps/studio/routes/project/$ref/workers/$name.tsx
@@ -0,0 +1,14 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+import WorkerDetailPage from '@/pages/project/[ref]/workers/[name]'
+
+export const Route = createFileRoute('/project/$ref/workers/$name')({
+ component: WorkerDetailRoute,
+ staticData: {
+ workersLayoutTitle: 'Worker',
+ },
+})
+
+function WorkerDetailRoute() {
+ return <WorkerDetailPage dehydratedState={undefined} />
+}