Skip to content

fix(studio): refine organisation invite state helpers#45813

Merged
dnywh merged 1 commit into
masterfrom
dnywh/fix/organisation-invite-state-utils
May 13, 2026
Merged

fix(studio): refine organisation invite state helpers#45813
dnywh merged 1 commit into
masterfrom
dnywh/fix/organisation-invite-state-utils

Conversation

@dnywh
Copy link
Copy Markdown
Contributor

@dnywh dnywh commented May 12, 2026

What kind of change does this PR introduce?

Code cleanup. Follow-up to #45774.

What is the current behavior?

The organisation invite interstitial derives invite states, titles, and descriptions from nested conditional logic in the component. That makes the component harder to scan and pushes too much state coverage into render tests.

What is the new behavior?

See #45774 for screenshots of the general UI before-and-after (which this one builds upon). That PR also contains testing instructions.

Extracts the invite status and content decisions into small pure helpers, then covers those helpers with focused unit tests.

The component keeps the user-facing render and interaction coverage, including the invalid lookup regression where a 404 should render the invalid invite state instead of raw backend copy.

Summary by CodeRabbit

  • Refactor
    • Improved organization invite flow with enhanced error state handling for expired, invalid, and wrong-account scenarios.
    • Better consistency in error messages and user guidance throughout the invite process.

Review Change Stack

@dnywh dnywh requested a review from a team as a code owner May 12, 2026 04:16
@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

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

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment May 12, 2026 4:21am
studio-staging Ready Ready Preview, Comment May 12, 2026 4:21am
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored May 12, 2026 4:21am
design-system Skipped Skipped May 12, 2026 4:21am
docs Skipped Skipped Open in v0 May 12, 2026 4:21am
ui-library Skipped Skipped May 12, 2026 4:21am
zone-www-dot-com Skipped Skipped Open in v0 May 12, 2026 4:21am

Request Review

@supabase
Copy link
Copy Markdown

supabase Bot commented May 12, 2026

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

The PR refactors OrganizationInvite to extract state-computation and content-generation logic into dedicated utility functions. It introduces getOrganizationInviteStatus and getOrganizationInviteContent, updates the component to use these utilities, and adds comprehensive test coverage for both the utilities and component integration.

Changes

Invite Status and Content Utilities

Layer / File(s) Summary
Invite status and content utilities
apps/studio/components/interfaces/OrganizationInvite/OrganizationInvite.utils.ts
OrganizationInviteStatus type and getOrganizationInviteStatus function derive invite state (signed-out, loading, invalid, expired, wrong-account, no-longer-valid, ready) from auth/loading/router/error flags. getOrganizationInviteContent maps status to user-facing title and description with dynamic sign-in/signup and organization-specific messaging.
Component refactoring to use utilities
apps/studio/components/interfaces/OrganizationInvite/OrganizationInvite.tsx
Component imports and uses getOrganizationInviteStatus and getOrganizationInviteContent to replace inline state computation. InterstitialLayout renders title/description from inviteContent. Conditional branches updated to compare inviteStatus strings instead of boolean flags.
Test coverage for utilities and component
apps/studio/tests/components/OrganizationInvite.utils.test.ts, apps/studio/tests/components/OrganizationInvite.test.tsx
New utils test suite with fixtures and test.each tables validate getOrganizationInviteStatus and getOrganizationInviteContent across all invite states. Component tests updated to assert routerReload is called after sign-out and consolidated error-state scenarios.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A refactor hops along with glee,
State logic bundled, clean and free!
Utilities extracted, tested true,
Less duplicated, more maintainable too!
The OrganizationInvite takes its leap. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'refine organisation invite state helpers' accurately describes the main change: extracting state logic into helper functions and refining those utilities.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed PR description is well-structured with all required template sections completed: change type (code cleanup), current behavior (nested conditional logic), new behavior (extracted pure helpers with unit tests), and context linking to related PR #45774.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dnywh/fix/organisation-invite-state-utils

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.

@github-actions
Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  207 passed
skipped  5 skipped

Details

stats  212 tests across 23 suites
duration  6 minutes, 34 seconds
commit  fadab74

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@dnywh dnywh merged commit 9660b00 into master May 13, 2026
32 of 34 checks passed
@dnywh dnywh deleted the dnywh/fix/organisation-invite-state-utils branch May 13, 2026 00:40
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

Braintrust eval report

Assistant (master-1778632947)

Score Average Improvements Regressions
Completeness 100% (+9pp) 5 🟢 -
Conciseness 44.7% (+2pp) 7 🟢 7 🔴
Correctness 73.6% (+4pp) 3 🟢 2 🔴
Docs Faithfulness 64.1% (-2pp) 4 🟢 5 🔴
Goal Completion 79.3% (+3pp) 6 🟢 4 🔴
Safety 90.5% (-5pp) 1 🟢 1 🔴
Tool Usage 73.3% (+2pp) 1 🟢 -
Knowledge Usage 100% (+0pp) - -
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Time_to_first_token 0.01tok (-0.01tok) 19 🟢 6 🔴
Llm_calls 11.27 (+0.09) 10 🟢 11 🔴
Tool_calls 2.97 (-0.04) 7 🟢 12 🔴
Errors 0.04 (+0.04) - 1 🔴
Llm_errors 0.03 (+0.03) - 1 🔴
Tool_errors 0 (+0) - -
Prompt_tokens 19674.63tok (-1796.21tok) 12 🟢 10 🔴
Prompt_cached_tokens 7031.47tok (-225.28tok) 12 🟢 10 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 566.4tok (+22.63tok) 13 🟢 11 🔴
Completion_reasoning_tokens 105.13tok (+16.24tok) 9 🟢 14 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 20241.03tok (-1773.59tok) 13 🟢 12 🔴
Estimated_cost 0$ (0$) 7 🟢 15 🔴
Duration 17.16s (-3.72s) 21 🟢 4 🔴
Llm_duration 11.05s (-2.57s) 18 🟢 7 🔴

@dnywh dnywh changed the title refine organisation invite state helpers fix(studio): refine organisation invite state helpers May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants