You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GitNexus reports CRITICAL impact because the centralized runQuery path has 11 direct callers. The behavior change is limited to safety-guard ordering and is covered by a dedicated query-guard pipeline test.
The PR unifies safety-confirmation guards behind a shared useQueryGuards hook that composes the production-write guard and the dangerous-query guard in the correct order (production first, short-circuits on block), and gates the 5-second confirmation countdown behind a persisted safetyConfirmationDelayEnabled setting (default off).
Incremental verification (commit 16b5e2b)
The new useQueryGuards hook correctly composes useProductionGuard + useDangerousQueryGuard(!isProduction) and exposes a single guardQuery(sql | string[]) gate. Batch SQL is joined with ;\n for the production guard while the original array is preserved for dangerous-statement classification.
No stale closures: the hook's guardQuery deps are [connectionId, guardDangerousQuery, guardProductionWrite]; useDangerousQueryGuard refreshes its guardQuery identity when enabled (= !isProduction) changes, so the composed gate always sees the current production flag.
No state split: Editor.tsx still calls useProductionGuard() directly for the unchanged grid-save and AI-insert paths, and useQueryGuards calls it internally for runQuery/runMultipleQueries — both consume the same ProductionGuardContext, so the modal state stays shared.
NotebookView.tsx is fully migrated to useQueryGuards, with guardQueryExecution included in the runCell dependency array.
New tests/hooks/useQueryGuards.test.ts covers guard ordering, prod-guard short-circuit, disabled dangerous guard on production connections, and batch SQL serialization.
The PR unifies safety-confirmation guards by running the production-write guard before the standard dangerous-query guard across editor, batch, notebook, and AI-generated query paths, gates the 5-second confirmation countdown behind a persisted safetyConfirmationDelayEnabled setting (default off), and suppresses the dangerous-query modal on production connections.
Verification highlights:
Guard ordering is correct in passQueryGuards (production first, short-circuits on block) and wired into runQuery, runMultipleQueries, runCell, and the AI onInsert handler.
No coverage gap from disabling the dangerous-query guard on production connections: isReadOnlyQuery returns false for DROP/TRUNCATE/DELETE/UPDATE, so the production guard is a strict superset and still prompts for every non-read-only write.
No stale closures: guardDangerousQuery/guardProductionWrite are included in the useCallback dependency arrays of runQuery (Editor.tsx:1170-1171), runMultipleQueries (1373-1374), and runCell (NotebookView.tsx:446-447).
Countdown timer in ProductionGuardContext decrements correctly (5→0 over 5 ticks), resets on finish, and keeps cancel/X enabled throughout.
confirmDelaySeconds={undefined} is safe — ConfirmModal treats the prop as optional (?? 0, !confirmDelaySeconds guard).
Config persistence in config.rs follows the established is_some() merge pattern; serde camelCase round-trip is covered by tests.
i18n: both safetyConfirmationDelay and safetyConfirmationDelayDesc keys are present in all 11 locales; zh.json also fixes a missing trailing comma.
Tests cover guard ordering, countdown behavior, environment detection, the disabled-guard path, and settings persistence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
pnpm test --run— 228 files, 3822 tests passedpnpm exec tsc --noEmitcargo test --manifest-path src-tauri/Cargo.toml config::tests --lib— 17 tests passedrustfmt --check --edition 2021 src-tauri/src/config.rsgit diff --checkRisk
GitNexus reports CRITICAL impact because the centralized
runQuerypath has 11 direct callers. The behavior change is limited to safety-guard ordering and is covered by a dedicated query-guard pipeline test.