Commit Graph
7 Commits
Author SHA1 Message Date
5d52b00f70 feat(studio): combine function invocations and logs (#50957)
With the unified logs preview on, an edge function's Logs tab renders
the unified logs view scoped to that function (#50954), with its
invocations and runtime output in one list. That replaces the separate
Invocations and Logs tabs.

- `UnifiedLogs` takes a `scope` plus view props: `hasFilterSideBar`,
`offeredFilters` and `columnPreferencesKey`. The function Logs tab turns
the sidebar off, which also drops the filters-toggle shortcut, and saves
its columns and panel layout separately from the Logs page.
- `getEdgeFunctionLogsScope` and `EDGE_FUNCTION_LOGS_VIEW` are the edge
function preset: the scope's fixed filters, the filters the tab offers
and its saved-columns key. It offers date, log type, level and message,
so no user filter, since no function row has a user.
- The Invocations tab and its shortcut are hidden. Old Invocations links
redirect to Logs, converting `its`/`ite`/`log` to `date`/`id`.
- `getEdgeFunctionLogsUrl` builds links into the scoped tab with the
shared params serializer from #50953, and clicking a bar on the
invocations chart uses it.

With the preview off, both tabs work as on master.

### How to test

1. Turn on the unified logs preview and open an edge function's Logs
tab. You should see only that function's invocations and runtime logs,
with the filter bar limited to date, log type, level and message.
2. Filter to Edge Function runtime, then to errors, and check counts and
the chart follow.
3. Open an old `/functions/<slug>/invocations?its=…&ite=…&log=…` link.
It lands on Logs with the same range and log selected.
4. Click a bar on the Overview invocations chart. The Logs tab opens on
that bucket.

### Validation

- URL helper, offered filter and preset tests, plus the scoped query
tests from #50954.
- Studio typecheck, lint ratchet, Prettier and knip pass on this layer.

### Stack

Merge in order:

1. #50953 — reusable logs table building blocks
2. #50954 — function-scoped unified logs queries
3. #50955 — slimmer function detail layout, header on Overview
4. #50957 — Invocations merged into a function-scoped Logs tab
5. #50958 — Overview errors in the shared logs table
6. #52281 — remove the legacy Overview

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2026-10-27 14:54:56 +01:00
080b888e6b feat(studio): slim edge function detail layout and move header to Overview (#50955)
The edge function detail layout is now breadcrumbs plus tabs
(`PageNav`), without the page header, so tabs like Logs and Code get the
full height below the tabs. The function name, invoke URL and last
deploy details move into a header on the Overview tab, which also holds
the chart period selector. Both the new and legacy Overview render it,
and both now default to a 1 hour period instead of 15 minutes.

The Overview sections (invocations, errors, performance and usage) now
sit in one default-width `PageContainer` instead of each nesting a
full-width one, and the invocations chart moves into a chart card.
Invocations has no section heading, since it's the headline metric right
below the page header.

Both overview versions use the same chart periods. Sparse chart data is
filled only between returned API buckets, avoiding synthetic zeros
outside the reported range. Chart navigation uses the full rolling
period, including a full day for the 1 day option.

The selector shows a checkmark for the selected period, and the header
announces loaded details. Self-hosted Studio retains a Copy URL action
in the detail toolbar because it has no Overview tab.

This layer doesn't depend on the logs changes below it.

**Heads-up:** the header now only appears on Overview. Code, Details,
Invocations and Logs show breadcrumbs and tabs only. This change isn't
behind a flag.

### How to test

1. Open an edge function's Overview. The header shows the name, URL
(with copy) and last deploy hover card, and the period selector sits in
the header with 1 hour selected.
2. Switch through the other tabs. Breadcrumbs and tabs stay sticky, and
there's no header.
3. With the `edgeFunctionsOverview` flag off, the legacy Overview
renders with the same header.

### Validation

- 104 focused tests pass with retries disabled and shuffled order (seed
50968). New tests cover both overview versions, period changes, empty
results, header loading and copying, and self-hosted URL copying. Test
names describe observable behavior.
- 12 targeted regression mutations were detected and restored; the
selected-indicator mutation was repeated after the visual alignment fix.
- Browser QA on the staging preview for `3d055c0dc4` covers the header
and deploy details, copied URL, period changes, all detail tabs, sticky
navigation, the legacy overview, and empty results. Temporary local flag
overrides were removed. The final test-only commit `5af6a2896b` has
identical production code; its matching preview also passed header,
URL-copy, period-switching, and Settings smoke checks.
- Independent code review and changed-file formatting checks pass. All
40 executed CI checks pass on `5af6a2896b`, including TypeScript/lint,
unit tests, Next.js and TanStack E2E tests, and builds. All six review
threads are resolved.

### Stack

Merge in order:

1. #50953 — reusable logs table building blocks
2. #50954 — function-scoped unified logs queries
3. #50955 — slimmer function detail layout, header on Overview
4. #50957 — Invocations merged into a function-scoped Logs tab
5. #50958 — Overview errors in the shared logs table
6. #52281 — remove the legacy Overview

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2026-10-27 09:29:10 +01:00
Joshen Lim 60b51d74d5 Audit existing unit tests + Remove redundant ones (#52215)
## Context

_TLDR: Changes here speeds up unit tests on CI from ~14 minutes to ~3
minutes_ 😂
_TLDR 2: The file changes are solely only test files +
`studio-unit-tests.yml`_

We've currently got a lot of unit tests in the repository which while
great for coverage, hasn't been ideally written. There's a lot of
redundancy + overly specific tests that break easily, and our current
unit test takes about 15 minutes to run in the GHA per PR. Hence am
doing a audit clean up of all existing unit tests in the studio repo.

## Changes involved
- `.test.ts` files now run in `node`, `.test.tsx` in `jsdom`
- jsdom costs about 1s of setup per file. A `.ts` test that needs the
DOM opts in with `// @vitest-environment jsdom` (46 files do).
- Removed redundant and over-specific tests
- Duplicates are merged into `test.each`. Tests that only covered
libraries, existed for coverage, or asserted class names and snapshots
are deleted. 19 files are merged into a sibling or deleted.
- Fixed about 15 tests that couldn't fail 
- Examples: unawaited assertions, fixtures equal to the default, and a
`semverGte` test calling `semverLte`.
- Sped up the slowest files 
- Real sleeps are replaced with fake timers, `user.type` with paste, and
Radix option queries are scoped to the open listbox. For example,
`RestoringState` went from 18s to 0.3s and
`useTableEditorFiltersSort.navigation` from 20s to 3s.
- These ^ already shave down the unit tests time from 14 mins to 9 mins,
but am also sharding unit tests across 4 jobs to increase speed up
further which then shaves down time to 3 mins now
2026-10-23 18:51:27 +08:00
Jordi Enric c228ca4f61 fix(studio): restore function deployment annotations FE-3921 (#50362)
## Problem

The Edge Function overview converted the numeric deployment timestamp to
a string before parsing it as a date. This produced an invalid date, so
the invocations chart omitted the deployment annotation.

## Fix

Preserve the numeric timestamp returned by the API and allow the
annotation helper to parse both numeric and string timestamps. Show
deployment details in an accessible tooltip when hovering or focusing
the rocket marker, and add regression coverage for numeric timestamps
and the existing invalid, missing, and out-of-range cases.

## How to test

- Run the focused EdgeFunctionOverview utility test suite.
- Open an Edge Function whose latest deployment is within the selected
chart interval.
- Hover or focus the rocket marker.
- Expected result: the invocations chart shows the dashed deployment
line and rocket marker, and the marker tooltip shows the deployment
time.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
- Invocation update annotations now display correctly when function
update times are provided as numbers.
  - Timestamps at the start of the Unix epoch are now supported.
- Annotations no longer appear when update times are invalid or chart
data is incomplete.

- **Accessibility**
- Deployment markers in invocation charts are now keyboard-focusable and
include accessible labels.
  - Deployment timestamps are available in a tooltip on hover or focus.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-15 12:04:15 +02:00
Jordi Enric 24f8549e41 fix(studio): open edge function logs from chart clicks FE-3922 (#50364)
## Problem

Clicking an invocation bar on the Edge Function overview did not
preserve the selected chart segment, so the destination could not open a
focused investigation window.

## Fix

Forward the clicked bar timestamp and navigate to Logs or Invocations
with an encoded, focused time range. Share the existing chart range
calculation and add real Recharts interaction coverage.

## How to test

- Open an Edge Function Overview page with invocation data.
- Click a populated bar in the Total Invocations chart.
- Expected result: Logs or Invocations opens with its and ite query
parameters centered on the clicked bar.
- Repeat with unified logs enabled and disabled to verify both
destinations.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Clicking a bar in the Edge Function invocations chart now opens the
relevant logs or invocations view.
- The destination is focused on a time window surrounding the selected
invocation, making investigation faster.
- Chart bars now provide a pointer cursor to indicate they are
interactive.

- **Bug Fixes**
- Chart clicks without valid invocation data no longer trigger incorrect
navigation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-15 11:06:37 +02:00
4a0bb36ca8 style: require sorted imports in studio/components (#44408)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-04-01 10:22:37 +02:00
Saxon FletcherandAli Waseem e21088144d Edge function overview (#44009)
<img width="1575" height="1134" alt="image"
src="https://github.com/user-attachments/assets/994b1113-717f-44a2-89a4-13bc0182db20"
/>

Attempts to improve our edge function overview pages to provide stronger
insights into the health of a function, including reliability (error
rates), performance (execution times) and usage (cpu and memory).

As part of this work it refactors existing charts to use our new chart
components.

main consideration is the collective performance of error queries
https://github.com/supabase/supabase/pull/44009/changes#diff-2a79cf61c5397a8ef363c333229fa7729a2efc90a4d8e0806e49c212d5aa97e7

## To test:
1. Create an edge function that errors out randomly across requests. You
can use cron to poll this function every second.
2. View the edge function and on the overview page confirm that errors
are showing and grouped correctly in recent failed invocations sections.

---------

Co-authored-by: Ali Waseem <waseema393@gmail.com>
2026-04-01 14:59:12 +10:00