Skip to content

feat(studio-local): functions management api - function details - #42322

Merged
charislam merged 6 commits into
supabase:masterfrom
kallebysantos:feat-local-functions-management-api-2-function-by-slug
Jan 30, 2026
Merged

charislam merged 6 commits into
supabase:masterfrom
kallebysantos:feat-local-functions-management-api-2-function-by-slug

Conversation

@kallebysantos

@kallebysantos kallebysantos commented Jan 30, 2026 •

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Feature

What is the current behavior?

Functions page on self-hosted differs from Platform

What is the new behavior?

Adds the possibility to see function details page in Self-Host version.

Details image

Summary by CodeRabbit

  • New Features

    • Edge function detail lookup added for self‑hosted deployments (new retrieval endpoint & store method).
    • Consistent navigation to function pages from the functions list.
  • Improvements

    • UI tabs, download, and test controls adapt to deployment type.
    • Region, JWT verification, local development, and delete controls shown only on the platform.
    • Edit/save/delete controls enable/disable correctly based on deployment and permissions.
    • Function details load reliably across deployments.

✏️ Tip: You can customize this high-level summary in your review settings.

@kallebysantos
kallebysantos requested a review from a team as a code owner January 30, 2026 15:58
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to Supabase! ❤️ Our team will review your PR.

