Skip to content

fix: Refactor some suspicious Valtio uses - #48141

Merged
ivasilov merged 3 commits into
masterfrom
fix/safe-valtio-proxies
Jul 24, 2026
Merged

ivasilov merged 3 commits into
masterfrom
fix/safe-valtio-proxies

Conversation

@ivasilov

@ivasilov ivasilov commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

This PR is partly driven by changes in #48102. Claude identified code smells of Valtio state which are not bugs at the moment, but we should address in case their usage changes.

Summary by CodeRabbit

  • Bug Fixes
    • Improved AI assistant message updates to prevent unexpected state changes.
    • Fixed table editing behavior to preserve shared data and prevent accidental in-place mutations.
    • Improved consent handling by preventing SDK internals from being altered by state management.

@ivasilov
ivasilov requested a review from a team as a code owner July 21, 2026 11:50
@supabase

supabase Bot commented Jul 21, 2026

Copy link
Copy Markdown

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 ↗︎.

@vercel

vercel Bot commented Jul 21, 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 Jul 21, 2026 11:50am
docs Ready Ready Preview, Comment, Open in v0 Jul 21, 2026 11:50am
studio-self-hosted Ready Ready Preview, Comment Jul 21, 2026 11:50am
studio-staging Ready Ready Preview, Comment Jul 21, 2026 11:50am
ui-library Ready Ready Preview, Comment Jul 21, 2026 11:50am
zone-www-dot-com Ready Ready Preview, Comment, Open in v0 Jul 21, 2026 11:50am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jul 21, 2026 11:50am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4443fb36-3597-4a69-8c5b-5b4f7ce46e40

📥 Commits

Reviewing files that changed from the base of the PR and between 7ce1291 and 1cd8e82.

📒 Files selected for processing (3)
  • apps/studio/state/ai-assistant-state.tsx
  • apps/studio/state/table-editor-table.tsx
  • packages/common/consent-state.ts

📝 Walkthrough

Walkthrough

The changes prevent unintended valtio proxying and mutation across AI assistant messages, table editor state, and consent SDK storage. The AI assistant state API also removes the obsolete saveMessage method.

Changes

State safety updates

Layer / File(s) Summary
Sanitized AI assistant messages
apps/studio/state/ai-assistant-state.tsx
updateMessage stores a sanitized clone, and saveMessage is removed from the exported state type.
Safe table snapshot assignment
apps/studio/state/table-editor-table.tsx
The original table reference is created before assigning originalTable to avoid proxy-driven mutation of shared cache objects.
Referenced consent SDK storage
packages/common/consent-state.ts
The Usercentrics SDK is stored with ref(UC) to prevent recursive valtio proxying.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • supabase/supabase#48102: Applies a similar sanitized-clone approach to prevent live objects from being written directly into valtio state.

Suggested reviewers: jeremenichelli

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is far too incomplete and omits the required template sections for behavior, change type, and context. Fill in the template sections: confirm CONTRIBUTING.md, classify the change, describe current/new behavior, link issues, and add any extra context.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the PR's main goal of cleaning up Valtio usage across the affected files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 fix/safe-valtio-proxies

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.

@github-actions

github-actions Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  238 passed
flaky  1 flaky
skipped  5 skipped

Details

stats  244 tests across 29 suites
duration  4 minutes, 12 seconds
commit  1cd8e82

Flaky tests

Features › queue-table-operations.spec.ts › Queue Table Operations › pending changes persist when switching between tables

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

@ivasilov
ivasilov merged commit 99fd5d0 into master Jul 24, 2026
37 checks passed
@ivasilov
ivasilov deleted the fix/safe-valtio-proxies branch July 24, 2026 14:36
@github-actions

github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1784904005)

Score Average Improvements Regressions
Completeness 98.9% (+0pp) 1 🟢 1 🔴
Conciseness 43.1% (+1pp) 8 🟢 7 🔴
Correctness 67.8% (-3pp) 2 🟢 3 🔴
Docs Faithfulness 65.5% (+1pp) 3 🟢 3 🔴
Goal Completion 78.2% (-1pp) 5 🟢 7 🔴
Tool Usage 74.5% (+4pp) 1 🟢 -
URL Validity 100% - -
Knowledge Usage 97.4% (-3pp) - 1 🔴
Safety 85.7% (-5pp) - 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Time_to_first_token 3.45tok (-0.07tok) 16 🟢 13 🔴
Llm_calls 6.95 (+0.05) 9 🟢 10 🔴
Tool_calls 2.98 (-0.16) 10 🟢 10 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 23039.51tok (-141.16tok) 11 🟢 14 🔴
Prompt_cached_tokens 6720.74tok (-270.71tok) 16 🟢 13 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 607.1tok (+10.28tok) 10 🟢 18 🔴
Completion_reasoning_tokens 103.03tok (+18.95tok) 5 🟢 21 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 23646.61tok (-130.89tok) 12 🟢 16 🔴
Estimated_cost 0$ (+0$) 15 🟢 14 🔴
Duration 17.03s (-0.85s) 18 🟢 11 🔴
Llm_duration 11.66s (-0.75s) 18 🟢 11 🔴

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