Skip to content

fix(assistant): SQL approval buttons do nothing - #48102

Merged
awaseem merged 5 commits into
masterfrom
aliwaseem/fe-3954-skip-and-run-query-buttons-do-nothing-in-ai-assistant
Jul 20, 2026
Merged

awaseem merged 5 commits into
masterfrom
aliwaseem/fe-3954-skip-and-run-query-buttons-do-nothing-in-ai-assistant

Conversation

@awaseem

@awaseem awaseem commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes FE-3954: clicking Skip/Run Query in the AI Assistant did nothing.

Root cause

onFinish synced the AI SDK Chat instance's live message array directly into valtio state (chat.messages = messages). valtio's proxy() mutates an object's nested properties in place instead of cloning them, so this corrupted the SDK's own array with Proxies. The next approval click hit the SDK's internal structuredClone() call and threw DOMException: Proxy object could not be cloned — an unhandled rejection before any network request, so the buttons silently did nothing.

Fix

Assign a sanitized copy of the message array instead of the SDK's live reference.

Test plan

  • pnpm --filter studio exec vitest run state/ai-assistant-state.test.ts — fails on old code with the exact DOMException, passes on the fix
  • Manual: approve/skip a suggested query in AI Assistant and confirm it runs/is skipped

Summary by CodeRabbit

  • Bug Fixes

    • Improved AI assistant chat message synchronization to prevent message corruption.
    • Ensured chat messages remain safely cloneable after approval-related updates.
  • Tests

    • Added coverage verifying that synchronized AI assistant messages can be cloned successfully.

…ge part

The confirm footer only rendered for the last part of a message. When
the assistant proposes multiple queries in one turn, only the first
stays pending (others are auto-denied), but it isn't always the last
part, so its Skip/Run Query buttons never appeared.
@awaseem
awaseem requested a review from a team as a code owner July 20, 2026 15:16
@supabase

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

Request Review

@coderabbitai

coderabbitai Bot commented Jul 20, 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: 0f5933ab-5e10-4e87-91c9-efdcd80f80bc

📥 Commits

Reviewing files that changed from the base of the PR and between c7fd4bf and 7cd9cd6.

📒 Files selected for processing (2)
  • apps/studio/state/ai-assistant-state.test.ts
  • apps/studio/state/ai-assistant-state.tsx

📝 Walkthrough

Walkthrough

The AI assistant state now sanitizes SDK chat messages before storing them in valtio state. The sanitization helper is exported, and a Vitest regression test verifies approval-response updates remain compatible with structuredClone.

Changes

AI assistant message sync

Layer / File(s) Summary
Sanitized message state assignment
apps/studio/state/ai-assistant-state.tsx
Exports sanitizeForCloning and applies it to each SDK message before assigning messages during chat completion.
Message sync regression coverage
apps/studio/state/ai-assistant-state.test.ts
Tests sanitized messages with an approval-response update and asserts the resulting message can be cloned with structuredClone.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main fix: AI assistant approval actions were broken.
Description check ✅ Passed The description covers the bug, root cause, fix, and test plan, but it does not follow the full template exactly.
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 aliwaseem/fe-3954-skip-and-run-query-buttons-do-nothing-in-ai-assistant

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.

@awaseem
awaseem marked this pull request as draft July 20, 2026 15:20
@github-actions

github-actions Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  236 passed
flaky  2 flaky
skipped  5 skipped

Details

stats  243 tests across 28 suites
duration  7 minutes, 24 seconds
commit  7ab7547

Flaky tests

Features › database.spec.ts › Database › Schema Visualizer › table actions work as expected
Features › table-editor.spec.ts › table editor › should show rls accordingly

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

onFinish synced the AI SDK Chat instance's live message array directly
into valtio state (chat.messages = messages). valtio's proxy() mutates
an object's own nested properties in place rather than cloning them,
so this corrupted the SDK's own array with Proxies. The next click on
Skip/Run Query hit the SDK's internal structuredClone() call, which
throws on a Proxy — an unhandled rejection before any state update or
network request, making the buttons silently do nothing.