A few tips for a smoother review process:

  • If you have a local version of the repo, run pnpm run format to make sure formatting checks pass.
  • Once we've reviewed your PR, please don't trivially merge master (don't click Update branch if there are no merge conflicts to be fixed). This invalidates any pre-merge checks we've run.

@vercel

vercel Bot commented Jan 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview, Comment Jan 30, 2026 8:14pm
docs Ready Ready Preview, Comment Jan 30, 2026 8:14pm
studio-self-hosted Ready Ready Preview, Comment Jan 30, 2026 8:14pm
studio-staging Ready Ready Preview, Comment Jan 30, 2026 8:14pm
ui-library Ready Ready Preview, Comment Jan 30, 2026 8:14pm
zone-www-dot-com Ready Ready Preview, Comment Jan 30, 2026 8:14pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
cms Ignored Ignored Jan 30, 2026 8:14pm
studio Ignored Ignored Jan 30, 2026 8:14pm

Request Review

@vercel

vercel Bot commented Jan 30, 2026

Copy link
Copy Markdown

@kallebysantos is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jan 30, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds self‑hosted edge function retrieval and a GET API route by slug, a filesystem lookup method, removes IS_PLATFORM gating from query enabling, and introduces platform-aware UI/permisssion gating across studio edge-function components.

Changes

Cohort / File(s) Summary
Edge Function Details UI
apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx
Introduces permission gating (canUpdateEdgeFunction = IS_PLATFORM && ...) and wraps Region, Verify JWT, Develop locally, Delete function, and related ConfirmationModal UI blocks behind IS_PLATFORM; Verify JWT form/footer Save button disabled by permission and form dirtiness.
Edge Functions Layout
apps/studio/components/layouts/EdgeFunctionsLayout/EdgeFunctionDetailsLayout.tsx
Uses IS_PLATFORM to conditionally render navigation tabs (Overview, Invocations, Logs, Code vs only Details), Download-as-ZIP and CLI download UI, and platform-gated Test button rendering.
List Item Navigation
apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx
Reintroduced IS_PLATFORM and useParams imports, migrated imports to alias paths, made navigation handler always defined (createNavigationHandler) and adjusted URL building to append /details when not platform; simplified className to a static string.
Query behavior
apps/studio/data/edge-functions/edge-function-query.ts
Removed IS_PLATFORM from the query enable condition so edge-function queries enable when enabled and both projectRef and slug exist regardless of platform.
Self-hosted artifact store
apps/studio/lib/api/self-hosted/functions/fileSystemStore.ts
Added `getFunctionBySlug(slug: string): Promise<FunctionArtifact
API route
apps/studio/pages/api/v1/projects/[ref]/functions/[slug]/index.ts
New Next.js API handler exporting GET to return a structured function response by slug (404 if missing/not found, 405 for other methods); uses filesystem artifact store and uuidv4 to form response.
Page routing
apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx
Minor import adjustments adding IS_PLATFORM and useEffect; preserves existing routing flow (no exported signature changes).

Sequence Diagram(s)

sequenceDiagram
participant Browser as Browser
participant NextAPI as Next.js API
participant FS as FileSystemFunctionsArtifactStore

Browser->>NextAPI: GET /api/v1/projects/:ref/functions/:slug
Note right of NextAPI: handlerWithErrorCatching -> GET branch
NextAPI->>FS: getFunctionBySlug(slug)
FS-->>NextAPI: FunctionArtifact or undefined
alt Function found
NextAPI-->>Browser: 200 JSON (FunctionResponse)
else Not found
NextAPI-->>Browser: 404 Not Found
end
Loading

Possibly related PRs

Suggested reviewers

  • saltcod
  • awaseem
  • aantti
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main feature: adding function details API capability to studio-local, which aligns with the primary objective of enabling self-hosted Functions UX parity with Platform.
Description check ✅ Passed The description addresses the core requirements from template (change type, current behavior, new behavior) but misses the CONTRIBUTING.md acknowledgment section and lacks detailed technical context for code review.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls

coveralls commented Jan 30, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 66.278% (-0.1%) from 66.383%
when pulling 8d38b9b on kallebysantos:feat-local-functions-management-api-2-function-by-slug
into 4b8bab4 on supabase:master.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/studio/pages/project/`[ref]/functions/[functionSlug]/index.tsx:
- Around line 69-71: The redirect currently calls router.push inside render when
!IS_PLATFORM (using router, projectRef, functionSlug from useParams); move that
side-effect into a useEffect hook: create a useEffect that depends on
IS_PLATFORM, router, projectRef, and functionSlug, check IS_PLATFORM === false
and that projectRef and functionSlug are defined before calling
router.push(`/project/${projectRef}/functions/${functionSlug}/details`), and
during render return null or a placeholder while projectRef/functionSlug are
undefined to avoid invoking router.push during render.

@aantti aantti added the self-hosted Related to self-hosted Supabase label Jan 30, 2026
@aantti aantti added the cli Related to supabase/cli label Jan 30, 2026
@aantti
aantti requested review from awaseem and charislam January 30, 2026 16:55
</PageSectionContent>
</PageSection>

<ConfirmationModal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was deleted by accident

const router = useRouter()
const { ref: projectRef, functionSlug } = useParams()

useEffect(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will lead to a brief flash of the wrong page

@charislam
charislam enabled auto-merge (squash) January 30, 2026 21:13
@charislam
charislam merged commit 8c3655c into supabase:master Jan 30, 2026
14 checks passed
@github-actions

github-actions Bot commented Jan 30, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1769807773)

Score Average Improvements Regressions
Completeness 100% (+0pp) - -
Conciseness 0% (+0pp) - -
Goal Completion 100% (+8pp) 2 🟢 -
Tool Usage 100% (+0pp) - -
Correctness 100% (+0pp) - -
Docs Faithfulness 50% (-17pp) - 2 🔴
URL Validity 100% (+0pp) - -
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Time_to_first_token 0.21tok (+0.04tok) 5 🟢 7 🔴
Llm_calls 8.42 (+0) - -
Tool_calls 3.25 (+0.08) 3 🟢 1 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 94236.33tok (-13675.67tok) 5 🟢 7 🔴
Prompt_cached_tokens 49792tok (-6122.67tok) 3 🟢 4 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Completion_tokens 5901.17tok (+639.83tok) 3 🟢 9 🔴
Completion_reasoning_tokens 4234.67tok (+373.33tok) 4 🟢 7 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 100137.5tok (-13035.83tok) 8 🟢 4 🔴
Estimated_cost 0.02$ (0$) 7 🟢 5 🔴
Duration 53.16s (+12.2s) 4 🟢 8 🔴
Llm_duration 105.33s (+24.36s) 3 🟢 9 🔴

awaseem pushed a commit that referenced this pull request Feb 3, 2026
Functions page on self-hosted differs from Platform Adds the possibility to see function details page in Self-Host version.

## Summary by CodeRabbit

* **New Features**
* Edge function detail lookup added for self‑hosted deployments (new
retrieval endpoint & store method).
  * Consistent navigation to function pages from the functions list.

* **Improvements**
  * UI tabs, download, and test controls adapt to deployment type.
* Region, JWT verification, local development, and delete controls shown
only on the platform.
* Edit/save/delete controls enable/disable correctly based on deployment
and permissions.
  * Function details load reliably across deployments.
charislam added a commit that referenced this pull request Feb 18, 2026
…nments (#42992)

Feature

## What is the current behavior?

The Functions counter on the Home page is only displayed in platform
environments.
In self-hosted setups, the counter is hidden due to a platform guard,
even though Functions may be available.

## What is the new behavior?

The Functions counter is now also displayed in self-hosted environments.

This is now possible thanks to the following PRs:

- #40690  
- #42322  
- #42349  
- #42350  

These PRs introduce and enable the API required for listing Functions in
Studio, making it feasible to show the Functions count outside of the
platform environment.

## Additional context

Related issues: #36285

This change removes the platform-only restriction around the Functions
card in the Home interface, allowing feature parity between platform and
self-hosted deployments where the Functions API is available.

---------

Co-authored-by: Andrey A. <[email protected]>
Co-authored-by: Charis Lam <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to supabase/cli self-hosted Related to self-hosted Supabase

Projects

Development

Successfully merging this pull request may close these issues.

4 participants