Repository navigation
refactor(sql-editor): extract deriveSnippetIdentity, debug/completion/diff-key helpers - #48014
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
📝 WalkthroughWalkthroughSQL Editor utilities now centralize snippet identity, completion request construction, debug context and chat payload creation, diff application planning, and keyboard action resolution. The snippet identity and AI hooks delegate to these helpers, with unit tests covering the updated behavior. ChangesSQL Editor utility extraction
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
🎭 Playwright Test Results (tanstack)Details
Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
dd7b26e to
caebe4f
Compare
Pulls the id + isLoading derivation out of useSnippetIdentity into a pure, unit-testable function in SQLEditor.utils.ts. Behavior-preserving.
Pulls the shared snippet/result/error extraction and the newChat payload builder out of useSqlEditorAi's buildDebugPrompt/onDebug into pure, unit-testable functions in SQLEditor.utils.ts. Minor behavior normalization: onDebug previously assumed snippet/result were defined and would throw (caught by its own try/catch, surfacing a generic toast) if the debug button was somehow clicked before a result existed. It now shares buildDebugPrompt's defensive fallbacks (empty sql / 'Unknown error') instead of relying on the catch block for that case.
468678f to
8c8f3e7
Compare
…estApplication Continues extracting useSqlEditorAi's decision logic into pure, unit-testable functions: the AI completion endpoint's request body builder, and the pending-diff-request application decision (replace vs. open a diff, depending on whether the editor is currently empty). The effect (drainDiffRequest) now just applies the plan instead of branching inline. Behavior-preserving.
Pulls the window-keydown Enter/Escape branch out of useSqlEditorShortcuts into a pure, unit-testable function in SQLEditor.utils.ts. Behavior- preserving. This completes the Step 1 pure-fn extraction pass across the SQL editor hooks.
Braintrust eval report
|
Summary
Pure-fn extraction pass across the SQL editor hooks.
deriveSnippetIdentityout ofuseSnippetIdentity's inline id +isLoadingderivation intoSQLEditor.utils.ts.extractDebugContext(shared snippet/result/error extraction) andbuildDebugChatArgs(theaiSnap.newChat(...)payload builder) out ofuseSqlEditorAi'sbuildDebugPrompt/onDebugintoSQLEditor.utils.ts.buildCompletionRequestBody(the AI completion endpoint's request body builder) andplanDiffRequestApplication(the pending-diff-request application decision: replace vs. open a diff, depending on whether the editor is currently empty) out ofuseSqlEditorAiintoSQLEditor.utils.ts. ThedrainDiffRequesteffect now just applies the plan instead of branching inline.resolveDiffKeyActionout ofuseSqlEditorShortcuts's window-keydown Enter/Escape branch intoSQLEditor.utils.ts.Test plan
pnpm --filter studio typecheckpnpm test:studio -- SQLEditor(265 tests passing)pnpm --filter studio run lint:ratchet