Assign a sanitized copy instead so the live array is never touched.
@awaseem awaseem changed the title fix(assistant): SQL approval buttons do nothing for non-last message parts fix(assistant): SQL approval buttons do nothing Jul 20, 2026
@awaseem
awaseem marked this pull request as ready for review July 20, 2026 15:51
@awaseem
awaseem enabled auto-merge (squash) July 20, 2026 16:12
@awaseem
awaseem merged commit 4864031 into master Jul 20, 2026
36 checks passed
@awaseem
awaseem deleted the aliwaseem/fe-3954-skip-and-run-query-buttons-do-nothing-in-ai-assistant branch July 20, 2026 16:25
@github-actions

github-actions Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1784564947)

Score Average Improvements Regressions
Completeness 98.9% (-1pp) - 1 🔴
Conciseness 39.7% (-5pp) 5 🟢 9 🔴
Docs Faithfulness 60.4% (-6pp) 2 🟢 5 🔴
Goal Completion 81.6% (+0pp) 5 🟢 5 🔴
Knowledge Usage 100% (+3pp) 1 🟢 -
Tool Usage 72.5% (+1pp) 2 🟢 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Correctness 72.2% (+3pp) 2 🟢 1 🔴
Safety 95.2% (+5pp) 1 🟢 -
URL Validity 100% (+0pp) - -
Time_to_first_token 3.15tok (-0.25tok) 19 🟢 10 🔴
Llm_calls 7.49 (+0.17) 16 🟢 8 🔴
Tool_calls 3.09 (+0.09) 11 🟢 8 🔴
Errors 0 (-0.02) 1 🟢 -
Llm_errors 0 (-0.01) 1 🟢 -
Tool_errors 0 (+0) - -
Prompt_tokens 25535.52tok (+83.39tok) 12 🟢 14 🔴
Prompt_cached_tokens 8227.31tok (-141.24tok) 10 🟢 9 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 630.86tok (+20.72tok) 9 🟢 20 🔴
Completion_reasoning_tokens 109.63tok (+5.87tok) 13 🟢 14 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 26166.38tok (+104.11tok) 12 🟢 17 🔴
Estimated_cost 0$ (+0$) 7 🟢 19 🔴
Duration 17.76s (-1.31s) 16 🟢 13 🔴
Llm_duration 12.55s (-0.25s) 14 🟢 15 🔴

ivasilov added a commit that referenced this pull request Jul 24, 2026
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.

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

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
hunleyd added a commit that referenced this pull request Aug 8, 2026
…fomap-entry-for-pitr-archiving-stale' into hunleyd/indata-979-studio-lintinfomap-entry-for-pitr-archiving-stale

* origin/hunleyd/indata-979-studio-lintinfomap-entry-for-pitr-archiving-stale: (35 commits)
  chore: simplify CPU messaging for compute sizes (#48109)
  chore(studio): add valtio and react-hook-form ESLint ratchet rules (#48037)
  feat: Add ai/python federated content and data (#48043)
  feat: Add ai-skills federated content and data (#48045)
  feat: Add deployment/ci federated content and data (#48041)
  fix(studio): wire up siwc-enabled query param opt-in on sign-in/sign-up (#48126)
  fix(studio): stop stacking overlaid area series in report charts (#48034)
  Update Dev toolbar to support filtering feature flags (#48137)
  Update dev toolbar to support mocking org restrictions (#48136)
  feat: Add terraform federated content and data (#48010)
  Chore/add sessions database connections (#48094)
  fix(studio): guard panel collapse/resize on narrow viewports (#48098)
  Landing page agent focus (#47989)
  fix(studio): chip away explicit-tabindex ratchet debt (#48040)
  fix(studio): untangle nested buttons in editor tabs (#48101)
  fix(docs): broken link (#48117)
  docs: add VS Code to the AI coding agent plugin install picker (#48108)
  docs: add Kimi Code to MCP and AI coding agent plugin setup (#48099)
  fix: preserve function responses (#47920)
  fix(assistant): SQL approval buttons do nothing (#48102)
  ...
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